From 84a5e9640812f2b6411db0ca9b2af3265f08a46e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=B6rl?= Date: Mon, 7 Oct 2024 18:52:32 +0200 Subject: [PATCH] avoid circular dependency for predictor --- .../estimators/IDFPtUtilityEstimator.java | 14 ++++++++++---- .../utilities/predictors/IDFPtPredictor.java | 12 +++--------- .../utilities/variables/IDFPtVariables.java | 4 +--- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/ile_de_france/src/main/java/org/eqasim/ile_de_france/mode_choice/utilities/estimators/IDFPtUtilityEstimator.java b/ile_de_france/src/main/java/org/eqasim/ile_de_france/mode_choice/utilities/estimators/IDFPtUtilityEstimator.java index b79c8859b..39bdaee0f 100644 --- a/ile_de_france/src/main/java/org/eqasim/ile_de_france/mode_choice/utilities/estimators/IDFPtUtilityEstimator.java +++ b/ile_de_france/src/main/java/org/eqasim/ile_de_france/mode_choice/utilities/estimators/IDFPtUtilityEstimator.java @@ -2,6 +2,7 @@ import java.util.List; +import org.eqasim.core.simulation.mode_choice.cost.CostModel; import org.eqasim.core.simulation.mode_choice.utilities.UtilityEstimator; import org.eqasim.core.simulation.mode_choice.utilities.estimators.EstimatorUtils; import org.eqasim.ile_de_france.mode_choice.parameters.IDFModeParameters; @@ -14,18 +15,21 @@ import org.matsim.contribs.discrete_mode_choice.model.DiscreteModeChoiceTrip; import com.google.inject.Inject; +import com.google.inject.name.Named; public class IDFPtUtilityEstimator implements UtilityEstimator { private final IDFModeParameters parameters; private final IDFPersonPredictor personPredictor; private final IDFPtPredictor idfPtPredictor; + private final CostModel costModel; @Inject public IDFPtUtilityEstimator(IDFModeParameters parameters, IDFPtPredictor idfPtPredictor, - IDFPersonPredictor personPredictor) { + IDFPersonPredictor personPredictor, @Named("pt") CostModel costModel) { this.personPredictor = personPredictor; this.idfPtPredictor = idfPtPredictor; this.parameters = parameters; + this.costModel = costModel; } protected double estimateConstantUtility() { @@ -48,9 +52,9 @@ protected double estimateLineSwitchUtility(IDFPtVariables variables) { return parameters.pt.betaLineSwitch_u * variables.numberOfLineSwitches; } - protected double estimateMonetaryCostUtility(IDFPtVariables variables) { + protected double estimateMonetaryCostUtility(IDFPtVariables variables, double cost_EUR) { return parameters.betaCost_u_MU * EstimatorUtils.interaction(variables.euclideanDistance_km, - parameters.referenceEuclideanDistance_km, parameters.lambdaCostEuclideanDistance) * variables.cost_MU; + parameters.referenceEuclideanDistance_km, parameters.lambdaCostEuclideanDistance) * cost_EUR; } protected double estimateDrivingPermitUtility(IDFPersonVariables variables) { @@ -66,6 +70,8 @@ public double estimateUtility(Person person, DiscreteModeChoiceTrip trip, List { static public final String PARIS_ATTRIBUTE = "isParis"; private final TransitSchedule schedule; - private final CostModel costModel; @Inject - public IDFPtPredictor(TransitSchedule schedule, @Named("pt") CostModel costModel) { + public IDFPtPredictor(TransitSchedule schedule) { this.schedule = schedule; - this.costModel = costModel; } protected CostModel getCostModel() { - return this.costModel; + return null; } @Override @@ -108,9 +105,6 @@ public IDFPtVariables predict(Person person, DiscreteModeChoiceTrip trip, List 0 && subwayCount == 0 && otherCount == 0; @@ -129,6 +123,6 @@ public IDFPtVariables predict(Person person, DiscreteModeChoiceTrip trip, List