diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 253882b..2cd3150 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 17 + - name: Set up JDK 21 uses: actions/setup-java@v1 with: - java-version: 17 + java-version: 21 - 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/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/glpk/src/test/java/org/matsim/alonso_mora/glpk/GlpkExamplesIT.java b/glpk/src/test/java/org/matsim/alonso_mora/glpk/GlpkExamplesIT.java index 3e89a9e..569ca2f 100644 --- a/glpk/src/test/java/org/matsim/alonso_mora/glpk/GlpkExamplesIT.java +++ b/glpk/src/test/java/org/matsim/alonso_mora/glpk/GlpkExamplesIT.java @@ -19,53 +19,18 @@ package org.matsim.alonso_mora.glpk; -import static org.junit.jupiter.api.Assertions.assertEquals; - -import java.io.IOException; -import java.net.URL; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Random; -import java.util.stream.Collectors; - import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.alonso_mora.AlonsoMoraConfigGroup; import org.matsim.alonso_mora.AlonsoMoraConfigurator; import org.matsim.alonso_mora.MultiModeAlonsoMoraConfigGroup; -import org.matsim.alonso_mora.shifts.ShiftAlonsoMoraModule; 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.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; -import org.matsim.contrib.drt.run.DrtModeQSimModule; import org.matsim.contrib.drt.run.MultiModeDrtConfigGroup; import org.matsim.contrib.drt.run.MultiModeDrtModule; -import org.matsim.contrib.dvrp.run.AbstractDvrpModeModule; import org.matsim.contrib.dvrp.run.DvrpConfigGroup; import org.matsim.contrib.dvrp.run.DvrpModule; import org.matsim.contrib.dvrp.run.DvrpQSimComponents; @@ -79,6 +44,17 @@ import org.matsim.testcases.MatsimTestUtils; import org.matsim.vis.otfvis.OTFVisConfigGroup; +import java.io.IOException; +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * @author sebhoerl */ 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