From d35465662b825e1bcf14f4da81518f2281c7d3f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=B6rl?= Date: Mon, 27 Nov 2023 22:14:02 +0100 Subject: [PATCH] chore: update to MATSim 15 (#29) * chore: update to MATSim 15 * update github workflow --- .github/workflows/tests.yml | 4 +- .../alonso_mora/AlonsoMoraModeQSimModule.java | 15 ++--- .../alonso_mora/AlonsoMoraOptimizer.java | 1 + .../algorithm/AlonsoMoraAlgorithm.java | 10 ++-- .../algorithm/AlonsoMoraRequest.java | 3 + .../algorithm/DefaultAlonsoMoraRequest.java | 13 ++++- .../assignment/CbcMpsAssignmentSolver.java | 5 +- .../assignment/GlpkMpsAssignmentSolver.java | 5 +- .../relocation/CbcMpsRelocationSolver.java | 5 +- .../relocation/GlpkMpsRelocationSolver.java | 5 +- .../example/CalculateTravelTimes.java | 5 +- .../alonso_mora/example/RunNewYork.java | 27 +++++---- .../DefaultAlonsoMoraScheduler.java | 12 ++-- .../shifts/AlonsoMoraShiftConstraint.java | 2 +- .../shifts/ShiftAlonsoMoraModule.java | 18 +++--- .../shifts/ShiftAlonsoMoraScheduler.java | 10 ++-- .../shifts/ShiftAlonsoMoraVehicle.java | 2 +- .../shifts/ShiftOperationalVoter.java | 8 +-- .../graphs/DefaultRequestGraphTest.java | 7 +++ .../graphs/DefaultVehicleGraphTest.java | 7 +++ .../alonso_mora/run/AlonsoMoraExamplesIT.java | 56 ++++++++++++------- .../gurobi/CplexAssignmentSolver.java | 5 +- .../glpk/GlpkJniAssignmentSolver.java | 5 +- .../glpk/GlpkJniRelocationSolver.java | 5 +- .../gurobi/GurobiAssignmentSolver.java | 5 +- pom.xml | 7 ++- 26 files changed, 154 insertions(+), 93 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ed6e6fd..253882b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -12,10 +12,10 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Set up JDK 11 + - name: Set up JDK 17 uses: actions/setup-java@v1 with: - java-version: 11 + java-version: 17 - name: Install GLPK and CBC run: sudo apt install glpk-utils coinor-cbc libglpk-java - name: Run tests diff --git a/core/src/main/java/org/matsim/alonso_mora/AlonsoMoraModeQSimModule.java b/core/src/main/java/org/matsim/alonso_mora/AlonsoMoraModeQSimModule.java index 5cee27f..1c9c686 100644 --- a/core/src/main/java/org/matsim/alonso_mora/AlonsoMoraModeQSimModule.java +++ b/core/src/main/java/org/matsim/alonso_mora/AlonsoMoraModeQSimModule.java @@ -59,6 +59,7 @@ import org.matsim.contrib.drt.run.DrtConfigGroup; import org.matsim.contrib.drt.schedule.DrtStayTaskEndTimeCalculator; import org.matsim.contrib.drt.schedule.DrtTaskFactory; +import org.matsim.contrib.drt.schedule.StopDurationEstimator; import org.matsim.contrib.drt.scheduler.DrtScheduleInquiry; import org.matsim.contrib.drt.scheduler.EmptyVehicleRelocator; import org.matsim.contrib.dvrp.fleet.Fleet; @@ -219,7 +220,7 @@ protected void configureQSim() { Network network = getter.getModal(Network.class); TravelTime travelTime = getter.getModal(TravelTime.class); - return new ParallelLeastCostPathCalculator(drtConfig.getNumberOfThreads(), factory, network, + return new ParallelLeastCostPathCalculator(drtConfig.numberOfThreads, factory, network, new OnlyTimeDependentTravelDisutility(travelTime), travelTime); })); @@ -322,7 +323,7 @@ protected void configureQSim() { CongestionMitigationParameters congestionParameters = amConfig.getCongestionMitigationParameters(); return new DefaultAlonsoMoraFunction(travelTimeEstimator, sequenceGeneratorFactory, - drtConfig.getStopDuration(), congestionParameters.getAllowPickupViolations(), + drtConfig.stopDuration, congestionParameters.getAllowPickupViolations(), congestionParameters.getAllowPickupsWithDropoffViolations(), amConfig.getCheckDeterminsticTravelTimes(), objective, constraint, amConfig.getViolationFactor(), amConfig.getViolationOffset(), amConfig.getPreferNonViolation()); @@ -332,7 +333,7 @@ protected void configureQSim() { bindModal(Constraint.class).toInstance(new NoopConstraint()); bindModal(StayTaskEndTimeCalculator.class).toProvider(modalProvider(getter -> { - return new DrtStayTaskEndTimeCalculator(drtConfig); + return new DrtStayTaskEndTimeCalculator(getter.getModal(StopDurationEstimator.class)); })); bindModal(AlonsoMoraScheduler.class).toProvider(modalProvider(getter -> { @@ -345,7 +346,7 @@ protected void configureQSim() { OperationalVoter operationalVoter = getter.getModal(OperationalVoter.class); - return new DefaultAlonsoMoraScheduler(taskFactory, drtConfig.getStopDuration(), + return new DefaultAlonsoMoraScheduler(taskFactory, drtConfig.stopDuration, amConfig.getCheckDeterminsticTravelTimes(), amConfig.getRerouteDuringScheduling(), travelTime, network, endTimeCalculator, router, operationalVoter); })); @@ -356,7 +357,7 @@ protected void configureQSim() { Double rebalancingInterval = null; if (drtConfig.getRebalancingParams().isPresent()) { - rebalancingInterval = (double) drtConfig.getRebalancingParams().get().getInterval(); + rebalancingInterval = (double) drtConfig.getRebalancingParams().get().interval; } return new StandardRebalancer( // @@ -388,7 +389,7 @@ protected void configureQSim() { getter.getModal(AlonsoMoraVehicleFactory.class), // getter.getModal(QSimScopeForkJoinPoolHolder.class).getPool(), // getter.getModal(TravelTimeEstimator.class), // - drtConfig.getStopDuration(), // + drtConfig.stopDuration, // new AlgorithmSettings(amConfig)); })); @@ -408,7 +409,7 @@ protected void configureQSim() { getter.getModal(QSimScopeForkJoinPoolHolder.class).getPool(), // getter.getModal(LeastCostPathCalculator.class), // getter.getModal(TravelTime.class), // - drtConfig.getAdvanceRequestPlanningHorizon(), // + drtConfig.advanceRequestPlanningHorizon, // getter.getModal(InformationCollector.class) // ); })); diff --git a/core/src/main/java/org/matsim/alonso_mora/AlonsoMoraOptimizer.java b/core/src/main/java/org/matsim/alonso_mora/AlonsoMoraOptimizer.java index aa840d3..1f7de50 100644 --- a/core/src/main/java/org/matsim/alonso_mora/AlonsoMoraOptimizer.java +++ b/core/src/main/java/org/matsim/alonso_mora/AlonsoMoraOptimizer.java @@ -15,6 +15,7 @@ import org.matsim.alonso_mora.algorithm.AlonsoMoraRequest; import org.matsim.alonso_mora.algorithm.AlonsoMoraRequestFactory; import org.matsim.contrib.drt.optimizer.DrtOptimizer; +import org.matsim.contrib.drt.passenger.AcceptedDrtRequest; import org.matsim.contrib.drt.passenger.DrtRequest; import org.matsim.contrib.dvrp.fleet.DvrpVehicle; import org.matsim.contrib.dvrp.fleet.Fleet; diff --git a/core/src/main/java/org/matsim/alonso_mora/algorithm/AlonsoMoraAlgorithm.java b/core/src/main/java/org/matsim/alonso_mora/algorithm/AlonsoMoraAlgorithm.java index d223689..12d97b1 100644 --- a/core/src/main/java/org/matsim/alonso_mora/algorithm/AlonsoMoraAlgorithm.java +++ b/core/src/main/java/org/matsim/alonso_mora/algorithm/AlonsoMoraAlgorithm.java @@ -18,7 +18,8 @@ import java.util.stream.Stream; import org.apache.commons.lang3.tuple.Pair; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.alonso_mora.AlonsoMoraConfigGroup; import org.matsim.alonso_mora.AlonsoMoraSubmissionEvent; import org.matsim.alonso_mora.algorithm.AlonsoMoraStop.StopType; @@ -36,6 +37,7 @@ import org.matsim.alonso_mora.scheduling.AlonsoMoraScheduler; import org.matsim.alonso_mora.travel_time.TravelTimeEstimator; import org.matsim.api.core.v01.network.Link; +import org.matsim.contrib.drt.passenger.AcceptedDrtRequest; import org.matsim.contrib.drt.passenger.DrtRequest; import org.matsim.contrib.drt.schedule.DefaultDrtStopTask; import org.matsim.contrib.drt.scheduler.EmptyVehicleRelocator; @@ -65,7 +67,7 @@ * */ public class AlonsoMoraAlgorithm { - private final Logger logger = Logger.getLogger(AlonsoMoraAlgorithm.class); + private final Logger logger = LogManager.getLogger(AlonsoMoraAlgorithm.class); private RequestGraph requestGraph; private final AssignmentSolver assignmentSolver; @@ -474,9 +476,9 @@ private void processAssignedRequests(Solution solution, double now, Information } } } - + /* For each DRT request, we create a scheduling event */ - for (DrtRequest drtRequest : request.getDrtRequests()) { + for (AcceptedDrtRequest drtRequest : request.getAcceptedDrtRequests()) { eventsManager.processEvent(new PassengerRequestScheduledEvent(now, mode, drtRequest.getId(), drtRequest.getPassengerId(), trip.getVehicle().getVehicle().getId(), expectedPickupTime, expectedDropoffTime)); diff --git a/core/src/main/java/org/matsim/alonso_mora/algorithm/AlonsoMoraRequest.java b/core/src/main/java/org/matsim/alonso_mora/algorithm/AlonsoMoraRequest.java index e27a811..1652b4f 100644 --- a/core/src/main/java/org/matsim/alonso_mora/algorithm/AlonsoMoraRequest.java +++ b/core/src/main/java/org/matsim/alonso_mora/algorithm/AlonsoMoraRequest.java @@ -3,6 +3,7 @@ import java.util.Collection; import org.matsim.api.core.v01.network.Link; +import org.matsim.contrib.drt.passenger.AcceptedDrtRequest; import org.matsim.contrib.drt.passenger.DrtRequest; import org.matsim.contrib.drt.schedule.DrtStopTask; @@ -34,6 +35,8 @@ public interface AlonsoMoraRequest extends Comparable { double getLatestAssignmentTime(); Collection getDrtRequests(); + + Collection getAcceptedDrtRequests(); public int getSize(); diff --git a/core/src/main/java/org/matsim/alonso_mora/algorithm/DefaultAlonsoMoraRequest.java b/core/src/main/java/org/matsim/alonso_mora/algorithm/DefaultAlonsoMoraRequest.java index 2152cdf..6d58ee3 100644 --- a/core/src/main/java/org/matsim/alonso_mora/algorithm/DefaultAlonsoMoraRequest.java +++ b/core/src/main/java/org/matsim/alonso_mora/algorithm/DefaultAlonsoMoraRequest.java @@ -7,6 +7,7 @@ import java.util.stream.Collectors; import org.matsim.api.core.v01.network.Link; +import org.matsim.contrib.drt.passenger.AcceptedDrtRequest; import org.matsim.contrib.drt.passenger.DrtRequest; import org.matsim.contrib.drt.schedule.DrtStopTask; import org.matsim.contrib.dvrp.schedule.Task.TaskStatus; @@ -26,6 +27,7 @@ */ public class DefaultAlonsoMoraRequest implements AlonsoMoraRequest { private final List drtRequests; + private List acceptedDrtRequests; private DrtStopTask pickupTask; private DrtStopTask dropoffTask; @@ -169,7 +171,16 @@ public double getLatestAssignmentTime() { public Collection getDrtRequests() { return drtRequests; } - + + public Collection getAcceptedDrtRequests() { + if (acceptedDrtRequests == null) { + acceptedDrtRequests = drtRequests.stream().map(AcceptedDrtRequest::createFromOriginalRequest) + .collect(Collectors.toList()); + } + + return acceptedDrtRequests; + } + @Override public void setVehicle(AlonsoMoraVehicle vehicle) { this.vehicle = vehicle; diff --git a/core/src/main/java/org/matsim/alonso_mora/algorithm/assignment/CbcMpsAssignmentSolver.java b/core/src/main/java/org/matsim/alonso_mora/algorithm/assignment/CbcMpsAssignmentSolver.java index 0c7d4dd..5498e60 100644 --- a/core/src/main/java/org/matsim/alonso_mora/algorithm/assignment/CbcMpsAssignmentSolver.java +++ b/core/src/main/java/org/matsim/alonso_mora/algorithm/assignment/CbcMpsAssignmentSolver.java @@ -13,7 +13,8 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.alonso_mora.algorithm.AlonsoMoraTrip; import org.matsim.alonso_mora.algorithm.assignment.AssignmentSolver.Solution.Status; @@ -27,7 +28,7 @@ public class CbcMpsAssignmentSolver implements AssignmentSolver { static public final String TYPE = "CbcMps"; - private final static Logger logger = Logger.getLogger(CbcMpsAssignmentSolver.class); + private final static Logger logger = LogManager.getLogger(CbcMpsAssignmentSolver.class); private final double rejectionPenalty; private final double unassignmentPenalty; diff --git a/core/src/main/java/org/matsim/alonso_mora/algorithm/assignment/GlpkMpsAssignmentSolver.java b/core/src/main/java/org/matsim/alonso_mora/algorithm/assignment/GlpkMpsAssignmentSolver.java index bd9f9fd..c33c47e 100644 --- a/core/src/main/java/org/matsim/alonso_mora/algorithm/assignment/GlpkMpsAssignmentSolver.java +++ b/core/src/main/java/org/matsim/alonso_mora/algorithm/assignment/GlpkMpsAssignmentSolver.java @@ -13,7 +13,8 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.alonso_mora.algorithm.AlonsoMoraTrip; import org.matsim.alonso_mora.algorithm.assignment.AssignmentSolver.Solution.Status; @@ -27,7 +28,7 @@ public class GlpkMpsAssignmentSolver implements AssignmentSolver { static public final String TYPE = "GlpkMps"; - private static final Logger logger = Logger.getLogger(GlpkMpsAssignmentSolver.class); + private static final Logger logger = LogManager.getLogger(GlpkMpsAssignmentSolver.class); private final double unassignmentPenalty; private final double rejectionPenalty; diff --git a/core/src/main/java/org/matsim/alonso_mora/algorithm/relocation/CbcMpsRelocationSolver.java b/core/src/main/java/org/matsim/alonso_mora/algorithm/relocation/CbcMpsRelocationSolver.java index 269180f..c956b92 100644 --- a/core/src/main/java/org/matsim/alonso_mora/algorithm/relocation/CbcMpsRelocationSolver.java +++ b/core/src/main/java/org/matsim/alonso_mora/algorithm/relocation/CbcMpsRelocationSolver.java @@ -12,7 +12,8 @@ import java.util.LinkedList; import java.util.List; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; /** * Solves the relocation problem as described by Alonso-Mora et al. using the @@ -24,7 +25,7 @@ public class CbcMpsRelocationSolver implements RelocationSolver { static public final String TYPE = "CbcMps"; - private final static Logger logger = Logger.getLogger(CbcMpsRelocationSolver.class); + private final static Logger logger = LogManager.getLogger(CbcMpsRelocationSolver.class); private final File problemPath; private final File solutionPath; diff --git a/core/src/main/java/org/matsim/alonso_mora/algorithm/relocation/GlpkMpsRelocationSolver.java b/core/src/main/java/org/matsim/alonso_mora/algorithm/relocation/GlpkMpsRelocationSolver.java index 9096586..d2638a8 100644 --- a/core/src/main/java/org/matsim/alonso_mora/algorithm/relocation/GlpkMpsRelocationSolver.java +++ b/core/src/main/java/org/matsim/alonso_mora/algorithm/relocation/GlpkMpsRelocationSolver.java @@ -12,7 +12,8 @@ import java.util.LinkedList; import java.util.List; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.alonso_mora.algorithm.assignment.GlpkMpsAssignmentSolver; /** @@ -25,7 +26,7 @@ public class GlpkMpsRelocationSolver implements RelocationSolver { static public final String TYPE = "GlpkMps"; - private static final Logger logger = Logger.getLogger(GlpkMpsRelocationSolver.class); + private static final Logger logger = LogManager.getLogger(GlpkMpsRelocationSolver.class); private final File problemPath; private final File solutionPath; diff --git a/core/src/main/java/org/matsim/alonso_mora/example/CalculateTravelTimes.java b/core/src/main/java/org/matsim/alonso_mora/example/CalculateTravelTimes.java index 3516ced..eb69103 100644 --- a/core/src/main/java/org/matsim/alonso_mora/example/CalculateTravelTimes.java +++ b/core/src/main/java/org/matsim/alonso_mora/example/CalculateTravelTimes.java @@ -16,7 +16,8 @@ import java.util.concurrent.atomic.AtomicLong; import java.util.stream.Collectors; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; @@ -41,7 +42,7 @@ import org.matsim.core.trafficmonitoring.FreeSpeedTravelTime; public class CalculateTravelTimes { - private final static Logger logger = Logger.getLogger(CalculateTravelTimes.class); + private final static Logger logger = LogManager.getLogger(CalculateTravelTimes.class); static public void main(String[] args) throws ConfigurationException { CommandLine cmd = new CommandLine.Builder(args) // diff --git a/core/src/main/java/org/matsim/alonso_mora/example/RunNewYork.java b/core/src/main/java/org/matsim/alonso_mora/example/RunNewYork.java index b7f3994..2849cc8 100644 --- a/core/src/main/java/org/matsim/alonso_mora/example/RunNewYork.java +++ b/core/src/main/java/org/matsim/alonso_mora/example/RunNewYork.java @@ -201,20 +201,19 @@ static public void main(String[] args) throws CommandLine.ConfigurationException MultiModeDrtConfigGroup drtConfig = new MultiModeDrtConfigGroup(); config.addModule(drtConfig); - - DrtConfigGroup modeConfig = new DrtConfigGroup() // - .setMode(TransportMode.drt) // - .setMaxTravelTimeAlpha(detourFactor) // - .setMaxTravelTimeBeta(stopDuration) // - .setMaxWaitTime(maximumWaitingTime + stopDuration) // - .setStopDuration(stopDuration) // - .setRejectRequestIfMaxWaitOrTravelTimeViolated(true) // - .setUseModeFilteredSubnetwork(false) // - .setIdleVehiclesReturnToDepots(false) // - .setOperationalScheme(DrtConfigGroup.OperationalScheme.door2door) // - .setPlotDetailedCustomerStats(true) // - .setMaxWalkDistance(1000.) // - .setNumberOfThreads(threads); + + DrtConfigGroup modeConfig = new DrtConfigGroup(); + modeConfig.mode = TransportMode.drt; + modeConfig.maxTravelTimeAlpha = detourFactor; + modeConfig.maxTravelTimeBeta = stopDuration; + modeConfig.maxWaitTime = maximumWaitingTime + stopDuration; + modeConfig.rejectRequestIfMaxWaitOrTravelTimeViolated = true; + modeConfig.useModeFilteredSubnetwork = false; + modeConfig.idleVehiclesReturnToDepots = false; + modeConfig.operationalScheme = DrtConfigGroup.OperationalScheme.door2door; + modeConfig.plotDetailedCustomerStats = true; + modeConfig.maxWalkDistance = 1000.0; + modeConfig.numberOfThreads = threads; modeConfig.addParameterSet(new ExtensiveInsertionSearchParams()); drtConfig.addParameterSet(modeConfig); diff --git a/core/src/main/java/org/matsim/alonso_mora/scheduling/DefaultAlonsoMoraScheduler.java b/core/src/main/java/org/matsim/alonso_mora/scheduling/DefaultAlonsoMoraScheduler.java index 76d4ca6..f549541 100644 --- a/core/src/main/java/org/matsim/alonso_mora/scheduling/DefaultAlonsoMoraScheduler.java +++ b/core/src/main/java/org/matsim/alonso_mora/scheduling/DefaultAlonsoMoraScheduler.java @@ -12,8 +12,8 @@ import org.matsim.alonso_mora.algorithm.AlonsoMoraVehicle; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; -import org.matsim.contrib.drt.extension.shifts.schedule.WaitForShiftStayTask; -import org.matsim.contrib.drt.passenger.DrtRequest; +import org.matsim.contrib.drt.extension.operations.shifts.schedule.WaitForShiftStayTask; +import org.matsim.contrib.drt.passenger.AcceptedDrtRequest; import org.matsim.contrib.drt.schedule.DrtDriveTask; import org.matsim.contrib.drt.schedule.DrtStayTask; import org.matsim.contrib.drt.schedule.DrtStopTask; @@ -121,13 +121,13 @@ private void verifyActivePickupAndDropoff(AlonsoMoraVehicle vehicle, List { - return new ShiftDrtStayTaskEndTimeCalculator(shiftConfig, new DrtStayTaskEndTimeCalculator(drtConfig)); + return new ShiftDrtStayTaskEndTimeCalculator(shiftConfig, + new DrtStayTaskEndTimeCalculator(getter.getModal(StopDurationEstimator.class))); })); bindModal(OperationalVoter.class).toProvider(modalProvider(getter -> { @@ -70,7 +72,7 @@ protected void configureQSim() { OperationalVoter operationalVoter = getter.getModal(OperationalVoter.class); - return new ShiftAlonsoMoraScheduler(taskFactory, drtConfig.getStopDuration(), + return new ShiftAlonsoMoraScheduler(taskFactory, drtConfig.stopDuration, amConfig.getCheckDeterminsticTravelTimes(), amConfig.getRerouteDuringScheduling(), travelTime, network, endTimeCalculator, router, operationalVoter); })); diff --git a/core/src/main/java/org/matsim/alonso_mora/shifts/ShiftAlonsoMoraScheduler.java b/core/src/main/java/org/matsim/alonso_mora/shifts/ShiftAlonsoMoraScheduler.java index 2bb1ada..c37c2db 100644 --- a/core/src/main/java/org/matsim/alonso_mora/shifts/ShiftAlonsoMoraScheduler.java +++ b/core/src/main/java/org/matsim/alonso_mora/shifts/ShiftAlonsoMoraScheduler.java @@ -14,9 +14,9 @@ import org.matsim.alonso_mora.scheduling.WaitForStopTask; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; -import org.matsim.contrib.drt.extension.shifts.schedule.ShiftBreakTask; -import org.matsim.contrib.drt.extension.shifts.schedule.ShiftChangeOverTask; -import org.matsim.contrib.drt.extension.shifts.schedule.WaitForShiftStayTask; +import org.matsim.contrib.drt.extension.operations.shifts.schedule.ShiftBreakTask; +import org.matsim.contrib.drt.extension.operations.shifts.schedule.ShiftChangeOverTask; +import org.matsim.contrib.drt.extension.operations.shifts.schedule.WaitForShiftStayTask; import org.matsim.contrib.drt.passenger.DrtRequest; import org.matsim.contrib.drt.schedule.DrtDriveTask; import org.matsim.contrib.drt.schedule.DrtStayTask; @@ -292,7 +292,7 @@ public void schedule(AlonsoMoraVehicle vehicle, double now) { // Add requests to the stop task if (stop.getType().equals(StopType.Pickup)) { - stop.getRequest().getDrtRequests().forEach(stopTask::addPickupRequest); + stop.getRequest().getAcceptedDrtRequests().forEach(stopTask::addPickupRequest); stop.getRequest().setPickupTask(vehicle, stopTask); if (checkDeterminsticTravelTimes) { @@ -302,7 +302,7 @@ public void schedule(AlonsoMoraVehicle vehicle, double now) { "Checking for determinstic travel times and found mismatch between expected stop time and planned stop time."); } } else if (stop.getType().equals(StopType.Dropoff)) { - stop.getRequest().getDrtRequests().forEach(stopTask::addDropoffRequest); + stop.getRequest().getAcceptedDrtRequests().forEach(stopTask::addDropoffRequest); stop.getRequest().setDropoffTask(vehicle, stopTask); if (checkDeterminsticTravelTimes) { diff --git a/core/src/main/java/org/matsim/alonso_mora/shifts/ShiftAlonsoMoraVehicle.java b/core/src/main/java/org/matsim/alonso_mora/shifts/ShiftAlonsoMoraVehicle.java index 30edc26..e6f49db 100644 --- a/core/src/main/java/org/matsim/alonso_mora/shifts/ShiftAlonsoMoraVehicle.java +++ b/core/src/main/java/org/matsim/alonso_mora/shifts/ShiftAlonsoMoraVehicle.java @@ -1,7 +1,7 @@ package org.matsim.alonso_mora.shifts; import org.matsim.alonso_mora.algorithm.DefaultAlonsoMoraVehicle; -import org.matsim.contrib.drt.extension.shifts.schedule.OperationalStop; +import org.matsim.contrib.drt.extension.operations.shifts.schedule.OperationalStop; import org.matsim.contrib.dvrp.fleet.DvrpVehicle; import org.matsim.contrib.dvrp.schedule.Schedule; import org.matsim.contrib.dvrp.schedule.Schedule.ScheduleStatus; diff --git a/core/src/main/java/org/matsim/alonso_mora/shifts/ShiftOperationalVoter.java b/core/src/main/java/org/matsim/alonso_mora/shifts/ShiftOperationalVoter.java index 4b3cfde..0121ce6 100644 --- a/core/src/main/java/org/matsim/alonso_mora/shifts/ShiftOperationalVoter.java +++ b/core/src/main/java/org/matsim/alonso_mora/shifts/ShiftOperationalVoter.java @@ -1,10 +1,10 @@ package org.matsim.alonso_mora.shifts; import org.matsim.alonso_mora.scheduling.DefaultAlonsoMoraScheduler.OperationalVoter; -import org.matsim.contrib.drt.extension.shifts.schedule.OperationalStop; -import org.matsim.contrib.drt.extension.shifts.schedule.ShiftBreakTask; -import org.matsim.contrib.drt.extension.shifts.schedule.ShiftChangeOverTask; -import org.matsim.contrib.drt.extension.shifts.scheduler.ShiftTaskScheduler; +import org.matsim.contrib.drt.extension.operations.shifts.schedule.OperationalStop; +import org.matsim.contrib.drt.extension.operations.shifts.schedule.ShiftBreakTask; +import org.matsim.contrib.drt.extension.operations.shifts.schedule.ShiftChangeOverTask; +import org.matsim.contrib.drt.extension.operations.shifts.scheduler.ShiftTaskScheduler; import org.matsim.contrib.drt.schedule.DrtDriveTask; import org.matsim.contrib.drt.schedule.DrtTaskType; import org.matsim.contrib.dvrp.schedule.Task; diff --git a/core/src/test/java/org/matsim/alonso_mora/algorithm/function/graphs/DefaultRequestGraphTest.java b/core/src/test/java/org/matsim/alonso_mora/algorithm/function/graphs/DefaultRequestGraphTest.java index 37e9ff2..387a702 100644 --- a/core/src/test/java/org/matsim/alonso_mora/algorithm/function/graphs/DefaultRequestGraphTest.java +++ b/core/src/test/java/org/matsim/alonso_mora/algorithm/function/graphs/DefaultRequestGraphTest.java @@ -12,6 +12,7 @@ import org.matsim.alonso_mora.algorithm.graphs.DefaultRequestGraph; import org.matsim.alonso_mora.algorithm.graphs.RequestGraph; import org.matsim.api.core.v01.network.Link; +import org.matsim.contrib.drt.passenger.AcceptedDrtRequest; import org.matsim.contrib.drt.passenger.DrtRequest; import org.matsim.contrib.drt.schedule.DrtStopTask; @@ -153,6 +154,12 @@ public Collection getDrtRequests() { // TODO Auto-generated method stub return null; } + + @Override + public Collection getAcceptedDrtRequests() { + // TODO Auto-generated method stub + return null; + } @Override public int getSize() { diff --git a/core/src/test/java/org/matsim/alonso_mora/algorithm/function/graphs/DefaultVehicleGraphTest.java b/core/src/test/java/org/matsim/alonso_mora/algorithm/function/graphs/DefaultVehicleGraphTest.java index a27411e..c5178ff 100644 --- a/core/src/test/java/org/matsim/alonso_mora/algorithm/function/graphs/DefaultVehicleGraphTest.java +++ b/core/src/test/java/org/matsim/alonso_mora/algorithm/function/graphs/DefaultVehicleGraphTest.java @@ -19,6 +19,7 @@ import org.matsim.alonso_mora.algorithm.graphs.RequestGraph; import org.matsim.alonso_mora.algorithm.graphs.VehicleGraph; import org.matsim.api.core.v01.network.Link; +import org.matsim.contrib.drt.passenger.AcceptedDrtRequest; import org.matsim.contrib.drt.passenger.DrtRequest; import org.matsim.contrib.drt.schedule.DrtStopTask; import org.matsim.contrib.dvrp.fleet.DvrpVehicle; @@ -396,6 +397,12 @@ public Collection getDrtRequests() { return null; } + @Override + public Collection getAcceptedDrtRequests() { + // TODO Auto-generated method stub + return null; + } + @Override public int getSize() { // TODO Auto-generated method stub diff --git a/core/src/test/java/org/matsim/alonso_mora/run/AlonsoMoraExamplesIT.java b/core/src/test/java/org/matsim/alonso_mora/run/AlonsoMoraExamplesIT.java index da8a21c..427d603 100644 --- a/core/src/test/java/org/matsim/alonso_mora/run/AlonsoMoraExamplesIT.java +++ b/core/src/test/java/org/matsim/alonso_mora/run/AlonsoMoraExamplesIT.java @@ -42,20 +42,25 @@ import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; -import org.matsim.contrib.drt.extension.shifts.config.ShiftDrtConfigGroup; -import org.matsim.contrib.drt.extension.shifts.operationFacilities.OperationFacilitiesSpecification; -import org.matsim.contrib.drt.extension.shifts.operationFacilities.OperationFacilitiesSpecificationImpl; -import org.matsim.contrib.drt.extension.shifts.operationFacilities.OperationFacility; -import org.matsim.contrib.drt.extension.shifts.operationFacilities.OperationFacilitySpecificationImpl; -import org.matsim.contrib.drt.extension.shifts.operationFacilities.OperationFacilityType; -import org.matsim.contrib.drt.extension.shifts.run.ShiftDrtModeModule; -import org.matsim.contrib.drt.extension.shifts.run.ShiftDrtModeOptimizerQSimModule; -import org.matsim.contrib.drt.extension.shifts.run.ShiftDvrpFleetQsimModule; -import org.matsim.contrib.drt.extension.shifts.shift.DrtShift; -import org.matsim.contrib.drt.extension.shifts.shift.DrtShiftBreakSpecificationImpl; -import org.matsim.contrib.drt.extension.shifts.shift.DrtShiftSpecificationImpl; -import org.matsim.contrib.drt.extension.shifts.shift.DrtShiftsSpecification; -import org.matsim.contrib.drt.extension.shifts.shift.DrtShiftsSpecificationImpl; +import org.matsim.contrib.drt.extension.DrtWithExtensionsConfigGroup; +import org.matsim.contrib.drt.extension.operations.DrtOperationsParams; +import org.matsim.contrib.drt.extension.operations.DrtWithOperationsConfigGroup; +import org.matsim.contrib.drt.extension.operations.operationFacilities.OperationFacilitiesParams; +import org.matsim.contrib.drt.extension.operations.operationFacilities.OperationFacilitiesQSimModule; +import org.matsim.contrib.drt.extension.operations.operationFacilities.OperationFacilitiesSpecification; +import org.matsim.contrib.drt.extension.operations.operationFacilities.OperationFacilitiesSpecificationImpl; +import org.matsim.contrib.drt.extension.operations.operationFacilities.OperationFacility; +import org.matsim.contrib.drt.extension.operations.operationFacilities.OperationFacilitySpecificationImpl; +import org.matsim.contrib.drt.extension.operations.operationFacilities.OperationFacilityType; +import org.matsim.contrib.drt.extension.operations.shifts.config.ShiftsParams; +import org.matsim.contrib.drt.extension.operations.shifts.run.ShiftDrtModeModule; +import org.matsim.contrib.drt.extension.operations.shifts.run.ShiftDrtModeOptimizerQSimModule; +import org.matsim.contrib.drt.extension.operations.shifts.run.ShiftDvrpFleetQsimModule; +import org.matsim.contrib.drt.extension.operations.shifts.shift.DrtShift; +import org.matsim.contrib.drt.extension.operations.shifts.shift.DrtShiftBreakSpecificationImpl; +import org.matsim.contrib.drt.extension.operations.shifts.shift.DrtShiftSpecificationImpl; +import org.matsim.contrib.drt.extension.operations.shifts.shift.DrtShiftsSpecification; +import org.matsim.contrib.drt.extension.operations.shifts.shift.DrtShiftsSpecificationImpl; import org.matsim.contrib.drt.routing.DrtRoute; import org.matsim.contrib.drt.routing.DrtRouteFactory; import org.matsim.contrib.drt.run.DrtConfigGroup; @@ -132,20 +137,28 @@ public void testRunAlonsoMora() { public void testRunAlonsoMoraWithShifts() { Id.resetCaches(); URL configUrl = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("mielec"), "mielec_drt_config.xml"); - Config config = ConfigUtils.loadConfig(configUrl, new MultiModeDrtConfigGroup(), new DvrpConfigGroup(), + Config config = ConfigUtils.loadConfig(configUrl, new MultiModeDrtConfigGroup(DrtWithOperationsConfigGroup::new), new DvrpConfigGroup(), new MultiModeAlonsoMoraConfigGroup(), new OTFVisConfigGroup()); AlonsoMoraConfigGroup amConfig = new AlonsoMoraConfigGroup(); MultiModeAlonsoMoraConfigGroup.get(config).addParameterSet(amConfig); - ShiftDrtConfigGroup shiftDrtConfigGroup = ConfigUtils.addOrGetModule(config, ShiftDrtConfigGroup.class); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); config.controler().setOutputDirectory(utils.getOutputDirectory()); // Remove DRT rebalancer as we want to use AM rebalancer - DrtConfigGroup drtConfig = MultiModeDrtConfigGroup.get(config).getModalElements().iterator().next(); + DrtWithOperationsConfigGroup drtConfig = (DrtWithOperationsConfigGroup) MultiModeDrtConfigGroup.get(config).getModalElements().iterator().next(); drtConfig.removeParameterSet(drtConfig.getRebalancingParams().get()); + + // shift parameters + DrtOperationsParams operationsParams = new DrtOperationsParams(); + drtConfig.addParameterSet(operationsParams); + + OperationFacilitiesParams operationFacilitiesParams = new OperationFacilitiesParams(); + operationsParams.addParameterSet(operationFacilitiesParams); + + ShiftsParams shiftParams = new ShiftsParams(); + operationsParams.addParameterSet(shiftParams); // Load scenario Scenario scenario = ScenarioUtils.createScenario(config); @@ -221,9 +234,10 @@ public void testRunAlonsoMoraWithShifts() { controller.configureQSimComponents(DvrpQSimComponents.activateAllModes(MultiModeDrtConfigGroup.get(config))); for (DrtConfigGroup drtCfg : MultiModeDrtConfigGroup.get(config).getModalElements()) { - controller.addOverridingModule(new ShiftDrtModeModule(drtCfg, shiftDrtConfigGroup)); - controller.addOverridingQSimModule(new DrtModeQSimModule(drtCfg, new ShiftDrtModeOptimizerQSimModule(drtCfg, shiftDrtConfigGroup))); + controller.addOverridingModule(new ShiftDrtModeModule(drtCfg)); + controller.addOverridingQSimModule(new DrtModeQSimModule(drtCfg, new ShiftDrtModeOptimizerQSimModule(drtCfg))); controller.addOverridingQSimModule(new ShiftDvrpFleetQsimModule(drtCfg.getMode())); + controller.addOverridingQSimModule(new OperationFacilitiesQSimModule(drtConfig)); } controller.addOverridingModule(new AbstractDvrpModeModule("drt") { @@ -235,7 +249,7 @@ public void install() { }); AlonsoMoraConfigurator.configure(controller, amConfig.getMode()); - controller.addOverridingQSimModule(new ShiftAlonsoMoraModule(drtConfig, shiftDrtConfigGroup, amConfig)); + controller.addOverridingQSimModule(new ShiftAlonsoMoraModule(drtConfig, shiftParams, amConfig)); controller.run(); var expectedStats = Stats.newBuilder() // diff --git a/cplex/src/main/java/org/matsim/alonso_mora/gurobi/CplexAssignmentSolver.java b/cplex/src/main/java/org/matsim/alonso_mora/gurobi/CplexAssignmentSolver.java index 6501232..f6b7c19 100644 --- a/cplex/src/main/java/org/matsim/alonso_mora/gurobi/CplexAssignmentSolver.java +++ b/cplex/src/main/java/org/matsim/alonso_mora/gurobi/CplexAssignmentSolver.java @@ -7,7 +7,8 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.alonso_mora.algorithm.AlonsoMoraRequest; import org.matsim.alonso_mora.algorithm.AlonsoMoraTrip; import org.matsim.alonso_mora.algorithm.AlonsoMoraVehicle; @@ -31,7 +32,7 @@ public class CplexAssignmentSolver implements AssignmentSolver { public static final String TYPE = "CPLEX"; - private static final Logger logger = Logger.getLogger(CplexAssignmentSolver.class); + private static final Logger logger = LogManager.getLogger(CplexAssignmentSolver.class); private final double unassignmentPenalty; private final double rejectionPenalty; diff --git a/glpk/src/main/java/org/matsim/alonso_mora/glpk/GlpkJniAssignmentSolver.java b/glpk/src/main/java/org/matsim/alonso_mora/glpk/GlpkJniAssignmentSolver.java index 32ddb58..d493427 100644 --- a/glpk/src/main/java/org/matsim/alonso_mora/glpk/GlpkJniAssignmentSolver.java +++ b/glpk/src/main/java/org/matsim/alonso_mora/glpk/GlpkJniAssignmentSolver.java @@ -10,7 +10,8 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.gnu.glpk.GLPK; import org.gnu.glpk.GLPKConstants; import org.gnu.glpk.SWIGTYPE_p_double; @@ -32,7 +33,7 @@ public class GlpkJniAssignmentSolver implements AssignmentSolver { static public final String TYPE = "GlpkJni"; - private static final Logger logger = Logger.getLogger(GlpkJniAssignmentSolver.class); + private static final Logger logger = LogManager.getLogger(GlpkJniAssignmentSolver.class); private final double unassignmentPenalty; private final double rejectionPenalty; diff --git a/glpk/src/main/java/org/matsim/alonso_mora/glpk/GlpkJniRelocationSolver.java b/glpk/src/main/java/org/matsim/alonso_mora/glpk/GlpkJniRelocationSolver.java index d548809..53c53f1 100644 --- a/glpk/src/main/java/org/matsim/alonso_mora/glpk/GlpkJniRelocationSolver.java +++ b/glpk/src/main/java/org/matsim/alonso_mora/glpk/GlpkJniRelocationSolver.java @@ -7,7 +7,8 @@ import java.util.List; import java.util.stream.Collectors; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.gnu.glpk.GLPK; import org.gnu.glpk.GLPKConstants; import org.gnu.glpk.SWIGTYPE_p_double; @@ -26,7 +27,7 @@ public class GlpkJniRelocationSolver implements RelocationSolver { static public final String TYPE = "GlpkJni"; - private static final Logger logger = Logger.getLogger(GlpkJniRelocationSolver.class); + private static final Logger logger = LogManager.getLogger(GlpkJniRelocationSolver.class); @Override public Collection solve(List candidates) { diff --git a/gurobi/src/main/java/org/matsim/alonso_mora/gurobi/GurobiAssignmentSolver.java b/gurobi/src/main/java/org/matsim/alonso_mora/gurobi/GurobiAssignmentSolver.java index cd259c9..e739ae1 100644 --- a/gurobi/src/main/java/org/matsim/alonso_mora/gurobi/GurobiAssignmentSolver.java +++ b/gurobi/src/main/java/org/matsim/alonso_mora/gurobi/GurobiAssignmentSolver.java @@ -7,7 +7,8 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.alonso_mora.algorithm.AlonsoMoraRequest; import org.matsim.alonso_mora.algorithm.AlonsoMoraTrip; import org.matsim.alonso_mora.algorithm.AlonsoMoraVehicle; @@ -33,7 +34,7 @@ public class GurobiAssignmentSolver implements AssignmentSolver { public static final String TYPE = "Gurobi"; - private static final Logger logger = Logger.getLogger(GurobiAssignmentSolver.class); + private static final Logger logger = LogManager.getLogger(GurobiAssignmentSolver.class); private final double unassignmentPenalty; private final double rejectionPenalty; diff --git a/pom.xml b/pom.xml index 468b390..8dfe1a1 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,7 @@ to the MATSim framework. 11 11 - 14.0 + 15.0 @@ -70,6 +70,11 @@ to the MATSim framework. ${matsim.version} test + + org.matsim.contrib + drt-extensions + ${matsim.version} + org.matsim.contrib drt