-
Notifications
You must be signed in to change notification settings - Fork 33
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
5 changed files
with
59 additions
and
9 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
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
50 changes: 50 additions & 0 deletions
50
src/main/java/org/matsim/run/drt/OptimisticDrtEstimator.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,50 @@ | ||
package org.matsim.run.drt; | ||
|
||
import org.matsim.contrib.drt.extension.estimator.DrtInitialEstimator; | ||
import org.matsim.contrib.drt.fare.DrtFareParams; | ||
import org.matsim.contrib.drt.routing.DrtRoute; | ||
import org.matsim.contrib.drt.run.DrtConfigGroup; | ||
import org.matsim.core.utils.misc.OptionalTime; | ||
|
||
/** | ||
* Estimates using a constant detour factor and waiting time. | ||
*/ | ||
public class OptimisticDrtEstimator implements DrtInitialEstimator { | ||
|
||
private final DrtConfigGroup drtConfig; | ||
|
||
/** | ||
* Proportion of the max total travel time. | ||
*/ | ||
private final double proportion; | ||
|
||
/** | ||
* Constant waiting time estimate in seconds. | ||
*/ | ||
private final double waitingTime; | ||
|
||
public OptimisticDrtEstimator(DrtConfigGroup drtConfig, double proportion, double waitingTime) { | ||
this.drtConfig = drtConfig; | ||
this.proportion = proportion; | ||
this.waitingTime = waitingTime; | ||
} | ||
|
||
@Override | ||
public Estimate estimate(DrtRoute route, OptionalTime departureTime) { | ||
|
||
double distance = route.getDistance(); | ||
double travelTime = Math.max(route.getTravelTime().seconds(), route.getMaxTravelTime() * proportion); | ||
|
||
double fare = 0; | ||
if (drtConfig.getDrtFareParams().isPresent()) { | ||
DrtFareParams fareParams = drtConfig.getDrtFareParams().get(); | ||
fare = fareParams.distanceFare_m * distance | ||
+ fareParams.timeFare_h * travelTime / 3600.0 | ||
+ fareParams.baseFare; | ||
|
||
fare = Math.max(fare, fareParams.minFarePerTrip); | ||
} | ||
|
||
return new Estimate(distance, travelTime, waitingTime, fare, 0); | ||
} | ||
} |