-
Notifications
You must be signed in to change notification settings - Fork 454
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 feat/withinday-interaction-activities
- Loading branch information
Showing
31 changed files
with
597 additions
and
102 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
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
9 changes: 9 additions & 0 deletions
9
...ensions/src/main/java/org/matsim/contrib/drt/extension/estimator/DrtInitialEstimator.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,9 @@ | ||
package org.matsim.contrib.drt.extension.estimator; | ||
|
||
/** | ||
* This interface is used to provide an initial estimate for the drt service. | ||
* Supposed to be used when no data is available from the simulation yet. | ||
* The interface is exactly the same as {@link DrtEstimator}, but this class won't be called with update events. | ||
*/ | ||
public interface DrtInitialEstimator extends DrtEstimator { | ||
} |
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
...s/src/main/java/org/matsim/contrib/drt/extension/estimator/impl/ConstantDrtEstimator.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.contrib.drt.extension.estimator.impl; | ||
|
||
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 ConstantDrtEstimator implements DrtInitialEstimator { | ||
|
||
private final DrtConfigGroup drtConfig; | ||
|
||
/** | ||
* Detour factor for the estimate. 1.0 means no detour, 2.0 means twice the distance. | ||
*/ | ||
private final double detourFactor; | ||
|
||
/** | ||
* Constant waiting time estimate in seconds. | ||
*/ | ||
private final double waitingTime; | ||
|
||
public ConstantDrtEstimator(DrtConfigGroup drtConfig, double detourFactor, double waitingTime) { | ||
this.drtConfig = drtConfig; | ||
this.detourFactor = detourFactor; | ||
this.waitingTime = waitingTime; | ||
} | ||
|
||
@Override | ||
public Estimate estimate(DrtRoute route, OptionalTime departureTime) { | ||
|
||
double distance = route.getDistance() * detourFactor; | ||
double travelTime = route.getDirectRideTime() * detourFactor; | ||
|
||
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); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...rc/main/java/org/matsim/contrib/drt/extension/estimator/impl/PessimisticDrtEstimator.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,40 @@ | ||
package org.matsim.contrib.drt.extension.estimator.impl; | ||
|
||
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; | ||
|
||
/** | ||
* Uses the upper bounds from config for the initial estimate. | ||
*/ | ||
public class PessimisticDrtEstimator implements DrtInitialEstimator { | ||
private final DrtConfigGroup drtConfig; | ||
|
||
public PessimisticDrtEstimator(DrtConfigGroup drtConfig) { | ||
this.drtConfig = drtConfig; | ||
} | ||
|
||
@Override | ||
public Estimate estimate(DrtRoute route, OptionalTime departureTime) { | ||
// If not estimates are present, use travel time alpha as detour | ||
// beta is not used, because estimates are supposed to be minimums and not worst cases | ||
double travelTime = Math.min(route.getDirectRideTime() + drtConfig.maxAbsoluteDetour, | ||
route.getDirectRideTime() * drtConfig.maxTravelTimeAlpha); | ||
|
||
double fare = 0; | ||
if (drtConfig.getDrtFareParams().isPresent()) { | ||
DrtFareParams fareParams = drtConfig.getDrtFareParams().get(); | ||
fare = fareParams.distanceFare_m * route.getDistance() | ||
+ fareParams.timeFare_h * route.getDirectRideTime() / 3600.0 | ||
+ fareParams.baseFare; | ||
|
||
fare = Math.max(fare, fareParams.minFarePerTrip); | ||
} | ||
|
||
// for distance, also use the max travel time alpha | ||
return new Estimate(route.getDistance() * drtConfig.maxTravelTimeAlpha, travelTime, drtConfig.maxWaitTime, fare, 0); | ||
} | ||
|
||
} |
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
Oops, something went wrong.