diff --git a/contribs/drt/src/main/java/org/matsim/contrib/drt/routing/DefaultDrtRouteConstraintsCalculator.java b/contribs/drt/src/main/java/org/matsim/contrib/drt/routing/DefaultDrtRouteConstraintsCalculator.java index 039890d8801..9e95514294d 100644 --- a/contribs/drt/src/main/java/org/matsim/contrib/drt/routing/DefaultDrtRouteConstraintsCalculator.java +++ b/contribs/drt/src/main/java/org/matsim/contrib/drt/routing/DefaultDrtRouteConstraintsCalculator.java @@ -1,7 +1,9 @@ package org.matsim.contrib.drt.routing; +import org.matsim.api.core.v01.population.Person; import org.matsim.contrib.drt.optimizer.constraints.DefaultDrtOptimizationConstraintsSet; import org.matsim.contrib.drt.optimizer.constraints.DrtOptimizationConstraintsSet; +import org.matsim.utils.objectattributes.attributable.Attributes; /** * @author nkuehnel / MOIA @@ -16,7 +18,7 @@ public class DefaultDrtRouteConstraintsCalculator implements DrtRouteConstraints * @return maximum travel time */ @Override - public double getMaxTravelTime(DrtOptimizationConstraintsSet constraintsSet, double unsharedRideTime) { + public double getMaxTravelTime(DrtOptimizationConstraintsSet constraintsSet, double unsharedRideTime, Person person, Attributes attributes) { if(constraintsSet instanceof DefaultDrtOptimizationConstraintsSet defaultSet) { return defaultSet.maxTravelTimeAlpha * unsharedRideTime + defaultSet.maxTravelTimeBeta; @@ -33,7 +35,7 @@ public double getMaxTravelTime(DrtOptimizationConstraintsSet constraintsSet, dou * @return maximum ride time */ @Override - public double getMaxRideTime(DrtOptimizationConstraintsSet constraintsSet, double unsharedRideTime) { + public double getMaxRideTime(DrtOptimizationConstraintsSet constraintsSet, double unsharedRideTime, Person person, Attributes attributes) { if(constraintsSet instanceof DefaultDrtOptimizationConstraintsSet defaultSet) { return Math.min(unsharedRideTime + defaultSet.maxAbsoluteDetour, defaultSet.maxDetourAlpha * unsharedRideTime @@ -42,4 +44,14 @@ public double getMaxRideTime(DrtOptimizationConstraintsSet constraintsSet, doubl throw new IllegalArgumentException("Constraint set is not a default set"); } } + + @Override + public double getMaxWaitTime(DrtOptimizationConstraintsSet constraintsSet, double unsharedRideTime, Person person, + Attributes tripAttributes) { + if(constraintsSet instanceof DefaultDrtOptimizationConstraintsSet defaultSet) { + return constraintsSet.maxWaitTime; + } else { + throw new IllegalArgumentException("Constraint set is not a default set"); + } + } } \ No newline at end of file diff --git a/contribs/drt/src/main/java/org/matsim/contrib/drt/routing/DrtRouteConstraintsCalculator.java b/contribs/drt/src/main/java/org/matsim/contrib/drt/routing/DrtRouteConstraintsCalculator.java index a22a942f35a..b2c70b34af2 100644 --- a/contribs/drt/src/main/java/org/matsim/contrib/drt/routing/DrtRouteConstraintsCalculator.java +++ b/contribs/drt/src/main/java/org/matsim/contrib/drt/routing/DrtRouteConstraintsCalculator.java @@ -1,13 +1,17 @@ package org.matsim.contrib.drt.routing; +import org.matsim.api.core.v01.population.Person; import org.matsim.contrib.drt.optimizer.constraints.DrtOptimizationConstraintsSet; +import org.matsim.utils.objectattributes.attributable.Attributes; /** * @author nkuehnel / MOIA */ public interface DrtRouteConstraintsCalculator { - double getMaxTravelTime(DrtOptimizationConstraintsSet constraintsSet, double unsharedRideTime); + double getMaxTravelTime(DrtOptimizationConstraintsSet constraintsSet, double unsharedRideTime, Person person, Attributes tripAttributes); - double getMaxRideTime(DrtOptimizationConstraintsSet constraintsSet, double unsharedRideTime); + double getMaxRideTime(DrtOptimizationConstraintsSet constraintsSet, double unsharedRideTime, Person person, Attributes tripAttributes); + + double getMaxWaitTime(DrtOptimizationConstraintsSet constraintsSet, double unsharedRideTime, Person person, Attributes tripAttributes); } 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 b646494a1fc..d7279155a26 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 @@ -74,15 +74,16 @@ public Route createRoute(double departureTime, Link accessActLink, Link egressAc DrtOptimizationConstraintsSet constraintsSet = constraintSetChooser.chooseConstraintSet(departureTime, accessActLink, egressActLink, person, tripAttributes) .orElse(drtCfg.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet()); - double maxTravelTime = routeConstraintsCalculator.getMaxTravelTime(constraintsSet, unsharedRideTime); - double maxRideDuration = routeConstraintsCalculator.getMaxRideTime(constraintsSet, unsharedRideTime); + double maxTravelTime = routeConstraintsCalculator.getMaxTravelTime(constraintsSet, unsharedRideTime, person, tripAttributes); + double maxRideDuration = routeConstraintsCalculator.getMaxRideTime(constraintsSet, unsharedRideTime, person, tripAttributes); + double maxWaitTime = routeConstraintsCalculator.getMaxWaitTime(constraintsSet, unsharedRideTime, person, tripAttributes); DrtRoute route = routeFactories.createRoute(DrtRoute.class, accessActLink.getId(), egressActLink.getId()); route.setDistance(unsharedDistance); route.setTravelTime(maxTravelTime); route.setMaxRideTime(maxRideDuration); route.setDirectRideTime(unsharedRideTime); - route.setMaxWaitTime(constraintsSet.maxWaitTime); + route.setMaxWaitTime(maxWaitTime); if (this.drtCfg.storeUnsharedPath) { route.setUnsharedPath(unsharedPath);