From b249b4c4a7db1a06c274170919157c2d9c0d6195 Mon Sep 17 00:00:00 2001 From: rakow Date: Sun, 26 May 2024 13:36:51 +0200 Subject: [PATCH] calculate geh value for traffic counts --- .../traffic/CountComparisonAnalysis.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/contribs/application/src/main/java/org/matsim/application/analysis/traffic/CountComparisonAnalysis.java b/contribs/application/src/main/java/org/matsim/application/analysis/traffic/CountComparisonAnalysis.java index adc9a86f435..e0c02a41831 100644 --- a/contribs/application/src/main/java/org/matsim/application/analysis/traffic/CountComparisonAnalysis.java +++ b/contribs/application/src/main/java/org/matsim/application/analysis/traffic/CountComparisonAnalysis.java @@ -76,6 +76,16 @@ private static int[] sum(int[] a, int[] b) { return counts; } + /** + * Calculate the geh value for simulated and reference count + */ + private static double geh(double simulated, double observed) { + final double diff = simulated - observed; + final double sum = simulated + observed; + + return Math.sqrt(2 * diff * diff / sum); + } + @Override public Integer call() throws Exception { @@ -114,14 +124,16 @@ private Table writeOutput(Counts counts, Network network, VolumesAnalyzer StringColumn.create("road_type"), IntColumn.create("hour"), DoubleColumn.create("observed_traffic_volume"), - DoubleColumn.create("simulated_traffic_volume") + DoubleColumn.create("simulated_traffic_volume"), + DoubleColumn.create("geh") ); Table dailyTrafficVolume = Table.create(StringColumn.create("link_id"), StringColumn.create("name"), StringColumn.create("road_type"), DoubleColumn.create("observed_traffic_volume"), - DoubleColumn.create("simulated_traffic_volume") + DoubleColumn.create("simulated_traffic_volume"), + DoubleColumn.create("geh") ); for (Map.Entry, MeasurementLocation> entry : counts.getMeasureLocations().entrySet()) { @@ -170,6 +182,7 @@ private Table writeOutput(Counts counts, Network network, VolumesAnalyzer row.setInt("hour", hour); row.setDouble("observed_traffic_volume", observedTrafficVolumeAtHour); row.setDouble("simulated_traffic_volume", simulatedTrafficVolumeAtHour); + row.setDouble("geh", geh(simulatedTrafficVolumeAtHour, observedTrafficVolumeAtHour)); } } else { // Get the daily values @@ -183,6 +196,7 @@ private Table writeOutput(Counts counts, Network network, VolumesAnalyzer row.setString("road_type", type); row.setDouble("observed_traffic_volume", observedTrafficVolumeByDay); row.setDouble("simulated_traffic_volume", simulatedTrafficVolumeByDay); + row.setDouble("geh", geh(simulatedTrafficVolumeByDay, observedTrafficVolumeByDay)); } DoubleColumn relError = dailyTrafficVolume.doubleColumn("simulated_traffic_volume")