-
Notifications
You must be signed in to change notification settings - Fork 452
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feature/fixPseudoNetworkWithLoopLinks
- Loading branch information
Showing
9 changed files
with
92 additions
and
58 deletions.
There are no files selected for viewing
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
12 changes: 12 additions & 0 deletions
12
...s/drt/src/main/java/org/matsim/contrib/drt/optimizer/constraints/DrtRouteConstraints.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,12 @@ | ||
package org.matsim.contrib.drt.optimizer.constraints; | ||
|
||
/** | ||
* @author Sebastian Hörl, IRT SystemX | ||
*/ | ||
public record DrtRouteConstraints( // | ||
double maxTravelTime, // | ||
double maxRideTime, // | ||
double maxWaitTime// | ||
) { | ||
|
||
} |
76 changes: 42 additions & 34 deletions
76
...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 |
---|---|---|
@@ -1,45 +1,53 @@ | ||
package org.matsim.contrib.drt.routing; | ||
|
||
import org.matsim.api.core.v01.network.Link; | ||
import org.matsim.api.core.v01.population.Person; | ||
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.optimizer.constraints.DrtRouteConstraints; | ||
import org.matsim.contrib.drt.run.DrtConfigGroup; | ||
import org.matsim.utils.objectattributes.attributable.Attributes; | ||
|
||
/** | ||
* @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"); | ||
} | ||
} | ||
private final DrtConfigGroup drtCfg; | ||
private final ConstraintSetChooser constraintSetChooser; | ||
|
||
public DefaultDrtRouteConstraintsCalculator(DrtConfigGroup drtCfg, ConstraintSetChooser constraintSetChooser) { | ||
this.drtCfg = drtCfg; | ||
this.constraintSetChooser = constraintSetChooser; | ||
} | ||
|
||
/** | ||
* Calculates the maximum travel time defined as: drtCfg.getMaxTravelTimeAlpha() | ||
* unsharedRideTime + drtCfg.getMaxTravelTimeBeta() | ||
* | ||
* Calculates the maximum ride time defined as: drtCfg.maxDetourAlpha * | ||
* unsharedRideTime + drtCfg.maxDetourBeta | ||
* | ||
* @return DrtRouteConstraints constraints | ||
*/ | ||
@Override | ||
public DrtRouteConstraints calculateRouteConstraints(double departureTime, Link accessActLink, Link egressActLink, | ||
Person person, Attributes tripAttributes, double unsharedRideTime, double unsharedDistance) { | ||
DrtOptimizationConstraintsSet constraintsSet = constraintSetChooser | ||
.chooseConstraintSet(departureTime, accessActLink, egressActLink, person, tripAttributes).orElse(drtCfg | ||
.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet()); | ||
|
||
if (constraintsSet instanceof DefaultDrtOptimizationConstraintsSet defaultSet) { | ||
double maxTravelTime = defaultSet.maxTravelTimeAlpha * unsharedRideTime + defaultSet.maxTravelTimeBeta; | ||
double maxRideTime = Math.min(unsharedRideTime + defaultSet.maxAbsoluteDetour, | ||
defaultSet.maxDetourAlpha * unsharedRideTime + defaultSet.maxDetourBeta); | ||
double maxWaitTime = constraintsSet.maxWaitTime; | ||
|
||
return new DrtRouteConstraints(maxTravelTime, maxRideTime, maxWaitTime); | ||
} else { | ||
throw new IllegalArgumentException("Constraint set is not a default set"); | ||
} | ||
|
||
} | ||
} |
17 changes: 14 additions & 3 deletions
17
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 |
---|---|---|
@@ -1,13 +1,24 @@ | ||
package org.matsim.contrib.drt.routing; | ||
|
||
import org.matsim.contrib.drt.optimizer.constraints.DrtOptimizationConstraintsSet; | ||
import org.matsim.api.core.v01.network.Link; | ||
import org.matsim.api.core.v01.population.Person; | ||
import org.matsim.contrib.drt.optimizer.constraints.DrtRouteConstraints; | ||
import org.matsim.utils.objectattributes.attributable.Attributes; | ||
|
||
/** | ||
* @author nkuehnel / MOIA | ||
* @author Sebastian Hörl, IRT SystemX | ||
*/ | ||
public interface DrtRouteConstraintsCalculator { | ||
|
||
double getMaxTravelTime(DrtOptimizationConstraintsSet constraintsSet, double unsharedRideTime); | ||
DrtRouteConstraints calculateRouteConstraints( // | ||
double departureTime, // | ||
Link accessActLink, // | ||
Link egressActLink, // | ||
Person person, // | ||
Attributes tripAttributes, // | ||
double unsharedRideTime, // | ||
double unsharedDistance // | ||
); | ||
|
||
double getMaxRideTime(DrtOptimizationConstraintsSet constraintsSet, double unsharedRideTime); | ||
} |
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
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
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
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
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