From 682f7bf6fef9f0dd5e6c679e34ea67157a1068cd Mon Sep 17 00:00:00 2001 From: rakow Date: Sun, 21 Jul 2024 08:51:36 +0200 Subject: [PATCH] adding model --- input/v6.3/params/bg_diverse_9_fixed_v2.yaml | 42 +++++++++++++++++++ .../IndividualPersonScoringParameters.java | 14 +++---- 2 files changed, 48 insertions(+), 8 deletions(-) create mode 100644 input/v6.3/params/bg_diverse_9_fixed_v2.yaml diff --git a/input/v6.3/params/bg_diverse_9_fixed_v2.yaml b/input/v6.3/params/bg_diverse_9_fixed_v2.yaml new file mode 100644 index 00000000..6673144c --- /dev/null +++ b/input/v6.3/params/bg_diverse_9_fixed_v2.yaml @@ -0,0 +1,42 @@ +# Results for model plan-choices-diverse_9 +# Nbr of parameters: 8 +# Sample size: 8259 +# Excluded data: 0 +# Null log likelihood: -16584.31 +# Final log likelihood: -17686.88 +# Likelihood ratio test (null): -2205.153 +# Rho square (null): -0.0665 +# Rho bar square (null): -0.067 +# Akaike Information Criterion: 35389.77 +# Bayesian Information Criterion: 35445.92 +scoring: + scoringParameters: + - modeParams: + - mode: walk + constant: 0 + - mode: car + constant: -0.5341414592094356 + dailyMonetaryConstant: -14.30 + dailyUtilityConstant: 0.000000 + - mode: pt + constant: 0.302651 + - mode: bike + constant: -1.809881 + - mode: ride + constant: -1.864216 +advancedScoring: + scoringParameters: + - subpopulation: person + modeParams: + - mode: car + deltaDailyConstant: 17.564513 + varDailyConstant: truncatedNormal + - mode: bike + deltaConstant: 1.876431 + varConstant: normal + - mode: pt + deltaConstant: 2.953148 + varConstant: normal + - mode: ride + deltaConstant: 1.317065 + varConstant: normal \ No newline at end of file diff --git a/src/main/java/org/matsim/run/scoring/IndividualPersonScoringParameters.java b/src/main/java/org/matsim/run/scoring/IndividualPersonScoringParameters.java index fa4a971e..67339bec 100644 --- a/src/main/java/org/matsim/run/scoring/IndividualPersonScoringParameters.java +++ b/src/main/java/org/matsim/run/scoring/IndividualPersonScoringParameters.java @@ -248,7 +248,7 @@ public ScoringParameters getScoringParameters(Person person) { DistanceGroup[] groups = distGroups.computeIfAbsent(delta.getPerDistGroup(), k -> calcDistanceGroups(scoring.distGroups, k)); // This may overwrite the preferences with the one stored - loadPreferences(mode.getKey(), delta, person, existing, params); + loadPreferences(mode.getKey(), delta, person, existing); DistanceGroupModeUtilityParameters p = new DistanceGroupModeUtilityParameters(params, delta, groups); builder.setModeParameters(mode.getKey(), p); @@ -257,15 +257,14 @@ public ScoringParameters getScoringParameters(Person person) { Object2DoubleMap values = info.computeIfAbsent(person.getId(), k -> new Object2DoubleOpenHashMap<>()); // Write the overall constants, but only if they are different to the base values - // TODO: store delta and not params if (delta.constant != 0) { values.put(mode.getKey() + "_constant", p.constant); - existing.put(mode.getKey() + "_constant", p.constant); + existing.put(mode.getKey() + "_constant", delta.constant); } if (delta.dailyUtilityConstant != 0) { values.put(mode.getKey() + "_dailyConstant", p.dailyUtilityConstant); - existing.put(mode.getKey() + "_dailyConstant", p.dailyUtilityConstant); + existing.put(mode.getKey() + "_dailyConstant", delta.dailyUtilityConstant); } if (groups != null) { @@ -286,7 +285,7 @@ public ScoringParameters getScoringParameters(Person person) { }); } - private void loadPreferences(String mode, DistanceGroupModeUtilityParameters.DeltaBuilder delta, Person person, Object2DoubleMap existing, ModeUtilityParameters params) { + private void loadPreferences(String mode, DistanceGroupModeUtilityParameters.DeltaBuilder delta, Person person, Object2DoubleMap existing) { boolean isRefPerson = person.getAttributes().getAttribute(TripAnalysis.ATTR_REF_ID) != null; @@ -303,13 +302,12 @@ private void loadPreferences(String mode, DistanceGroupModeUtilityParameters.Del throw new IllegalArgumentException("Person " + person.getId() + " does not have attribute " + mode + "_dailyConstant"); } - // TODO: remove params, as only the delta is needed // Use attributes if they are present if (existing.containsKey(mode + "_constant")) - delta.constant = existing.getDouble(mode + "_constant") - params.constant; + delta.constant = existing.getDouble(mode + "_constant") ; if (existing.containsKey(mode + "_dailyConstant")) - delta.dailyUtilityConstant = existing.getDouble(mode + "_dailyConstant") - params.dailyUtilityConstant; + delta.dailyUtilityConstant = existing.getDouble(mode + "_dailyConstant"); } /**