From 2a93ac6e4900c006ff11f08de12813efe3c245ef Mon Sep 17 00:00:00 2001 From: rakow Date: Tue, 9 Jul 2024 11:23:44 +0200 Subject: [PATCH] fix small style issues --- .../matsim/prepare/choices/ComputePlanChoices.java | 9 ++++----- .../org/matsim/prepare/population/PlanBuilder.java | 12 ++++++------ 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/matsim/prepare/choices/ComputePlanChoices.java b/src/main/java/org/matsim/prepare/choices/ComputePlanChoices.java index 9c93412b..3e2bc576 100644 --- a/src/main/java/org/matsim/prepare/choices/ComputePlanChoices.java +++ b/src/main/java/org/matsim/prepare/choices/ComputePlanChoices.java @@ -52,16 +52,15 @@ public class ComputePlanChoices implements MATSimAppCommand, PersonAlgorithm { * Rows for the result table. */ private final Queue> rows = new ConcurrentLinkedQueue<>(); + private final MainModeIdentifier mmi = new DefaultAnalysisMainModeIdentifier(); @CommandLine.Mixin private ScenarioOptions scenario; @CommandLine.Option(names = "--top-k", description = "Use top k estimates", defaultValue = "9") private int topK; @CommandLine.Option(names = "--modes", description = "Modes to include in estimation", split = ",") private Set modes; - @CommandLine.Option(names = "--id-filter", description = "Filter for person ids") private Pattern idFilter; - @CommandLine.Option(names = "--time-util-only", description = "Reset scoring for estimation and only use time utility", defaultValue = "false") private boolean timeUtil; @CommandLine.Option(names = "--calc-scores", description = "Perform pseudo scoring for each plan", defaultValue = "false") @@ -70,11 +69,9 @@ public class ComputePlanChoices implements MATSimAppCommand, PersonAlgorithm { private PlanCandidates planCandidates = PlanCandidates.bestK; @CommandLine.Option(names = "--output", description = "Path to output csv.", defaultValue = "plan-choices.csv") private Path output; - private ThreadLocal thread; private ProgressBar pb; private double globalAvgIncome; - private final MainModeIdentifier mmi = new DefaultAnalysisMainModeIdentifier(); public static void main(String[] args) { new ComputePlanChoices().execute(args); @@ -236,7 +233,9 @@ public void run(Person person) { } if (split.length != currentModes.length) { - log.warn("Number of trips ref/current do not match: {} / {}", Arrays.toString(split), Arrays.toString(currentModes)); + if (log.isWarnEnabled()) + log.warn("Number of trips ref/current do not match: {} / {}", Arrays.toString(split), Arrays.toString(currentModes)); + pb.step(); return; } diff --git a/src/main/java/org/matsim/prepare/population/PlanBuilder.java b/src/main/java/org/matsim/prepare/population/PlanBuilder.java index b6c5d22f..43d07000 100644 --- a/src/main/java/org/matsim/prepare/population/PlanBuilder.java +++ b/src/main/java/org/matsim/prepare/population/PlanBuilder.java @@ -137,9 +137,9 @@ public Long2ObjectMap> createHomeIndex(Population population) { */ public long findHomeZone(String personId) { - List activities = this.activities.get(personId); + List acts = activities.get(personId); - Optional home = activities.stream().filter(r -> r.get("type").equals("home")).findFirst(); + Optional home = acts.stream().filter(r -> r.get("type").equals("home")).findFirst(); if (home.isEmpty()) return -1; @@ -154,12 +154,12 @@ public long findHomeZone(String personId) { */ public boolean assignLocationsFromZones(String personId, Plan plan, Coord homeCoord) { - List activities = this.activities.get(personId); + List acts = activities.get(personId); List existing = TripStructureUtils.getActivities(plan, TripStructureUtils.StageActivityHandling.ExcludeStageActivities); // If activities don't match, this entry is skipped // this can happen if an end home activity has been added at the end - if (activities.size() != existing.size()) + if (acts.size() != existing.size()) return false; ActLocation home = new ActLocation(null, homeCoord); @@ -169,9 +169,9 @@ public boolean assignLocationsFromZones(String personId, Plan plan, Coord homeCo // Distances between activities in meter DoubleList dists = new DoubleArrayList(); - for (int i = 0; i < activities.size(); i++) { + for (int i = 0; i < acts.size(); i++) { - CSVRecord ref = activities.get(i); + CSVRecord ref = acts.get(i); Activity activity = existing.get(i); String type = activity.getType();