From aa0024cb7606e11d768f31738d8718262900b5fa Mon Sep 17 00:00:00 2001 From: nkuehnel Date: Tue, 23 Jul 2024 15:17:39 +0200 Subject: [PATCH] update to matsim 2025-3380 --- .../alonso_mora/AlonsoMoraConfigGroup.java | 2 +- .../alonso_mora/example/RunNewYork.java | 21 ++++++++++++------- .../DefaultAlonsoMoraScheduler.java | 4 ++-- .../shifts/ShiftAlonsoMoraScheduler.java | 4 ++-- .../org/matsim/alonso_mora/DiversionTest.java | 4 ++-- .../alonso_mora/run/AlonsoMoraExamplesIT.java | 21 +++++++++++++------ pom.xml | 6 +++--- 7 files changed, 39 insertions(+), 23 deletions(-) diff --git a/core/src/main/java/org/matsim/alonso_mora/AlonsoMoraConfigGroup.java b/core/src/main/java/org/matsim/alonso_mora/AlonsoMoraConfigGroup.java index b547dda..72ea7b6 100644 --- a/core/src/main/java/org/matsim/alonso_mora/AlonsoMoraConfigGroup.java +++ b/core/src/main/java/org/matsim/alonso_mora/AlonsoMoraConfigGroup.java @@ -16,9 +16,9 @@ import org.matsim.alonso_mora.travel_time.HybridTravelTimeEstimator; import org.matsim.alonso_mora.travel_time.MatrixTravelTimeEstimator; import org.matsim.alonso_mora.travel_time.RoutingTravelTimeEstimator; +import org.matsim.contrib.common.util.ReflectiveConfigGroupWithConfigurableParameterSets; import org.matsim.contrib.drt.run.DrtConfigGroup; import org.matsim.contrib.drt.run.MultiModeDrtConfigGroup; -import org.matsim.contrib.util.ReflectiveConfigGroupWithConfigurableParameterSets; import org.matsim.core.config.Config; import org.matsim.core.config.ReflectiveConfigGroup; 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 f72d5e1..bbf42f9 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 @@ -19,6 +19,8 @@ import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Node; import org.matsim.api.core.v01.population.Person; +import org.matsim.contrib.drt.optimizer.constraints.DefaultDrtOptimizationConstraintsSet; +import org.matsim.contrib.drt.optimizer.constraints.DrtOptimizationConstraintsSet; import org.matsim.contrib.drt.optimizer.insertion.extensive.ExtensiveInsertionSearchParams; import org.matsim.contrib.drt.routing.DrtRoute; import org.matsim.contrib.drt.routing.DrtRouteFactory; @@ -43,10 +45,9 @@ import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; import org.matsim.core.scenario.ScenarioUtils; -import org.opengis.referencing.FactoryException; public class RunNewYork { - static public void main(String[] args) throws CommandLine.ConfigurationException, FactoryException { + static public void main(String[] args) throws CommandLine.ConfigurationException { CommandLine cmd = new CommandLine.Builder(args).requireOptions( // "demand-path", "network-path", "output-path", // "use-alonso-mora" // @@ -204,15 +205,21 @@ static public void main(String[] args) throws CommandLine.ConfigurationException DrtConfigGroup modeConfig = new DrtConfigGroup(); modeConfig.mode = TransportMode.drt; - modeConfig.maxTravelTimeAlpha = detourFactor; - modeConfig.maxTravelTimeBeta = stopDuration; - modeConfig.maxWaitTime = maximumWaitingTime + stopDuration; - modeConfig.rejectRequestIfMaxWaitOrTravelTimeViolated = true; + + DefaultDrtOptimizationConstraintsSet constraintsSet = + (DefaultDrtOptimizationConstraintsSet) modeConfig + .addOrGetDrtOptimizationConstraintsParams() + .addOrGetDefaultDrtOptimizationConstraintsSet(); + constraintsSet.maxTravelTimeAlpha = detourFactor; + constraintsSet.maxTravelTimeBeta = stopDuration; + constraintsSet.maxWaitTime = maximumWaitingTime + stopDuration; + constraintsSet.rejectRequestIfMaxWaitOrTravelTimeViolated = true; + constraintsSet.maxWalkDistance = 1000.0; + 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()); 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 5cd3298..6257b7e 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,7 +12,7 @@ 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.operations.shifts.schedule.WaitForShiftStayTask; +import org.matsim.contrib.drt.extension.operations.shifts.schedule.WaitForShiftTask; import org.matsim.contrib.drt.passenger.AcceptedDrtRequest; import org.matsim.contrib.drt.schedule.DrtDriveTask; import org.matsim.contrib.drt.schedule.DrtStayTask; @@ -472,7 +472,7 @@ public void schedule(AlonsoMoraVehicle vehicle, double now) { if (currentTask instanceof DrtStayTask) { currentTask.setEndTime(Math.max(currentTask.getEndTime(), vehicle.getVehicle().getServiceEndTime())); - } else if (currentTask instanceof WaitForShiftStayTask) { + } else if (currentTask instanceof WaitForShiftTask) { if (currentTask.getEndTime() == now) { // if the shift just started, re-create the stay task StayTask stayTask = taskFactory.createStayTask(dvrpVehicle, currentTask.getEndTime(), 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 4ebe041..1ea651f 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 @@ -15,7 +15,7 @@ import org.matsim.api.core.v01.network.Network; 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.extension.operations.shifts.schedule.WaitForShiftTask; import org.matsim.contrib.drt.passenger.AcceptedDrtRequest; import org.matsim.contrib.drt.schedule.DrtDriveTask; import org.matsim.contrib.drt.schedule.DrtStayTask; @@ -497,7 +497,7 @@ public void schedule(AlonsoMoraVehicle vehicle, double now) { if (currentTask instanceof DrtStayTask) { currentTask.setEndTime(Math.max(currentTask.getEndTime(), vehicle.getVehicle().getServiceEndTime())); - } else if (currentTask instanceof WaitForShiftStayTask) { + } else if (currentTask instanceof WaitForShiftTask) { if (currentTask.getEndTime() == now) { // if the shift just started, re-create the stay task StayTask stayTask = taskFactory.createStayTask(dvrpVehicle, currentTask.getEndTime(), diff --git a/core/src/test/java/org/matsim/alonso_mora/DiversionTest.java b/core/src/test/java/org/matsim/alonso_mora/DiversionTest.java index 8bc2699..254dea0 100644 --- a/core/src/test/java/org/matsim/alonso_mora/DiversionTest.java +++ b/core/src/test/java/org/matsim/alonso_mora/DiversionTest.java @@ -303,7 +303,7 @@ protected void configureQSim() { }; })); - bindModal(VehicleType.class).toInstance(VehicleUtils.getDefaultVehicleType()); + bindModal(VehicleType.class).toInstance(VehicleUtils.createDefaultVehicleType()); } } @@ -537,7 +537,7 @@ protected void configureQSim() { testTracker); })).in(Singleton.class); - bindModal(VehicleType.class).toInstance(VehicleUtils.getDefaultVehicleType()); + bindModal(VehicleType.class).toInstance(VehicleUtils.createDefaultVehicleType()); } }); 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 38a2029..c092a44 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 @@ -43,8 +43,9 @@ 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.common.zones.systems.grid.square.SquareGridZoneSystemParams; +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; @@ -95,7 +96,9 @@ public class AlonsoMoraExamplesIT { public void testRunAlonsoMora() { Id.resetCaches(); URL configUrl = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("mielec"), "mielec_drt_config.xml"); - Config config = ConfigUtils.loadConfig(configUrl, new MultiModeDrtConfigGroup(), new DvrpConfigGroup(), + DvrpConfigGroup dvrpConfigGroup = new DvrpConfigGroup(); + dvrpConfigGroup.getTravelTimeMatrixParams().addParameterSet(new SquareGridZoneSystemParams()); + Config config = ConfigUtils.loadConfig(configUrl, new MultiModeDrtConfigGroup(), dvrpConfigGroup, new MultiModeAlonsoMoraConfigGroup(), new OTFVisConfigGroup()); AlonsoMoraConfigGroup amConfig = new AlonsoMoraConfigGroup(); @@ -139,7 +142,9 @@ public void testRunAlonsoMora() { public void testRunAlonsoMoraWithDeterministicTravelTimesCheck() { Id.resetCaches(); URL configUrl = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("mielec"), "mielec_drt_config.xml"); - Config config = ConfigUtils.loadConfig(configUrl, new MultiModeDrtConfigGroup(), new DvrpConfigGroup(), + DvrpConfigGroup dvrpConfigGroup = new DvrpConfigGroup(); + dvrpConfigGroup.getTravelTimeMatrixParams().addParameterSet(new SquareGridZoneSystemParams()); + Config config = ConfigUtils.loadConfig(configUrl, new MultiModeDrtConfigGroup(), dvrpConfigGroup, new MultiModeAlonsoMoraConfigGroup(), new OTFVisConfigGroup()); AlonsoMoraConfigGroup amConfig = new AlonsoMoraConfigGroup(); @@ -197,8 +202,10 @@ public void testRunAlonsoMoraWithDeterministicTravelTimesCheck() { public void testRunAlonsoMoraWithShifts() { Id.resetCaches(); URL configUrl = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("mielec"), "mielec_drt_config.xml"); + DvrpConfigGroup dvrpConfigGroup = new DvrpConfigGroup(); + dvrpConfigGroup.getTravelTimeMatrixParams().addParameterSet(new SquareGridZoneSystemParams()); Config config = ConfigUtils.loadConfig(configUrl, - new MultiModeDrtConfigGroup(DrtWithOperationsConfigGroup::new), new DvrpConfigGroup(), + new MultiModeDrtConfigGroup(DrtWithExtensionsConfigGroup::new), dvrpConfigGroup, new MultiModeAlonsoMoraConfigGroup(), new OTFVisConfigGroup()); AlonsoMoraConfigGroup amConfig = new AlonsoMoraConfigGroup(); @@ -208,7 +215,7 @@ public void testRunAlonsoMoraWithShifts() { config.controller().setOutputDirectory(utils.getOutputDirectory()); // Remove DRT rebalancer as we want to use AM rebalancer - DrtWithOperationsConfigGroup drtConfig = (DrtWithOperationsConfigGroup) MultiModeDrtConfigGroup.get(config) + DrtWithExtensionsConfigGroup drtConfig = (DrtWithExtensionsConfigGroup) MultiModeDrtConfigGroup.get(config) .getModalElements().iterator().next(); drtConfig.removeParameterSet(drtConfig.getRebalancingParams().get()); @@ -431,7 +438,9 @@ public Stats build() { public void testRunAlonsoMoraWithPrebooking() { Id.resetCaches(); URL configUrl = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("mielec"), "mielec_drt_config.xml"); - Config config = ConfigUtils.loadConfig(configUrl, new MultiModeDrtConfigGroup(), new DvrpConfigGroup(), + DvrpConfigGroup dvrpConfigGroup = new DvrpConfigGroup(); + dvrpConfigGroup.getTravelTimeMatrixParams().addParameterSet(new SquareGridZoneSystemParams()); + Config config = ConfigUtils.loadConfig(configUrl, new MultiModeDrtConfigGroup(), dvrpConfigGroup, new MultiModeAlonsoMoraConfigGroup(), new OTFVisConfigGroup()); AlonsoMoraConfigGroup amConfig = new AlonsoMoraConfigGroup(); diff --git a/pom.xml b/pom.xml index 51de9c3..970c9d9 100644 --- a/pom.xml +++ b/pom.xml @@ -18,9 +18,9 @@ to the MATSim framework. - 11 - 11 - 16.0-PR3096 + 21 + 21 + 2025.0-PR3380 5.10.1