diff --git a/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/examples/RunJointDemandDRTExample.java b/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/examples/RunJointDemandDRTExample.java index 6c9c91e249e..b4041318704 100644 --- a/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/examples/RunJointDemandDRTExample.java +++ b/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/examples/RunJointDemandDRTExample.java @@ -142,7 +142,9 @@ private static void loadConfigGroups(Config config) { MultiModeDrtConfigGroup multiModeDrtConfigGroup = ConfigUtils.addOrGetModule(config, MultiModeDrtConfigGroup.class); DrtConfigGroup drtCfg = new DrtConfigGroup(); - DefaultDrtOptimizationConstraintsSet defaultConstraintsSet = drtCfg.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet(); + DefaultDrtOptimizationConstraintsSet defaultConstraintsSet = + (DefaultDrtOptimizationConstraintsSet) drtCfg.addOrGetDrtOptimizationConstraintsParams() + .addOrGetDefaultDrtOptimizationConstraintsSet(); defaultConstraintsSet.maxWaitTime = 2 * 3600; defaultConstraintsSet.maxTravelTimeAlpha = 5; defaultConstraintsSet.maxTravelTimeBeta = 15 * 60; diff --git a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/edrt/run/EDrtModeOptimizerQSimModule.java b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/edrt/run/EDrtModeOptimizerQSimModule.java index a31b692605b..00dabefc585 100644 --- a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/edrt/run/EDrtModeOptimizerQSimModule.java +++ b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/edrt/run/EDrtModeOptimizerQSimModule.java @@ -30,6 +30,7 @@ import org.matsim.contrib.drt.extension.edrt.scheduler.EmptyVehicleChargingScheduler; import org.matsim.contrib.drt.optimizer.*; import org.matsim.contrib.drt.optimizer.constraints.DefaultDrtOptimizationConstraintsSet; +import org.matsim.contrib.drt.optimizer.constraints.DrtOptimizationConstraintsSet; import org.matsim.contrib.drt.optimizer.depot.DepotFinder; import org.matsim.contrib.drt.optimizer.insertion.CostCalculationStrategy; import org.matsim.contrib.drt.optimizer.insertion.DefaultInsertionCostCalculator; @@ -143,7 +144,7 @@ public EmptyVehicleChargingScheduler get() { bindModal(VehicleEntry.EntryFactory.class).toProvider( EDrtVehicleDataEntryFactory.EDrtVehicleDataEntryFactoryProvider.class).asEagerSingleton(); - DefaultDrtOptimizationConstraintsSet defaultConstraintsSet = drtCfg.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet(); + DrtOptimizationConstraintsSet defaultConstraintsSet = drtCfg.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet(); bindModal(CostCalculationStrategy.class) .to(defaultConstraintsSet.rejectRequestIfMaxWaitOrTravelTimeViolated ? diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/fiss/RunFissDrtScenarioIT.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/fiss/RunFissDrtScenarioIT.java index 1a04aa12b86..3ae153f665a 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/fiss/RunFissDrtScenarioIT.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/fiss/RunFissDrtScenarioIT.java @@ -55,7 +55,9 @@ void test() { DrtConfigGroup drtConfigGroup = drtWithShiftsConfigGroup; drtConfigGroup.mode = TransportMode.drt; drtConfigGroup.stopDuration = 30.; - DefaultDrtOptimizationConstraintsSet defaultConstraintsSet = drtConfigGroup.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet(); + DefaultDrtOptimizationConstraintsSet defaultConstraintsSet = + (DefaultDrtOptimizationConstraintsSet) drtConfigGroup.addOrGetDrtOptimizationConstraintsParams() + .addOrGetDefaultDrtOptimizationConstraintsSet(); defaultConstraintsSet.maxTravelTimeAlpha = 1.5; defaultConstraintsSet.maxTravelTimeBeta = 10. * 60.; defaultConstraintsSet.maxWaitTime = 600.; diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/eshifts/run/RunEShiftDrtScenarioIT.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/eshifts/run/RunEShiftDrtScenarioIT.java index c3b27b13bde..3b5d9830c29 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/eshifts/run/RunEShiftDrtScenarioIT.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/eshifts/run/RunEShiftDrtScenarioIT.java @@ -57,7 +57,9 @@ void test() { DrtConfigGroup drtConfigGroup = drtWithShiftsConfigGroup; drtConfigGroup.mode = TransportMode.drt; - DefaultDrtOptimizationConstraintsSet constraintsSet = drtConfigGroup.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet(); + DefaultDrtOptimizationConstraintsSet constraintsSet = + (DefaultDrtOptimizationConstraintsSet) drtConfigGroup.addOrGetDrtOptimizationConstraintsParams() + .addOrGetDefaultDrtOptimizationConstraintsSet(); constraintsSet.maxTravelTimeAlpha = 1.5; constraintsSet.maxTravelTimeBeta = 10. * 60.; drtConfigGroup.stopDuration = 30.; diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunMultiHubShiftDrtScenarioIT.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunMultiHubShiftDrtScenarioIT.java index 8e6b512f552..6f08a46d3c7 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunMultiHubShiftDrtScenarioIT.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunMultiHubShiftDrtScenarioIT.java @@ -46,7 +46,9 @@ void test() { DrtConfigGroup drtConfigGroup = drtWithShiftsConfigGroup; drtConfigGroup.mode = TransportMode.drt; - DefaultDrtOptimizationConstraintsSet defaultConstraintsSet = drtConfigGroup.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet(); + DefaultDrtOptimizationConstraintsSet defaultConstraintsSet = + (DefaultDrtOptimizationConstraintsSet) drtConfigGroup.addOrGetDrtOptimizationConstraintsParams() + .addOrGetDefaultDrtOptimizationConstraintsSet(); drtConfigGroup.stopDuration = 30.; defaultConstraintsSet.maxTravelTimeAlpha = 1.5; defaultConstraintsSet.maxTravelTimeBeta = 10. * 60.; diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunShiftDrtScenarioIT.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunShiftDrtScenarioIT.java index c0365c8b006..1b866a314d2 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunShiftDrtScenarioIT.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunShiftDrtScenarioIT.java @@ -33,122 +33,124 @@ public class RunShiftDrtScenarioIT { - @Test - void test() { - - MultiModeDrtConfigGroup multiModeDrtConfigGroup = new MultiModeDrtConfigGroup(DrtWithOperationsConfigGroup::new); - - String fleetFile = "holzkirchenFleet.xml"; - String plansFile = "holzkirchenPlans.xml.gz"; - String networkFile = "holzkirchenNetwork.xml.gz"; - String opFacilitiesFile = "holzkirchenOperationFacilities.xml"; - String shiftsFile = "holzkirchenShifts.xml"; - - DrtWithOperationsConfigGroup drtWithShiftsConfigGroup = (DrtWithOperationsConfigGroup) multiModeDrtConfigGroup.createParameterSet("drt"); - - drtWithShiftsConfigGroup.mode = TransportMode.drt; - DefaultDrtOptimizationConstraintsSet defaultConstraintsSet = drtWithShiftsConfigGroup.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet(); - drtWithShiftsConfigGroup.stopDuration = 30.; - defaultConstraintsSet.maxTravelTimeAlpha = 1.5; - defaultConstraintsSet.maxTravelTimeBeta = 10. * 60.; - defaultConstraintsSet.maxWaitTime = 600.; - defaultConstraintsSet.rejectRequestIfMaxWaitOrTravelTimeViolated = true; - defaultConstraintsSet.maxWalkDistance = 1000.; - drtWithShiftsConfigGroup.useModeFilteredSubnetwork = false; - drtWithShiftsConfigGroup.vehiclesFile = fleetFile; - drtWithShiftsConfigGroup.operationalScheme = DrtConfigGroup.OperationalScheme.door2door; - drtWithShiftsConfigGroup.plotDetailedCustomerStats = true; - drtWithShiftsConfigGroup.idleVehiclesReturnToDepots = false; - - drtWithShiftsConfigGroup.addParameterSet(new ExtensiveInsertionSearchParams()); - - ConfigGroup rebalancing = drtWithShiftsConfigGroup.createParameterSet("rebalancing"); - drtWithShiftsConfigGroup.addParameterSet(rebalancing); - ((RebalancingParams) rebalancing).interval = 600; - - MinCostFlowRebalancingStrategyParams strategyParams = new MinCostFlowRebalancingStrategyParams(); - strategyParams.targetAlpha = 0.3; - strategyParams.targetBeta = 0.3; - - drtWithShiftsConfigGroup.getRebalancingParams().get().addParameterSet(strategyParams); - - DrtZoneSystemParams drtZoneSystemParams = new DrtZoneSystemParams(); - SquareGridZoneSystemParams zoneParams = (SquareGridZoneSystemParams) drtZoneSystemParams.createParameterSet(SquareGridZoneSystemParams.SET_NAME); - zoneParams.cellSize = 500.; - drtZoneSystemParams.addParameterSet(zoneParams); - drtZoneSystemParams.targetLinkSelection = DrtZoneSystemParams.TargetLinkSelection.mostCentral; - drtWithShiftsConfigGroup.addParameterSet(drtZoneSystemParams); - - multiModeDrtConfigGroup.addParameterSet(drtWithShiftsConfigGroup); - - DvrpConfigGroup dvrpConfigGroup = new DvrpConfigGroup(); - DvrpTravelTimeMatrixParams matrixParams = dvrpConfigGroup.getTravelTimeMatrixParams(); - matrixParams.addParameterSet(matrixParams.createParameterSet(SquareGridZoneSystemParams.SET_NAME)); - - final Config config = ConfigUtils.createConfig(multiModeDrtConfigGroup, - dvrpConfigGroup); - config.setContext(ExamplesUtils.getTestScenarioURL("holzkirchen")); - - Set modes = new HashSet<>(); - modes.add("drt"); - config.travelTimeCalculator().setAnalyzedModes(modes); - - ScoringConfigGroup.ModeParams scoreParams = new ScoringConfigGroup.ModeParams("drt"); - config.scoring().addModeParams(scoreParams); - ScoringConfigGroup.ModeParams scoreParams2 = new ScoringConfigGroup.ModeParams("walk"); - config.scoring().addModeParams(scoreParams2); - - config.plans().setInputFile(plansFile); - config.network().setInputFile(networkFile); - - config.qsim().setSimStarttimeInterpretation(QSimConfigGroup.StarttimeInterpretation.onlyUseStarttime); - config.qsim().setSimEndtimeInterpretation(QSimConfigGroup.EndtimeInterpretation.minOfEndtimeAndMobsimFinished); - - final ScoringConfigGroup.ActivityParams home = new ScoringConfigGroup.ActivityParams("home"); - home.setTypicalDuration(8 * 3600); - final ScoringConfigGroup.ActivityParams other = new ScoringConfigGroup.ActivityParams("other"); - other.setTypicalDuration(4 * 3600); - final ScoringConfigGroup.ActivityParams education = new ScoringConfigGroup.ActivityParams("education"); - education.setTypicalDuration(6 * 3600); - final ScoringConfigGroup.ActivityParams shopping = new ScoringConfigGroup.ActivityParams("shopping"); - shopping.setTypicalDuration(2 * 3600); - final ScoringConfigGroup.ActivityParams work = new ScoringConfigGroup.ActivityParams("work"); - work.setTypicalDuration(2 * 3600); - - config.scoring().addActivityParams(home); - config.scoring().addActivityParams(other); - config.scoring().addActivityParams(education); - config.scoring().addActivityParams(shopping); - config.scoring().addActivityParams(work); - - final ReplanningConfigGroup.StrategySettings stratSets = new ReplanningConfigGroup.StrategySettings(); - stratSets.setWeight(1); - stratSets.setStrategyName("ChangeExpBeta"); - config.replanning().addStrategySettings(stratSets); - - config.controller().setLastIteration(1); - config.controller().setWriteEventsInterval(1); - - config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); - config.controller().setOutputDirectory("test/output/holzkirchen_shifts"); - - DrtOperationsParams operationsParams = (DrtOperationsParams) drtWithShiftsConfigGroup.createParameterSet(DrtOperationsParams.SET_NAME); - ShiftsParams shiftsParams = (ShiftsParams) operationsParams.createParameterSet(ShiftsParams.SET_NAME); - OperationFacilitiesParams operationFacilitiesParams = (OperationFacilitiesParams) operationsParams.createParameterSet(OperationFacilitiesParams.SET_NAME); - operationsParams.addParameterSet(shiftsParams); - operationsParams.addParameterSet(operationFacilitiesParams); - - operationFacilitiesParams.operationFacilityInputFile = opFacilitiesFile; - shiftsParams.shiftInputFile = shiftsFile; - shiftsParams.allowInFieldChangeover = true; - drtWithShiftsConfigGroup.addParameterSet(operationsParams); - - DrtFareParams drtFareParams = new DrtFareParams(); - drtFareParams.baseFare = 1.; - drtFareParams.distanceFare_m = 1. / 1000; - drtWithShiftsConfigGroup.addParameterSet(drtFareParams); - - final Controler run = DrtOperationsControlerCreator.createControler(config, false); - run.run(); - } + @Test + void test() { + + MultiModeDrtConfigGroup multiModeDrtConfigGroup = new MultiModeDrtConfigGroup(DrtWithOperationsConfigGroup::new); + + String fleetFile = "holzkirchenFleet.xml"; + String plansFile = "holzkirchenPlans.xml.gz"; + String networkFile = "holzkirchenNetwork.xml.gz"; + String opFacilitiesFile = "holzkirchenOperationFacilities.xml"; + String shiftsFile = "holzkirchenShifts.xml"; + + DrtWithOperationsConfigGroup drtWithShiftsConfigGroup = (DrtWithOperationsConfigGroup) multiModeDrtConfigGroup.createParameterSet("drt"); + + drtWithShiftsConfigGroup.mode = TransportMode.drt; + DefaultDrtOptimizationConstraintsSet defaultConstraintsSet = + (DefaultDrtOptimizationConstraintsSet) drtWithShiftsConfigGroup.addOrGetDrtOptimizationConstraintsParams() + .addOrGetDefaultDrtOptimizationConstraintsSet(); + drtWithShiftsConfigGroup.stopDuration = 30.; + defaultConstraintsSet.maxTravelTimeAlpha = 1.5; + defaultConstraintsSet.maxTravelTimeBeta = 10. * 60.; + defaultConstraintsSet.maxWaitTime = 600.; + defaultConstraintsSet.rejectRequestIfMaxWaitOrTravelTimeViolated = true; + defaultConstraintsSet.maxWalkDistance = 1000.; + drtWithShiftsConfigGroup.useModeFilteredSubnetwork = false; + drtWithShiftsConfigGroup.vehiclesFile = fleetFile; + drtWithShiftsConfigGroup.operationalScheme = DrtConfigGroup.OperationalScheme.door2door; + drtWithShiftsConfigGroup.plotDetailedCustomerStats = true; + drtWithShiftsConfigGroup.idleVehiclesReturnToDepots = false; + + drtWithShiftsConfigGroup.addParameterSet(new ExtensiveInsertionSearchParams()); + + ConfigGroup rebalancing = drtWithShiftsConfigGroup.createParameterSet("rebalancing"); + drtWithShiftsConfigGroup.addParameterSet(rebalancing); + ((RebalancingParams) rebalancing).interval = 600; + + MinCostFlowRebalancingStrategyParams strategyParams = new MinCostFlowRebalancingStrategyParams(); + strategyParams.targetAlpha = 0.3; + strategyParams.targetBeta = 0.3; + + drtWithShiftsConfigGroup.getRebalancingParams().get().addParameterSet(strategyParams); + + DrtZoneSystemParams drtZoneSystemParams = new DrtZoneSystemParams(); + SquareGridZoneSystemParams zoneParams = (SquareGridZoneSystemParams) drtZoneSystemParams.createParameterSet(SquareGridZoneSystemParams.SET_NAME); + zoneParams.cellSize = 500.; + drtZoneSystemParams.addParameterSet(zoneParams); + drtZoneSystemParams.targetLinkSelection = DrtZoneSystemParams.TargetLinkSelection.mostCentral; + drtWithShiftsConfigGroup.addParameterSet(drtZoneSystemParams); + + multiModeDrtConfigGroup.addParameterSet(drtWithShiftsConfigGroup); + + DvrpConfigGroup dvrpConfigGroup = new DvrpConfigGroup(); + DvrpTravelTimeMatrixParams matrixParams = dvrpConfigGroup.getTravelTimeMatrixParams(); + matrixParams.addParameterSet(matrixParams.createParameterSet(SquareGridZoneSystemParams.SET_NAME)); + + final Config config = ConfigUtils.createConfig(multiModeDrtConfigGroup, + dvrpConfigGroup); + config.setContext(ExamplesUtils.getTestScenarioURL("holzkirchen")); + + Set modes = new HashSet<>(); + modes.add("drt"); + config.travelTimeCalculator().setAnalyzedModes(modes); + + ScoringConfigGroup.ModeParams scoreParams = new ScoringConfigGroup.ModeParams("drt"); + config.scoring().addModeParams(scoreParams); + ScoringConfigGroup.ModeParams scoreParams2 = new ScoringConfigGroup.ModeParams("walk"); + config.scoring().addModeParams(scoreParams2); + + config.plans().setInputFile(plansFile); + config.network().setInputFile(networkFile); + + config.qsim().setSimStarttimeInterpretation(QSimConfigGroup.StarttimeInterpretation.onlyUseStarttime); + config.qsim().setSimEndtimeInterpretation(QSimConfigGroup.EndtimeInterpretation.minOfEndtimeAndMobsimFinished); + + final ScoringConfigGroup.ActivityParams home = new ScoringConfigGroup.ActivityParams("home"); + home.setTypicalDuration(8 * 3600); + final ScoringConfigGroup.ActivityParams other = new ScoringConfigGroup.ActivityParams("other"); + other.setTypicalDuration(4 * 3600); + final ScoringConfigGroup.ActivityParams education = new ScoringConfigGroup.ActivityParams("education"); + education.setTypicalDuration(6 * 3600); + final ScoringConfigGroup.ActivityParams shopping = new ScoringConfigGroup.ActivityParams("shopping"); + shopping.setTypicalDuration(2 * 3600); + final ScoringConfigGroup.ActivityParams work = new ScoringConfigGroup.ActivityParams("work"); + work.setTypicalDuration(2 * 3600); + + config.scoring().addActivityParams(home); + config.scoring().addActivityParams(other); + config.scoring().addActivityParams(education); + config.scoring().addActivityParams(shopping); + config.scoring().addActivityParams(work); + + final ReplanningConfigGroup.StrategySettings stratSets = new ReplanningConfigGroup.StrategySettings(); + stratSets.setWeight(1); + stratSets.setStrategyName("ChangeExpBeta"); + config.replanning().addStrategySettings(stratSets); + + config.controller().setLastIteration(1); + config.controller().setWriteEventsInterval(1); + + config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOutputDirectory("test/output/holzkirchen_shifts"); + + DrtOperationsParams operationsParams = (DrtOperationsParams) drtWithShiftsConfigGroup.createParameterSet(DrtOperationsParams.SET_NAME); + ShiftsParams shiftsParams = (ShiftsParams) operationsParams.createParameterSet(ShiftsParams.SET_NAME); + OperationFacilitiesParams operationFacilitiesParams = (OperationFacilitiesParams) operationsParams.createParameterSet(OperationFacilitiesParams.SET_NAME); + operationsParams.addParameterSet(shiftsParams); + operationsParams.addParameterSet(operationFacilitiesParams); + + operationFacilitiesParams.operationFacilityInputFile = opFacilitiesFile; + shiftsParams.shiftInputFile = shiftsFile; + shiftsParams.allowInFieldChangeover = true; + drtWithShiftsConfigGroup.addParameterSet(operationsParams); + + DrtFareParams drtFareParams = new DrtFareParams(); + drtFareParams.baseFare = 1.; + drtFareParams.distanceFare_m = 1. / 1000; + drtWithShiftsConfigGroup.addParameterSet(drtFareParams); + + final Controler run = DrtOperationsControlerCreator.createControler(config, false); + run.run(); + } } diff --git a/contribs/drt/src/main/java/org/matsim/contrib/drt/analysis/DrtAnalysisControlerListener.java b/contribs/drt/src/main/java/org/matsim/contrib/drt/analysis/DrtAnalysisControlerListener.java index cb8416cc654..bd3d93e57b8 100644 --- a/contribs/drt/src/main/java/org/matsim/contrib/drt/analysis/DrtAnalysisControlerListener.java +++ b/contribs/drt/src/main/java/org/matsim/contrib/drt/analysis/DrtAnalysisControlerListener.java @@ -45,6 +45,7 @@ import org.matsim.contrib.common.util.ChartSaveUtils; import org.matsim.contrib.drt.analysis.DrtEventSequenceCollector.EventSequence; import org.matsim.contrib.drt.optimizer.constraints.DefaultDrtOptimizationConstraintsSet; +import org.matsim.contrib.drt.optimizer.constraints.DrtOptimizationConstraintsSet; import org.matsim.contrib.drt.passenger.events.DrtRequestSubmittedEvent; import org.matsim.contrib.drt.run.DrtConfigGroup; import org.matsim.contrib.drt.schedule.DrtStayTask; @@ -664,15 +665,18 @@ private static void analyseDetours(Network network, List legs, Map lineCoeffs = null; + if(constraintsSet instanceof DefaultDrtOptimizationConstraintsSet defaultConstraintsSet) { + lineCoeffs = Pair.of(defaultConstraintsSet.maxTravelTimeAlpha, + defaultConstraintsSet.maxTravelTimeBeta); + } final JFreeChart chart2 = DensityScatterPlots.createPlot("Travel Times", "travel time [s]", "unshared ride time [s]", travelTimes, - Pair.of(defaultConstraintsSet.maxTravelTimeAlpha, - defaultConstraintsSet.maxTravelTimeBeta)); + lineCoeffs); ChartSaveUtils.saveAsPNG(chart2, fileName + "_travelTimePlot", 1500, 1500); final JFreeChart chart3 = DensityScatterPlots.createPlot("Ride Times", "ride time [s]", "unshared ride time [s]", rideTimes, - Pair.of(defaultConstraintsSet.maxTravelTimeAlpha, - defaultConstraintsSet.maxTravelTimeBeta)); + lineCoeffs); ChartSaveUtils.saveAsPNG(chart3, fileName + "_rideTimePlot", 1500, 1500); } } diff --git a/contribs/drt/src/main/java/org/matsim/contrib/drt/estimator/impl/PessimisticDrtEstimator.java b/contribs/drt/src/main/java/org/matsim/contrib/drt/estimator/impl/PessimisticDrtEstimator.java index cc85c5d03e8..02c294aafb8 100644 --- a/contribs/drt/src/main/java/org/matsim/contrib/drt/estimator/impl/PessimisticDrtEstimator.java +++ b/contribs/drt/src/main/java/org/matsim/contrib/drt/estimator/impl/PessimisticDrtEstimator.java @@ -2,6 +2,7 @@ import org.matsim.contrib.drt.estimator.DrtEstimator; import org.matsim.contrib.drt.optimizer.constraints.DefaultDrtOptimizationConstraintsSet; +import org.matsim.contrib.drt.optimizer.constraints.DrtOptimizationConstraintsSet; import org.matsim.contrib.drt.routing.DrtRoute; import org.matsim.contrib.drt.run.DrtConfigGroup; import org.matsim.core.utils.misc.OptionalTime; @@ -20,12 +21,15 @@ public PessimisticDrtEstimator(DrtConfigGroup drtConfig) { public Estimate estimate(DrtRoute route, OptionalTime departureTime) { // If not estimates are present, use travel time alpha as detour // beta is not used, because estimates are supposed to be minimums and not worst cases - DefaultDrtOptimizationConstraintsSet constraints = drtConfig.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet(); - double travelTime = Math.min(route.getDirectRideTime() + constraints.maxAbsoluteDetour, - route.getDirectRideTime() * constraints.maxTravelTimeAlpha); + DrtOptimizationConstraintsSet constraints = drtConfig.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet(); + if(constraints instanceof DefaultDrtOptimizationConstraintsSet defaultConstraints) { + double travelTime = Math.min(route.getDirectRideTime() + defaultConstraints.maxAbsoluteDetour, + route.getDirectRideTime() * defaultConstraints.maxTravelTimeAlpha); - // for distance, also use the max travel time alpha - return new Estimate(route.getDistance() * constraints.maxTravelTimeAlpha, travelTime, constraints.maxWaitTime, 0); + // for distance, also use the max travel time alpha + return new Estimate(route.getDistance() * defaultConstraints.maxTravelTimeAlpha, travelTime, constraints.maxWaitTime, 0); + } else { + throw new RuntimeException("Not implemented for custom constraints sets"); + } } - } diff --git a/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/DrtModeOptimizerQSimModule.java b/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/DrtModeOptimizerQSimModule.java index 9a608af8979..25c64fd0150 100644 --- a/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/DrtModeOptimizerQSimModule.java +++ b/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/DrtModeOptimizerQSimModule.java @@ -20,16 +20,13 @@ package org.matsim.contrib.drt.optimizer; +import com.google.inject.Inject; +import com.google.inject.Singleton; import org.matsim.api.core.v01.network.Network; -import org.matsim.contrib.drt.optimizer.constraints.DefaultDrtOptimizationConstraintsSet; +import org.matsim.contrib.drt.optimizer.constraints.DrtOptimizationConstraintsSet; import org.matsim.contrib.drt.optimizer.depot.DepotFinder; import org.matsim.contrib.drt.optimizer.depot.NearestStartLinkAsDepot; -import org.matsim.contrib.drt.optimizer.insertion.CostCalculationStrategy; -import org.matsim.contrib.drt.optimizer.insertion.DefaultInsertionCostCalculator; -import org.matsim.contrib.drt.optimizer.insertion.DefaultUnplannedRequestInserter; -import org.matsim.contrib.drt.optimizer.insertion.DrtInsertionSearch; -import org.matsim.contrib.drt.optimizer.insertion.InsertionCostCalculator; -import org.matsim.contrib.drt.optimizer.insertion.UnplannedRequestInserter; +import org.matsim.contrib.drt.optimizer.insertion.*; import org.matsim.contrib.drt.optimizer.insertion.extensive.ExtensiveInsertionSearchParams; import org.matsim.contrib.drt.optimizer.insertion.extensive.ExtensiveInsertionSearchQSimModule; import org.matsim.contrib.drt.optimizer.insertion.repeatedselective.RepeatedSelectiveInsertionSearchParams; @@ -37,8 +34,8 @@ import org.matsim.contrib.drt.optimizer.insertion.selective.SelectiveInsertionSearchParams; import org.matsim.contrib.drt.optimizer.insertion.selective.SelectiveInsertionSearchQSimModule; import org.matsim.contrib.drt.optimizer.rebalancing.RebalancingStrategy; -import org.matsim.contrib.drt.passenger.DrtOfferAcceptor; import org.matsim.contrib.drt.passenger.DefaultOfferAcceptor; +import org.matsim.contrib.drt.passenger.DrtOfferAcceptor; import org.matsim.contrib.drt.prebooking.PrebookingActionCreator; import org.matsim.contrib.drt.run.DrtConfigGroup; import org.matsim.contrib.drt.schedule.DrtStayTaskEndTimeCalculator; @@ -67,9 +64,6 @@ import org.matsim.core.router.util.TravelDisutility; import org.matsim.core.router.util.TravelTime; -import com.google.inject.Inject; -import com.google.inject.Singleton; - /** * @author Michal Maciejewski (michalm) */ @@ -118,7 +112,7 @@ protected void configureQSim() { bindModal(VehicleEntry.EntryFactory.class).toInstance(new VehicleDataEntryFactoryImpl()); - DefaultDrtOptimizationConstraintsSet defaultOptimizationConstraintsSet = drtCfg.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet(); + DrtOptimizationConstraintsSet defaultOptimizationConstraintsSet = drtCfg.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet(); bindModal(CostCalculationStrategy.class) .to(defaultOptimizationConstraintsSet.rejectRequestIfMaxWaitOrTravelTimeViolated ? diff --git a/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/constraints/DefaultDrtOptimizationConstraintsSet.java b/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/constraints/DefaultDrtOptimizationConstraintsSet.java index f292776f71e..3ba0a7ce169 100644 --- a/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/constraints/DefaultDrtOptimizationConstraintsSet.java +++ b/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/constraints/DefaultDrtOptimizationConstraintsSet.java @@ -45,14 +45,6 @@ public class DefaultDrtOptimizationConstraintsSet extends DrtOptimizationConstra @PositiveOrZero public double maxDetourBeta = Double.POSITIVE_INFINITY;// [s] - @Parameter - @Comment( - "Defines the maximum delay allowed from the initial scheduled pick up time. Once the initial pickup time is offered, the latest promised" - + "pickup time is calculated based on initial scheduled pickup time + maxAllowedPickupDelay. " - + "By default, this limit is disabled. If enabled, a value between 0 and 240 is a good choice.") - @PositiveOrZero - public double maxAllowedPickupDelay = Double.POSITIVE_INFINITY;// [s] - @Override protected void checkConsistency(Config config) { super.checkConsistency(config); diff --git a/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/constraints/DrtOptimizationConstraintsParams.java b/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/constraints/DrtOptimizationConstraintsParams.java index a272e49b2a9..acbc6822ec4 100644 --- a/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/constraints/DrtOptimizationConstraintsParams.java +++ b/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/constraints/DrtOptimizationConstraintsParams.java @@ -54,17 +54,16 @@ public List getDrtOptimizationConstraintsSets() { .toList(); } - public DefaultDrtOptimizationConstraintsSet addOrGetDefaultDrtOptimizationConstraintsSet() { + public DrtOptimizationConstraintsSet addOrGetDefaultDrtOptimizationConstraintsSet() { Optional drtOptParams = getDrtOptimizationConstraintsSets().stream() .filter(params -> params.name.equals(defaultConstraintSet)) - .filter(DefaultDrtOptimizationConstraintsSet.class::isInstance) .findAny(); if (drtOptParams.isEmpty()) { - DefaultDrtOptimizationConstraintsSet defaultDrtOptimizationConstraintsSet = new DefaultDrtOptimizationConstraintsSet(); - addParameterSet(defaultDrtOptimizationConstraintsSet); - return defaultDrtOptimizationConstraintsSet; + DrtOptimizationConstraintsSet defaultSet = optimizationConstraintsSetSupplier.get(); + addParameterSet(defaultSet); + return defaultSet; } - return (DefaultDrtOptimizationConstraintsSet) drtOptParams.get(); + return drtOptParams.get(); } @Override diff --git a/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/constraints/DrtOptimizationConstraintsSet.java b/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/constraints/DrtOptimizationConstraintsSet.java index 66f4d83650c..c907d916efc 100644 --- a/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/constraints/DrtOptimizationConstraintsSet.java +++ b/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/constraints/DrtOptimizationConstraintsSet.java @@ -45,6 +45,14 @@ public abstract class DrtOptimizationConstraintsSet extends ReflectiveConfigGrou @PositiveOrZero public double lateDiversionthreshold = 0; // [s]; + @Parameter + @Comment( + "Defines the maximum delay allowed from the initial scheduled pick up time. Once the initial pickup time is offered, the latest promised" + + "pickup time is calculated based on initial scheduled pickup time + maxAllowedPickupDelay. " + + "By default, this limit is disabled. If enabled, a value between 0 and 240 is a good choice.") + @PositiveOrZero + public double maxAllowedPickupDelay = Double.POSITIVE_INFINITY;// [s] + public DrtOptimizationConstraintsSet() { super(SET_NAME); } diff --git a/contribs/drt/src/main/java/org/matsim/contrib/drt/routing/DrtRouteCreator.java b/contribs/drt/src/main/java/org/matsim/contrib/drt/routing/DrtRouteCreator.java index 45dce290b0f..b646494a1fc 100644 --- a/contribs/drt/src/main/java/org/matsim/contrib/drt/routing/DrtRouteCreator.java +++ b/contribs/drt/src/main/java/org/matsim/contrib/drt/routing/DrtRouteCreator.java @@ -82,7 +82,7 @@ public Route createRoute(double departureTime, Link accessActLink, Link egressAc route.setTravelTime(maxTravelTime); route.setMaxRideTime(maxRideDuration); route.setDirectRideTime(unsharedRideTime); - route.setMaxWaitTime(drtCfg.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet().maxWaitTime); + route.setMaxWaitTime(constraintsSet.maxWaitTime); if (this.drtCfg.storeUnsharedPath) { route.setUnsharedPath(unsharedPath); diff --git a/contribs/drt/src/main/java/org/matsim/contrib/drt/run/DrtModeRoutingModule.java b/contribs/drt/src/main/java/org/matsim/contrib/drt/run/DrtModeRoutingModule.java index d0b82a10f10..fcbc25faea1 100644 --- a/contribs/drt/src/main/java/org/matsim/contrib/drt/run/DrtModeRoutingModule.java +++ b/contribs/drt/src/main/java/org/matsim/contrib/drt/run/DrtModeRoutingModule.java @@ -31,7 +31,7 @@ import org.matsim.contrib.drt.estimator.DrtEstimator; import org.matsim.contrib.drt.estimator.EstimationRoutingModuleProvider; import org.matsim.contrib.drt.optimizer.constraints.ConstraintSetChooser; -import org.matsim.contrib.drt.optimizer.constraints.DefaultDrtOptimizationConstraintsSet; +import org.matsim.contrib.drt.optimizer.constraints.DrtOptimizationConstraintsSet; import org.matsim.contrib.drt.routing.*; import org.matsim.contrib.dvrp.router.ClosestAccessEgressFacilityFinder; import org.matsim.contrib.dvrp.router.DecideOnLinkAccessEgressFacilityFinder; @@ -98,7 +98,7 @@ public void install() { bindModal(DrtRouteConstraintsCalculator.class).toProvider(modalProvider(getter -> new DefaultDrtRouteConstraintsCalculator())).in(Singleton.class); - DefaultDrtOptimizationConstraintsSet optimizationConstraintsSet = drtCfg.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet(); + DrtOptimizationConstraintsSet optimizationConstraintsSet = drtCfg.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet(); bindModal(ConstraintSetChooser.class).toProvider( () -> (departureTime, accessActLink, egressActLink, person, tripAttributes) -> Optional.of(optimizationConstraintsSet) diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/config/ConfigBehaviorTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/config/ConfigBehaviorTest.java index 0c365bbc5e7..9e5c5db1521 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/config/ConfigBehaviorTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/config/ConfigBehaviorTest.java @@ -100,7 +100,7 @@ final void testMaterializeAfterReadDrtConstraints() { DrtOptimizationConstraintsParams drtOptimizationConstraintsParams = drtConfigGroup.addOrGetDrtOptimizationConstraintsParams(); DefaultDrtOptimizationConstraintsSet optimizationConstraintsSet = - drtOptimizationConstraintsParams.addOrGetDefaultDrtOptimizationConstraintsSet(); + (DefaultDrtOptimizationConstraintsSet) drtOptimizationConstraintsParams.addOrGetDefaultDrtOptimizationConstraintsSet(); optimizationConstraintsSet.maxTravelTimeAlpha = 2.; optimizationConstraintsSet.maxTravelTimeBeta = 5. * 60; @@ -115,8 +115,11 @@ final void testMaterializeAfterReadDrtConstraints() { DrtConfigGroup drtConfigGroup = multiModeDrtConfigGroup.getModalElements().iterator().next(); // check if you are getting back the values from the config file: - Assertions.assertEquals( 2., drtConfigGroup.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet().maxTravelTimeAlpha, Double.MIN_VALUE ); - Assertions.assertEquals( 300., drtConfigGroup.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet().maxTravelTimeBeta, Double.MIN_VALUE ); + DefaultDrtOptimizationConstraintsSet constraintsSet = + (DefaultDrtOptimizationConstraintsSet) drtConfigGroup.addOrGetDrtOptimizationConstraintsParams(). + addOrGetDefaultDrtOptimizationConstraintsSet(); + Assertions.assertEquals( 2., constraintsSet.maxTravelTimeAlpha, Double.MIN_VALUE ); + Assertions.assertEquals( 300., constraintsSet.maxTravelTimeBeta, Double.MIN_VALUE ); } } diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/MaxDetourConstraintTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/MaxDetourConstraintTest.java index c1d93c9d65b..4f883cfdf38 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/MaxDetourConstraintTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/MaxDetourConstraintTest.java @@ -37,7 +37,9 @@ public void testMaxDetourConstraint() { DrtConfigGroup drtConfigGroup = DrtConfigGroup.getSingleModeDrtConfig(config); // Max wait time - DefaultDrtOptimizationConstraintsSet defaultConstraintsSet = drtConfigGroup.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet(); + DefaultDrtOptimizationConstraintsSet defaultConstraintsSet = + (DefaultDrtOptimizationConstraintsSet) drtConfigGroup.addOrGetDrtOptimizationConstraintsParams() + .addOrGetDefaultDrtOptimizationConstraintsSet(); defaultConstraintsSet.maxWaitTime = 300; // Turn on the max detour constraint diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/DrtPoolingParameterTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/DrtPoolingParameterTest.java index e9e9f566ebd..758dd6e4ebc 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/DrtPoolingParameterTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/DrtPoolingParameterTest.java @@ -11,6 +11,7 @@ import org.matsim.api.core.v01.population.*; import org.matsim.contrib.common.zones.systems.grid.square.SquareGridZoneSystemParams; import org.matsim.contrib.drt.optimizer.constraints.DefaultDrtOptimizationConstraintsSet; +import org.matsim.contrib.drt.optimizer.constraints.DrtOptimizationConstraintsSet; import org.matsim.contrib.drt.run.DrtControlerCreator; import org.matsim.contrib.drt.run.MultiModeDrtConfigGroup; import org.matsim.contrib.dvrp.fleet.DvrpVehicle; @@ -226,7 +227,9 @@ private PersonEnterDrtVehicleEventHandler setupAndRunScenario(double maxWaitTime MultiModeDrtConfigGroup mm = ConfigUtils.addOrGetModule(config, MultiModeDrtConfigGroup.class); mm.getModalElements().forEach(x -> { - DefaultDrtOptimizationConstraintsSet defaultConstraintsSet = x.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet(); + DefaultDrtOptimizationConstraintsSet defaultConstraintsSet = + (DefaultDrtOptimizationConstraintsSet) x.addOrGetDrtOptimizationConstraintsParams() + .addOrGetDefaultDrtOptimizationConstraintsSet(); defaultConstraintsSet.maxWaitTime = maxWaitTime; defaultConstraintsSet.maxTravelTimeAlpha = maxTravelTimeAlpha; defaultConstraintsSet.maxTravelTimeBeta = maxTravelTimeBeta; diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/PrebookingTestEnvironment.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/PrebookingTestEnvironment.java index 0b459e8e470..60108070ab8 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/PrebookingTestEnvironment.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/PrebookingTestEnvironment.java @@ -227,7 +227,9 @@ private void buildConfig(Config config) { DrtConfigGroup modeConfig = new DrtConfigGroup(); drtConfig.addParameterSet(modeConfig); modeConfig.mode = "drt"; - DefaultDrtOptimizationConstraintsSet defaultConstraintsSet = modeConfig.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet(); + DefaultDrtOptimizationConstraintsSet defaultConstraintsSet = + (DefaultDrtOptimizationConstraintsSet) modeConfig.addOrGetDrtOptimizationConstraintsParams() + .addOrGetDefaultDrtOptimizationConstraintsSet(); defaultConstraintsSet.maxWaitTime = maximumWaitTime; defaultConstraintsSet.maxTravelTimeAlpha = detourRelative; defaultConstraintsSet.maxTravelTimeBeta = detourAbsolute; diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/routing/DrtRoutingModuleTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/routing/DrtRoutingModuleTest.java index 8325834c96b..a9c0a735b47 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/routing/DrtRoutingModuleTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/routing/DrtRoutingModuleTest.java @@ -76,7 +76,9 @@ void testCottbusClosestAccessEgressStopFinder() { DrtConfigGroup drtCfg = DrtConfigGroup.getSingleModeDrtConfig(scenario.getConfig()); String drtMode = "DrtX"; drtCfg.mode = drtMode; - DefaultDrtOptimizationConstraintsSet defaultConstraintsSet = drtCfg.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet(); + DefaultDrtOptimizationConstraintsSet defaultConstraintsSet = + (DefaultDrtOptimizationConstraintsSet) drtCfg.addOrGetDrtOptimizationConstraintsParams() + .addOrGetDefaultDrtOptimizationConstraintsSet(); defaultConstraintsSet.maxTravelTimeAlpha = 1.5; defaultConstraintsSet.maxTravelTimeBeta = 5 * 60; defaultConstraintsSet.maxWaitTime = 5 * 60; diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/teleportation/DrtTeleportationTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/teleportation/DrtTeleportationTest.java index 3dfa12c7e26..39b1e8fa92c 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/teleportation/DrtTeleportationTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/teleportation/DrtTeleportationTest.java @@ -46,7 +46,8 @@ void testTeleportationEngine() throws IOException { Controler controler = DrtControlerCreator.createControler(config, false); DrtConfigGroup drtConfigGroup = DrtConfigGroup.getSingleModeDrtConfig(config); - DefaultDrtOptimizationConstraintsSet defaultConstraintsSet = drtConfigGroup.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet(); + DefaultDrtOptimizationConstraintsSet defaultConstraintsSet = (DefaultDrtOptimizationConstraintsSet) drtConfigGroup + .addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet(); defaultConstraintsSet.maxTravelTimeAlpha = 1.2; defaultConstraintsSet.maxTravelTimeBeta = 600; defaultConstraintsSet.maxWaitTime = 300; diff --git a/contribs/taxi/src/main/java/org/matsim/contrib/taxi/run/MultiModeTaxiModule.java b/contribs/taxi/src/main/java/org/matsim/contrib/taxi/run/MultiModeTaxiModule.java index 9eb0d706eb9..ccc6bfc69cf 100644 --- a/contribs/taxi/src/main/java/org/matsim/contrib/taxi/run/MultiModeTaxiModule.java +++ b/contribs/taxi/src/main/java/org/matsim/contrib/taxi/run/MultiModeTaxiModule.java @@ -67,7 +67,9 @@ public static DrtConfigGroup convertTaxiToDrtCfg(TaxiConfigGroup taxiCfg) { // Taxi optimisers do not reject, so time constraints are only used for routing plans (DrtRouteCreator). // Using some (relatively high) values as we do not know what values should be there. They can be adjusted // manually after the TaxiAsDrtConfigGroup config is created. - DefaultDrtOptimizationConstraintsSet defaultConstraintsSet = drtCfg.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet(); + DefaultDrtOptimizationConstraintsSet defaultConstraintsSet = + (DefaultDrtOptimizationConstraintsSet) drtCfg.addOrGetDrtOptimizationConstraintsParams() + .addOrGetDefaultDrtOptimizationConstraintsSet(); defaultConstraintsSet.maxWaitTime = 3600; defaultConstraintsSet.maxTravelTimeAlpha = 2; defaultConstraintsSet.maxTravelTimeBeta = 3600; diff --git a/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALine2Test.java b/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALine2Test.java index 29bf6b6b789..d298b4ad003 100644 --- a/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALine2Test.java +++ b/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALine2Test.java @@ -230,7 +230,9 @@ void testPtAlongALineWithRaptorAndDrtServiceArea() { { DrtConfigGroup drtConfigGroup = new DrtConfigGroup(); drtConfigGroup.mode = TransportMode.drt; - DefaultDrtOptimizationConstraintsSet defaultConstraintsSet = drtConfigGroup.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet(); + DefaultDrtOptimizationConstraintsSet defaultConstraintsSet = + (DefaultDrtOptimizationConstraintsSet) drtConfigGroup.addOrGetDrtOptimizationConstraintsParams() + .addOrGetDefaultDrtOptimizationConstraintsSet(); defaultConstraintsSet.maxTravelTimeAlpha = 2.0; defaultConstraintsSet.maxTravelTimeBeta = 5. * 60.; drtConfigGroup.stopDuration = 60.; @@ -245,7 +247,9 @@ void testPtAlongALineWithRaptorAndDrtServiceArea() { if (drt2) { DrtConfigGroup drtConfigGroup = new DrtConfigGroup(); drtConfigGroup.mode = "drt2"; - DefaultDrtOptimizationConstraintsSet defaultConstraintsSet = drtConfigGroup.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet(); + DefaultDrtOptimizationConstraintsSet defaultConstraintsSet = + (DefaultDrtOptimizationConstraintsSet) drtConfigGroup.addOrGetDrtOptimizationConstraintsParams() + .addOrGetDefaultDrtOptimizationConstraintsSet(); defaultConstraintsSet.maxTravelTimeAlpha = 1.3; defaultConstraintsSet.maxTravelTimeBeta = 5. * 60.; drtConfigGroup.stopDuration = 60.; @@ -259,7 +263,9 @@ void testPtAlongALineWithRaptorAndDrtServiceArea() { if (drt3) { DrtConfigGroup drtConfigGroup = new DrtConfigGroup(); drtConfigGroup.mode = "drt3"; - DefaultDrtOptimizationConstraintsSet defaultConstraintsSet = drtConfigGroup.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet(); + DefaultDrtOptimizationConstraintsSet defaultConstraintsSet = + (DefaultDrtOptimizationConstraintsSet) drtConfigGroup.addOrGetDrtOptimizationConstraintsParams() + .addOrGetDefaultDrtOptimizationConstraintsSet(); defaultConstraintsSet.maxTravelTimeAlpha = 1.3; defaultConstraintsSet.maxTravelTimeBeta = 5. * 60.; drtConfigGroup.stopDuration = 60.; diff --git a/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALineTest.java b/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALineTest.java index 772ffe1aaa4..ec251b59164 100644 --- a/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALineTest.java +++ b/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALineTest.java @@ -112,7 +112,8 @@ void testDrtAlongALine() { drtConfig.mode = "drt_A"; drtConfig.stopDuration = 60.; DefaultDrtOptimizationConstraintsSet defaultConstraintsSet = - drtConfig.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet(); + (DefaultDrtOptimizationConstraintsSet) drtConfig.addOrGetDrtOptimizationConstraintsParams() + .addOrGetDefaultDrtOptimizationConstraintsSet(); defaultConstraintsSet.maxWaitTime = 900.; defaultConstraintsSet.maxTravelTimeAlpha = 1.3; defaultConstraintsSet.maxTravelTimeBeta = 10. * 60.; @@ -251,7 +252,9 @@ void testPtAlongALineWithRaptorAndDrtStopFilterAttribute() { { DrtConfigGroup drtConfig = new DrtConfigGroup(); drtConfig.stopDuration = 60.; - DefaultDrtOptimizationConstraintsSet defaultConstraintsSet = drtConfig.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet(); + DefaultDrtOptimizationConstraintsSet defaultConstraintsSet = + (DefaultDrtOptimizationConstraintsSet) drtConfig.addOrGetDrtOptimizationConstraintsParams() + .addOrGetDefaultDrtOptimizationConstraintsSet(); defaultConstraintsSet.maxTravelTimeAlpha = 1.3; defaultConstraintsSet.maxTravelTimeBeta = 5. * 60.; defaultConstraintsSet.maxWaitTime = Double.MAX_VALUE;