Skip to content

Commit

Permalink
adding model
Browse files Browse the repository at this point in the history
  • Loading branch information
rakow committed Jul 21, 2024
1 parent adf4e00 commit 682f7bf
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 8 deletions.
42 changes: 42 additions & 0 deletions input/v6.3/params/bg_diverse_9_fixed_v2.yaml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -257,15 +257,14 @@ public ScoringParameters getScoringParameters(Person person) {
Object2DoubleMap<String> 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) {
Expand All @@ -286,7 +285,7 @@ public ScoringParameters getScoringParameters(Person person) {
});
}

private void loadPreferences(String mode, DistanceGroupModeUtilityParameters.DeltaBuilder delta, Person person, Object2DoubleMap<String> existing, ModeUtilityParameters params) {
private void loadPreferences(String mode, DistanceGroupModeUtilityParameters.DeltaBuilder delta, Person person, Object2DoubleMap<String> existing) {

boolean isRefPerson = person.getAttributes().getAttribute(TripAnalysis.ATTR_REF_ID) != null;

Expand All @@ -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");
}

/**
Expand Down

0 comments on commit 682f7bf

Please sign in to comment.