-
Notifications
You must be signed in to change notification settings - Fork 453
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
.../drt/src/main/java/org/matsim/contrib/drt/optimizer/constraints/ConstraintSetChooser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.matsim.contrib.drt.optimizer.constraints; | ||
|
||
import org.matsim.api.core.v01.network.Link; | ||
import org.matsim.api.core.v01.population.Person; | ||
import org.matsim.utils.objectattributes.attributable.Attributes; | ||
|
||
/** | ||
* @author nkuehnel / MOIA | ||
*/ | ||
public interface ConstraintSetChooser { | ||
|
||
DrtOptimizationConstraintsSet chooseConstraintSet(double departureTime, Link accessActLink, Link egressActLink, Person person, | ||
Attributes tripAttributes); | ||
} |
45 changes: 45 additions & 0 deletions
45
...rt/src/main/java/org/matsim/contrib/drt/routing/DefaultDrtRouteConstraintsCalculator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.matsim.contrib.drt.routing; | ||
|
||
import org.matsim.contrib.drt.optimizer.constraints.DefaultDrtOptimizationConstraintsSet; | ||
import org.matsim.contrib.drt.optimizer.constraints.DrtOptimizationConstraintsSet; | ||
|
||
/** | ||
* @author nkuehnel / MOIA | ||
*/ | ||
public class DefaultDrtRouteConstraintsCalculator implements DrtRouteConstraintsCalculator { | ||
|
||
/** | ||
* Calculates the maximum travel time defined as: drtCfg.getMaxTravelTimeAlpha() * unsharedRideTime + drtCfg.getMaxTravelTimeBeta() | ||
* | ||
* @param constraintsSet | ||
* @param unsharedRideTime ride time of the direct (shortest-time) route | ||
* @return maximum travel time | ||
*/ | ||
@Override | ||
public double getMaxTravelTime(DrtOptimizationConstraintsSet constraintsSet, double unsharedRideTime) { | ||
if(constraintsSet instanceof DefaultDrtOptimizationConstraintsSet defaultSet) { | ||
return defaultSet.maxTravelTimeAlpha * unsharedRideTime | ||
+ defaultSet.maxTravelTimeBeta; | ||
} else { | ||
throw new IllegalArgumentException("Constraint set is not a default set"); | ||
} | ||
} | ||
|
||
/** | ||
* Calculates the maximum ride time defined as: drtCfg.maxDetourAlpha * unsharedRideTime + drtCfg.maxDetourBeta | ||
* | ||
* @param constraintsSet | ||
* @param unsharedRideTime ride time of the direct (shortest-time) route | ||
* @return maximum ride time | ||
*/ | ||
@Override | ||
public double getMaxRideTime(DrtOptimizationConstraintsSet constraintsSet, double unsharedRideTime) { | ||
if(constraintsSet instanceof DefaultDrtOptimizationConstraintsSet defaultSet) { | ||
return Math.min(unsharedRideTime + defaultSet.maxAbsoluteDetour, | ||
defaultSet.maxDetourAlpha * unsharedRideTime | ||
+ defaultSet.maxDetourBeta); | ||
} else { | ||
throw new IllegalArgumentException("Constraint set is not a default set"); | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
contribs/drt/src/main/java/org/matsim/contrib/drt/routing/DrtRouteConstraintsCalculator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.matsim.contrib.drt.routing; | ||
|
||
import org.matsim.contrib.drt.optimizer.constraints.DrtOptimizationConstraintsSet; | ||
|
||
/** | ||
* @author nkuehnel / MOIA | ||
*/ | ||
public interface DrtRouteConstraintsCalculator { | ||
|
||
double getMaxTravelTime(DrtOptimizationConstraintsSet constraintsSet, double unsharedRideTime); | ||
|
||
double getMaxRideTime(DrtOptimizationConstraintsSet constraintsSet, double unsharedRideTime); | ||
} |