Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/network-improvments' into networ…
Browse files Browse the repository at this point in the history
…k-improvments
  • Loading branch information
frievoe97 committed May 27, 2024
2 parents c490cb6 + 033f872 commit f9c3c18
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -114,14 +124,16 @@ private Table writeOutput(Counts<Link> 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<Id<Link>, MeasurementLocation<Link>> entry : counts.getMeasureLocations().entrySet()) {
Expand Down Expand Up @@ -170,6 +182,7 @@ private Table writeOutput(Counts<Link> 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
Expand All @@ -183,6 +196,7 @@ private Table writeOutput(Counts<Link> 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")
Expand Down

0 comments on commit f9c3c18

Please sign in to comment.