Skip to content

Commit

Permalink
chore: Remove internal implementation usages
Browse files Browse the repository at this point in the history
  • Loading branch information
TomCools authored and triceo committed Nov 22, 2024
1 parent 99a9857 commit ddfcf20
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
Expand All @@ -19,8 +20,6 @@

import jakarta.enterprise.context.ApplicationScoped;

import ai.timefold.solver.core.impl.util.MutableInt;

import org.acme.flighcrewscheduling.domain.Airport;
import org.acme.flighcrewscheduling.domain.Employee;
import org.acme.flighcrewscheduling.domain.Flight;
Expand Down Expand Up @@ -132,18 +131,18 @@ private List<Employee> generateEmployees(List<Flight> flights, List<LocalDate> d
// two pilots and three attendants per airport
List<Employee> employees = new ArrayList<>(flightAirports.size() * 5);

MutableInt count = new MutableInt();
AtomicInteger count = new AtomicInteger();
// Two teams per airport
flightAirports.forEach(airport -> IntStream.range(0, 2).forEach(i -> {
employees.add(new Employee(String.valueOf(count.increment()), nameSupplier.get(), airport, List.of(PILOT_SKILL)));
employees.add(new Employee(String.valueOf(count.increment()), nameSupplier.get(), airport, List.of(PILOT_SKILL)));
employees.add(new Employee(String.valueOf(count.incrementAndGet()), nameSupplier.get(), airport, List.of(PILOT_SKILL)));
employees.add(new Employee(String.valueOf(count.incrementAndGet()), nameSupplier.get(), airport, List.of(PILOT_SKILL)));
employees.add(
new Employee(String.valueOf(count.increment()), nameSupplier.get(), airport, List.of(ATTENDANT_SKILL)));
new Employee(String.valueOf(count.incrementAndGet()), nameSupplier.get(), airport, List.of(ATTENDANT_SKILL)));
employees.add(
new Employee(String.valueOf(count.increment()), nameSupplier.get(), airport, List.of(ATTENDANT_SKILL)));
new Employee(String.valueOf(count.incrementAndGet()), nameSupplier.get(), airport, List.of(ATTENDANT_SKILL)));
if (airport.getCode().equals("CNF")) {
employees.add(
new Employee(String.valueOf(count.increment()), nameSupplier.get(), airport, List.of(ATTENDANT_SKILL)));
new Employee(String.valueOf(count.incrementAndGet()), nameSupplier.get(), airport, List.of(ATTENDANT_SKILL)));
}
}));

Expand Down Expand Up @@ -247,22 +246,22 @@ private int pickRandomRouteSize(int countFlights, int maxCountFlights) {
private List<FlightAssignment> generateFlightAssignments(List<Flight> flights) {
// 2 pilots and 2 or 3 attendants
List<FlightAssignment> flightAssignments = new ArrayList<>(flights.size() * 5);
MutableInt count = new MutableInt();
AtomicInteger count = new AtomicInteger();
flights.forEach(flight -> {
MutableInt indexSkill = new MutableInt();
AtomicInteger indexSkill = new AtomicInteger();
flightAssignments
.add(new FlightAssignment(String.valueOf(count.increment()), flight, indexSkill.increment(), PILOT_SKILL));
.add(new FlightAssignment(String.valueOf(count.incrementAndGet()), flight, indexSkill.incrementAndGet(), PILOT_SKILL));
flightAssignments
.add(new FlightAssignment(String.valueOf(count.increment()), flight, indexSkill.increment(), PILOT_SKILL));
.add(new FlightAssignment(String.valueOf(count.incrementAndGet()), flight, indexSkill.incrementAndGet(), PILOT_SKILL));
flightAssignments
.add(new FlightAssignment(String.valueOf(count.increment()), flight, indexSkill.increment(),
.add(new FlightAssignment(String.valueOf(count.incrementAndGet()), flight, indexSkill.incrementAndGet(),
ATTENDANT_SKILL));
flightAssignments
.add(new FlightAssignment(String.valueOf(count.increment()), flight, indexSkill.increment(),
.add(new FlightAssignment(String.valueOf(count.incrementAndGet()), flight, indexSkill.incrementAndGet(),
ATTENDANT_SKILL));
if (flight.getDepartureAirport().getCode().equals("CNF") || flight.getArrivalAirport().getCode().equals("CNF")) {
flightAssignments
.add(new FlightAssignment(String.valueOf(count.increment()), flight, indexSkill.increment(),
.add(new FlightAssignment(String.valueOf(count.incrementAndGet()), flight, indexSkill.incrementAndGet(),
ATTENDANT_SKILL));
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import ai.timefold.solver.core.api.domain.variable.ShadowVariable;

import org.acme.projectjobschedule.domain.solver.DelayStrengthComparator;
import org.acme.projectjobschedule.domain.solver.ExecutionModeStrengthWeightFactory;
import org.acme.projectjobschedule.domain.solver.NotSourceOrSinkAllocationFilter;
import org.acme.projectjobschedule.domain.solver.PredecessorsDoneDateUpdatingVariableListener;

Expand All @@ -41,7 +40,7 @@ public class Allocation {
private List<Allocation> successorAllocations;

// Planning variables: changes during planning, between score calculations.
@PlanningVariable(strengthWeightFactoryClass = ExecutionModeStrengthWeightFactory.class)
@PlanningVariable
private ExecutionMode executionMode;
@PlanningVariable(strengthComparatorClass = DelayStrengthComparator.class)
private Integer delay; // In days
Expand Down

This file was deleted.

0 comments on commit ddfcf20

Please sign in to comment.