From 5b2e9d4d18bc8f2adeff3e96d903401a478b28ed Mon Sep 17 00:00:00 2001 From: rakow Date: Sun, 9 Jun 2024 10:47:21 +0200 Subject: [PATCH] use enum for income dependent scoring --- .../org/matsim/run/scoring/AdvancedScoringConfigGroup.java | 7 ++++++- .../run/scoring/IndividualPersonScoringParameters.java | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/matsim/run/scoring/AdvancedScoringConfigGroup.java b/src/main/java/org/matsim/run/scoring/AdvancedScoringConfigGroup.java index f943a7aa..f86190bd 100644 --- a/src/main/java/org/matsim/run/scoring/AdvancedScoringConfigGroup.java +++ b/src/main/java/org/matsim/run/scoring/AdvancedScoringConfigGroup.java @@ -16,13 +16,18 @@ public final class AdvancedScoringConfigGroup extends ReflectiveConfigGroup { private final List scoringParameters = new ArrayList<>(); + public enum IncomeDependentScoring { + none, + avg_by_personal_income, + } + @Parameter @Comment("The distance groups if marginal utility of distance is adjusted. In meters.") public List distGroups; @Parameter @Comment("Enable income dependent marginal utility of money.") - public boolean incomeDependent = true; + public IncomeDependentScoring incomeDependent = IncomeDependentScoring.avg_by_personal_income; // TODO: maybe option to re-assign variations or use them from attributes diff --git a/src/main/java/org/matsim/run/scoring/IndividualPersonScoringParameters.java b/src/main/java/org/matsim/run/scoring/IndividualPersonScoringParameters.java index 10e9138e..d36cbb37 100644 --- a/src/main/java/org/matsim/run/scoring/IndividualPersonScoringParameters.java +++ b/src/main/java/org/matsim/run/scoring/IndividualPersonScoringParameters.java @@ -135,7 +135,7 @@ static DistanceGroup[] calcDistanceGroups(List dists, DoubleList distUt } private double computeAvgIncome(Population population) { - if (!scoring.incomeDependent) + if (scoring.incomeDependent == AdvancedScoringConfigGroup.IncomeDependentScoring.none) return Double.NaN; log.info("reading income attribute using " + PersonUtils.class + " of all agents and compute global average.\n" +