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 72144a8d440..4379075dc79 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 @@ -141,9 +141,9 @@ private static void loadConfigGroups(Config config) { MultiModeDrtConfigGroup multiModeDrtConfigGroup = ConfigUtils.addOrGetModule(config, MultiModeDrtConfigGroup.class); DrtConfigGroup drtCfg = new DrtConfigGroup(); - drtCfg.maxWaitTime = 2 * 3600; - drtCfg.maxTravelTimeAlpha = 5; - drtCfg.maxTravelTimeBeta = 15 * 60; + drtCfg.getDrtOptimizationConstraintsParam().maxWaitTime = 2 * 3600; + drtCfg.getDrtOptimizationConstraintsParam().maxTravelTimeAlpha = 5; + drtCfg.getDrtOptimizationConstraintsParam().maxTravelTimeBeta = 15 * 60; drtCfg.stopDuration = 60; drtCfg.vehiclesFile = "jointDemand_vehicles.xml"; multiModeDrtConfigGroup.addParameterSet(drtCfg); 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 b617a93a0d3..5333231bd6a 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 @@ -147,7 +147,7 @@ public EmptyVehicleChargingScheduler get() { bindModal(VehicleEntry.EntryFactory.class).toProvider( EDrtVehicleDataEntryFactory.EDrtVehicleDataEntryFactoryProvider.class).asEagerSingleton(); - bindModal(CostCalculationStrategy.class).to(drtCfg.rejectRequestIfMaxWaitOrTravelTimeViolated ? + bindModal(CostCalculationStrategy.class).to(drtCfg.getDrtOptimizationConstraintsParam().rejectRequestIfMaxWaitOrTravelTimeViolated ? CostCalculationStrategy.RejectSoftConstraintViolations.class : CostCalculationStrategy.DiscourageSoftConstraintViolations.class).asEagerSingleton(); @@ -179,7 +179,7 @@ public EmptyVehicleRelocator get() { getter.getModal(StopTimeCalculator.class), scheduleWaitBeforeDrive))) .asEagerSingleton(); - bindModal(DefaultOfferAcceptor.class).toProvider(modalProvider(getter -> new DefaultOfferAcceptor(drtCfg.maxAllowedPickupDelay))); + bindModal(DefaultOfferAcceptor.class).toProvider(modalProvider(getter -> new DefaultOfferAcceptor(drtCfg.getDrtOptimizationConstraintsParam().maxAllowedPickupDelay))); bindModal(DrtOfferAcceptor.class).to(modalKey(DefaultOfferAcceptor.class)); bindModal(ScheduleTimingUpdater.class).toProvider(modalProvider( 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 d9eda86cc8b..29f2a9b006d 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 @@ -53,16 +53,16 @@ void test() { DrtConfigGroup drtConfigGroup = drtWithShiftsConfigGroup; drtConfigGroup.mode = TransportMode.drt; - drtConfigGroup.maxTravelTimeAlpha = 1.5; - drtConfigGroup.maxTravelTimeBeta = 10. * 60.; + drtConfigGroup.getDrtOptimizationConstraintsParam().maxTravelTimeAlpha = 1.5; + drtConfigGroup.getDrtOptimizationConstraintsParam().maxTravelTimeBeta = 10. * 60.; drtConfigGroup.stopDuration = 30.; - drtConfigGroup.maxWaitTime = 600.; - drtConfigGroup.rejectRequestIfMaxWaitOrTravelTimeViolated = true; + drtConfigGroup.getDrtOptimizationConstraintsParam().maxWaitTime = 600.; + drtConfigGroup.getDrtOptimizationConstraintsParam().rejectRequestIfMaxWaitOrTravelTimeViolated = true; drtConfigGroup.useModeFilteredSubnetwork = false; drtConfigGroup.vehiclesFile = fleetFile; drtConfigGroup.operationalScheme = DrtConfigGroup.OperationalScheme.door2door; drtConfigGroup.plotDetailedCustomerStats = true; - drtConfigGroup.maxWalkDistance = 1000.; + drtConfigGroup.getDrtOptimizationConstraintsParam().maxWalkDistance = 1000.; drtConfigGroup.idleVehiclesReturnToDepots = false; drtConfigGroup.addParameterSet(new ExtensiveInsertionSearchParams()); 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 2bd5fdffc27..6f4e8ceb392 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 @@ -13,6 +13,7 @@ import org.matsim.contrib.drt.optimizer.rebalancing.RebalancingParams; import org.matsim.contrib.drt.optimizer.rebalancing.mincostflow.MinCostFlowRebalancingStrategyParams; import org.matsim.contrib.drt.run.DrtConfigGroup; +import org.matsim.contrib.drt.run.DrtOptimizationConstraintsParams; import org.matsim.contrib.drt.run.MultiModeDrtConfigGroup; import org.matsim.contrib.dvrp.run.DvrpConfigGroup; import org.matsim.contrib.ev.EvConfigGroup; @@ -56,16 +57,17 @@ void test() { DrtConfigGroup drtConfigGroup = drtWithShiftsConfigGroup; drtConfigGroup.mode = TransportMode.drt; - drtConfigGroup.maxTravelTimeAlpha = 1.5; - drtConfigGroup.maxTravelTimeBeta = 10. * 60.; + DrtOptimizationConstraintsParams constraintsParam = drtConfigGroup.getDrtOptimizationConstraintsParam(); + constraintsParam.maxTravelTimeAlpha = 1.5; + constraintsParam.maxTravelTimeBeta = 10. * 60.; drtConfigGroup.stopDuration = 30.; - drtConfigGroup.maxWaitTime = 600.; - drtConfigGroup.rejectRequestIfMaxWaitOrTravelTimeViolated = true; + constraintsParam.maxWaitTime = 600.; + constraintsParam.rejectRequestIfMaxWaitOrTravelTimeViolated = true; drtConfigGroup.useModeFilteredSubnetwork = false; drtConfigGroup.vehiclesFile = fleetFile; drtConfigGroup.operationalScheme = DrtConfigGroup.OperationalScheme.door2door; drtConfigGroup.plotDetailedCustomerStats = true; - drtConfigGroup.maxWalkDistance = 1000.; + constraintsParam.maxWalkDistance = 1000.; drtConfigGroup.idleVehiclesReturnToDepots = false; drtConfigGroup.addParameterSet(new ExtensiveInsertionSearchParams()); 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 b0b5089b81e..49033927906 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 @@ -13,6 +13,7 @@ import org.matsim.contrib.drt.optimizer.rebalancing.RebalancingParams; import org.matsim.contrib.drt.optimizer.rebalancing.mincostflow.MinCostFlowRebalancingStrategyParams; import org.matsim.contrib.drt.run.DrtConfigGroup; +import org.matsim.contrib.drt.run.DrtOptimizationConstraintsParams; import org.matsim.contrib.drt.run.MultiModeDrtConfigGroup; import org.matsim.contrib.dvrp.run.DvrpConfigGroup; import org.matsim.contrib.zone.skims.DvrpTravelTimeMatrixParams; @@ -45,16 +46,17 @@ void test() { DrtConfigGroup drtConfigGroup = drtWithShiftsConfigGroup; drtConfigGroup.mode = TransportMode.drt; - drtConfigGroup.maxTravelTimeAlpha = 1.5; - drtConfigGroup.maxTravelTimeBeta = 10. * 60.; + DrtOptimizationConstraintsParams constraintsParam = drtConfigGroup.getDrtOptimizationConstraintsParam(); + constraintsParam.maxTravelTimeAlpha = 1.5; + constraintsParam.maxTravelTimeBeta = 10. * 60.; drtConfigGroup.stopDuration = 30.; - drtConfigGroup.maxWaitTime = 600.; - drtConfigGroup.rejectRequestIfMaxWaitOrTravelTimeViolated = true; + constraintsParam.maxWaitTime = 600.; + constraintsParam.rejectRequestIfMaxWaitOrTravelTimeViolated = true; drtConfigGroup.useModeFilteredSubnetwork = false; drtConfigGroup.vehiclesFile = fleetFile; drtConfigGroup.operationalScheme = DrtConfigGroup.OperationalScheme.door2door; drtConfigGroup.plotDetailedCustomerStats = true; - drtConfigGroup.maxWalkDistance = 1000.; + constraintsParam.maxWalkDistance = 1000.; drtConfigGroup.idleVehiclesReturnToDepots = false; drtConfigGroup.addParameterSet(new ExtensiveInsertionSearchParams()); 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 1d85910ebec..f794e546c51 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 @@ -13,6 +13,7 @@ import org.matsim.contrib.drt.optimizer.rebalancing.RebalancingParams; import org.matsim.contrib.drt.optimizer.rebalancing.mincostflow.MinCostFlowRebalancingStrategyParams; import org.matsim.contrib.drt.run.DrtConfigGroup; +import org.matsim.contrib.drt.run.DrtOptimizationConstraintsParams; import org.matsim.contrib.drt.run.MultiModeDrtConfigGroup; import org.matsim.contrib.dvrp.run.DvrpConfigGroup; import org.matsim.contrib.zone.skims.DvrpTravelTimeMatrixParams; @@ -46,16 +47,17 @@ void test() { DrtConfigGroup drtConfigGroup = drtWithShiftsConfigGroup; drtConfigGroup.mode = TransportMode.drt; - drtConfigGroup.maxTravelTimeAlpha = 1.5; - drtConfigGroup.maxTravelTimeBeta = 10. * 60.; + DrtOptimizationConstraintsParams constraintsParam = drtConfigGroup.getDrtOptimizationConstraintsParam(); + constraintsParam.maxTravelTimeAlpha = 1.5; + constraintsParam.maxTravelTimeBeta = 10. * 60.; drtConfigGroup.stopDuration = 30.; - drtConfigGroup.maxWaitTime = 600.; - drtConfigGroup.rejectRequestIfMaxWaitOrTravelTimeViolated = true; + constraintsParam.maxWaitTime = 600.; + constraintsParam.rejectRequestIfMaxWaitOrTravelTimeViolated = true; drtConfigGroup.useModeFilteredSubnetwork = false; drtConfigGroup.vehiclesFile = fleetFile; drtConfigGroup.operationalScheme = DrtConfigGroup.OperationalScheme.door2door; drtConfigGroup.plotDetailedCustomerStats = true; - drtConfigGroup.maxWalkDistance = 1000.; + constraintsParam.maxWalkDistance = 1000.; drtConfigGroup.idleVehiclesReturnToDepots = false; drtConfigGroup.addParameterSet(new ExtensiveInsertionSearchParams()); 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 edc20fb87b7..3cc19b7a938 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 @@ -400,7 +400,7 @@ private void writeAndPlotWaitTimeEstimateComparison(Collection pe if (createChart) { final JFreeChart chart2 = DensityScatterPlots.createPlot("Wait times", "Actual wait time [s]", "Initially planned wait time [s]", - times, Pair.of(0., drtCfg.maxWaitTime)); + times, Pair.of(0., drtCfg.getDrtOptimizationConstraintsParam().maxWaitTime)); // xAxis.setLowerBound(0); // yAxis.setLowerBound(0); ChartUtils.writeChartAsPNG(new FileOutputStream(plotFileName), chart2, 1500, 1500); @@ -664,11 +664,11 @@ private static void analyseDetours(Network network, List legs, Map new DefaultOfferAcceptor(drtCfg.maxAllowedPickupDelay))); + bindModal(DefaultOfferAcceptor.class).toProvider(modalProvider(getter -> new DefaultOfferAcceptor(drtCfg.getDrtOptimizationConstraintsParam().maxAllowedPickupDelay))); bindModal(DrtOfferAcceptor.class).to(modalKey(DefaultOfferAcceptor.class)); bindModal(ScheduleTimingUpdater.class).toProvider(modalProvider( 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 15f9bb77530..c19a631ac44 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 @@ -61,7 +61,7 @@ public DrtRouteCreator(DrtConfigGroup drtCfg, Network modalNetwork, * @return maximum travel time */ static double getMaxTravelTime(DrtConfigGroup drtCfg, double unsharedRideTime) { - return drtCfg.maxTravelTimeAlpha * unsharedRideTime + drtCfg.maxTravelTimeBeta; + return drtCfg.getDrtOptimizationConstraintsParam().maxTravelTimeAlpha * unsharedRideTime + drtCfg.getDrtOptimizationConstraintsParam().maxTravelTimeBeta; } /** @@ -72,7 +72,7 @@ static double getMaxTravelTime(DrtConfigGroup drtCfg, double unsharedRideTime) { * @return maximum ride time */ static double getMaxRideTime(DrtConfigGroup drtCfg, double unsharedRideTime) { - return Math.min(unsharedRideTime + drtCfg.maxAbsoluteDetour, drtCfg.maxDetourAlpha * unsharedRideTime + drtCfg.maxDetourBeta); + return Math.min(unsharedRideTime + drtCfg.getDrtOptimizationConstraintsParam().maxAbsoluteDetour, drtCfg.getDrtOptimizationConstraintsParam().maxDetourAlpha * unsharedRideTime + drtCfg.getDrtOptimizationConstraintsParam().maxDetourBeta); } public Route createRoute(double departureTime, Link accessActLink, Link egressActLink, Person person, @@ -89,7 +89,7 @@ public Route createRoute(double departureTime, Link accessActLink, Link egressAc route.setTravelTime(maxTravelTime); route.setMaxRideTime(maxRideDuration); route.setDirectRideTime(unsharedRideTime); - route.setMaxWaitTime(drtCfg.maxWaitTime); + route.setMaxWaitTime(drtCfg.getDrtOptimizationConstraintsParam().maxWaitTime); if (this.drtCfg.storeUnsharedPath) { route.setUnsharedPath(unsharedPath); diff --git a/contribs/drt/src/main/java/org/matsim/contrib/drt/run/DrtConfigGroup.java b/contribs/drt/src/main/java/org/matsim/contrib/drt/run/DrtConfigGroup.java index 2e1923688c6..687b48b16fc 100644 --- a/contribs/drt/src/main/java/org/matsim/contrib/drt/run/DrtConfigGroup.java +++ b/contribs/drt/src/main/java/org/matsim/contrib/drt/run/DrtConfigGroup.java @@ -19,17 +19,15 @@ package org.matsim.contrib.drt.run; -import static org.matsim.core.config.groups.QSimConfigGroup.EndtimeInterpretation; - -import java.util.Collection; -import java.util.Optional; - -import javax.annotation.Nullable; - +import com.google.common.base.Preconditions; +import com.google.common.base.Verify; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Positive; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.checkerframework.checker.units.qual.C; import org.matsim.api.core.v01.TransportMode; +import org.matsim.contrib.common.util.ReflectiveConfigGroupWithConfigurableParameterSets; import org.matsim.contrib.drt.analysis.zonal.DrtZoneSystemParams; import org.matsim.contrib.drt.estimator.DrtEstimatorParams; import org.matsim.contrib.drt.fare.DrtFareParams; @@ -44,19 +42,15 @@ import org.matsim.contrib.drt.speedup.DrtSpeedUpParams; import org.matsim.contrib.dvrp.router.DvrpModeRoutingNetworkModule; import org.matsim.contrib.dvrp.run.Modal; -import org.matsim.contrib.common.util.ReflectiveConfigGroupWithConfigurableParameterSets; import org.matsim.core.config.Config; -import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.config.groups.RoutingConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; -import com.google.common.base.Preconditions; -import com.google.common.base.Verify; +import javax.annotation.Nullable; +import java.util.Collection; +import java.util.Optional; -import jakarta.validation.constraints.DecimalMin; -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.Positive; -import jakarta.validation.constraints.PositiveOrZero; +import static org.matsim.core.config.groups.QSimConfigGroup.EndtimeInterpretation; public class DrtConfigGroup extends ReflectiveConfigGroupWithConfigurableParameterSets implements Modal { private static final Logger log = LogManager.getLogger(DrtConfigGroup.class); @@ -70,6 +64,9 @@ public static DrtConfigGroup getSingleModeDrtConfig(Config config) { return drtConfigGroups.iterator().next(); } + @NotNull + private DrtOptimizationConstraintsParams drtOptimizationConstraintsParams; + @Parameter @Comment("Mode which will be handled by PassengerEngine and VrpOptimizer (passengers'/customers' perspective)") @NotBlank @@ -88,66 +85,6 @@ public static DrtConfigGroup getSingleModeDrtConfig(Config config) { @Positive public double stopDuration = Double.NaN;// seconds - @Parameter - @Comment("Max wait time for the bus to come (optimisation constraint).") - @PositiveOrZero - public double maxWaitTime = Double.NaN;// seconds - - @Parameter - @Comment("Defines the slope of the maxTravelTime estimation function (optimisation constraint), i.e. " - + "min(unsharedRideTime + maxAbsoluteDetour, maxTravelTimeAlpha * unsharedRideTime + maxTravelTimeBeta). " - + "Alpha should not be smaller than 1.") - @DecimalMin("1.0") - public double maxTravelTimeAlpha = Double.NaN;// [-] - - @Parameter - @Comment("Defines the shift of the maxTravelTime estimation function (optimisation constraint), i.e. " - + "min(unsharedRideTime + maxAbsoluteDetour, maxTravelTimeAlpha * unsharedRideTime + maxTravelTimeBeta). " - + "Beta should not be smaller than 0.") - @PositiveOrZero - public double maxTravelTimeBeta = Double.NaN;// [s] - - @Parameter - @Comment( - "Defines the maximum allowed absolute detour in seconds. Note that the detour is computed from the latest promised pickup time. " + - "To enable the max detour constraint, maxAllowedPickupDelay has to be specified. maxAbsoluteDetour should not be smaller than 0, " - + "and should be higher than the offset maxDetourBeta. By default, this limit is disabled (i.e. set to Inf)") - @PositiveOrZero - public double maxAbsoluteDetour = Double.POSITIVE_INFINITY;// [s] - - @Parameter - @Comment( - "Defines the maximum allowed absolute detour based on the unsharedRideTime. Note that the detour is computed from the latest promised " - + "pickup time. To enable the max detour constraint, maxAllowedPickupDelay has to be specified. A linear combination similar to travel " - + "time constrain is used. This is the ratio part. By default, this limit is disabled (i.e. set to Inf, together with maxDetourBeta).") - @DecimalMin("1.0") - public double maxDetourAlpha = Double.POSITIVE_INFINITY; - - @Parameter - @Comment( - "Defines the maximum allowed absolute detour based on the unsharedRideTime. Note that the detour is computed from the latest promised " - + "pickup time. To enable the max detour constraint, maxAllowedPickupDelay has to be specified. A linear combination similar to travel " - + "time constrain is used. This is the constant part. By default, this limit is disabled (i.e. set to Inf, together with maxDetourAlpha).") - @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] - - @Parameter - @Comment("If true, the max travel and wait times of a submitted request" - + " are considered hard constraints (the request gets rejected if one of the constraints is violated)." - + " If false, the max travel and wait times are considered soft constraints (insertion of a request that" - + " violates one of the constraints is allowed, but its cost is increased by additional penalty to make" - + " it relatively less attractive). Penalisation of insertions can be customised by injecting a customised" - + " InsertionCostCalculator.PenaltyCalculator") - public boolean rejectRequestIfMaxWaitOrTravelTimeViolated = true; - @Parameter @Comment("If true, the startLink is changed to last link in the current schedule, so the taxi starts the next " + "day at the link where it stopped operating the day before. False by default.") @@ -175,14 +112,6 @@ public enum OperationalScheme { @NotNull public OperationalScheme operationalScheme = OperationalScheme.door2door; - //TODO consider renaming maxWalkDistance to max access/egress distance (or even have 2 separate params) - @Parameter - @Comment( - "Maximum beeline distance (in meters) to next stop location in stopbased system for access/egress walk leg to/from drt." - + " If no stop can be found within this maximum distance will return null (in most cases caught by fallback routing module).") - @PositiveOrZero // used only for stopbased DRT scheme - public double maxWalkDistance = Double.MAX_VALUE;// [m]; - @Parameter @Comment("An XML file specifying the vehicle fleet." + " The file format according to dvrp_vehicles_v1.dtd" @@ -257,6 +186,10 @@ public DrtConfigGroup() { } private void initSingletonParameterSets() { + //drt optimization constraints + addDefinition(DrtOptimizationConstraintsParams.SET_NAME, DrtOptimizationConstraintsParams::new, + () -> drtOptimizationConstraintsParams, params -> drtOptimizationConstraintsParams = (DrtOptimizationConstraintsParams) params); + //rebalancing (optional) addDefinition(RebalancingParams.SET_NAME, RebalancingParams::new, () -> rebalancingParams, params -> rebalancingParams = (RebalancingParams)params); @@ -301,6 +234,27 @@ private void initSingletonParameterSets() { } + /** + * for backwards compatibility with old drt config groups + */ + public void handleAddUnknownParam(final String paramName, final String value) { + switch (paramName) { + case "maxWaitTime": + case "maxTravelTimeAlpha": + case "maxTravelTimeBeta": + case "maxAbsoluteDetour": + case "maxDetourAlpha": + case "maxDetourBeta": + case "maxAllowedPickupDelay": + case "rejectRequestIfMaxWaitOrTravelTimeViolated": + case "maxWalkDistance": + getDrtOptimizationConstraintsParam().addParam(paramName, value); + break; + default: + super.handleAddUnknownParam(paramName, value); + } + } + @Override protected void checkConsistency(Config config) { super.checkConsistency(config); @@ -315,7 +269,7 @@ protected void checkConsistency(Config config) { + "attempting to travel without vehicles being available."); } - Verify.verify(maxWaitTime >= stopDuration, "maxWaitTime must not be smaller than stopDuration"); + Verify.verify(drtOptimizationConstraintsParams.maxWaitTime >= stopDuration, "maxWaitTime must not be smaller than stopDuration"); Verify.verify(operationalScheme != OperationalScheme.stopbased || transitStopFile != null, "transitStopFile must not be null when operationalScheme is " + OperationalScheme.stopbased); @@ -344,11 +298,6 @@ protected void checkConsistency(Config config) { DvrpModeRoutingNetworkModule.checkUseModeFilteredSubnetworkAllowed(config, mode); } - if ((maxDetourAlpha != Double.POSITIVE_INFINITY && maxDetourBeta != Double.POSITIVE_INFINITY) || maxAbsoluteDetour != Double.POSITIVE_INFINITY) { - Verify.verify(maxAllowedPickupDelay != Double.POSITIVE_INFINITY, "Detour constraints are activated, " + - "maxAllowedPickupDelay must be specified! A value between 0 and 240 seconds can be a good choice for maxAllowedPickupDelay."); - } - if (simulationType == SimulationType.estimateAndTeleport) { Verify.verify(drtSpeedUpParams == null, "Simulation type is estimateAndTeleport, but drtSpeedUpParams is set. " + "Please remove drtSpeedUpParams from the config, as these two functionalities are not compatible."); @@ -360,6 +309,13 @@ public String getMode() { return mode; } + public DrtOptimizationConstraintsParams getDrtOptimizationConstraintsParam() { + if (drtOptimizationConstraintsParams == null) { + addParameterSet(new DrtOptimizationConstraintsParams()); + } + return drtOptimizationConstraintsParams; + } + public DrtInsertionSearchParams getDrtInsertionSearchParams() { return drtInsertionSearchParams; } 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 8d037b171dc..af5916d028a 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 @@ -104,7 +104,7 @@ public void install() { .asEagerSingleton(); case stopbased, serviceAreaBased -> { bindModal( AccessEgressFacilityFinder.class ).toProvider( modalProvider( - getter -> new ClosestAccessEgressFacilityFinder( drtCfg.maxWalkDistance, + getter -> new ClosestAccessEgressFacilityFinder( drtCfg.getDrtOptimizationConstraintsParam().maxWalkDistance, getter.get( Network.class ), QuadTrees.createQuadTree( getter.getModal( DrtStopNetwork.class ).getDrtStops().values() ) ) ) ) .asEagerSingleton(); diff --git a/contribs/drt/src/main/java/org/matsim/contrib/drt/run/DrtOptimizationConstraintsParams.java b/contribs/drt/src/main/java/org/matsim/contrib/drt/run/DrtOptimizationConstraintsParams.java new file mode 100644 index 00000000000..f3f1e1ed5f2 --- /dev/null +++ b/contribs/drt/src/main/java/org/matsim/contrib/drt/run/DrtOptimizationConstraintsParams.java @@ -0,0 +1,96 @@ +package org.matsim.contrib.drt.run; + +import com.google.common.base.Verify; +import jakarta.validation.constraints.DecimalMin; +import jakarta.validation.constraints.PositiveOrZero; +import org.matsim.core.config.Config; +import org.matsim.core.config.ReflectiveConfigGroup; + +/** + * @author nkuehnel / MOIA + */ +public class DrtOptimizationConstraintsParams extends ReflectiveConfigGroup { + + public final static String SET_NAME = "drtOptimizationConstraints"; + + + @Parameter + @Comment("Max wait time for the bus to come (optimisation constraint).") + @PositiveOrZero + public double maxWaitTime = Double.NaN;// seconds + + @Parameter + @Comment("Defines the slope of the maxTravelTime estimation function (optimisation constraint), i.e. " + + "min(unsharedRideTime + maxAbsoluteDetour, maxTravelTimeAlpha * unsharedRideTime + maxTravelTimeBeta). " + + "Alpha should not be smaller than 1.") + @DecimalMin("1.0") + public double maxTravelTimeAlpha = Double.NaN;// [-] + + @Parameter + @Comment("Defines the shift of the maxTravelTime estimation function (optimisation constraint), i.e. " + + "min(unsharedRideTime + maxAbsoluteDetour, maxTravelTimeAlpha * unsharedRideTime + maxTravelTimeBeta). " + + "Beta should not be smaller than 0.") + @PositiveOrZero + public double maxTravelTimeBeta = Double.NaN;// [s] + + @Parameter + @Comment( + "Defines the maximum allowed absolute detour in seconds. Note that the detour is computed from the latest promised pickup time. " + + "To enable the max detour constraint, maxAllowedPickupDelay has to be specified. maxAbsoluteDetour should not be smaller than 0, " + + "and should be higher than the offset maxDetourBeta. By default, this limit is disabled (i.e. set to Inf)") + @PositiveOrZero + public double maxAbsoluteDetour = Double.POSITIVE_INFINITY;// [s] + + @Parameter + @Comment( + "Defines the maximum allowed absolute detour based on the unsharedRideTime. Note that the detour is computed from the latest promised " + + "pickup time. To enable the max detour constraint, maxAllowedPickupDelay has to be specified. A linear combination similar to travel " + + "time constrain is used. This is the ratio part. By default, this limit is disabled (i.e. set to Inf, together with maxDetourBeta).") + @DecimalMin("1.0") + public double maxDetourAlpha = Double.POSITIVE_INFINITY; + + @Parameter + @Comment( + "Defines the maximum allowed absolute detour based on the unsharedRideTime. Note that the detour is computed from the latest promised " + + "pickup time. To enable the max detour constraint, maxAllowedPickupDelay has to be specified. A linear combination similar to travel " + + "time constrain is used. This is the constant part. By default, this limit is disabled (i.e. set to Inf, together with maxDetourAlpha).") + @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] + + @Parameter + @Comment("If true, the max travel and wait times of a submitted request" + + " are considered hard constraints (the request gets rejected if one of the constraints is violated)." + + " If false, the max travel and wait times are considered soft constraints (insertion of a request that" + + " violates one of the constraints is allowed, but its cost is increased by additional penalty to make" + + " it relatively less attractive). Penalisation of insertions can be customised by injecting a customised" + + " InsertionCostCalculator.PenaltyCalculator") + public boolean rejectRequestIfMaxWaitOrTravelTimeViolated = true;//TODO consider renaming maxWalkDistance to max access/egress distance (or even have 2 separate params) + + @Parameter + @Comment( + "Maximum beeline distance (in meters) to next stop location in stopbased system for access/egress walk leg to/from drt." + + " If no stop can be found within this maximum distance will return null (in most cases caught by fallback routing module).") + @PositiveOrZero // used only for stopbased DRT scheme + public double maxWalkDistance = Double.MAX_VALUE;// [m]; + + public DrtOptimizationConstraintsParams() { + super(SET_NAME); + } + + @Override + protected void checkConsistency(Config config) { + super.checkConsistency(config); + if ((maxDetourAlpha != Double.POSITIVE_INFINITY && maxDetourBeta != Double.POSITIVE_INFINITY) || maxAbsoluteDetour != Double.POSITIVE_INFINITY) { + Verify.verify(maxAllowedPickupDelay != Double.POSITIVE_INFINITY, "Detour constraints are activated, " + + "maxAllowedPickupDelay must be specified! A value between 0 and 240 seconds can be a good choice for maxAllowedPickupDelay."); + } + } +} \ No newline at end of file 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 ec0e2a1f030..8722cc9e657 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 @@ -36,17 +36,17 @@ public void testMaxDetourConstraint() { DrtConfigGroup drtConfigGroup = DrtConfigGroup.getSingleModeDrtConfig(config); // Max wait time - drtConfigGroup.maxWaitTime = 300; + drtConfigGroup.getDrtOptimizationConstraintsParam().maxWaitTime = 300; // Turn on the max detour constraint - drtConfigGroup.maxDetourAlpha = 1.5; - drtConfigGroup.maxDetourBeta = 300; - drtConfigGroup.maxAllowedPickupDelay = 180; - drtConfigGroup.maxAbsoluteDetour = 1200; + drtConfigGroup.getDrtOptimizationConstraintsParam().maxDetourAlpha = 1.5; + drtConfigGroup.getDrtOptimizationConstraintsParam().maxDetourBeta = 300; + drtConfigGroup.getDrtOptimizationConstraintsParam().maxAllowedPickupDelay = 180; + drtConfigGroup.getDrtOptimizationConstraintsParam().maxAbsoluteDetour = 1200; // Make the max total travel time constraints very loose (i.e., make it not active) - drtConfigGroup.maxTravelTimeAlpha = 10; - drtConfigGroup.maxTravelTimeBeta = 7200; + drtConfigGroup.getDrtOptimizationConstraintsParam().maxTravelTimeAlpha = 10; + drtConfigGroup.getDrtOptimizationConstraintsParam().maxTravelTimeBeta = 7200; config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); config.controller().setOutputDirectory(utils.getOutputDirectory()); 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 8451f93b1e2..dfff04e67da 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 @@ -225,9 +225,9 @@ private PersonEnterDrtVehicleEventHandler setupAndRunScenario(double maxWaitTime MultiModeDrtConfigGroup mm = ConfigUtils.addOrGetModule(config, MultiModeDrtConfigGroup.class); mm.getModalElements().forEach(x -> { - x.maxWaitTime = maxWaitTime; - x.maxTravelTimeAlpha = maxTravelTimeAlpha; - x.maxTravelTimeBeta = maxTravelTimeBeta; + x.getDrtOptimizationConstraintsParam().maxWaitTime = maxWaitTime; + x.getDrtOptimizationConstraintsParam().maxTravelTimeAlpha = maxTravelTimeAlpha; + x.getDrtOptimizationConstraintsParam().maxTravelTimeBeta = maxTravelTimeBeta; x.stopDuration = 1.; }); diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/ComplexUnschedulerTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/ComplexUnschedulerTest.java index 93a59a769bd..9f6b424da09 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/ComplexUnschedulerTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/ComplexUnschedulerTest.java @@ -626,7 +626,7 @@ private class Fixture { DrtConfigGroup drtConfig = new DrtConfigGroup(); drtConfig.stopDuration = 30.0; - drtConfig.maxWaitTime = 600.0; + drtConfig.getDrtOptimizationConstraintsParam().maxWaitTime = 600.0; this.entryFactory = new VehicleDataEntryFactoryImpl(); 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 c97f2c34a81..e4cece58765 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 @@ -226,9 +226,9 @@ private void buildConfig(Config config) { DrtConfigGroup modeConfig = new DrtConfigGroup(); drtConfig.addParameterSet(modeConfig); modeConfig.mode = "drt"; - modeConfig.maxWaitTime = maximumWaitTime; - modeConfig.maxTravelTimeAlpha = detourRelative; - modeConfig.maxTravelTimeBeta = detourAbsolute; + modeConfig.getDrtOptimizationConstraintsParam().maxWaitTime = maximumWaitTime; + modeConfig.getDrtOptimizationConstraintsParam().maxTravelTimeAlpha = detourRelative; + modeConfig.getDrtOptimizationConstraintsParam().maxTravelTimeBeta = detourAbsolute; modeConfig.stopDuration = stopDuration; modeConfig.idleVehiclesReturnToDepots = false; modeConfig.vehiclesFile = null; 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 e4d242dabcf..f86bbeb7215 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 @@ -80,9 +80,9 @@ void testCottbusClosestAccessEgressStopFinder() { DrtConfigGroup drtCfg = DrtConfigGroup.getSingleModeDrtConfig(scenario.getConfig()); String drtMode = "DrtX"; drtCfg.mode = drtMode; - drtCfg.maxTravelTimeAlpha = 1.5; - drtCfg.maxTravelTimeBeta = 5 * 60; - drtCfg.maxWaitTime = 5 * 60; + drtCfg.getDrtOptimizationConstraintsParam().maxTravelTimeAlpha = 1.5; + drtCfg.getDrtOptimizationConstraintsParam().maxTravelTimeBeta = 5 * 60; + drtCfg.getDrtOptimizationConstraintsParam().maxWaitTime = 5 * 60; ImmutableMap, DrtStopFacility> drtStops = scenario.getTransitSchedule() .getFacilities() @@ -91,7 +91,7 @@ void testCottbusClosestAccessEgressStopFinder() { .map(DrtStopFacilityImpl::createFromFacility) .collect(ImmutableMap.toImmutableMap(DrtStopFacility::getId, f -> f)); - AccessEgressFacilityFinder stopFinder = new ClosestAccessEgressFacilityFinder(drtCfg.maxWalkDistance, + AccessEgressFacilityFinder stopFinder = new ClosestAccessEgressFacilityFinder(drtCfg.getDrtOptimizationConstraintsParam().maxWalkDistance, scenario.getNetwork(), QuadTrees.createQuadTree(drtStops.values())); DrtRouteCreator drtRouteCreator = new DrtRouteCreator(drtCfg, scenario.getNetwork(), new SpeedyDijkstraFactory(), new FreeSpeedTravelTime(), TimeAsTravelDisutility::new); @@ -259,7 +259,7 @@ void testRouteDescriptionHandling() { private Scenario createTestScenario() { Config config = ConfigUtils.createConfig(); DrtConfigGroup drtConfigGroup = new DrtConfigGroup(); - drtConfigGroup.maxWalkDistance = 200; + drtConfigGroup.getDrtOptimizationConstraintsParam().maxWalkDistance = 200; drtConfigGroup.transitStopFile = utils.getClassInputDirectory() + "testCottbus/drtstops.xml.gz"; MultiModeDrtConfigGroup multiModeDrtConfigGroup = new MultiModeDrtConfigGroup(); multiModeDrtConfigGroup.addParameterSet(drtConfigGroup); diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/run/examples/RunDrtExampleIT.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/run/examples/RunDrtExampleIT.java index e1c1492fbed..6b15ba1bc9e 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/run/examples/RunDrtExampleIT.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/run/examples/RunDrtExampleIT.java @@ -90,7 +90,7 @@ void testRunDrtExampleWithNoRejections_ExtensiveSearch() { for (var drtCfg : MultiModeDrtConfigGroup.get(config).getModalElements()) { //disable rejections - drtCfg.rejectRequestIfMaxWaitOrTravelTimeViolated = false; + drtCfg.getDrtOptimizationConstraintsParam().rejectRequestIfMaxWaitOrTravelTimeViolated = false; } config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); @@ -129,7 +129,7 @@ void testRunDrtExampleWithNoRejections_SelectiveSearch() { drtCfg.addParameterSet(selectiveInsertionSearchParams); //disable rejections - drtCfg.rejectRequestIfMaxWaitOrTravelTimeViolated = false; + drtCfg.getDrtOptimizationConstraintsParam().rejectRequestIfMaxWaitOrTravelTimeViolated = false; } config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); @@ -168,7 +168,7 @@ void testRunDrtExampleWithNoRejections_RepeatedSelectiveSearch() { drtCfg.addParameterSet(repeatedSelectiveInsertionSearchParams); //disable rejections - drtCfg.rejectRequestIfMaxWaitOrTravelTimeViolated = false; + drtCfg.getDrtOptimizationConstraintsParam().rejectRequestIfMaxWaitOrTravelTimeViolated = false; } config.controller().setLastIteration(3); @@ -393,7 +393,7 @@ void testRunDrtWithPrebooking() { * rejectionRate, rejections, waitAverage, inVehicleTravelTimeMean, & totalTravelTimeMean */ - private void verifyDrtCustomerStatsCloseToExpectedStats(String outputDirectory, Stats expectedStats) { + static void verifyDrtCustomerStatsCloseToExpectedStats(String outputDirectory, Stats expectedStats) { String filename = outputDirectory + "/drt_customer_stats_drt.csv"; @@ -424,7 +424,7 @@ private void verifyDrtCustomerStatsCloseToExpectedStats(String outputDirectory, assertThat(actualStats).usingRecursiveComparison().isEqualTo(expectedStats); } - private static class Stats { + static class Stats { private final double rejectionRate; private final double rejections; private final double waitAverage; diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/run/examples/RunOldDrtConfigCompatibilityIT.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/run/examples/RunOldDrtConfigCompatibilityIT.java new file mode 100644 index 00000000000..506bb7503c2 --- /dev/null +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/run/examples/RunOldDrtConfigCompatibilityIT.java @@ -0,0 +1,61 @@ +package org.matsim.contrib.drt.run.examples; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.matsim.api.core.v01.Id; +import org.matsim.contrib.common.zones.systems.grid.square.SquareGridZoneSystemParams; +import org.matsim.contrib.drt.run.MultiModeDrtConfigGroup; +import org.matsim.contrib.dvrp.run.DvrpConfigGroup; +import org.matsim.contrib.zone.skims.DvrpTravelTimeMatrixParams; +import org.matsim.core.config.Config; +import org.matsim.core.config.ConfigUtils; +import org.matsim.core.controler.OutputDirectoryHierarchy; +import org.matsim.core.utils.io.IOUtils; +import org.matsim.examples.ExamplesUtils; +import org.matsim.testcases.MatsimTestUtils; +import org.matsim.vis.otfvis.OTFVisConfigGroup; + +import java.net.URL; + +/** + * + * Tests the older drt config version where optimization constraints where not stored as separate parameters + * @author nkuehnel / MOIA + */ +public class RunOldDrtConfigCompatibilityIT { + + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); + + @Test + void testRunDrtExampleWithNoRejections_ExtensiveSearch() { + Id.resetCaches(); + + DvrpConfigGroup dvrpConfigGroup = new DvrpConfigGroup(); + DvrpTravelTimeMatrixParams matrixParams = dvrpConfigGroup.getTravelTimeMatrixParams(); + matrixParams.addParameterSet(matrixParams.createParameterSet(SquareGridZoneSystemParams.SET_NAME)); + + URL configUrl = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("mielec"), "mielec_drt_config_v1.xml"); + Config config = ConfigUtils.loadConfig(configUrl, new MultiModeDrtConfigGroup(), dvrpConfigGroup, + new OTFVisConfigGroup()); + + for (var drtCfg : MultiModeDrtConfigGroup.get(config).getModalElements()) { + //disable rejections + drtCfg.getDrtOptimizationConstraintsParam().rejectRequestIfMaxWaitOrTravelTimeViolated = false; + } + + config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOutputDirectory(utils.getOutputDirectory()); + RunDrtExample.run(config, false); + + var expectedStats = RunDrtExampleIT.Stats.newBuilder() + .rejectionRate(0.0) + .rejections(0) + .waitAverage(297.19) + .inVehicleTravelTimeMean(386.78) + .totalTravelTimeMean(683.97) + .build(); + + RunDrtExampleIT.verifyDrtCustomerStatsCloseToExpectedStats(utils.getOutputDirectory(), expectedStats); + } +} 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 4cd79608057..27dfd190989 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 @@ -12,6 +12,7 @@ import org.matsim.contrib.drt.fare.DrtFareParams; import org.matsim.contrib.drt.run.DrtConfigGroup; import org.matsim.contrib.drt.run.DrtControlerCreator; +import org.matsim.contrib.drt.run.DrtOptimizationConstraintsParams; import org.matsim.contrib.drt.run.MultiModeDrtConfigGroup; import org.matsim.contrib.dvrp.run.DvrpConfigGroup; import org.matsim.core.config.Config; @@ -45,9 +46,10 @@ void testTeleportationEngine() throws IOException { Controler controler = DrtControlerCreator.createControler(config, false); DrtConfigGroup drtConfigGroup = DrtConfigGroup.getSingleModeDrtConfig(config); - drtConfigGroup.maxTravelTimeAlpha = 1.2; - drtConfigGroup.maxTravelTimeBeta = 600; - drtConfigGroup.maxWaitTime = 300; + DrtOptimizationConstraintsParams constraintsParam = drtConfigGroup.getDrtOptimizationConstraintsParam(); + constraintsParam.maxTravelTimeAlpha = 1.2; + constraintsParam.maxTravelTimeBeta = 600; + constraintsParam.maxWaitTime = 300; DrtFareParams fareParams = new DrtFareParams(); fareParams.baseFare = 1.0; fareParams.distanceFare_m = 0.001; @@ -75,12 +77,12 @@ public void install() { double waitAvg = Double.parseDouble(row.get("wait_average")); - assertThat(waitAvg).isEqualTo(drtConfigGroup.maxWaitTime); + assertThat(waitAvg).isEqualTo(constraintsParam.maxWaitTime); double distMean = Double.parseDouble(row.get("distance_m_mean")); double directDistMean = Double.parseDouble(row.get("directDistance_m_mean")); - assertThat(distMean / directDistMean).isCloseTo(drtConfigGroup.maxTravelTimeAlpha, Offset.offset(0.0001)); + assertThat(distMean / directDistMean).isCloseTo(constraintsParam.maxTravelTimeAlpha, Offset.offset(0.0001)); } 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 31bf3440150..b4aa67762e0 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 @@ -66,16 +66,16 @@ 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. - drtCfg.maxWaitTime = 3600; - drtCfg.maxTravelTimeAlpha = 2; - drtCfg.maxTravelTimeBeta = 3600; - drtCfg.maxAbsoluteDetour = Double.MAX_VALUE; + drtCfg.getDrtOptimizationConstraintsParam().maxWaitTime = 3600; + drtCfg.getDrtOptimizationConstraintsParam().maxTravelTimeAlpha = 2; + drtCfg.getDrtOptimizationConstraintsParam().maxTravelTimeBeta = 3600; + drtCfg.getDrtOptimizationConstraintsParam().maxAbsoluteDetour = Double.MAX_VALUE; - drtCfg.rejectRequestIfMaxWaitOrTravelTimeViolated = false; + drtCfg.getDrtOptimizationConstraintsParam().rejectRequestIfMaxWaitOrTravelTimeViolated = false; drtCfg.changeStartLinkToLastLinkInSchedule = taxiCfg.changeStartLinkToLastLinkInSchedule; drtCfg.idleVehiclesReturnToDepots = false; drtCfg.operationalScheme = DrtConfigGroup.OperationalScheme.door2door; - drtCfg.maxWalkDistance = Double.MAX_VALUE; + drtCfg.getDrtOptimizationConstraintsParam().maxWalkDistance = Double.MAX_VALUE; drtCfg.vehiclesFile = taxiCfg.taxisFile; drtCfg.transitStopFile = null; drtCfg.drtServiceAreaShapeFile = null; 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 3e00dd03d50..f99512782ef 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 @@ -229,11 +229,11 @@ void testPtAlongALineWithRaptorAndDrtServiceArea() { { DrtConfigGroup drtConfigGroup = new DrtConfigGroup(); drtConfigGroup.mode = TransportMode.drt; - drtConfigGroup.maxTravelTimeAlpha = 2.0; - drtConfigGroup.maxTravelTimeBeta = 5. * 60.; + drtConfigGroup.getDrtOptimizationConstraintsParam().maxTravelTimeAlpha = 2.0; + drtConfigGroup.getDrtOptimizationConstraintsParam().maxTravelTimeBeta = 5. * 60.; drtConfigGroup.stopDuration = 60.; - drtConfigGroup.maxWaitTime = Double.MAX_VALUE; - drtConfigGroup.rejectRequestIfMaxWaitOrTravelTimeViolated = false; + drtConfigGroup.getDrtOptimizationConstraintsParam().maxWaitTime = Double.MAX_VALUE; + drtConfigGroup.getDrtOptimizationConstraintsParam().rejectRequestIfMaxWaitOrTravelTimeViolated = false; drtConfigGroup.useModeFilteredSubnetwork = true; drtConfigGroup.addParameterSet(new ExtensiveInsertionSearchParams()); @@ -243,11 +243,11 @@ void testPtAlongALineWithRaptorAndDrtServiceArea() { if (drt2) { DrtConfigGroup drtConfigGroup = new DrtConfigGroup(); drtConfigGroup.mode = "drt2"; - drtConfigGroup.maxTravelTimeAlpha = 1.3; - drtConfigGroup.maxTravelTimeBeta = 5. * 60.; + drtConfigGroup.getDrtOptimizationConstraintsParam().maxTravelTimeAlpha = 1.3; + drtConfigGroup.getDrtOptimizationConstraintsParam().maxTravelTimeBeta = 5. * 60.; drtConfigGroup.stopDuration = 60.; - drtConfigGroup.maxWaitTime = Double.MAX_VALUE; - drtConfigGroup.rejectRequestIfMaxWaitOrTravelTimeViolated = false; + drtConfigGroup.getDrtOptimizationConstraintsParam().maxWaitTime = Double.MAX_VALUE; + drtConfigGroup.getDrtOptimizationConstraintsParam().rejectRequestIfMaxWaitOrTravelTimeViolated = false; drtConfigGroup.useModeFilteredSubnetwork = true; drtConfigGroup.addParameterSet(new ExtensiveInsertionSearchParams()); @@ -256,11 +256,11 @@ void testPtAlongALineWithRaptorAndDrtServiceArea() { if (drt3) { DrtConfigGroup drtConfigGroup = new DrtConfigGroup(); drtConfigGroup.mode = "drt3"; - drtConfigGroup.maxTravelTimeAlpha = 1.3; - drtConfigGroup.maxTravelTimeBeta = 5. * 60.; + drtConfigGroup.getDrtOptimizationConstraintsParam().maxTravelTimeAlpha = 1.3; + drtConfigGroup.getDrtOptimizationConstraintsParam().maxTravelTimeBeta = 5. * 60.; drtConfigGroup.stopDuration = 60.; - drtConfigGroup.maxWaitTime = Double.MAX_VALUE; - drtConfigGroup.rejectRequestIfMaxWaitOrTravelTimeViolated = false; + drtConfigGroup.getDrtOptimizationConstraintsParam().maxWaitTime = Double.MAX_VALUE; + drtConfigGroup.getDrtOptimizationConstraintsParam().rejectRequestIfMaxWaitOrTravelTimeViolated = false; drtConfigGroup.useModeFilteredSubnetwork = true; drtConfigGroup.addParameterSet(new ExtensiveInsertionSearchParams()); 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 00c908721c0..fd92aafff84 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 @@ -110,10 +110,10 @@ void testDrtAlongALine() { DrtConfigGroup drtConfig = new DrtConfigGroup(); drtConfig.mode = "drt_A"; drtConfig.stopDuration = 60.; - drtConfig.maxWaitTime = 900.; - drtConfig.maxTravelTimeAlpha = 1.3; - drtConfig.maxTravelTimeBeta = 10. * 60.; - drtConfig.rejectRequestIfMaxWaitOrTravelTimeViolated = false; + drtConfig.getDrtOptimizationConstraintsParam().maxWaitTime = 900.; + drtConfig.getDrtOptimizationConstraintsParam().maxTravelTimeAlpha = 1.3; + drtConfig.getDrtOptimizationConstraintsParam().maxTravelTimeBeta = 10. * 60.; + drtConfig.getDrtOptimizationConstraintsParam().rejectRequestIfMaxWaitOrTravelTimeViolated = false; drtConfig.changeStartLinkToLastLinkInSchedule = true; multiModeDrtCfg.addParameterSet(drtConfig); } @@ -247,11 +247,11 @@ void testPtAlongALineWithRaptorAndDrtStopFilterAttribute() { MultiModeDrtConfigGroup mm = ConfigUtils.addOrGetModule(config, MultiModeDrtConfigGroup.class); { DrtConfigGroup drtConfig = new DrtConfigGroup(); - drtConfig.maxTravelTimeAlpha = 1.3; - drtConfig.maxTravelTimeBeta = 5. * 60.; + drtConfig.getDrtOptimizationConstraintsParam().maxTravelTimeAlpha = 1.3; + drtConfig.getDrtOptimizationConstraintsParam().maxTravelTimeBeta = 5. * 60.; drtConfig.stopDuration = 60.; - drtConfig.maxWaitTime = Double.MAX_VALUE; - drtConfig.rejectRequestIfMaxWaitOrTravelTimeViolated = false; + drtConfig.getDrtOptimizationConstraintsParam().maxWaitTime = Double.MAX_VALUE; + drtConfig.getDrtOptimizationConstraintsParam().rejectRequestIfMaxWaitOrTravelTimeViolated = false; drtConfig.mode = TransportMode.drt; mm.addParameterSet(drtConfig); } diff --git a/examples/scenarios/dvrp-grid/eight_shared_taxi_config.xml b/examples/scenarios/dvrp-grid/eight_shared_taxi_config.xml index fa26707492f..4dd451ddac4 100644 --- a/examples/scenarios/dvrp-grid/eight_shared_taxi_config.xml +++ b/examples/scenarios/dvrp-grid/eight_shared_taxi_config.xml @@ -5,10 +5,12 @@ - - - - + + + + + + diff --git a/examples/scenarios/dvrp-grid/multi_mode_one_shared_taxi_config.xml b/examples/scenarios/dvrp-grid/multi_mode_one_shared_taxi_config.xml index bb0c4beed1f..1d306865741 100644 --- a/examples/scenarios/dvrp-grid/multi_mode_one_shared_taxi_config.xml +++ b/examples/scenarios/dvrp-grid/multi_mode_one_shared_taxi_config.xml @@ -14,10 +14,12 @@ - - - - + + + + + + @@ -30,10 +32,12 @@ - - - - + + + + + + diff --git a/examples/scenarios/dvrp-grid/one_shared_taxi_config.xml b/examples/scenarios/dvrp-grid/one_shared_taxi_config.xml index 6f727d250e8..2d3b062aea6 100644 --- a/examples/scenarios/dvrp-grid/one_shared_taxi_config.xml +++ b/examples/scenarios/dvrp-grid/one_shared_taxi_config.xml @@ -13,10 +13,12 @@ - - - - + + + + + + diff --git a/examples/scenarios/dvrp-grid/one_taxi_and_one_shared_taxi_config.xml b/examples/scenarios/dvrp-grid/one_taxi_and_one_shared_taxi_config.xml index 4d953cfcf33..1f1f0a1b3fa 100644 --- a/examples/scenarios/dvrp-grid/one_taxi_and_one_shared_taxi_config.xml +++ b/examples/scenarios/dvrp-grid/one_taxi_and_one_shared_taxi_config.xml @@ -8,9 +8,12 @@ - - - + + + + + + diff --git a/examples/scenarios/kelheim/config-with-drt.xml b/examples/scenarios/kelheim/config-with-drt.xml index 7657d679502..65d678e96d3 100644 --- a/examples/scenarios/kelheim/config-with-drt.xml +++ b/examples/scenarios/kelheim/config-with-drt.xml @@ -243,15 +243,17 @@ - - - - - - - - - + + + + + + + + + + + @@ -286,15 +288,17 @@ - - - - - - - - - + + + + + + + + + + + diff --git a/examples/scenarios/mielec/mielec_drt_config.xml b/examples/scenarios/mielec/mielec_drt_config.xml index 403207359f5..6557f58136a 100644 --- a/examples/scenarios/mielec/mielec_drt_config.xml +++ b/examples/scenarios/mielec/mielec_drt_config.xml @@ -8,9 +8,11 @@ - - - + + + + + diff --git a/examples/scenarios/mielec/mielec_drt_config_v1.xml b/examples/scenarios/mielec/mielec_drt_config_v1.xml new file mode 100644 index 00000000000..403207359f5 --- /dev/null +++ b/examples/scenarios/mielec/mielec_drt_config_v1.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/scenarios/mielec/mielec_edrt_config.xml b/examples/scenarios/mielec/mielec_edrt_config.xml index 5ab35db759d..fa045f53415 100644 --- a/examples/scenarios/mielec/mielec_edrt_config.xml +++ b/examples/scenarios/mielec/mielec_edrt_config.xml @@ -13,9 +13,11 @@ - - - + + + + + diff --git a/examples/scenarios/mielec/mielec_multiModeEdrt_config.xml b/examples/scenarios/mielec/mielec_multiModeEdrt_config.xml index 2d20b7b5756..9f0ac950685 100644 --- a/examples/scenarios/mielec/mielec_multiModeEdrt_config.xml +++ b/examples/scenarios/mielec/mielec_multiModeEdrt_config.xml @@ -14,9 +14,11 @@ - - - + + + + + @@ -40,9 +42,11 @@ - - - + + + + + diff --git a/examples/scenarios/mielec/mielec_serviceArea_based_drt_config.xml b/examples/scenarios/mielec/mielec_serviceArea_based_drt_config.xml index ceb0ca0a3cb..98754db5f24 100644 --- a/examples/scenarios/mielec/mielec_serviceArea_based_drt_config.xml +++ b/examples/scenarios/mielec/mielec_serviceArea_based_drt_config.xml @@ -13,10 +13,11 @@ - - - - + + + + + diff --git a/examples/scenarios/mielec/mielec_stop_based_drt_config.xml b/examples/scenarios/mielec/mielec_stop_based_drt_config.xml index 5b9da8ef8d0..7d07ee1fd64 100644 --- a/examples/scenarios/mielec/mielec_stop_based_drt_config.xml +++ b/examples/scenarios/mielec/mielec_stop_based_drt_config.xml @@ -13,12 +13,14 @@ - - - + + + + + + + - -