From 0b0cd57063eb69f01eb8b49d9dc510a47be70bd4 Mon Sep 17 00:00:00 2001 From: frievoe97 Date: Wed, 18 Dec 2024 09:58:33 +0100 Subject: [PATCH] update activity dashboard --- .../analysis/activity/ActivityCountAnalysis.java | 6 +++++- .../matsim/simwrapper/SimWrapperConfigGroup.java | 14 ++++++++++++++ .../matsim/simwrapper/SimWrapperListener.java | 7 +++++-- .../org/matsim/simwrapper/SimWrapperRunner.java | 5 +++++ .../simwrapper/dashboard/ActivityDashboard.java | 16 ++++++++-------- 5 files changed, 37 insertions(+), 11 deletions(-) diff --git a/contribs/application/src/main/java/org/matsim/application/analysis/activity/ActivityCountAnalysis.java b/contribs/application/src/main/java/org/matsim/application/analysis/activity/ActivityCountAnalysis.java index 75c5951704a..b944ee044fb 100644 --- a/contribs/application/src/main/java/org/matsim/application/analysis/activity/ActivityCountAnalysis.java +++ b/contribs/application/src/main/java/org/matsim/application/analysis/activity/ActivityCountAnalysis.java @@ -203,7 +203,11 @@ public Integer call() throws Exception { for (Row row : resultTable) { Double value = row.getDouble("density"); - row.setDouble("relative_density", (((value - averageDensity) / (averageDensity)) * 100)); + if (averageDensity != 0) { + row.setDouble("relative_density", value / averageDensity); + } else { + row.setDouble("relative_density", 0.0); + } } diff --git a/contribs/simwrapper/src/main/java/org/matsim/simwrapper/SimWrapperConfigGroup.java b/contribs/simwrapper/src/main/java/org/matsim/simwrapper/SimWrapperConfigGroup.java index 6bb420d1292..0914fda1eb7 100644 --- a/contribs/simwrapper/src/main/java/org/matsim/simwrapper/SimWrapperConfigGroup.java +++ b/contribs/simwrapper/src/main/java/org/matsim/simwrapper/SimWrapperConfigGroup.java @@ -1,5 +1,6 @@ package org.matsim.simwrapper; +import org.matsim.core.config.Config; import org.matsim.core.config.ConfigGroup; import org.matsim.core.config.ReflectiveConfigGroup; @@ -28,6 +29,10 @@ public class SimWrapperConfigGroup extends ReflectiveConfigGroup { @Comment("Set of simple class names or fully qualified class names of dashboards to exclude") public Set exclude = new HashSet<>(); + @Parameter + @Comment("Set of simple class names or fully qualified class names of dashboards to include. Any none included dashboard will be excluded.") + public Set include = new HashSet<>(); + @Parameter @Comment("Sample size of the run, which may be required by certain analysis functions.") public Double sampleSize = 1.0d; @@ -83,6 +88,15 @@ public void addParameterSet(ConfigGroup set) { } } + @Override + protected void checkConsistency(Config config) { + super.checkConsistency(config); + + if (!include.isEmpty() && !exclude.isEmpty()) { + throw new IllegalStateException("Include and exclude option can't be set both."); + } + } + /** * Mode how default dashboards are loaded. */ diff --git a/contribs/simwrapper/src/main/java/org/matsim/simwrapper/SimWrapperListener.java b/contribs/simwrapper/src/main/java/org/matsim/simwrapper/SimWrapperListener.java index 1270c938ee4..b9bd8c261a3 100644 --- a/contribs/simwrapper/src/main/java/org/matsim/simwrapper/SimWrapperListener.java +++ b/contribs/simwrapper/src/main/java/org/matsim/simwrapper/SimWrapperListener.java @@ -34,8 +34,8 @@ public class SimWrapperListener implements StartupListener, ShutdownListener { @Inject public SimWrapperListener(SimWrapper simWrapper, Set bindings, Config config) { this.simWrapper = simWrapper; - this.bindings = bindings; - this.config = config; + this.bindings = bindings; + this.config = config; } /** @@ -105,6 +105,9 @@ private void addFromProvider(SimWrapperConfigGroup config, Iterable exclude; + @CommandLine.Option(names = "--include", split = ",", description = "Use only the dashboards which classnames match.") + private Set include; + public static void main(String[] args) { new SimWrapperRunner().execute(args); } @@ -58,6 +61,8 @@ public Integer call() throws Exception { if (exclude != null) simWrapperConfigGroup.exclude.addAll(exclude); + if (include != null) + simWrapperConfigGroup.include.addAll(include); SimWrapperListener listener = new SimWrapperListener(SimWrapper.create(config), config); try { diff --git a/contribs/simwrapper/src/main/java/org/matsim/simwrapper/dashboard/ActivityDashboard.java b/contribs/simwrapper/src/main/java/org/matsim/simwrapper/dashboard/ActivityDashboard.java index 413dec0da79..47c5326c031 100644 --- a/contribs/simwrapper/src/main/java/org/matsim/simwrapper/dashboard/ActivityDashboard.java +++ b/contribs/simwrapper/src/main/java/org/matsim/simwrapper/dashboard/ActivityDashboard.java @@ -15,7 +15,7 @@ /** * Dashboard to show activity related statistics aggregated by type and location. - * + *

* Note that {@link #addActivityType(String, List, List, boolean, String)} needs to be called for each activity type. * There is no default configuration. */ @@ -43,12 +43,13 @@ public ActivityDashboard addActivityType(String name, List activities, L /** * Add an activity type to the dashboard. - * @param name name to show in the dashboard - * @param activities List of activity names to include in this type - * @param indicators List of indicators to show + * + * @param name name to show in the dashboard + * @param activities List of activity names to include in this type + * @param indicators List of indicators to show * @param countMultipleOccurrences Whether multiple occurrences of the same activity for one person should be counted. * Can be used to count home or workplaces only once. - * @param refCsv Reference CSV file to compare the activities to. Can be null. + * @param refCsv Reference CSV file to compare the activities to. Can be null. */ public ActivityDashboard addActivityType(String name, List activities, List indicators, boolean countMultipleOccurrences, @Nullable String refCsv) { @@ -106,7 +107,7 @@ public void configure(Header header, Layout layout) { viz.display.fill.dataset = "transit-trips"; viz.display.fill.join = REF_JOIN; if (ind == Indicator.RELATIVE_DENSITY) { - viz.display.fill.setColorRamp(ColorScheme.RdBu, 12, false, "-80,-75,-67,-50,-33,50,100,200,300,400,500"); + viz.display.fill.setColorRamp(ColorScheme.RdBu, 12, false, "0.2, 0.25, 0.33, 0.5, 0.67, 1.5, 2.0, 3.0, 4.0, 5.0, 6.0"); } }); @@ -126,12 +127,11 @@ public void configure(Header header, Layout layout) { if (ind == Indicator.RELATIVE_DENSITY) { viz.display.fill.columnName = "relative_density"; - viz.display.fill.setColorRamp(ColorScheme.RdBu, 12, false, "-80,-75,-67,-50,-33,50,100,200,300,400,500"); + viz.display.fill.setColorRamp(ColorScheme.RdBu, 12, false, "0.2, 0.25, 0.33, 0.5, 0.67, 1.5, 2.0, 3.0, 4.0, 5.0, 6.0"); } else if (ind == Indicator.DENSITY) { viz.display.fill.columnName = "density"; } else { viz.display.fill.columnName = "count"; - viz.display.fill.normalize = "transit-trips:area"; } }); }