From 1890a24f7f49396ce188db33d41ae959a50efa90 Mon Sep 17 00:00:00 2001 From: rakow Date: Wed, 6 Dec 2023 14:45:00 +0100 Subject: [PATCH] changes for imc --- input/v3.1/kelheim-v3.1-25pct.kexi.config.xml | 6 +-- input/v3.1/kelheim-v3.1-config.xml | 6 +-- pom.xml | 2 +- .../org/matsim/run/RunKelheimScenario.java | 4 +- .../run/drt/OptimisticDrtEstimator.java | 50 +++++++++++++++++++ 5 files changed, 59 insertions(+), 9 deletions(-) create mode 100644 src/main/java/org/matsim/run/drt/OptimisticDrtEstimator.java diff --git a/input/v3.1/kelheim-v3.1-25pct.kexi.config.xml b/input/v3.1/kelheim-v3.1-25pct.kexi.config.xml index a2152121..31b24b9c 100644 --- a/input/v3.1/kelheim-v3.1-25pct.kexi.config.xml +++ b/input/v3.1/kelheim-v3.1-25pct.kexi.config.xml @@ -73,7 +73,7 @@ - + @@ -99,7 +99,7 @@ - + @@ -132,7 +132,7 @@ - + diff --git a/input/v3.1/kelheim-v3.1-config.xml b/input/v3.1/kelheim-v3.1-config.xml index 08c7d108..8f293547 100644 --- a/input/v3.1/kelheim-v3.1-config.xml +++ b/input/v3.1/kelheim-v3.1-config.xml @@ -74,7 +74,7 @@ - + @@ -100,7 +100,7 @@ - + @@ -133,7 +133,7 @@ - + diff --git a/pom.xml b/pom.xml index e17abad9..50f533b1 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ matsim-all - 16.0-PR2982 + 16.0-PR2983 diff --git a/src/main/java/org/matsim/run/RunKelheimScenario.java b/src/main/java/org/matsim/run/RunKelheimScenario.java index 87c1783f..6030e1fe 100644 --- a/src/main/java/org/matsim/run/RunKelheimScenario.java +++ b/src/main/java/org/matsim/run/RunKelheimScenario.java @@ -31,7 +31,6 @@ import org.matsim.contrib.drt.extension.companions.DrtCompanionParams; import org.matsim.contrib.drt.extension.companions.MultiModeDrtCompanionModule; import org.matsim.contrib.drt.extension.estimator.MultiModalDrtLegEstimator; -import org.matsim.contrib.drt.extension.estimator.impl.ConstantDrtEstimator; import org.matsim.contrib.drt.extension.estimator.impl.PessimisticDrtEstimator; import org.matsim.contrib.drt.extension.estimator.run.DrtEstimatorConfigGroup; import org.matsim.contrib.drt.extension.estimator.run.DrtEstimatorModule; @@ -67,6 +66,7 @@ import org.matsim.modechoice.estimators.DefaultLegScoreEstimator; import org.matsim.modechoice.estimators.FixedCostsEstimator; import org.matsim.modechoice.pruning.DistanceBasedPruner; +import org.matsim.run.drt.OptimisticDrtEstimator; import org.matsim.run.prepare.PrepareNetwork; import org.matsim.run.prepare.PreparePopulation; import org.matsim.simwrapper.SimWrapperConfigGroup; @@ -365,7 +365,7 @@ public void handleEvent(PersonDepartureEvent event) { controler.addOverridingModule(new DrtEstimatorModule() .withInitialEstimator((cfg) -> switch (drtEstimator) { - case optimistic -> new ConstantDrtEstimator(cfg, 1, 200); + case optimistic -> new OptimisticDrtEstimator(cfg, 0.5, 200); case pessimistic -> new PessimisticDrtEstimator(cfg); }, "drt", "av")); diff --git a/src/main/java/org/matsim/run/drt/OptimisticDrtEstimator.java b/src/main/java/org/matsim/run/drt/OptimisticDrtEstimator.java new file mode 100644 index 00000000..32a365fe --- /dev/null +++ b/src/main/java/org/matsim/run/drt/OptimisticDrtEstimator.java @@ -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); + } +}