|
10 | 10 | import java.util.List;
|
11 | 11 | import java.util.Map;
|
12 | 12 | import java.util.Random;
|
| 13 | +import java.util.concurrent.atomic.AtomicInteger; |
13 | 14 | import java.util.function.BiConsumer;
|
14 | 15 | import java.util.function.Consumer;
|
15 | 16 | import java.util.function.Function;
|
|
19 | 20 |
|
20 | 21 | import jakarta.enterprise.context.ApplicationScoped;
|
21 | 22 |
|
22 |
| -import ai.timefold.solver.core.impl.util.MutableInt; |
23 |
| - |
24 | 23 | import org.acme.flighcrewscheduling.domain.Airport;
|
25 | 24 | import org.acme.flighcrewscheduling.domain.Employee;
|
26 | 25 | import org.acme.flighcrewscheduling.domain.Flight;
|
@@ -132,18 +131,18 @@ private List<Employee> generateEmployees(List<Flight> flights, List<LocalDate> d
|
132 | 131 | // two pilots and three attendants per airport
|
133 | 132 | List<Employee> employees = new ArrayList<>(flightAirports.size() * 5);
|
134 | 133 |
|
135 |
| - MutableInt count = new MutableInt(); |
| 134 | + AtomicInteger count = new AtomicInteger(); |
136 | 135 | // Two teams per airport
|
137 | 136 | flightAirports.forEach(airport -> IntStream.range(0, 2).forEach(i -> {
|
138 |
| - employees.add(new Employee(String.valueOf(count.increment()), nameSupplier.get(), airport, List.of(PILOT_SKILL))); |
139 |
| - employees.add(new Employee(String.valueOf(count.increment()), nameSupplier.get(), airport, List.of(PILOT_SKILL))); |
| 137 | + employees.add(new Employee(String.valueOf(count.incrementAndGet()), nameSupplier.get(), airport, List.of(PILOT_SKILL))); |
| 138 | + employees.add(new Employee(String.valueOf(count.incrementAndGet()), nameSupplier.get(), airport, List.of(PILOT_SKILL))); |
140 | 139 | employees.add(
|
141 |
| - new Employee(String.valueOf(count.increment()), nameSupplier.get(), airport, List.of(ATTENDANT_SKILL))); |
| 140 | + new Employee(String.valueOf(count.incrementAndGet()), nameSupplier.get(), airport, List.of(ATTENDANT_SKILL))); |
142 | 141 | employees.add(
|
143 |
| - new Employee(String.valueOf(count.increment()), nameSupplier.get(), airport, List.of(ATTENDANT_SKILL))); |
| 142 | + new Employee(String.valueOf(count.incrementAndGet()), nameSupplier.get(), airport, List.of(ATTENDANT_SKILL))); |
144 | 143 | if (airport.getCode().equals("CNF")) {
|
145 | 144 | employees.add(
|
146 |
| - new Employee(String.valueOf(count.increment()), nameSupplier.get(), airport, List.of(ATTENDANT_SKILL))); |
| 145 | + new Employee(String.valueOf(count.incrementAndGet()), nameSupplier.get(), airport, List.of(ATTENDANT_SKILL))); |
147 | 146 | }
|
148 | 147 | }));
|
149 | 148 |
|
@@ -247,22 +246,22 @@ private int pickRandomRouteSize(int countFlights, int maxCountFlights) {
|
247 | 246 | private List<FlightAssignment> generateFlightAssignments(List<Flight> flights) {
|
248 | 247 | // 2 pilots and 2 or 3 attendants
|
249 | 248 | List<FlightAssignment> flightAssignments = new ArrayList<>(flights.size() * 5);
|
250 |
| - MutableInt count = new MutableInt(); |
| 249 | + AtomicInteger count = new AtomicInteger(); |
251 | 250 | flights.forEach(flight -> {
|
252 |
| - MutableInt indexSkill = new MutableInt(); |
| 251 | + AtomicInteger indexSkill = new AtomicInteger(); |
253 | 252 | flightAssignments
|
254 |
| - .add(new FlightAssignment(String.valueOf(count.increment()), flight, indexSkill.increment(), PILOT_SKILL)); |
| 253 | + .add(new FlightAssignment(String.valueOf(count.incrementAndGet()), flight, indexSkill.incrementAndGet(), PILOT_SKILL)); |
255 | 254 | flightAssignments
|
256 |
| - .add(new FlightAssignment(String.valueOf(count.increment()), flight, indexSkill.increment(), PILOT_SKILL)); |
| 255 | + .add(new FlightAssignment(String.valueOf(count.incrementAndGet()), flight, indexSkill.incrementAndGet(), PILOT_SKILL)); |
257 | 256 | flightAssignments
|
258 |
| - .add(new FlightAssignment(String.valueOf(count.increment()), flight, indexSkill.increment(), |
| 257 | + .add(new FlightAssignment(String.valueOf(count.incrementAndGet()), flight, indexSkill.incrementAndGet(), |
259 | 258 | ATTENDANT_SKILL));
|
260 | 259 | flightAssignments
|
261 |
| - .add(new FlightAssignment(String.valueOf(count.increment()), flight, indexSkill.increment(), |
| 260 | + .add(new FlightAssignment(String.valueOf(count.incrementAndGet()), flight, indexSkill.incrementAndGet(), |
262 | 261 | ATTENDANT_SKILL));
|
263 | 262 | if (flight.getDepartureAirport().getCode().equals("CNF") || flight.getArrivalAirport().getCode().equals("CNF")) {
|
264 | 263 | flightAssignments
|
265 |
| - .add(new FlightAssignment(String.valueOf(count.increment()), flight, indexSkill.increment(), |
| 264 | + .add(new FlightAssignment(String.valueOf(count.incrementAndGet()), flight, indexSkill.incrementAndGet(), |
266 | 265 | ATTENDANT_SKILL));
|
267 | 266 | }
|
268 | 267 | });
|
|
0 commit comments