diff --git a/examples/tutorial/example90TrafficLights/createSignalInput/network.xml.gz b/examples/tutorial/example90TrafficLights/createSignalInput/network.xml.gz new file mode 100644 index 000000000..1ca53a79f Binary files /dev/null and b/examples/tutorial/example90TrafficLights/createSignalInput/network.xml.gz differ diff --git a/examples/tutorial/example90TrafficLights/createSignalInput/population.xml.gz b/examples/tutorial/example90TrafficLights/createSignalInput/population.xml.gz new file mode 100644 index 000000000..fb485306b Binary files /dev/null and b/examples/tutorial/example90TrafficLights/createSignalInput/population.xml.gz differ diff --git a/examples/tutorial/example90TrafficLights/createSignalInput/population.xml/population.xml b/examples/tutorial/example90TrafficLights/createSignalInput/population.xml/population.xml new file mode 100644 index 000000000..17ec254b1 --- /dev/null +++ b/examples/tutorial/example90TrafficLights/createSignalInput/population.xml/population.xml @@ -0,0 +1,25604 @@ + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 5 4 3 2 + + + + + + + 5 8 7 2 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + + + + + 2 3 4 5 + + + + + + + 2 7 8 5 + + + + + diff --git a/examples/tutorial/example90TrafficLights/useSignalInput/withLanes/config.xml b/examples/tutorial/example90TrafficLights/useSignalInput/withLanes/config.xml new file mode 100644 index 000000000..d77841bcc --- /dev/null +++ b/examples/tutorial/example90TrafficLights/useSignalInput/withLanes/config.xml @@ -0,0 +1,799 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/tutorial/example90TrafficLights/useSignalInput/withLanes/lane_definitions_v2.0.xml b/examples/tutorial/example90TrafficLights/useSignalInput/withLanes/lane_definitions_v2.0.xml new file mode 100644 index 000000000..937645800 --- /dev/null +++ b/examples/tutorial/example90TrafficLights/useSignalInput/withLanes/lane_definitions_v2.0.xml @@ -0,0 +1,69 @@ + + + + + + + + + + + 1 + + + + + + + + + + + 0 + + + + + + + + + + -1 + + + + + + + + + + + + 1 + + + + + + + + + + + 0 + + + + + + + + + + -1 + + + + diff --git a/examples/tutorial/example90TrafficLights/useSignalInput/withLanes/signal_control.xml b/examples/tutorial/example90TrafficLights/useSignalInput/withLanes/signal_control.xml new file mode 100644 index 000000000..cd3951c9b --- /dev/null +++ b/examples/tutorial/example90TrafficLights/useSignalInput/withLanes/signal_control.xml @@ -0,0 +1,53 @@ + + + + + DefaultPlanbasedSignalSystemController + + + + + + + + + + + + + + + + + + + + + + + + + DefaultPlanbasedSignalSystemController + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/tutorial/example90TrafficLights/useSignalInput/withLanes/signal_groups.xml b/examples/tutorial/example90TrafficLights/useSignalInput/withLanes/signal_groups.xml new file mode 100644 index 000000000..7198c882c --- /dev/null +++ b/examples/tutorial/example90TrafficLights/useSignalInput/withLanes/signal_groups.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/tutorial/example90TrafficLights/useSignalInput/withLanes/signal_systems.xml b/examples/tutorial/example90TrafficLights/useSignalInput/withLanes/signal_systems.xml new file mode 100644 index 000000000..cd49d728f --- /dev/null +++ b/examples/tutorial/example90TrafficLights/useSignalInput/withLanes/signal_systems.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/org/matsim/contrib/signals/analysis/MixedTrafficDelayAnalysisTool.java b/src/main/java/org/matsim/contrib/signals/analysis/MixedTrafficDelayAnalysisTool.java new file mode 100644 index 000000000..6fbd67908 --- /dev/null +++ b/src/main/java/org/matsim/contrib/signals/analysis/MixedTrafficDelayAnalysisTool.java @@ -0,0 +1,236 @@ +package org.matsim.contrib.signals.analysis; + +import com.google.inject.Inject; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.matsim.api.core.v01.Id; +import org.matsim.api.core.v01.events.*; +import org.matsim.api.core.v01.events.handler.*; +import org.matsim.api.core.v01.network.Link; +import org.matsim.api.core.v01.network.Network; +import org.matsim.api.core.v01.population.Person; +import org.matsim.contrib.signals.events.SignalGroupStateChangedEvent; +import org.matsim.contrib.signals.events.SignalGroupStateChangedEventHandler; +import org.matsim.contrib.signals.model.SignalGroup; +import org.matsim.contrib.signals.model.SignalSystem; +import org.matsim.core.api.experimental.events.EventsManager; +import org.matsim.core.controler.events.AfterMobsimEvent; +import org.matsim.core.controler.events.IterationEndsEvent; +import org.matsim.core.controler.listener.AfterMobsimListener; +import org.matsim.vehicles.Vehicle; +import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.Vehicles; + +import java.util.*; + +public class MixedTrafficDelayAnalysisTool implements SignalGroupStateChangedEventHandler, PersonDepartureEventHandler, PersonEntersVehicleEventHandler, LinkEnterEventHandler, LinkLeaveEventHandler, PersonStuckEventHandler, AfterMobsimListener { + private static final Logger LOG = LogManager.getLogger(DelayAnalysisTool.class); + private final Network network; + private boolean considerStuckedAgents; + private double totalDelay; + private Map, Double>> summedBygoneDelayPerCycle; + private Map, Double> totalDelayPerLink; + private Map, Integer> numberOfAgentsPerLink; + private Map, Double> earliestLinkExitTimePerAgent; + private Map, Set>> vehicleIdToPassengerIds; + private Map, Map, Double>> flowPerLinkPerVehicleType; + private Map, Map, Double>>> summedBygoneFlowPerLinkPerVehicleTypePerCycle; + private Map, Vehicle> vehicleMap; + private double flow; + private double currentCycleTime; + private Map, Id> firstSignalGroupOfSignalSystem; + private Map, Double> lastSwitchesToGreen; + private Map, Double> lastSwitchesToRed; + private final List> vehicleTypes; + + public MixedTrafficDelayAnalysisTool(Network network, Vehicles vehicles) { + this.considerStuckedAgents = false; + this.totalDelay = 0.0D; + this.totalDelayPerLink = new HashMap(); + this.numberOfAgentsPerLink = new HashMap(); + this.earliestLinkExitTimePerAgent = new HashMap(); + this.vehicleIdToPassengerIds = new HashMap(); + this.flowPerLinkPerVehicleType = new TreeMap<>(); + this.network = network; + this.vehicleMap = vehicles.getVehicles(); + this.vehicleTypes = new ArrayList<>(vehicles.getVehicleTypes().keySet()); + this.firstSignalGroupOfSignalSystem = new HashMap<>(); + } + +// @Inject +// public MixedTrafficDelayAnalysisTool(Network network, EventsManager em, Vehicles vehicles) { +// this(network, vehicles); +// em.addHandler(this); +// } + + public void reset(int iteration) { + this.totalDelay = 0.0D; + this.earliestLinkExitTimePerAgent.clear(); + this.vehicleIdToPassengerIds.clear(); + this.totalDelayPerLink.clear(); + this.numberOfAgentsPerLink.clear(); + this.flowPerLinkPerVehicleType.clear(); + this.flow = 0.0D; + this.lastSwitchesToGreen = new HashMap(); + this.summedBygoneFlowPerLinkPerVehicleTypePerCycle = new TreeMap<>(); + this.summedBygoneDelayPerCycle = new TreeMap<>(); + this.lastSwitchesToRed = new HashMap(); + this.currentCycleTime = 0; + } + + public void handleEvent(PersonDepartureEvent event) { + this.earliestLinkExitTimePerAgent.put(event.getPersonId(), event.getTime() + 1.0D); + } + + + public void handleEvent(PersonEntersVehicleEvent event) { + if (!this.vehicleIdToPassengerIds.containsKey(event.getVehicleId())) { + this.vehicleIdToPassengerIds.put(event.getVehicleId(), new HashSet()); + } + ((Set) this.vehicleIdToPassengerIds.get(event.getVehicleId())).add(event.getPersonId()); + } + + public void handleEvent(LinkEnterEvent event) { + Link currentLink = (Link) this.network.getLinks().get(event.getLinkId()); + double freespeedTt = currentLink.getLength() / currentLink.getFreespeed(); + double matsimFreespeedTT = Math.floor(freespeedTt + 1.0D); + this.summedBygoneFlowPerLinkPerVehicleTypePerCycle.putIfAbsent(this.currentCycleTime, new TreeMap<>()); + this.summedBygoneFlowPerLinkPerVehicleTypePerCycle.get(this.currentCycleTime).putIfAbsent(event.getLinkId(), new HashMap<>()); + this.flowPerLinkPerVehicleType.putIfAbsent(event.getLinkId(), new HashMap<>()); + for (var vehicleType : vehicleTypes) { + this.flowPerLinkPerVehicleType.get(event.getLinkId()).putIfAbsent(vehicleType, 0.0D); + this.summedBygoneFlowPerLinkPerVehicleTypePerCycle.get(this.currentCycleTime).get(event.getLinkId()).putIfAbsent(vehicleType, 0.0D); + } + for (Object o : this.vehicleIdToPassengerIds.get(event.getVehicleId())) { + Id passengerId = (Id) o; + this.earliestLinkExitTimePerAgent.put(passengerId, event.getTime() + matsimFreespeedTT); + } + this.flow += this.vehicleMap.get(event.getVehicleId()).getType().getPcuEquivalents(); + + for (var vehicleType : vehicleTypes) { + if (this.vehicleMap.get(event.getVehicleId()).getType().getId().equals(vehicleType)) { + this.flowPerLinkPerVehicleType.get(event.getLinkId()).put(vehicleType, this.flowPerLinkPerVehicleType.get(event.getLinkId()).get(vehicleType) + this.vehicleMap.get(event.getVehicleId()).getType().getPcuEquivalents()); + this.summedBygoneFlowPerLinkPerVehicleTypePerCycle.get(this.currentCycleTime).get(event.getLinkId()).put(vehicleType, this.summedBygoneFlowPerLinkPerVehicleTypePerCycle.get(this.currentCycleTime).get(event.getLinkId()).get(vehicleType) + this.vehicleMap.get(event.getVehicleId()).getType().getPcuEquivalents()); + } + } + + } + + public void handleEvent(LinkLeaveEvent event) { + if (!this.totalDelayPerLink.containsKey(event.getLinkId())) { + this.totalDelayPerLink.put(event.getLinkId(), 0.0D); + this.numberOfAgentsPerLink.put(event.getLinkId(), 0); + } + this.summedBygoneDelayPerCycle.putIfAbsent(this.currentCycleTime, new HashMap<>()); + if (!this.summedBygoneDelayPerCycle.get(this.currentCycleTime).containsKey(event.getLinkId())) { + this.summedBygoneDelayPerCycle.get(this.currentCycleTime).put(event.getLinkId(), 0.0D); + } + + Iterator var2 = ((Set) this.vehicleIdToPassengerIds.get(event.getVehicleId())).iterator(); + + while (var2.hasNext()) { + Id passengerId = (Id) var2.next(); + double currentDelay = event.getTime() - (Double) this.earliestLinkExitTimePerAgent.remove(passengerId); + + this.totalDelayPerLink.put(event.getLinkId(), (Double) this.totalDelayPerLink.get(event.getLinkId()) + currentDelay); + this.summedBygoneDelayPerCycle.get(this.currentCycleTime).put(event.getLinkId(), currentDelay); + this.totalDelay += currentDelay; + this.numberOfAgentsPerLink.put(event.getLinkId(), (Integer) this.numberOfAgentsPerLink.get(event.getLinkId()) + 1); + } + + } + + public void handleEvent(PersonStuckEvent event) { + if (this.considerStuckedAgents) { + if (!this.totalDelayPerLink.containsKey(event.getLinkId())) { + this.totalDelayPerLink.put(event.getLinkId(), 0.0D); + this.numberOfAgentsPerLink.put(event.getLinkId(), 0); + } + if (!this.summedBygoneDelayPerCycle.get(this.currentCycleTime).containsKey(event.getLinkId())) { + this.summedBygoneDelayPerCycle.get(this.currentCycleTime).put(event.getLinkId(), 0.0D); + } + + double stuckDelay = event.getTime() - (Double) this.earliestLinkExitTimePerAgent.remove(event.getPersonId()); + LOG.warn("Add delay " + stuckDelay + " of agent " + event.getPersonId() + " that stucked on link " + event.getLinkId()); + this.totalDelayPerLink.put(event.getLinkId(), (Double) this.totalDelayPerLink.get(event.getLinkId()) + stuckDelay); + this.summedBygoneDelayPerCycle.get(this.currentCycleTime).put(event.getLinkId(), stuckDelay); + this.totalDelay += stuckDelay; + this.numberOfAgentsPerLink.put(event.getLinkId(), (Integer) this.numberOfAgentsPerLink.get(event.getLinkId()) + 1); + } + + } + + public double getTotalDelay() { + return this.totalDelay; + } + + public Map, Double> getTotalDelayPerLink() { + return this.totalDelayPerLink; + } +// public Map, Double> getFlowPerLinkPerVehicleType() { +// return flowPerLinkPerVehicleType; +// } + + public double getFlow() { + return flow; + } + + public Map, Double> getAvgDelayPerLink() { + Map, Double> avgDelayMap = new HashMap(); + Iterator var2 = this.totalDelayPerLink.keySet().iterator(); + + while (var2.hasNext()) { + Id linkId = (Id) var2.next(); + avgDelayMap.put(linkId, (Double) this.totalDelayPerLink.get(linkId) / (double) (Integer) this.numberOfAgentsPerLink.get(linkId)); + } + + return avgDelayMap; + } + + public void considerDelayOfStuckedAgents() { + this.considerStuckedAgents = true; + } + + public void handleEvent(SignalGroupStateChangedEvent event) { + + switch (event.getNewState()) { + case RED: + this.lastSwitchesToRed.put(event.getSignalGroupId(), event.getTime()); + break; + case GREEN: + this.lastSwitchesToGreen.put(event.getSignalGroupId(), event.getTime()); + this.doCycleAnalysis(event); + } + + } + + private void doCycleAnalysis(SignalGroupStateChangedEvent event) { + if (!this.firstSignalGroupOfSignalSystem.containsKey(event.getSignalSystemId())) { + this.firstSignalGroupOfSignalSystem.put(event.getSignalSystemId(), event.getSignalGroupId()); + } + if (event.getSignalGroupId().equals(this.firstSignalGroupOfSignalSystem.get(event.getSignalSystemId()))) { + this.currentCycleTime = event.getTime(); + } + + } + + + public void notifyAfterMobsim(AfterMobsimEvent afterMobsimEvent) { + this.lastSwitchesToGreen.clear(); + this.lastSwitchesToRed.clear(); + this.summedBygoneDelayPerCycle.clear(); + this.summedBygoneFlowPerLinkPerVehicleTypePerCycle.clear(); + } + + public Map, Double>> getSummedBygoneDelayPerCycle() { + return summedBygoneDelayPerCycle; + } + + public Map, Map, Double>>> getSummedBygoneFlowPerLinkPerVehicleTypePerCycle() { + return summedBygoneFlowPerLinkPerVehicleTypePerCycle; + } + + public void notifyIterationEnds(IterationEndsEvent iterationEndsEvent) { + System.out.println(); + } +} diff --git a/src/main/java/org/matsim/contrib/signals/analysis/MixedTrafficSignalAnalysisTool.java b/src/main/java/org/matsim/contrib/signals/analysis/MixedTrafficSignalAnalysisTool.java new file mode 100644 index 000000000..b891779e8 --- /dev/null +++ b/src/main/java/org/matsim/contrib/signals/analysis/MixedTrafficSignalAnalysisTool.java @@ -0,0 +1,261 @@ +package org.matsim.contrib.signals.analysis; + + +import com.google.inject.Inject; +import com.google.inject.Singleton; + +import java.util.*; + +import org.matsim.api.core.v01.Id; +import org.matsim.api.core.v01.events.ActivityEndEvent; +import org.matsim.api.core.v01.events.ActivityStartEvent; +import org.matsim.api.core.v01.events.handler.ActivityEndEventHandler; +import org.matsim.api.core.v01.events.handler.ActivityStartEventHandler; +import org.matsim.contrib.signals.data.SignalsData; +import org.matsim.contrib.signals.events.SignalGroupStateChangedEvent; +import org.matsim.contrib.signals.events.SignalGroupStateChangedEventHandler; +import org.matsim.contrib.signals.model.SignalGroup; +import org.matsim.contrib.signals.model.SignalSystem; +import org.matsim.core.api.experimental.events.EventsManager; +import org.matsim.core.controler.ControlerListenerManager; +import org.matsim.core.controler.events.AfterMobsimEvent; +import org.matsim.core.controler.events.IterationEndsEvent; +import org.matsim.core.controler.listener.AfterMobsimListener; +import org.matsim.core.controler.listener.IterationEndsListener; +import org.matsim.core.mobsim.qsim.interfaces.SignalGroupState; + +@Singleton +public class MixedTrafficSignalAnalysisTool implements SignalGroupStateChangedEventHandler, AfterMobsimListener, ActivityStartEventHandler, ActivityEndEventHandler { + private Map, Double> totalSignalGreenTime; + private Map, Double>> summedBygoneSignalGreenTimesPerCycle; + private List cycleTimes; + private Map, Integer> numberOfCyclesPerSystem; + private Map, Double> sumOfSystemCycleTimes; + private Map, Double>> summedBygoneSignalGreenTimesPerSecond; + private Map, Double> lastSwitchesToGreen; + private Map, Double> lastSwitchesToRed; + private Map, Double> lastCycleStartPerSystem; + private Map, Id> signalGroup2signalSystemId; + private Map, Id> firstSignalGroupOfSignalSystem; + private double lastActStartTime; + private Double firstActEndTime; + private double currentCycleTime; + + + public Map, Id> getSignalGroup2signalSystemId() { + return signalGroup2signalSystemId; + } + public Map, Double> getSumOfSystemCycleTimes() { + return sumOfSystemCycleTimes; + } + public List getCycleTimes() { + return cycleTimes; + } + public MixedTrafficSignalAnalysisTool() { + } + +// @Inject +// public MixedTrafficSignalAnalysisTool(EventsManager em, ControlerListenerManager clm) { +// em.addHandler(this); +// clm.addControlerListener(this); +// } + + public void reset(int iteration) { + this.totalSignalGreenTime = new HashMap(); + this.numberOfCyclesPerSystem = new HashMap(); + this.signalGroup2signalSystemId = new HashMap(); + this.firstSignalGroupOfSignalSystem = new HashMap(); + this.sumOfSystemCycleTimes = new HashMap(); + this.summedBygoneSignalGreenTimesPerSecond = new TreeMap(); + this.lastSwitchesToGreen = new HashMap(); + this.lastSwitchesToRed = new HashMap(); + this.lastCycleStartPerSystem = new HashMap(); + this.summedBygoneSignalGreenTimesPerCycle = new TreeMap<>(); + this.cycleTimes = new ArrayList<>(); + cycleTimes.add(0.0); + this.currentCycleTime = 0; + } + + public void handleEvent(ActivityStartEvent event) { + this.lastActStartTime = event.getTime(); + } + + public void handleEvent(ActivityEndEvent event) { + if (this.firstActEndTime == null) { + this.firstActEndTime = event.getTime(); + } + } + + public void handleEvent(SignalGroupStateChangedEvent event) { + + if (!this.signalGroup2signalSystemId.containsKey(event.getSignalGroupId())) { + this.signalGroup2signalSystemId.put(event.getSignalGroupId(), event.getSignalSystemId()); + } + this.summedBygoneSignalGreenTimesPerCycle.putIfAbsent(this.currentCycleTime, new HashMap<>()); + this.summedBygoneSignalGreenTimesPerCycle.get(this.currentCycleTime).putIfAbsent(event.getSignalGroupId(), 0.0D); + switch(event.getNewState()) { + case RED: + this.lastSwitchesToRed.put(event.getSignalGroupId(), event.getTime()); + Double lastSwitchToGreen = (Double)this.lastSwitchesToGreen.remove(event.getSignalGroupId()); + this.doBygoneGreenTimeAnalysis(event, lastSwitchToGreen); + break; + case GREEN: + this.lastSwitchesToGreen.put(event.getSignalGroupId(), event.getTime()); + this.doCycleAnalysis(event); + Double lastSwitchToRed = (Double)this.lastSwitchesToRed.remove(event.getSignalGroupId()); + this.doBygoneGreenTimeAnalysis(event, lastSwitchToRed); + } + + } + + + public void notifyAfterMobsim(AfterMobsimEvent event) { + double simEndTime = this.lastActStartTime; + Iterator var4 = this.lastSwitchesToGreen.keySet().iterator(); + Id signalSystemId; + while(var4.hasNext()) { + signalSystemId = (Id)var4.next(); + this.calculateLastGreenTimeOfTheGroupAndAddToTotalGreen(signalSystemId, simEndTime, (Double)this.lastSwitchesToGreen.get(signalSystemId)); + this.fillBygoneGreenTimeMapForEverySecondSinceLastSwitch(signalSystemId, simEndTime, (Double)this.lastSwitchesToGreen.get(signalSystemId), 1); + } + + this.lastSwitchesToGreen.clear(); + var4 = this.lastSwitchesToRed.keySet().iterator(); + + while(var4.hasNext()) { + signalSystemId = (Id)var4.next(); +// this.calculateLastGreenTimeOfTheGroupAndAddToTotalGreen(signalSystemId, simEndTime, (Double)this.lastSwitchesToRed.get(signalSystemId)); + this.fillBygoneGreenTimeMapForEverySecondSinceLastSwitch(signalSystemId, simEndTime, (Double)this.lastSwitchesToRed.get(signalSystemId), 0); + } + + this.lastSwitchesToRed.clear(); + var4 = this.lastCycleStartPerSystem.keySet().iterator(); + while (var4.hasNext()) { + signalSystemId = (Id) var4.next(); + this.addLastSystemCycleTime(signalSystemId, simEndTime); + } + } + + private void doBygoneGreenTimeAnalysis(SignalGroupStateChangedEvent event, Double lastSwitch) { + if (lastSwitch == null) { + if (!this.summedBygoneSignalGreenTimesPerSecond.containsKey(event.getTime())) { + this.summedBygoneSignalGreenTimesPerSecond.put(event.getTime(), new HashMap()); + } + ((Map)this.summedBygoneSignalGreenTimesPerSecond.get(event.getTime())).put(event.getSignalGroupId(), 0.0D); + } else { + int increment = 0; + if (event.getNewState().equals(SignalGroupState.RED)) { + increment = 1; + this.calculateLastGreenTimeOfTheGroupAndAddToTotalGreen(event.getSignalGroupId(), event.getTime(), lastSwitch); + } + + this.fillBygoneGreenTimeMapForEverySecondSinceLastSwitch(event.getSignalGroupId(), event.getTime(), lastSwitch, increment); + } + + } + + private void fillBygoneGreenTimeMapForEverySecondSinceLastSwitch(Id signalGroupId, double thisSwitch, double lastSwitch, int increment) { + double lastBygoneSignalGreenTimeInsideMap = (Double)((Map)this.summedBygoneSignalGreenTimesPerSecond.get(lastSwitch)).get(signalGroupId); + + for(double time = lastSwitch + 1.0D; time <= thisSwitch; ++time) { + if (!this.summedBygoneSignalGreenTimesPerSecond.containsKey(time)) { + this.summedBygoneSignalGreenTimesPerSecond.put(time, new HashMap()); + } + + lastBygoneSignalGreenTimeInsideMap += (double)increment; + ((Map)this.summedBygoneSignalGreenTimesPerSecond.get(time)).put(signalGroupId, lastBygoneSignalGreenTimeInsideMap); + } + + } + + private void calculateLastGreenTimeOfTheGroupAndAddToTotalGreen(Id signalGroupId, double redSwitch, double lastGreenSwitch) { + if (!this.totalSignalGreenTime.containsKey(signalGroupId)) { + this.totalSignalGreenTime.put(signalGroupId, 0.0D); + } + + double greenTime = redSwitch - lastGreenSwitch; + this.totalSignalGreenTime.put(signalGroupId, (Double)this.totalSignalGreenTime.get(signalGroupId) + greenTime); + this.summedBygoneSignalGreenTimesPerCycle.get(this.currentCycleTime).put(signalGroupId, this.summedBygoneSignalGreenTimesPerCycle.get(this.currentCycleTime).get(signalGroupId) + greenTime); + } + + private void doCycleAnalysis(SignalGroupStateChangedEvent event) { + if (!this.firstSignalGroupOfSignalSystem.containsKey(event.getSignalSystemId())) { + this.firstSignalGroupOfSignalSystem.put(event.getSignalSystemId(), event.getSignalGroupId()); + this.numberOfCyclesPerSystem.put(event.getSignalSystemId(), 0); + } + + if (event.getSignalGroupId().equals(this.firstSignalGroupOfSignalSystem.get(event.getSignalSystemId()))) { + this.currentCycleTime = event.getTime(); + this.numberOfCyclesPerSystem.put(event.getSignalSystemId(), (Integer)this.numberOfCyclesPerSystem.get(event.getSignalSystemId()) + 1); + if (this.lastCycleStartPerSystem.containsKey(event.getSignalSystemId())) { + this.addLastSystemCycleTime(event.getSignalSystemId(), event.getTime()); + } + cycleTimes.add(event.getTime()); + this.lastCycleStartPerSystem.put(event.getSignalSystemId(), event.getTime()); + } + + } + + private void addLastSystemCycleTime(Id signalSystemId, double cycleStartTime) { + if (!this.sumOfSystemCycleTimes.containsKey(signalSystemId)) { + this.sumOfSystemCycleTimes.put(signalSystemId, 0.0D); + } + double lastCycleTime = cycleStartTime - (Double)this.lastCycleStartPerSystem.get(signalSystemId); + double cycleTime = this.sumOfSystemCycleTimes.get(signalSystemId) + lastCycleTime; + this.sumOfSystemCycleTimes.put(signalSystemId, cycleTime); + } + + public Map, Double> getTotalSignalGreenTime() { + return this.totalSignalGreenTime; + } + + public Map, Double> calculateAvgSignalGreenTimePerFlexibleCycle() { + Map, Double> avgSignalGreenTimePerCycle = new HashMap(); + Iterator var2 = this.totalSignalGreenTime.keySet().iterator(); + + while(var2.hasNext()) { + Id signalGroupId = (Id)var2.next(); + Id signalSystemId = (Id)this.signalGroup2signalSystemId.get(signalGroupId); + double avgSignalGreenTime = (Double)this.totalSignalGreenTime.get(signalGroupId) / (double)(Integer)this.numberOfCyclesPerSystem.get(signalSystemId); + avgSignalGreenTimePerCycle.put(signalGroupId, avgSignalGreenTime); + } + + return avgSignalGreenTimePerCycle; + } + + public Map, Double> calculateAvgFlexibleCycleTimePerSignalSystem() { + Map, Double> avgCycleTimePerSystem = new HashMap(); + Iterator var2 = this.sumOfSystemCycleTimes.keySet().iterator(); + + while(var2.hasNext()) { + Id signalSystemId = (Id)var2.next(); + double avgSystemCylceTime = (Double)this.sumOfSystemCycleTimes.get(signalSystemId) / (double)(Integer)this.numberOfCyclesPerSystem.get(signalSystemId); + avgCycleTimePerSystem.put(signalSystemId, avgSystemCylceTime); + } + + return avgCycleTimePerSystem; + } + + public Map, Double>> getSumOfBygoneSignalGreenTime() { + return this.summedBygoneSignalGreenTimesPerSecond; + } + + public Map, Double> calculateSignalGreenTimeRatios() { + Map, Double> signalGreenTimeRatios = new HashMap(); + Iterator var2 = this.totalSignalGreenTime.keySet().iterator(); + + while(var2.hasNext()) { + Id signalGroupId = (Id)var2.next(); + double avgSignalGreenTime = (Double)this.totalSignalGreenTime.get(signalGroupId) / (this.lastActStartTime - this.firstActEndTime); + signalGreenTimeRatios.put(signalGroupId, avgSignalGreenTime); + } + + return signalGreenTimeRatios; + } + + public Map, Double>> getSummedBygoneSignalGreenTimesPerCycle() { + return summedBygoneSignalGreenTimesPerCycle; + } + +} + diff --git a/src/main/java/org/matsim/contrib/signals/builder/MixedTrafficSignals.java b/src/main/java/org/matsim/contrib/signals/builder/MixedTrafficSignals.java new file mode 100644 index 000000000..40dee9008 --- /dev/null +++ b/src/main/java/org/matsim/contrib/signals/builder/MixedTrafficSignals.java @@ -0,0 +1,29 @@ +package org.matsim.contrib.signals.builder; + +import org.matsim.contrib.signals.controller.SignalControllerFactory; +import org.matsim.core.controler.AllowsConfiguration; +import playground.amit.fundamentalDiagrams.dynamicPCU.areaSpeedRatioMethod.estimation.ChandraSikdarPCUUpdator; + +public final class MixedTrafficSignals { + public MixedTrafficSignals() { + } + + public static void configure(AllowsConfiguration ao) { + ao.addOverridingModule(new MixedTrafficSignalsModule()); + ao.addOverridingModule(new SignalsModule()); + ao.addOverridingQSimModule(new SignalsQSimModule()); + } + + public static class Configurator { + private final MixedTrafficSignalsModule mixedTrafficSignalsModule = new MixedTrafficSignalsModule(); + + public Configurator(AllowsConfiguration ao) { + ao.addOverridingModule(this.mixedTrafficSignalsModule); + ao.addOverridingQSimModule(new SignalsQSimModule()); + } + + public final void addSignalControllerFactory(String key, Class signalControllerFactoryClassName) { + this.mixedTrafficSignalsModule.addSignalControllerFactory(key, signalControllerFactoryClassName); + } + } +} \ No newline at end of file diff --git a/src/main/java/org/matsim/contrib/signals/builder/MixedTrafficSignalsModule.java b/src/main/java/org/matsim/contrib/signals/builder/MixedTrafficSignalsModule.java new file mode 100644 index 000000000..aa1ac74b2 --- /dev/null +++ b/src/main/java/org/matsim/contrib/signals/builder/MixedTrafficSignalsModule.java @@ -0,0 +1,79 @@ +package org.matsim.contrib.signals.builder; + + +import com.google.inject.Singleton; +import com.google.inject.TypeLiteral; +import com.google.inject.multibindings.MapBinder; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.matsim.contrib.signals.SignalSystemsConfigGroup; +import org.matsim.contrib.signals.analysis.SignalEvents2ViaCSVWriter; +import org.matsim.contrib.signals.controller.SignalControllerFactory; +import org.matsim.contrib.signals.controller.fixedTime.DefaultPlanbasedSignalSystemController.FixedTimeFactory; +import org.matsim.contrib.signals.controller.laemmerFix.LaemmerSignalController.LaemmerFactory; +import org.matsim.contrib.signals.controller.laemmerFix.MixedTrafficLaemmerSignalController; +import org.matsim.contrib.signals.controller.sylvia.SylviaSignalController.SylviaFactory; +import org.matsim.contrib.signals.model.SignalSystemsManager; +import org.matsim.contrib.signals.sensor.DownstreamSensor; +import org.matsim.contrib.signals.sensor.LinkSensorManager; +import org.matsim.contrib.signals.sensor.MixedTrafficLinkSensorManager; +import org.matsim.core.config.ConfigUtils; +import org.matsim.core.controler.AbstractModule; +import org.matsim.core.network.algorithms.NetworkTurnInfoBuilderI; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +class MixedTrafficSignalsModule extends AbstractModule { + private static final Logger log = LogManager.getLogger(SignalsModule.class); + private MapBinder signalControllerFactoryMultibinder; + private Map> signalControllerFactoryClassNames = new HashMap(); + + MixedTrafficSignalsModule() { + this.signalControllerFactoryClassNames.put("DefaultPlanbasedSignalSystemController", FixedTimeFactory.class); + this.signalControllerFactoryClassNames.put("SylviaSignalControl", SylviaFactory.class); + this.signalControllerFactoryClassNames.put("LaemmerSignalController", LaemmerFactory.class); + this.signalControllerFactoryClassNames.put("MixedTrafficLaemmerSignalController", MixedTrafficLaemmerSignalController.LaemmerFactory.class); + } + + public void install() { + this.getConfig().travelTimeCalculator().setSeparateModes(false); + log.warn("setting travelTimeCalculatur.setSeparateModes to false since otherwise link2link routing does not work"); + this.signalControllerFactoryMultibinder = MapBinder.newMapBinder(this.binder(), new TypeLiteral() { + }, new TypeLiteral() { + }); + if (((SignalSystemsConfigGroup)ConfigUtils.addOrGetModule(this.getConfig(), "signalsystems", SignalSystemsConfigGroup.class)).isUseSignalSystems()) { + this.bind(SignalModelFactory.class).to(SignalModelFactoryImpl.class); + this.addControlerListenerBinding().to(SensorBasedSignalControlerListener.class); + this.bind(MixedTrafficLinkSensorManager.class).in(Singleton.class); + this.bind(LinkSensorManager.class).in(Singleton.class); + this.bind(DownstreamSensor.class).in(Singleton.class); + Iterator var1 = this.signalControllerFactoryClassNames.keySet().iterator(); + + while(var1.hasNext()) { + String identifier = (String)var1.next(); + this.signalControllerFactoryMultibinder.addBinding(identifier).to((Class)this.signalControllerFactoryClassNames.get(identifier)); + } + + this.bind(SignalSystemsManager.class).toProvider(FromDataBuilder.class).in(Singleton.class); + this.addMobsimListenerBinding().to(QSimSignalEngine.class); + this.bind(SignalEvents2ViaCSVWriter.class).asEagerSingleton(); + this.addControlerListenerBinding().to(SignalEvents2ViaCSVWriter.class); + this.addEventHandlerBinding().to(SignalEvents2ViaCSVWriter.class); + if (this.getConfig().qsim().isUsingFastCapacityUpdate()) { + throw new RuntimeException("Fast flow capacity update does not support signals"); + } + } + + if (this.getConfig().controler().isLinkToLinkRoutingEnabled()) { + this.bind(NetworkTurnInfoBuilderI.class).to(NetworkWithSignalsTurnInfoBuilder.class); + } + + } + + final void addSignalControllerFactory(String key, Class signalControllerFactoryClassName) { + this.signalControllerFactoryClassNames.put(key, signalControllerFactoryClassName); + } +} + diff --git a/src/main/java/org/matsim/contrib/signals/controller/laemmerFix/MixedTrafficLaemmerSignalController.java b/src/main/java/org/matsim/contrib/signals/controller/laemmerFix/MixedTrafficLaemmerSignalController.java new file mode 100644 index 000000000..2add146fb --- /dev/null +++ b/src/main/java/org/matsim/contrib/signals/controller/laemmerFix/MixedTrafficLaemmerSignalController.java @@ -0,0 +1,573 @@ +package org.matsim.contrib.signals.controller.laemmerFix; + +import com.google.inject.Inject; +import org.matsim.api.core.v01.Id; +import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.network.Link; +import org.matsim.api.core.v01.network.Network; +import org.matsim.contrib.signals.builder.SignalModelFactory; +import org.matsim.contrib.signals.controller.AbstractSignalController; +import org.matsim.contrib.signals.controller.SignalController; +import org.matsim.contrib.signals.controller.SignalControllerFactory; +import org.matsim.contrib.signals.controller.fixedTime.DefaultPlanbasedSignalSystemController; +import org.matsim.contrib.signals.controller.laemmerFix.LaemmerConfigGroup.Regime; +import org.matsim.contrib.signals.model.Signal; +import org.matsim.contrib.signals.model.SignalGroup; +import org.matsim.contrib.signals.model.SignalPlan; +import org.matsim.contrib.signals.model.SignalSystem; +import org.matsim.contrib.signals.sensor.DownstreamSensor; +import org.matsim.contrib.signals.sensor.MixedTrafficLinkSensorManager; +import org.matsim.core.config.Config; +import org.matsim.core.config.ConfigUtils; +import org.matsim.core.controler.ControlerListenerManager; +import org.matsim.core.controler.listener.ControlerListener; +import org.matsim.core.mobsim.qsim.interfaces.SignalGroupState; +import org.matsim.lanes.Lane; +import org.matsim.lanes.Lanes; +import org.matsim.lanes.LanesToLinkAssignment; + +import java.util.*; + +public final class MixedTrafficLaemmerSignalController extends AbstractSignalController implements SignalController, ControlerListener { + public static final String IDENTIFIER = "MixedTrafficLaemmerSignalController"; + private MixedTrafficLaemmerSignalController.Request activeRequest = null; + private Queue regulationQueue = new LinkedList(); + private final List laemmerSignals = new ArrayList(); + private MixedTrafficLinkSensorManager sensorManager; + private DownstreamSensor downstreamSensor; + private Scenario scenario; + private final Network network; + private final Lanes lanes; + private final Config config; + private final LaemmerConfigGroup laemmerConfig; + private SignalModelFactory factory; + private double tIdle; + private double systemOutflowCapacity; + + + private MixedTrafficLaemmerSignalController(Scenario scenario, MixedTrafficLinkSensorManager sensorManager, DownstreamSensor downstreamSensor) { + this.sensorManager = sensorManager; + this.network = scenario.getNetwork(); + this.lanes = scenario.getLanes(); + this.config = scenario.getConfig(); + this.downstreamSensor = downstreamSensor; + this.laemmerConfig = (LaemmerConfigGroup)ConfigUtils.addOrGetModule(this.config, LaemmerConfigGroup.class); + } + public void simulationInitialized(double simStartTimeSeconds) { + this.laemmerSignals.clear(); + this.activeRequest = null; + this.regulationQueue.clear(); + this.systemOutflowCapacity = 0.0D; + this.initializeSensoring(); + + MixedTrafficLaemmerSignalController.LaemmerSignal laemmerSignal; + for(Iterator var3 = this.system.getSignalGroups().values().iterator(); var3.hasNext(); this.systemOutflowCapacity += laemmerSignal.signalOutflowCapacityPerS) { + SignalGroup group = (SignalGroup)var3.next(); + this.system.scheduleDropping(simStartTimeSeconds, group.getId()); + laemmerSignal = new MixedTrafficLaemmerSignalController.LaemmerSignal(group); + this.laemmerSignals.add(laemmerSignal); + } + + } + + public void updateState(double now) { + this.updateRepresentativeDriveways(now); + if (!this.laemmerConfig.getActiveRegime().equals(Regime.OPTIMIZING)) { + this.updateActiveRegulation(now); + } + + Iterator var3 = this.laemmerSignals.iterator(); + + while(var3.hasNext()) { + MixedTrafficLaemmerSignalController.LaemmerSignal signal = (MixedTrafficLaemmerSignalController.LaemmerSignal)var3.next(); + signal.update(now); + } + + if (this.activeRequest != null && this.activeRequest.signal.group.getState().equals(SignalGroupState.GREEN)) { + double remainingMinG = this.activeRequest.onsetTime + this.laemmerConfig.getMinGreenTime() - now; + if (remainingMinG > 0.0D) { + return; + } + } + + MixedTrafficLaemmerSignalController.LaemmerSignal selection = this.selectSignal(); + this.processSelection(now, selection); + } + + + private void updateActiveRegulation(double now) { + if (this.activeRequest != null && !this.regulationQueue.isEmpty() && ((MixedTrafficLaemmerSignalController.LaemmerSignal)this.regulationQueue.peek()).equals(this.activeRequest.signal)) { + MixedTrafficLaemmerSignalController.LaemmerSignal signal = (MixedTrafficLaemmerSignalController.LaemmerSignal)this.regulationQueue.peek(); + double n; + if (signal.determiningLane != null) { + n = this.getNumberOfExpectedVehiclesOnLane(now, signal.determiningLink, signal.determiningLane); + } else { + n = this.getNumberOfExpectedVehiclesOnLink(now, signal.determiningLink); + } + + if (this.activeRequest.signal.regulationTime + this.activeRequest.onsetTime - now <= 0.0D || n == 0) { + this.regulationQueue.poll(); + } + } + + } + + private MixedTrafficLaemmerSignalController.LaemmerSignal selectSignal() { + MixedTrafficLaemmerSignalController.LaemmerSignal max = null; + if (!this.laemmerConfig.getActiveRegime().equals(Regime.OPTIMIZING)) { + max = (MixedTrafficLaemmerSignalController.LaemmerSignal)this.regulationQueue.peek(); + } + + if (!this.laemmerConfig.getActiveRegime().equals(Regime.STABILIZING) && max == null) { + double index = 0.0D; + Iterator var4 = this.laemmerSignals.iterator(); + + while(true) { + MixedTrafficLaemmerSignalController.LaemmerSignal signal; + do { + do { + if (!var4.hasNext()) { + return max; + } + + signal = (MixedTrafficLaemmerSignalController.LaemmerSignal)var4.next(); + } while(!(signal.index > index)); + } while(this.laemmerConfig.isCheckDownstream() && !this.downstreamSensor.allDownstreamLinksEmpty(this.system.getId(), signal.group.getId())); + + max = signal; + index = signal.index; + } + } else { + return max; + } + } + + private void processSelection(double now, MixedTrafficLaemmerSignalController.LaemmerSignal max) { + if (this.activeRequest != null && (max == null || !max.equals(this.activeRequest.signal))) { + if (this.activeRequest.onsetTime < now) { + this.system.scheduleDropping(now, this.activeRequest.signal.group.getId()); + } + + this.activeRequest = null; + } + + if (this.activeRequest == null && max != null) { + this.activeRequest = new MixedTrafficLaemmerSignalController.Request(now + this.laemmerConfig.getIntergreenTime(), max); + } + + if (this.activeRequest != null && this.activeRequest.isDue(now)) { + this.system.scheduleOnset(now, this.activeRequest.signal.group.getId()); + } + + } + + private void updateRepresentativeDriveways(double now) { + this.tIdle = this.laemmerConfig.getDesiredCycleTime(); + + MixedTrafficLaemmerSignalController.LaemmerSignal signal; + for(Iterator var3 = this.laemmerSignals.iterator(); var3.hasNext(); this.tIdle -= Math.max(signal.determiningLoad * this.laemmerConfig.getDesiredCycleTime() + this.laemmerConfig.getIntergreenTime(), this.laemmerConfig.getMinGreenTime())) { + signal = (MixedTrafficLaemmerSignalController.LaemmerSignal)var3.next(); + signal.determineRepresentativeDriveway(now); + } + + this.tIdle = Math.max(0.0D, this.tIdle); + } + + private double getNumberOfExpectedVehiclesOnLink(double now, Id linkId) { + return this.sensorManager.getNumberOfCarsInDistance(linkId, 0.0D, now); + } + + private double getNumberOfExpectedVehiclesOnLane(double now, Id linkId, Id laneId) { + return ((LanesToLinkAssignment)this.lanes.getLanesToLinkAssignments().get(linkId)).getLanes().size() == 1 ? this.getNumberOfExpectedVehiclesOnLink(now, linkId) : this.sensorManager.getNumberOfCarsInDistanceOnLane(linkId, laneId, 0.0D, now); + } + + private double getAverageArrivalRate(double now, Id linkId) { + return this.laemmerConfig.getLinkArrivalRate(linkId) != null ? this.laemmerConfig.getLinkArrivalRate(linkId) : this.sensorManager.getAverageArrivalRateOnLink(linkId, now); + } + + private double getAverageLaneArrivalRate(double now, Id linkId, Id laneId) { + if (((LanesToLinkAssignment)this.lanes.getLanesToLinkAssignments().get(linkId)).getLanes().size() > 1) { + return this.laemmerConfig.getLaneArrivalRate(linkId, laneId) != null ? this.laemmerConfig.getLaneArrivalRate(linkId, laneId) : this.sensorManager.getAverageArrivalRateOnLane(linkId, laneId, now); + } else { + return this.getAverageArrivalRate(now, linkId); + } + } + + private void initializeSensoring() { + Iterator var1 = this.system.getSignalGroups().values().iterator(); + + while(var1.hasNext()) { + SignalGroup group = (SignalGroup)var1.next(); + Iterator var3 = group.getSignals().values().iterator(); + + while(var3.hasNext()) { + Signal signal = (Signal)var3.next(); + if (signal.getLaneIds() != null && !signal.getLaneIds().isEmpty()) { + Iterator var5 = signal.getLaneIds().iterator(); + + while(var5.hasNext()) { + Id laneId = (Id)var5.next(); + this.sensorManager.registerNumberOfCarsOnLaneInDistanceMonitoring(signal.getLinkId(), laneId, 0.0D); + this.sensorManager.registerAverageNumberOfCarsPerSecondMonitoringOnLane(signal.getLinkId(), laneId, this.laemmerConfig.getLookBackTime(), this.laemmerConfig.getTimeBucketSize()); + } + } + + this.sensorManager.registerNumberOfCarsInDistanceMonitoring(signal.getLinkId(), 0.0D); + this.sensorManager.registerAverageNumberOfCarsPerSecondMonitoring(signal.getLinkId(), this.laemmerConfig.getLookBackTime(), this.laemmerConfig.getTimeBucketSize()); + } + } + + if (this.laemmerConfig.isCheckDownstream()) { + this.downstreamSensor.registerDownstreamSensors(this.system); + } + + } + + class Request { + private final double onsetTime; + private final MixedTrafficLaemmerSignalController.LaemmerSignal signal; + + Request(double onsetTime, MixedTrafficLaemmerSignalController.LaemmerSignal laemmerSignal) { + this.signal = laemmerSignal; + this.onsetTime = onsetTime; + } + + private boolean isDue(double now) { + return now == this.onsetTime; + } + } + + class LaemmerSignal { + SignalGroup group; + double index = 0.0D; + private double abortionPenalty = 0.0D; + private boolean stabilize = false; + private double a; + private double regulationTime; + private Id determiningLane; + private Id determiningLink; + private double determiningArrivalRate; + private double determiningLoad; + private double signalOutflowCapacityPerS; + private Map, Double> laneOutflowCapacitiesPerS; + private Map, Double> linkOutflowCapacitiesPerS; + + LaemmerSignal(SignalGroup signalGroup) { + this.a = MixedTrafficLaemmerSignalController.this.laemmerConfig.getIntergreenTime(); + this.regulationTime = 0.0D; + this.laneOutflowCapacitiesPerS = new HashMap(); + this.linkOutflowCapacitiesPerS = new HashMap(); + this.group = signalGroup; + Iterator var3 = this.group.getSignals().values().iterator(); + + while(true) { + while(var3.hasNext()) { + Signal signal = (Signal)var3.next(); + double laneOutflow; + if (signal.getLaneIds() != null && !signal.getLaneIds().isEmpty() && ((LanesToLinkAssignment)MixedTrafficLaemmerSignalController.this.lanes.getLanesToLinkAssignments().get(signal.getLinkId())).getLanes().size() > 1) { + for(Iterator var9 = signal.getLaneIds().iterator(); var9.hasNext(); this.signalOutflowCapacityPerS += laneOutflow) { + Id laneId = (Id)var9.next(); + laneOutflow = ((Lane)((LanesToLinkAssignment)MixedTrafficLaemmerSignalController.this.lanes.getLanesToLinkAssignments().get(signal.getLinkId())).getLanes().get(laneId)).getCapacityVehiclesPerHour() * MixedTrafficLaemmerSignalController.this.config.qsim().getFlowCapFactor() / 3600.0D; + this.laneOutflowCapacitiesPerS.put(laneId, laneOutflow); + } + } else { + double linkOutflowPerS = ((Link)MixedTrafficLaemmerSignalController.this.network.getLinks().get(signal.getLinkId())).getCapacity() * MixedTrafficLaemmerSignalController.this.config.qsim().getFlowCapFactor() / 3600.0D; + this.linkOutflowCapacitiesPerS.put(signal.getLinkId(), linkOutflowPerS); + this.signalOutflowCapacityPerS += linkOutflowPerS; + } + } + + return; + } + } + + private void determineRepresentativeDriveway(double now) { + this.determiningLoad = 0.0D; + this.determiningLink = null; + this.determiningLane = null; + Iterator var3 = this.group.getSignals().values().iterator(); + + while(true) { + while(var3.hasNext()) { + Signal signal = (Signal)var3.next(); + double arrivalRate; + if (signal.getLaneIds() != null && !signal.getLaneIds().isEmpty() && ((LanesToLinkAssignment)MixedTrafficLaemmerSignalController.this.lanes.getLanesToLinkAssignments().get(signal.getLinkId())).getLanes().size() > 1) { + Iterator var11 = signal.getLaneIds().iterator(); + + while(var11.hasNext()) { + Id laneId = (Id)var11.next(); + arrivalRate = MixedTrafficLaemmerSignalController.this.getAverageLaneArrivalRate(now, signal.getLinkId(), laneId); + double tempLoad = Math.min(1.0D, arrivalRate / (Double)this.laneOutflowCapacitiesPerS.get(laneId)); + if (tempLoad >= this.determiningLoad) { + this.determiningLoad = tempLoad; + this.determiningArrivalRate = arrivalRate; + this.determiningLane = laneId; + this.determiningLink = signal.getLinkId(); + } + } + } else { + double arrivalRatex = MixedTrafficLaemmerSignalController.this.getAverageArrivalRate(now, signal.getLinkId()); + arrivalRate = Math.min(1.0D, arrivalRatex / (Double)this.linkOutflowCapacitiesPerS.get(signal.getLinkId())); + if (arrivalRate >= this.determiningLoad) { + this.determiningLoad = arrivalRate; + this.determiningArrivalRate = arrivalRatex; + this.determiningLane = null; + this.determiningLink = signal.getLinkId(); + } + } + } + + return; + } + } + + private void update(double now) { + this.updateAbortionPenalty(now); + if (!MixedTrafficLaemmerSignalController.this.laemmerConfig.getActiveRegime().equals(Regime.OPTIMIZING)) { + this.updateStabilization(now); + } + + if (!this.stabilize) { + this.calculatePriorityIndex(now); + } + + } + + private void updateAbortionPenalty(double now) { + this.abortionPenalty = 0.0D; + if (MixedTrafficLaemmerSignalController.this.activeRequest != null && this.equals(MixedTrafficLaemmerSignalController.this.activeRequest.signal)) { + double waitingTimeSum = 0.0D; + double remainingInBetweenTime = Math.max(MixedTrafficLaemmerSignalController.this.activeRequest.onsetTime - now, 0.0D); + + double i; + Iterator var9; + Signal signal; + Iterator var11; + Id laneId; + label74: + for(i = remainingInBetweenTime; i < MixedTrafficLaemmerSignalController.this.laemmerConfig.getIntergreenTime(); ++i) { + var9 = this.group.getSignals().values().iterator(); + + while(true) { + while(true) { + if (!var9.hasNext()) { + continue label74; + } + + signal = (Signal)var9.next(); + if (signal.getLaneIds() != null && !signal.getLaneIds().isEmpty() && ((LanesToLinkAssignment)MixedTrafficLaemmerSignalController.this.lanes.getLanesToLinkAssignments().get(signal.getLinkId())).getLanes().size() > 1) { + for(var11 = signal.getLaneIds().iterator(); var11.hasNext(); waitingTimeSum += (double)MixedTrafficLaemmerSignalController.this.getNumberOfExpectedVehiclesOnLane(now + i, signal.getLinkId(), laneId)) { + laneId = (Id)var11.next(); + } + } else { + waitingTimeSum += (double)MixedTrafficLaemmerSignalController.this.getNumberOfExpectedVehiclesOnLink(now + i, signal.getLinkId()); + } + } + } + } + + i = 0.0D; + var9 = this.group.getSignals().values().iterator(); + + while(true) { + while(var9.hasNext()) { + signal = (Signal)var9.next(); + if (signal.getLaneIds() != null && !signal.getLaneIds().isEmpty() && ((LanesToLinkAssignment)MixedTrafficLaemmerSignalController.this.lanes.getLanesToLinkAssignments().get(signal.getLinkId())).getLanes().size() > 1) { + for(var11 = signal.getLaneIds().iterator(); var11.hasNext(); i += (double)MixedTrafficLaemmerSignalController.this.getNumberOfExpectedVehiclesOnLane(now + MixedTrafficLaemmerSignalController.this.laemmerConfig.getIntergreenTime(), signal.getLinkId(), laneId)) { + laneId = (Id)var11.next(); + } + } else { + i += (double)MixedTrafficLaemmerSignalController.this.getNumberOfExpectedVehiclesOnLink(now + MixedTrafficLaemmerSignalController.this.laemmerConfig.getIntergreenTime(), signal.getLinkId()); + } + } + + if (i > 0.0D) { + this.abortionPenalty += waitingTimeSum / i; + } + break; + } + } + + } + + private void calculatePriorityIndex(double now) { + this.index = 0.0D; + double nExpected; + double remainingMinG; + double nExpectedx; + double reqGreenTime; + double i; + if (MixedTrafficLaemmerSignalController.this.activeRequest != null && MixedTrafficLaemmerSignalController.this.activeRequest.signal == this) { + nExpected = Math.max(MixedTrafficLaemmerSignalController.this.activeRequest.onsetTime - now, 0.0D); + remainingMinG = Math.max(MixedTrafficLaemmerSignalController.this.activeRequest.onsetTime - now + MixedTrafficLaemmerSignalController.this.laemmerConfig.getMinGreenTime() - nExpected, 0.0D); + + for(i = nExpected; i <= MixedTrafficLaemmerSignalController.this.laemmerConfig.getIntergreenTime(); ++i) { + nExpectedx = 0.0D; + reqGreenTime = remainingMinG; + Iterator var23 = this.group.getSignals().values().iterator(); + + while(var23.hasNext()) { + Signal signal = (Signal)var23.next(); + double tempIndex; + double tempGreenTimex; + if (signal.getLaneIds() != null && !signal.getLaneIds().isEmpty() && ((LanesToLinkAssignment)MixedTrafficLaemmerSignalController.this.lanes.getLanesToLinkAssignments().get(signal.getLinkId())).getLanes().size() > 1) { + Iterator var24 = signal.getLaneIds().iterator(); + + while(var24.hasNext()) { + Id laneId = (Id)var24.next(); + tempGreenTimex = (double)MixedTrafficLaemmerSignalController.this.getNumberOfExpectedVehiclesOnLane(now + i + remainingMinG, signal.getLinkId(), laneId); + nExpectedx += tempGreenTimex; + double tempGreenTimexx = tempGreenTimex / (Double)this.laneOutflowCapacitiesPerS.get(laneId); + if (tempGreenTimexx > reqGreenTime) { + reqGreenTime = tempGreenTimexx; + } + } + } else { + tempIndex = (double)MixedTrafficLaemmerSignalController.this.getNumberOfExpectedVehiclesOnLink(now + i + remainingMinG, signal.getLinkId()); + nExpectedx += tempIndex; + tempGreenTimex = tempIndex / (Double)this.linkOutflowCapacitiesPerS.get(signal.getLinkId()); + if (tempGreenTimex > reqGreenTime) { + reqGreenTime = tempGreenTimex; + } + } + + tempIndex = 0.0D; + if (nExpectedx > 0.0D) { + tempIndex = nExpectedx / (i + reqGreenTime); + } + + if (tempIndex > this.index) { + this.index = tempIndex; + } + } + } + } else { + nExpected = 0.0D; + remainingMinG = MixedTrafficLaemmerSignalController.this.laemmerConfig.getMinGreenTime(); + Iterator var7 = this.group.getSignals().values().iterator(); + + while(true) { + while(var7.hasNext()) { + Signal signalx = (Signal)var7.next(); + if (signalx.getLaneIds() != null && !signalx.getLaneIds().isEmpty() && ((LanesToLinkAssignment)MixedTrafficLaemmerSignalController.this.lanes.getLanesToLinkAssignments().get(signalx.getLinkId())).getLanes().size() > 1) { + Iterator var22 = signalx.getLaneIds().iterator(); + + while(var22.hasNext()) { + Id laneIdx = (Id)var22.next(); + reqGreenTime = (double)MixedTrafficLaemmerSignalController.this.getNumberOfExpectedVehiclesOnLane(now + MixedTrafficLaemmerSignalController.this.laemmerConfig.getIntergreenTime() + MixedTrafficLaemmerSignalController.this.laemmerConfig.getMinGreenTime(), signalx.getLinkId(), laneIdx); + nExpected += reqGreenTime; + double tempGreenTime = reqGreenTime / (Double)this.laneOutflowCapacitiesPerS.get(laneIdx); + if (tempGreenTime > remainingMinG) { + remainingMinG = tempGreenTime; + } + } + } else { + nExpectedx = (double)MixedTrafficLaemmerSignalController.this.getNumberOfExpectedVehiclesOnLink(now + MixedTrafficLaemmerSignalController.this.laemmerConfig.getIntergreenTime() + MixedTrafficLaemmerSignalController.this.laemmerConfig.getMinGreenTime(), signalx.getLinkId()); + nExpected += nExpectedx; + reqGreenTime = nExpectedx / (Double)this.linkOutflowCapacitiesPerS.get(signalx.getLinkId()); + if (reqGreenTime > remainingMinG) { + remainingMinG = reqGreenTime; + } + } + } + + i = 0.0D; + if (MixedTrafficLaemmerSignalController.this.activeRequest != null) { + i = MixedTrafficLaemmerSignalController.this.activeRequest.signal.abortionPenalty; + } + + this.index = nExpected / (i + MixedTrafficLaemmerSignalController.this.laemmerConfig.getIntergreenTime() + remainingMinG); + break; + } + } + + } + + private void updateStabilization(double now) { + if (this.determiningArrivalRate != 0.0D) { + double n = 0.0D; + if (this.determiningLane != null) { + n = (double)MixedTrafficLaemmerSignalController.this.getNumberOfExpectedVehiclesOnLane(now, this.determiningLink, this.determiningLane); + } else { + n = (double)MixedTrafficLaemmerSignalController.this.getNumberOfExpectedVehiclesOnLink(now, this.determiningLink); + } + + if (n == 0.0D) { + this.a = MixedTrafficLaemmerSignalController.this.laemmerConfig.getIntergreenTime(); + } else { + this.a += MixedTrafficLaemmerSignalController.this.config.qsim().getTimeStepSize(); + } + + if (!MixedTrafficLaemmerSignalController.this.regulationQueue.contains(this)) { + this.regulationTime = 0.0D; + this.stabilize = false; + double nCrit = this.determiningArrivalRate * MixedTrafficLaemmerSignalController.this.laemmerConfig.getDesiredCycleTime() * ((MixedTrafficLaemmerSignalController.this.laemmerConfig.getMaxCycleTime() - this.a / (1.0D - this.determiningLoad)) / (MixedTrafficLaemmerSignalController.this.laemmerConfig.getMaxCycleTime() - MixedTrafficLaemmerSignalController.this.laemmerConfig.getDesiredCycleTime())); + if (n > 0.0D && n >= nCrit && (!MixedTrafficLaemmerSignalController.this.laemmerConfig.isCheckDownstream() || MixedTrafficLaemmerSignalController.this.downstreamSensor.allDownstreamLinksEmpty(MixedTrafficLaemmerSignalController.this.system.getId(), this.group.getId()))) { + MixedTrafficLaemmerSignalController.this.regulationQueue.add(this); + this.regulationTime = Math.max(Math.rint(this.determiningLoad * MixedTrafficLaemmerSignalController.this.laemmerConfig.getDesiredCycleTime() + this.signalOutflowCapacityPerS / MixedTrafficLaemmerSignalController.this.systemOutflowCapacity * MixedTrafficLaemmerSignalController.this.tIdle), MixedTrafficLaemmerSignalController.this.laemmerConfig.getMinGreenTime()); + this.stabilize = true; + } + + } + } + } + + public void getStatFields(StringBuilder builder) { + builder.append("state_" + this.group.getId() + ";"); + builder.append("index_" + this.group.getId() + ";"); + builder.append("load_" + this.group.getId() + ";"); + builder.append("a_" + this.group.getId() + ";"); + builder.append("abortionPen_" + this.group.getId() + ";"); + builder.append("regTime_" + this.group.getId() + ";"); + builder.append("nTotal_" + this.group.getId() + ";"); + } + + public void getStepStats(StringBuilder builder, double now) { + int totalN = 0; + Iterator var5 = this.group.getSignals().values().iterator(); + + while(true) { + while(var5.hasNext()) { + Signal signal = (Signal)var5.next(); + Id laneId; + if (signal.getLaneIds() != null && !signal.getLaneIds().isEmpty() && ((LanesToLinkAssignment)MixedTrafficLaemmerSignalController.this.lanes.getLanesToLinkAssignments().get(signal.getLinkId())).getLanes().size() > 1) { + for(Iterator var7 = signal.getLaneIds().iterator(); var7.hasNext(); totalN += MixedTrafficLaemmerSignalController.this.getNumberOfExpectedVehiclesOnLane(now, signal.getLinkId(), laneId)) { + laneId = (Id)var7.next(); + } + } else { + totalN += MixedTrafficLaemmerSignalController.this.getNumberOfExpectedVehiclesOnLink(now, signal.getLinkId()); + } + } + + builder.append(this.group.getState().name() + ";").append(this.index + ";").append(this.determiningLoad + ";").append(this.a + ";").append(this.abortionPenalty + ";").append(this.regulationTime + ";").append(totalN + ";"); + return; + } + } + } + + public static final class LaemmerFactory implements SignalControllerFactory { + @Inject + private ControlerListenerManager manager; + @Inject + private MixedTrafficLinkSensorManager sensorManager; + @Inject + private DownstreamSensor downstreamSensor; + @Inject + private Scenario scenario; + + public LaemmerFactory() { + } + + public SignalController createSignalSystemController(SignalSystem signalSystem) { + MixedTrafficLaemmerSignalController controller = new MixedTrafficLaemmerSignalController(this.scenario, this.sensorManager, this.downstreamSensor); + controller.setSignalSystem(signalSystem); + controller.setScenario(this.scenario); + this.manager.addControlerListener(controller); + return controller; + } + } + + private void setScenario(Scenario scenario) { + this.scenario = scenario; + } +} diff --git a/src/main/java/org/matsim/contrib/signals/sensor/MixedTrafficLaneSensor.java b/src/main/java/org/matsim/contrib/signals/sensor/MixedTrafficLaneSensor.java new file mode 100644 index 000000000..0b29b55d2 --- /dev/null +++ b/src/main/java/org/matsim/contrib/signals/sensor/MixedTrafficLaneSensor.java @@ -0,0 +1,167 @@ +package org.matsim.contrib.signals.sensor; + + +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.Map; +import java.util.concurrent.atomic.AtomicInteger; +import org.matsim.api.core.v01.Id; +import org.matsim.api.core.v01.network.Link; +import org.matsim.core.api.experimental.events.LaneEnterEvent; +import org.matsim.core.api.experimental.events.LaneLeaveEvent; +import org.matsim.lanes.Lane; +import org.matsim.vehicles.Vehicle; + +final class MixedTrafficLaneSensor { + private Link link; + private Lane lane; + private int agentsOnLane = 0; + private boolean doDistanceMonitoring = false; + private boolean doAverageVehiclesPerSecondMonitoring = false; + private double totalVehicles = 0.0D; + private double monitoringStartTime; + private Map, CarLocator>> distanceMeterCarLocatorMap = null; + private double lookBackTime; + private LinkedList timeBuckets; + private double timeBucketSize; + private double currentBucketStartTime; + private AtomicInteger currentBucket; + private int numOfBucketsNeededForLookback; + private double volume = 0.0D; + private Map, Vehicle> vehicles; + + public MixedTrafficLaneSensor(Link link, Lane lane, Map, Vehicle> vehicles) { + this.link = link; + this.lane = lane; + this.vehicles = vehicles; + } + + public void registerDistanceToMonitor(Double distanceMeter) { + if (!this.doDistanceMonitoring) { + this.doDistanceMonitoring = true; + this.distanceMeterCarLocatorMap = new HashMap(); + } + + this.distanceMeterCarLocatorMap.put(distanceMeter, new HashMap()); + } + + public void handleEvent(LaneEnterEvent event) { + ++this.agentsOnLane; + if (this.doAverageVehiclesPerSecondMonitoring) { + if (this.lookBackTime != 1.0D / 0.0) { + this.updateBucketsUntil(event.getTime()); + this.currentBucket.incrementAndGet(); + } + + ++this.totalVehicles; + this.volume += this.vehicles.get(event.getVehicleId()).getType().getPcuEquivalents(); + if (this.totalVehicles == 1.0D) { + this.monitoringStartTime = event.getTime(); + } + } + + if (this.doDistanceMonitoring) { + + for (Double distance : this.distanceMeterCarLocatorMap.keySet()) { + Map, CarLocator> carLocatorPerVehicleId = (Map) this.distanceMeterCarLocatorMap.get(distance); + carLocatorPerVehicleId.put(event.getVehicleId(), new CarLocator(this.lane, this.link, event.getTime(), distance)); + } + } + + } + + public void handleEvent(LaneLeaveEvent event) { + --this.agentsOnLane; + if (this.doDistanceMonitoring) { + + for (Double distance : this.distanceMeterCarLocatorMap.keySet()) { + Map, CarLocator> carLocatorPerVehicleId = (Map) this.distanceMeterCarLocatorMap.get(distance); + carLocatorPerVehicleId.remove(event.getVehicleId()); + } + } + + } + + public int getNumberOfCarsOnLane() { + return this.agentsOnLane; + } + + public int getNumberOfCarsInDistance(Double distanceMeter, double now) { + Map, CarLocator> distSpecificCarLocators = (Map)this.distanceMeterCarLocatorMap.get(distanceMeter); + int count = 0; + + for (var entry: distSpecificCarLocators.entrySet()) { + if (entry.getValue().isCarinDistance(now)) { + count = (int) (count + this.vehicles.get(entry.getKey()).getType().getPcuEquivalents()); + } + } +// for (CarLocator cl : distSpecificCarLocators.values()) { +// if (cl.isCarinDistance(now)) { +// ++count; +// } +// } + + return count; + } + + public double getAvgVehiclesPerSecond(double now) { + double avgVehPerSecond = 0.0D; + if (now > this.monitoringStartTime) { + if (this.lookBackTime == 1.0D / 0.0) { +// avgVehPerSecond = this.totalVehicles / (now - this.monitoringStartTime + 1.0D); + avgVehPerSecond = this.volume / (now - this.monitoringStartTime + 1.0D); + } else { + this.updateBucketsUntil(now); + if (this.timeBuckets.size() > 0) { + avgVehPerSecond = (double)this.timeBuckets.stream().mapToInt(AtomicInteger::intValue).sum() / ((double)this.timeBuckets.size() * this.timeBucketSize); + } + + if ((this.timeBuckets.size() == 0 || avgVehPerSecond == 0.0D) && this.currentBucket != null && this.currentBucket.get() > 0) { + avgVehPerSecond = (double)this.currentBucket.get() / (now - this.currentBucketStartTime + 1.0D); + } + } + } + + return avgVehPerSecond; + } + + public void registerAverageVehiclesPerSecondToMonitor() { + this.registerAverageVehiclesPerSecondToMonitor(1.0D / 0.0, 1.0D / 0.0); + } + + public void registerAverageVehiclesPerSecondToMonitor(double lookBackTime, double timeBucketSize) { + if (!this.doAverageVehiclesPerSecondMonitoring) { + this.doAverageVehiclesPerSecondMonitoring = true; + this.lookBackTime = lookBackTime; + this.timeBucketSize = timeBucketSize; + this.timeBuckets = new LinkedList(); + this.currentBucketStartTime = 0.0D; + this.currentBucket = new AtomicInteger(0); + this.numOfBucketsNeededForLookback = (int)Math.ceil(lookBackTime / timeBucketSize); + } + + } + + private void queueFullBucket(AtomicInteger bucket) { + this.timeBuckets.add(bucket); + if (this.timeBuckets.size() > this.numOfBucketsNeededForLookback) { + this.timeBuckets.poll(); + } + + } + + private void updateBucketsUntil(double now) { + if (now >= this.currentBucketStartTime + this.timeBucketSize) { + this.queueFullBucket(this.currentBucket); + + for(this.currentBucketStartTime += this.timeBucketSize; this.currentBucketStartTime <= now - this.timeBucketSize; this.currentBucketStartTime += this.timeBucketSize) { + this.queueFullBucket(new AtomicInteger(0)); + } + + this.currentBucket = new AtomicInteger(0); + } + + } +} + diff --git a/src/main/java/org/matsim/contrib/signals/sensor/MixedTrafficLinkSensor.java b/src/main/java/org/matsim/contrib/signals/sensor/MixedTrafficLinkSensor.java new file mode 100644 index 000000000..c005e2469 --- /dev/null +++ b/src/main/java/org/matsim/contrib/signals/sensor/MixedTrafficLinkSensor.java @@ -0,0 +1,234 @@ +package org.matsim.contrib.signals.sensor; + + +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.Map; +import java.util.Queue; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Collectors; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.matsim.api.core.v01.Id; +import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.events.LinkEnterEvent; +import org.matsim.api.core.v01.events.LinkLeaveEvent; +import org.matsim.api.core.v01.events.PersonEntersVehicleEvent; +import org.matsim.api.core.v01.events.VehicleLeavesTrafficEvent; +import org.matsim.api.core.v01.network.Link; +import org.matsim.vehicles.Vehicle; +import org.matsim.vehicles.VehicleType; +import playground.amit.mixedTraffic.MixedTrafficVehiclesUtils; + +import javax.inject.Inject; + +final class MixedTrafficLinkSensor { + private static final Logger log = LogManager.getLogger(LinkSensor.class); + private Link link = null; + public int vehiclesOnLink = 0; + private double totalVehicles = 0.0D; + private boolean doDistanceMonitoring = false; + private boolean doAverageVehiclesPerSecondMonitoring = false; + private Map, CarLocator>> distanceMeterCarLocatorMap = null; + private double monitoringStartTime; + private double lookBackTime; + private double timeBucketSize; + private Queue timeBuckets; + private double currentBucketStartTime; + private AtomicInteger currentBucket; + private int numOfBucketsNeededForLookback; + private Map, Vehicle> vehicles; + private double volume = 0.0D; + private Map mode2PCUs; + + public Map getMode2PCUs() { + return mode2PCUs; + } + + + public MixedTrafficLinkSensor(Link link, Map, Vehicle> vehicles) { + this.link = link; + this.vehicles = vehicles; + this.mode2PCUs = vehicles + .values() + .stream() + .collect(Collectors.toMap(v -> v.getId().toString(), vehicle -> vehicle.getType().getPcuEquivalents())); + } + + + public void registerDistanceToMonitor(Double distanceMeter) { + if (!this.doDistanceMonitoring) { + this.enableDistanceMonitoring(); + } + + this.distanceMeterCarLocatorMap.put(distanceMeter, new HashMap()); + } + + public void registerAverageVehiclesPerSecondToMonitor() { + this.registerAverageVehiclesPerSecondToMonitor(1.0D / 0.0, 1.0D / 0.0); + } + + public void registerAverageVehiclesPerSecondToMonitor(double lookBackTime, double timeBucketCollectionDuration) { + if (!this.doAverageVehiclesPerSecondMonitoring) { + this.doAverageVehiclesPerSecondMonitoring = true; + this.lookBackTime = lookBackTime; + this.timeBucketSize = timeBucketCollectionDuration; + this.timeBuckets = new LinkedList(); + this.currentBucketStartTime = 0.0D; + this.currentBucket = new AtomicInteger(0); + this.numOfBucketsNeededForLookback = (int)Math.ceil(lookBackTime / timeBucketCollectionDuration); + } + + } + + private void enableDistanceMonitoring() { + this.doDistanceMonitoring = true; + this.distanceMeterCarLocatorMap = new HashMap(); + } + + public int getNumberOfCarsOnLink() { + return this.vehiclesOnLink; + } + + public int getNumberOfCarsInDistance(Double distanceMeter, double now) { + Map, CarLocator> distSpecificCarLocators = (Map)this.distanceMeterCarLocatorMap.get(distanceMeter); + int count = 0; + + for (var entry: distSpecificCarLocators.entrySet()) { + if (entry.getValue().isCarinDistance(now)) { + count = (int) (count + this.vehicles.get(entry.getKey()).getType().getPcuEquivalents()); + } + } +// for (CarLocator cl : distSpecificCarLocators.values()) { +// if (cl.isCarinDistance(now)) { +// ++count; +// } +// } + + return count; + } + + public double getAvgVehiclesPerSecond(double now) { + double avgVehPerSecond = 0.0D; + if (now > this.monitoringStartTime) { + if (this.lookBackTime == 1.0D / 0.0) { + avgVehPerSecond = this.volume / (now - this.monitoringStartTime + 1.0D); +// avgVehPerSecond = this.totalVehicles / (now - this.monitoringStartTime + 1.0D); + } else { + this.updateBucketsUntil(now); + if (this.timeBuckets.size() > 0) { + avgVehPerSecond = (double)this.timeBuckets.stream().mapToInt(AtomicInteger::intValue).sum() / ((double)this.timeBuckets.size() * this.timeBucketSize); + } + + if ((this.timeBuckets.size() == 0 || avgVehPerSecond == 0.0D) && this.currentBucket != null && this.currentBucket.get() > 0) { + avgVehPerSecond = (double)this.currentBucket.get() / (now - this.currentBucketStartTime + 1.0D); + } + } + } + + return avgVehPerSecond; + } + + private void updateBucketsUntil(double now) { + if (now >= this.currentBucketStartTime + this.timeBucketSize) { + this.queueFullBucket(this.currentBucket); + + for(this.currentBucketStartTime += this.timeBucketSize; this.currentBucketStartTime <= now - this.timeBucketSize; this.currentBucketStartTime += this.timeBucketSize) { + this.queueFullBucket(new AtomicInteger(0)); + } + + this.currentBucket = new AtomicInteger(0); + } + + } + + private void queueFullBucket(AtomicInteger bucket) { + this.timeBuckets.add(bucket); + if (this.timeBuckets.size() > this.numOfBucketsNeededForLookback) { + this.timeBuckets.poll(); + } + + } + + public void handleEvent(LinkEnterEvent event) { + ++this.vehiclesOnLink; + if (this.doAverageVehiclesPerSecondMonitoring) { + if (this.lookBackTime != 1.0D / 0.0) { + this.updateBucketsUntil(event.getTime()); + this.currentBucket.incrementAndGet(); + } + this.volume += this.vehicles.get(event.getVehicleId()).getType().getPcuEquivalents(); + ++this.totalVehicles; + if (this.volume == 1.0D) { + this.monitoringStartTime = event.getTime(); + } + } + if (this.doDistanceMonitoring) { + Iterator var2 = this.distanceMeterCarLocatorMap.keySet().iterator(); + + while(var2.hasNext()) { + Double distance = (Double)var2.next(); + Map, CarLocator> carLocatorPerVehicleId = (Map)this.distanceMeterCarLocatorMap.get(distance); + carLocatorPerVehicleId.put(event.getVehicleId(), new CarLocator(this.link, event.getTime(), distance)); + } + } + + } + + public void handleEvent(PersonEntersVehicleEvent event) { + ++this.vehiclesOnLink; + if (this.doAverageVehiclesPerSecondMonitoring) { + if (this.lookBackTime != 1.0D / 0.0) { + this.updateBucketsUntil(event.getTime()); + this.currentBucket.incrementAndGet(); + } + this.volume += this.vehicles.get(event.getVehicleId()).getType().getPcuEquivalents(); + ++this.totalVehicles; + if (this.volume == 1.0D) { + this.monitoringStartTime = event.getTime(); + } + } + + if (this.doDistanceMonitoring) { + Iterator var2 = this.distanceMeterCarLocatorMap.keySet().iterator(); + + while(var2.hasNext()) { + Double distance = (Double)var2.next(); + Map, CarLocator> carLocatorPerVehicleId = (Map)this.distanceMeterCarLocatorMap.get(distance); + double fs_tt = this.link.getLength() / this.link.getFreespeed(); + carLocatorPerVehicleId.put(event.getVehicleId(), new CarLocator(this.link, event.getTime() - fs_tt, distance)); + } + } + + } + + public void handleEvent(LinkLeaveEvent event) { + this.vehicleLeftLink(event.getVehicleId()); + this.volume -= this.vehicles.get(event.getVehicleId()).getType().getPcuEquivalents(); + } + + public void handleEvent(VehicleLeavesTrafficEvent event) { + this.vehicleLeftLink(event.getVehicleId()); + if (this.doAverageVehiclesPerSecondMonitoring) { + --this.totalVehicles; + this.volume -= this.vehicles.get(event.getVehicleId()).getType().getPcuEquivalents(); + } + + } + + private void vehicleLeftLink(Id vehId) { + --this.vehiclesOnLink; + if (this.doDistanceMonitoring) { + Iterator var2 = this.distanceMeterCarLocatorMap.keySet().iterator(); + + while(var2.hasNext()) { + Double distance = (Double)var2.next(); + Map, CarLocator> carLocatorPerVehicleId = (Map)this.distanceMeterCarLocatorMap.get(distance); + carLocatorPerVehicleId.remove(vehId); + } + } + + } +} diff --git a/src/main/java/org/matsim/contrib/signals/sensor/MixedTrafficLinkSensorManager.java b/src/main/java/org/matsim/contrib/signals/sensor/MixedTrafficLinkSensorManager.java new file mode 100644 index 000000000..60860e81d --- /dev/null +++ b/src/main/java/org/matsim/contrib/signals/sensor/MixedTrafficLinkSensorManager.java @@ -0,0 +1,260 @@ +package org.matsim.contrib.signals.sensor; + + +import com.google.inject.Inject; +import com.google.inject.Singleton; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.matsim.api.core.v01.Id; +import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.events.*; +import org.matsim.api.core.v01.events.handler.*; +import org.matsim.api.core.v01.network.Link; +import org.matsim.api.core.v01.network.Network; +import org.matsim.api.core.v01.population.Person; +import org.matsim.core.api.experimental.events.EventsManager; +import org.matsim.core.api.experimental.events.LaneEnterEvent; +import org.matsim.core.api.experimental.events.LaneLeaveEvent; +import org.matsim.core.api.experimental.events.handler.LaneEnterEventHandler; +import org.matsim.core.api.experimental.events.handler.LaneLeaveEventHandler; +import org.matsim.lanes.Lane; +import org.matsim.lanes.Lanes; +import org.matsim.lanes.LanesToLinkAssignment; +import org.matsim.vehicles.Vehicles; + +import java.util.HashMap; +import java.util.Map; + +@Singleton +public final class MixedTrafficLinkSensorManager implements LinkEnterEventHandler, LinkLeaveEventHandler, VehicleLeavesTrafficEventHandler, PersonEntersVehicleEventHandler, PersonDepartureEventHandler, LaneEnterEventHandler, LaneLeaveEventHandler { + private static final Logger log = LogManager.getLogger(LinkSensorManager.class); + private Map, MixedTrafficLinkSensor> linkIdSensorMap = new HashMap(); + private Map, Map, MixedTrafficLaneSensor>> linkIdLaneIdSensorMap = new HashMap(); + private final Network network; + private final Vehicles vehicles; + private Lanes laneDefinitions = null; + private Map, Id> personDepartureLinks = new HashMap(); + + @Inject + public MixedTrafficLinkSensorManager(Scenario scenario, EventsManager events) { + this.network = scenario.getNetwork(); + this.vehicles = scenario.getVehicles(); + if (scenario.getConfig().network().getLaneDefinitionsFile() != null || scenario.getConfig().qsim().isUseLanes()) { + this.laneDefinitions = scenario.getLanes(); + } + + events.addHandler(this); + } + + public void registerNumberOfCarsMonitoring(Id linkId) { + if (!this.linkIdSensorMap.containsKey(linkId)) { + Link link = (Link)this.network.getLinks().get(linkId); + if (link == null) { + throw new IllegalStateException("Link with Id " + linkId + " is not in the network, can't register sensor"); + } + + this.linkIdSensorMap.put(linkId, new MixedTrafficLinkSensor(link, vehicles.getVehicles())); + } + + } + + public void registerNumberOfCarsInDistanceMonitoring(Id linkId, Double distanceMeter) { + if (!this.linkIdSensorMap.containsKey(linkId)) { + Link link = this.network.getLinks().get(linkId); + if (link == null) { + throw new IllegalStateException("Link with Id " + linkId + " is not in the network, can't register sensor"); + } + + this.linkIdSensorMap.put(link.getId(), new MixedTrafficLinkSensor(link, vehicles.getVehicles())); + } + + ((MixedTrafficLinkSensor)this.linkIdSensorMap.get(linkId)).registerDistanceToMonitor(distanceMeter); + } + + public void registerNumberOfCarsOnLaneInDistanceMonitoring(Id linkId, Id laneId, Double distanceMeter) { + Link link = (Link)this.network.getLinks().get(linkId); + if (link == null) { + throw new IllegalStateException("Link with Id " + linkId + " is not in the network, can't register sensor"); + } else if (this.laneDefinitions != null && this.laneDefinitions.getLanesToLinkAssignments().get(linkId) != null && ((LanesToLinkAssignment)this.laneDefinitions.getLanesToLinkAssignments().get(linkId)).getLanes().get(laneId) != null) { + if (!this.linkIdLaneIdSensorMap.containsKey(linkId)) { + this.linkIdLaneIdSensorMap.put(linkId, new HashMap()); + } + + if (!((Map)this.linkIdLaneIdSensorMap.get(linkId)).containsKey(laneId)) { + Lane lane = (Lane)((LanesToLinkAssignment)this.laneDefinitions.getLanesToLinkAssignments().get(linkId)).getLanes().get(laneId); + ((Map)this.linkIdLaneIdSensorMap.get(linkId)).put(laneId, new MixedTrafficLaneSensor(link, lane, vehicles.getVehicles())); + } + + ((MixedTrafficLaneSensor)((Map)this.linkIdLaneIdSensorMap.get(linkId)).get(laneId)).registerDistanceToMonitor(distanceMeter); + } else { + throw new IllegalStateException("No data found for lane " + laneId + " on link " + linkId + " is not in the network, can't register sensor"); + } + } + + public void registerNumberOfCarsMonitoringOnLane(Id linkId, Id laneId) { + Link link = (Link)this.network.getLinks().get(linkId); + if (link == null) { + throw new IllegalStateException("Link with Id " + linkId + " is not in the network, can't register sensor"); + } else if (this.laneDefinitions != null && this.laneDefinitions.getLanesToLinkAssignments().get(linkId) != null && ((LanesToLinkAssignment)this.laneDefinitions.getLanesToLinkAssignments().get(linkId)).getLanes().get(laneId) != null) { + if (!this.linkIdLaneIdSensorMap.containsKey(linkId)) { + this.linkIdLaneIdSensorMap.put(linkId, new HashMap()); + } + + if (!((Map)this.linkIdLaneIdSensorMap.get(linkId)).containsKey(laneId)) { + Lane lane = (Lane)((LanesToLinkAssignment)this.laneDefinitions.getLanesToLinkAssignments().get(linkId)).getLanes().get(laneId); + ((Map)this.linkIdLaneIdSensorMap.get(linkId)).put(laneId, new MixedTrafficLaneSensor(link, lane, vehicles.getVehicles())); + } + + } else { + throw new IllegalStateException("No data found for lane " + laneId + " on link " + linkId + " is not in the network, can't register sensor"); + } + } + + public void registerAverageNumberOfCarsPerSecondMonitoringOnLane(Id linkId, Id laneId) { + this.registerAverageNumberOfCarsPerSecondMonitoringOnLane(linkId, laneId, 1.0D / 0.0, 1.0D / 0.0); + } + + public void registerAverageNumberOfCarsPerSecondMonitoringOnLane(Id linkId, Id laneId, double lookBackTime, double timeBucketCollectionDuration) { + Link link = (Link)this.network.getLinks().get(linkId); + if (link == null) { + throw new IllegalStateException("Link with Id " + linkId + " is not in the network, can't register sensor"); + } else if (this.laneDefinitions != null && this.laneDefinitions.getLanesToLinkAssignments().get(linkId) != null && ((LanesToLinkAssignment)this.laneDefinitions.getLanesToLinkAssignments().get(linkId)).getLanes().get(laneId) != null) { + if (!this.linkIdLaneIdSensorMap.containsKey(linkId)) { + this.linkIdLaneIdSensorMap.put(linkId, new HashMap()); + } + + if (!((Map)this.linkIdLaneIdSensorMap.get(linkId)).containsKey(laneId)) { + Lane lane = (Lane)((LanesToLinkAssignment)this.laneDefinitions.getLanesToLinkAssignments().get(linkId)).getLanes().get(laneId); + ((Map)this.linkIdLaneIdSensorMap.get(linkId)).put(laneId, new MixedTrafficLaneSensor(link, lane, vehicles.getVehicles())); + } + + ((MixedTrafficLaneSensor)((Map)this.linkIdLaneIdSensorMap.get(linkId)).get(laneId)).registerAverageVehiclesPerSecondToMonitor(lookBackTime, timeBucketCollectionDuration); + } else { + throw new IllegalStateException("No data found for lane " + laneId + " on link " + linkId + " is not in the network, can't register sensor"); + } + } + + public void registerAverageNumberOfCarsPerSecondMonitoring(Id linkId) { + this.registerAverageNumberOfCarsPerSecondMonitoring(linkId, 1.0D / 0.0, 1.0D / 0.0); + } + + public void registerAverageNumberOfCarsPerSecondMonitoring(Id linkId, double lookBackTime, double timeBucketCollectionDuration) { + if (!this.linkIdSensorMap.containsKey(linkId)) { + Link link = (Link)this.network.getLinks().get(linkId); + if (link == null) { + throw new IllegalStateException("Link with Id " + linkId + " is not in the network, can't register sensor"); + } + + this.linkIdSensorMap.put(link.getId(), new MixedTrafficLinkSensor(link, vehicles.getVehicles())); + } + + ((MixedTrafficLinkSensor)this.linkIdSensorMap.get(linkId)).registerAverageVehiclesPerSecondToMonitor(lookBackTime, timeBucketCollectionDuration); + } + + public int getNumberOfCarsOnLink(Id linkId) { + if (!this.linkIdSensorMap.containsKey(linkId)) { + throw new IllegalStateException("No sensor on link " + linkId + "! Register measurement for this link by calling one of the 'register...' methods of this class first."); + } else { + return ((MixedTrafficLinkSensor)this.linkIdSensorMap.get(linkId)).getNumberOfCarsOnLink(); + } + } + + public int getNumberOfCarsOnLane(Id linkId, Id laneId) { + if (!this.linkIdLaneIdSensorMap.containsKey(linkId)) { + throw new IllegalStateException("No sensor on link " + linkId + "! Register measurement for this link by calling one of the 'register...' methods of this class first."); + } else { + Map, MixedTrafficLaneSensor> map = (Map)this.linkIdLaneIdSensorMap.get(linkId); + if (map != null && map.containsKey(laneId)) { + return ((MixedTrafficLaneSensor)map.get(laneId)).getNumberOfCarsOnLane(); + } else { + throw new IllegalStateException("No sensor on lane " + laneId + " of link " + linkId + "! Register measurement for this link lane pair!"); + } + } + } + + public double getNumberOfCarsInDistance(Id linkId, Double distanceMeter, double timeSeconds) { + if (!this.linkIdSensorMap.containsKey(linkId)) { + throw new IllegalStateException("No sensor on link " + linkId + "! Register measurement for this link by calling one of the 'register...' methods of this class first."); + } else { + return ((MixedTrafficLinkSensor)this.linkIdSensorMap.get(linkId)).getNumberOfCarsInDistance(distanceMeter, timeSeconds); + } + } + + public double getNumberOfCarsInDistanceOnLane(Id linkId, Id laneId, Double distanceMeter, double timeSeconds) { + if (!this.linkIdLaneIdSensorMap.containsKey(linkId)) { + throw new IllegalStateException("No sensor on link " + linkId + "! Register measurement for this link by calling one of the 'register...' methods of this class first."); + } else { + Map, MixedTrafficLaneSensor> map = (Map)this.linkIdLaneIdSensorMap.get(linkId); + if (map != null && map.containsKey(laneId)) { + return ((MixedTrafficLaneSensor)map.get(laneId)).getNumberOfCarsInDistance(distanceMeter, timeSeconds); + } else { + throw new IllegalStateException("No sensor on lane " + laneId + " of link " + linkId + "! Register measurement for this link lane pair!"); + } + } + } + + public double getAverageArrivalRateOnLink(Id linkId, double now) { + return ((MixedTrafficLinkSensor)this.linkIdSensorMap.get(linkId)).getAvgVehiclesPerSecond(now); + } + + public double getAverageArrivalRateOnLane(Id linkId, Id laneId, double now) { + return ((MixedTrafficLaneSensor)((Map)this.linkIdLaneIdSensorMap.get(linkId)).get(laneId)).getAvgVehiclesPerSecond(now); + } + + public void handleEvent(LinkEnterEvent event) { + if (this.linkIdSensorMap.containsKey(event.getLinkId())) { + ((MixedTrafficLinkSensor)this.linkIdSensorMap.get(event.getLinkId())).handleEvent(event); + } + + } + + public void handleEvent(LinkLeaveEvent event) { + if (this.linkIdSensorMap.containsKey(event.getLinkId())) { + ((MixedTrafficLinkSensor)this.linkIdSensorMap.get(event.getLinkId())).handleEvent(event); + } + + } + + public void handleEvent(VehicleLeavesTrafficEvent event) { + if (this.linkIdSensorMap.containsKey(event.getLinkId())) { + ((MixedTrafficLinkSensor)this.linkIdSensorMap.get(event.getLinkId())).handleEvent(event); + } + + } + + public void handleEvent(PersonDepartureEvent event) { + this.personDepartureLinks.put(event.getPersonId(), event.getLinkId()); + } + + public void handleEvent(PersonEntersVehicleEvent event) { + if (this.linkIdSensorMap.containsKey(this.personDepartureLinks.get(event.getPersonId()))) { + ((MixedTrafficLinkSensor)this.linkIdSensorMap.get(this.personDepartureLinks.get(event.getPersonId()))).handleEvent(event); + } + + } + + public void reset(int iteration) { + this.linkIdSensorMap.clear(); + this.linkIdLaneIdSensorMap.clear(); + } + + public void handleEvent(LaneLeaveEvent event) { + if (this.linkIdLaneIdSensorMap.containsKey(event.getLinkId())) { + Map, MixedTrafficLaneSensor> map = (Map)this.linkIdLaneIdSensorMap.get(event.getLinkId()); + if (map.containsKey(event.getLaneId())) { + ((MixedTrafficLaneSensor)map.get(event.getLaneId())).handleEvent(event); + } + } + + } + + public void handleEvent(LaneEnterEvent event) { + if (this.linkIdLaneIdSensorMap.containsKey(event.getLinkId())) { + Map, MixedTrafficLaneSensor> map = (Map)this.linkIdLaneIdSensorMap.get(event.getLinkId()); + if (map.containsKey(event.getLaneId())) { + ((MixedTrafficLaneSensor)map.get(event.getLaneId())).handleEvent(event); + } + } + + } +} diff --git a/src/main/java/org/matsim/core/mobsim/qsim/qnetsimengine/DynamicHeadwayAbstractQLink.java b/src/main/java/org/matsim/core/mobsim/qsim/qnetsimengine/DynamicHeadwayAbstractQLink.java new file mode 100644 index 000000000..d536f88ee --- /dev/null +++ b/src/main/java/org/matsim/core/mobsim/qsim/qnetsimengine/DynamicHeadwayAbstractQLink.java @@ -0,0 +1,499 @@ +package org.matsim.core.mobsim.qsim.qnetsimengine; + + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Queue; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.matsim.api.core.v01.Id; +import org.matsim.api.core.v01.events.PersonEntersVehicleEvent; +import org.matsim.api.core.v01.events.PersonStuckEvent; +import org.matsim.api.core.v01.events.VehicleAbortsEvent; +import org.matsim.api.core.v01.events.VehicleLeavesTrafficEvent; +import org.matsim.api.core.v01.network.Link; +import org.matsim.api.core.v01.network.Node; +import org.matsim.api.core.v01.population.Person; +import org.matsim.core.api.experimental.events.EventsManager; +import org.matsim.core.gbl.Gbl; +import org.matsim.core.mobsim.framework.DriverAgent; +import org.matsim.core.mobsim.framework.MobsimAgent; +import org.matsim.core.mobsim.framework.MobsimDriverAgent; +import org.matsim.core.mobsim.framework.PassengerAgent; +import org.matsim.core.mobsim.framework.MobsimAgent.State; +import org.matsim.core.mobsim.qsim.interfaces.MobsimVehicle; +import org.matsim.core.mobsim.qsim.pt.TransitDriverAgent; +import org.matsim.core.mobsim.qsim.qnetsimengine.QNetsimEngineI.NetsimInternalInterface; +import org.matsim.core.mobsim.qsim.qnetsimengine.linkspeedcalculator.LinkSpeedCalculator; +import org.matsim.core.mobsim.qsim.qnetsimengine.vehicle_handler.VehicleHandler; +import org.matsim.core.network.NetworkUtils; +import org.matsim.vehicles.Vehicle; + +abstract class DynamicHeadwayAbstractQLink implements QLinkI { + private static final Logger log = LogManager.getLogger(DynamicHeadwayAbstractQLink.class); + private final Link link; + private NetElementActivationRegistry netElementActivationRegistry; + private final Map customAttributes = new HashMap(); + private final Map, QVehicle> parkedVehicles = new ConcurrentHashMap(10); + private final Map, MobsimAgent> additionalAgentsOnLink = new ConcurrentHashMap(); + private final Map, Queue> driversWaitingForCars = new LinkedHashMap(); + private final Map, MobsimDriverAgent> driversWaitingForPassengers = new LinkedHashMap(); + private final Map, Set> passengersWaitingForCars = new LinkedHashMap(); + private final Queue waitingList = new LinkedList(); + private boolean active = false; + private TransitQLink transitQLink; + private final QNodeI toQNode; + private final NetsimEngineContext context; + private final NetsimInternalInterface netsimEngine; + private final LinkSpeedCalculator linkSpeedCalculator; + private final VehicleHandler vehicleHandler; + private static int wrnCnt = 0; + private final DynamicHeadwayAbstractQLink.QLinkInternalInterface qLinkInternalInterface = new DynamicHeadwayAbstractQLink.QLinkInternalInterface(); + private final Double pcu; + + DynamicHeadwayAbstractQLink(Link link, QNodeI toNode, NetsimEngineContext context, NetsimInternalInterface netsimEngine2, LinkSpeedCalculator linkSpeedCalculator, VehicleHandler vehicleHandler, Double pcu) { + this.link = link; + this.toQNode = toNode; + this.context = context; + this.netsimEngine = netsimEngine2; + this.linkSpeedCalculator = linkSpeedCalculator; + this.vehicleHandler = vehicleHandler; + this.pcu = pcu; + } + + public QNodeI getToNode() { + return this.toQNode; + } + + private void activateLink() { + if (!this.active) { + this.netElementActivationRegistry.registerLinkAsActive(this); + this.active = true; + } + + } + + public void addParkedVehicle(MobsimVehicle vehicle, boolean isInitial) { + QVehicle qveh = (QVehicle)vehicle; + if (this.parkedVehicles.put(qveh.getId(), qveh) != null && wrnCnt < 1) { + ++wrnCnt; + log.warn("existing vehicle on link was just overwritten by other vehicle with same ID. Not clear what this means. Continuing anyways ..."); + log.warn(" This message given only once."); + } + + qveh.setCurrentLink(this.link); + if (isInitial) { + this.vehicleHandler.handleInitialVehicleArrival(qveh, this.link); + } + + } + + public final void addParkedVehicle(MobsimVehicle vehicle) { + this.addParkedVehicle(vehicle, true); + } + + final boolean letVehicleArrive(QVehicle qveh) { + if (this.vehicleHandler.handleVehicleArrival(qveh, this.getLink())) { + this.addParkedVehicle(qveh, false); + double now = this.context.getSimTimer().getTimeOfDay(); + this.context.getEventsManager().processEvent(new VehicleLeavesTrafficEvent(now, qveh.getDriver().getId(), this.link.getId(), qveh.getId(), qveh.getDriver().getMode(), 1.0D)); + this.netsimEngine.letVehicleArrive(qveh); + this.makeVehicleAvailableToNextDriver(qveh); + return true; + } else { + return false; + } + } + + public final QVehicle removeParkedVehicle(Id vehicleId) { + return (QVehicle)this.parkedVehicles.remove(vehicleId); + } + + public QVehicle getParkedVehicle(Id vehicleId) { + return (QVehicle)this.parkedVehicles.get(vehicleId); + } + + private final void addDepartingVehicle(MobsimVehicle mvehicle) { + QVehicle vehicle = (QVehicle)mvehicle; + this.waitingList.add(vehicle); + vehicle.setCurrentLink(this.getLink()); + this.activateLink(); + this.vehicleHandler.handleVehicleDeparture(vehicle, this.link); + } + + public void registerAdditionalAgentOnLink(MobsimAgent planAgent) { + this.additionalAgentsOnLink.put(planAgent.getId(), planAgent); + } + + public MobsimAgent unregisterAdditionalAgentOnLink(Id mobsimAgentId) { + return (MobsimAgent)this.additionalAgentsOnLink.remove(mobsimAgentId); + } + + public Collection getAdditionalAgentsOnLink() { + return Collections.unmodifiableCollection(this.additionalAgentsOnLink.values()); + } + + public void clearVehicles() { + double now = this.context.getSimTimer().getTimeOfDay(); + Set> stuckAgents = new HashSet(); + Iterator var4 = this.parkedVehicles.values().iterator(); + + while(true) { + QVehicle veh; + Iterator var6; + while(true) { + if (!var4.hasNext()) { + this.parkedVehicles.clear(); + var4 = this.driversWaitingForPassengers.values().iterator(); + + while(var4.hasNext()) { + MobsimAgent driver = (MobsimAgent)var4.next(); + if (!stuckAgents.contains(driver.getId())) { + stuckAgents.add(driver.getId()); + this.context.getEventsManager().processEvent(new PersonStuckEvent(now, driver.getId(), driver.getCurrentLinkId(), driver.getMode())); + this.context.getAgentCounter().incLost(); + this.context.getAgentCounter().decLiving(); + } + } + + this.driversWaitingForPassengers.clear(); + var4 = this.driversWaitingForCars.values().iterator(); + + MobsimAgent passenger; + while(var4.hasNext()) { + Queue queue = (Queue)var4.next(); + var6 = queue.iterator(); + + while(var6.hasNext()) { + passenger = (MobsimAgent)var6.next(); + if (!stuckAgents.contains(passenger.getId())) { + stuckAgents.add(passenger.getId()); + this.context.getEventsManager().processEvent(new PersonStuckEvent(now, passenger.getId(), passenger.getCurrentLinkId(), passenger.getMode())); + this.context.getAgentCounter().incLost(); + this.context.getAgentCounter().decLiving(); + } + } + } + + this.driversWaitingForCars.clear(); + var4 = this.passengersWaitingForCars.values().iterator(); + + while(var4.hasNext()) { + Set passengers = (Set)var4.next(); + var6 = passengers.iterator(); + + while(var6.hasNext()) { + passenger = (MobsimAgent)var6.next(); + if (!stuckAgents.contains(passenger.getId())) { + stuckAgents.add(passenger.getId()); + this.context.getEventsManager().processEvent(new PersonStuckEvent(now, passenger.getId(), passenger.getCurrentLinkId(), passenger.getMode())); + this.context.getAgentCounter().incLost(); + this.context.getAgentCounter().decLiving(); + } + } + } + + this.passengersWaitingForCars.clear(); + var4 = this.waitingList.iterator(); + + while(var4.hasNext()) { + veh = (QVehicle)var4.next(); + if (!stuckAgents.contains(veh.getDriver().getId())) { + stuckAgents.add(veh.getDriver().getId()); + this.context.getEventsManager().processEvent(new VehicleAbortsEvent(now, veh.getId(), veh.getCurrentLink().getId())); + this.context.getEventsManager().processEvent(new PersonStuckEvent(now, veh.getDriver().getId(), veh.getCurrentLink().getId(), veh.getDriver().getMode())); + this.context.getAgentCounter().incLost(); + this.context.getAgentCounter().decLiving(); + } + } + + this.waitingList.clear(); + return; + } + + veh = (QVehicle)var4.next(); + if (veh.getDriver() == null) { + break; + } + + if (veh.getDriver().getState() == State.LEG && !stuckAgents.contains(veh.getDriver().getId())) { + stuckAgents.add(veh.getDriver().getId()); + this.context.getEventsManager().processEvent(new VehicleAbortsEvent(now, veh.getId(), veh.getCurrentLink().getId())); + this.context.getEventsManager().processEvent(new PersonStuckEvent(now, veh.getDriver().getId(), veh.getCurrentLink().getId(), veh.getDriver().getMode())); + this.context.getAgentCounter().incLost(); + this.context.getAgentCounter().decLiving(); + break; + } + } + + var6 = veh.getPassengers().iterator(); + + while(var6.hasNext()) { + PassengerAgent passenger = (PassengerAgent)var6.next(); + if (!stuckAgents.contains(passenger.getId())) { + stuckAgents.add(passenger.getId()); + MobsimAgent mobsimAgent = (MobsimAgent)passenger; + this.context.getEventsManager().processEvent(new PersonStuckEvent(now, mobsimAgent.getId(), veh.getCurrentLink().getId(), mobsimAgent.getMode())); + this.context.getAgentCounter().incLost(); + this.context.getAgentCounter().decLiving(); + } + } + } + } + + void makeVehicleAvailableToNextDriver(QVehicle veh) { + Id vehicleId = veh.getId(); + Set passengers = (Set)this.passengersWaitingForCars.get(vehicleId); + if (passengers != null) { + List passengersToHandle = new ArrayList(passengers); + Iterator var5 = passengersToHandle.iterator(); + + while(var5.hasNext()) { + MobsimAgent passenger = (MobsimAgent)var5.next(); + this.unregisterPassengerAgentWaitingForCar(passenger, vehicleId); + this.insertPassengerIntoVehicle(passenger, vehicleId); + } + } + + Queue driversWaitingForCar = (Queue)this.driversWaitingForCars.get(veh.getId()); + boolean thereIsDriverWaiting = driversWaitingForCar != null && !driversWaitingForCar.isEmpty(); + if (thereIsDriverWaiting) { + MobsimDriverAgent driverWaitingForPassengers = (MobsimDriverAgent)this.driversWaitingForPassengers.get(((MobsimDriverAgent)driversWaitingForCar.element()).getId()); + if (driverWaitingForPassengers != null) { + return; + } + } + + if (thereIsDriverWaiting && veh.getDriver() == null) { + veh.setDriver((DriverAgent)driversWaitingForCar.remove()); + if (driversWaitingForCar.isEmpty()) { + Queue r = (Queue)this.driversWaitingForCars.remove(veh.getId()); + + assert r == driversWaitingForCar; + } + + this.removeParkedVehicle(veh.getId()); + this.letVehicleDepart(veh); + } + + } + + public final void letVehicleDepart(QVehicle vehicle) { + double now = this.context.getSimTimer().getTimeOfDay(); + MobsimDriverAgent driver = vehicle.getDriver(); + if (driver == null) { + throw new RuntimeException("Vehicle cannot depart without a driver!"); + } else { + EventsManager eventsManager = this.context.getEventsManager(); + eventsManager.processEvent(new PersonEntersVehicleEvent(now, driver.getId(), vehicle.getId())); + this.addDepartingVehicle(vehicle); + } + } + + public final boolean insertPassengerIntoVehicle(MobsimAgent passenger, Id vehicleId) { + double now = this.context.getSimTimer().getTimeOfDay(); + QVehicle vehicle = this.getParkedVehicle(vehicleId); + if (vehicle == null) { + this.registerPassengerAgentWaitingForCar(passenger, vehicleId); + return false; + } else { + boolean added = vehicle.addPassenger((PassengerAgent)passenger); + if (!added) { + Logger var10000 = log; + String var10001 = passenger.getId().toString(); + var10000.warn("Passenger " + var10001 + " could not be inserted into vehicle " + vehicleId.toString() + " since there is no free seat available!"); + return false; + } else { + ((PassengerAgent)passenger).setVehicle(vehicle); + EventsManager eventsManager = this.context.getEventsManager(); + eventsManager.processEvent(new PersonEntersVehicleEvent(now, passenger.getId(), vehicle.getId())); + return true; + } + } + } + + public QVehicle getVehicle(Id vehicleId) { + QVehicle ret = (QVehicle)this.parkedVehicles.get(vehicleId); + return ret; + } + + public final Collection getAllVehicles() { + Collection vehicles = this.getAllNonParkedVehicles(); + vehicles.addAll(this.parkedVehicles.values()); + return vehicles; + } + + public final Map getCustomAttributes() { + return this.customAttributes; + } + + void setNetElementActivationRegistry(NetElementActivationRegistry qSimEngineRunner) { + this.netElementActivationRegistry = qSimEngineRunner; + } + + public void registerDriverAgentWaitingForCar(MobsimDriverAgent agent) { + Id vehicleId = agent.getPlannedVehicleId(); + Queue queue = (Queue)this.driversWaitingForCars.get(vehicleId); + if (queue == null) { + queue = new LinkedList(); + this.driversWaitingForCars.put(vehicleId, queue); + } + + ((Queue)queue).add(agent); + } + + public void registerDriverAgentWaitingForPassengers(MobsimDriverAgent agent) { + this.driversWaitingForPassengers.put(agent.getId(), agent); + } + + public MobsimAgent unregisterDriverAgentWaitingForPassengers(Id agentId) { + return (MobsimAgent)this.driversWaitingForPassengers.remove(agentId); + } + + public void registerPassengerAgentWaitingForCar(MobsimAgent agent, Id vehicleId) { + Set passengers = (Set)this.passengersWaitingForCars.get(vehicleId); + if (passengers == null) { + passengers = new LinkedHashSet(); + this.passengersWaitingForCars.put(vehicleId, passengers); + } + + ((Set)passengers).add(agent); + } + + public MobsimAgent unregisterPassengerAgentWaitingForCar(MobsimAgent agent, Id vehicleId) { + Set passengers = (Set)this.passengersWaitingForCars.get(vehicleId); + return passengers != null && passengers.remove(agent) ? agent : null; + } + + public Set getAgentsWaitingForCar(Id vehicleId) { + Set set = (Set)this.passengersWaitingForCars.get(vehicleId); + return set != null ? Collections.unmodifiableSet(set) : null; + } + + public Link getLink() { + return this.link; + } + + boolean isActive() { + return this.active; + } + + void setActive(boolean active) { + this.active = active; + } + + Queue getWaitingList() { + return this.waitingList; + } + + TransitQLink getTransitQLink() { + return this.transitQLink; + } + + void setTransitQLink(TransitQLink transitQLink) { + this.transitQLink = transitQLink; + } + + public final DynamicHeadwayAbstractQLink.QLinkInternalInterface getInternalInterface() { + return this.qLinkInternalInterface; + } + + public Double getPCU() { + return this.pcu; + } + + public final class QLinkInternalInterface { + public QLinkInternalInterface() { + } + + public QNodeI getToNodeQ() { + return DynamicHeadwayAbstractQLink.this.toQNode; + } + + public Node getToNode() { + return DynamicHeadwayAbstractQLink.this.link.getToNode(); + } + + public double getFreespeed() { + return DynamicHeadwayAbstractQLink.this.link.getFreespeed(); + } + + public Id getId() { + return DynamicHeadwayAbstractQLink.this.link.getId(); + } + + public AbstractQLink.HandleTransitStopResult handleTransitStop(double now, QVehicle veh, TransitDriverAgent driver, Id linkId) { + return DynamicHeadwayAbstractQLink.this.transitQLink.handleTransitStop(now, veh, driver, linkId); + } + + public void addParkedVehicle(QVehicle veh) { + DynamicHeadwayAbstractQLink.this.addParkedVehicle(veh); + } + + public boolean letVehicleArrive(QVehicle veh) { + return DynamicHeadwayAbstractQLink.this.letVehicleArrive(veh); + } + + public void makeVehicleAvailableToNextDriver(QVehicle veh) { + DynamicHeadwayAbstractQLink.this.makeVehicleAvailableToNextDriver(veh); + } + + public void activateLink() { + DynamicHeadwayAbstractQLink.this.activateLink(); + } + + public double getMaximumVelocityFromLinkSpeedCalculator(QVehicle veh, double now) { + LinkSpeedCalculator linkSpeedCalculator = DynamicHeadwayAbstractQLink.this.linkSpeedCalculator; + Gbl.assertNotNull(linkSpeedCalculator); + return linkSpeedCalculator.getMaximumVelocity(veh, DynamicHeadwayAbstractQLink.this.link, now); + } + + public void setCurrentLinkToVehicle(QVehicle veh) { + veh.setCurrentLink(DynamicHeadwayAbstractQLink.this.link); + } + + public QLaneI getAcceptingQLane() { + return DynamicHeadwayAbstractQLink.this.getAcceptingQLane(); + } + + public List getOfferingQLanes() { + return DynamicHeadwayAbstractQLink.this.getOfferingQLanes(); + } + + public Node getFromNode() { + return DynamicHeadwayAbstractQLink.this.link.getFromNode(); + } + + public double getFreespeed(double now) { + return DynamicHeadwayAbstractQLink.this.link.getFreespeed(now); + } + + public int getNumberOfLanesAsInt(double now) { + return NetworkUtils.getNumberOfLanesAsInt(now, DynamicHeadwayAbstractQLink.this.link); + } + + public Link getLink() { + return DynamicHeadwayAbstractQLink.this.link; + } + } + + public static enum HandleTransitStopResult { + continue_driving, + rehandle, + accepted; + + private HandleTransitStopResult() { + } + } +} diff --git a/src/main/java/org/matsim/core/mobsim/qsim/qnetsimengine/DynamicHeadwayQNetworkFactory.java b/src/main/java/org/matsim/core/mobsim/qsim/qnetsimengine/DynamicHeadwayQNetworkFactory.java index 10124d270..8eae948de 100644 --- a/src/main/java/org/matsim/core/mobsim/qsim/qnetsimengine/DynamicHeadwayQNetworkFactory.java +++ b/src/main/java/org/matsim/core/mobsim/qsim/qnetsimengine/DynamicHeadwayQNetworkFactory.java @@ -31,13 +31,9 @@ import org.matsim.core.mobsim.qsim.qnetsimengine.linkspeedcalculator.DefaultLinkSpeedCalculator; import org.matsim.core.mobsim.qsim.qnetsimengine.linkspeedcalculator.LinkSpeedCalculator; import org.matsim.vis.snapshotwriters.SnapshotLinkWidthCalculator; -import playground.shivam.trafficChar.core.TrafficCharConfigGroup; import javax.inject.Inject; -import java.util.HashMap; -import java.util.Map; - import static org.matsim.core.mobsim.qsim.qnetsimengine.AbstractQNetsimEngine.createAgentSnapshotInfoBuilder; diff --git a/src/main/java/org/matsim/core/mobsim/qsim/qnetsimengine/DynamicHeadwayQueueWithBuffer.java b/src/main/java/org/matsim/core/mobsim/qsim/qnetsimengine/DynamicHeadwayQueueWithBuffer.java index 52ea43692..dbd452daa 100644 --- a/src/main/java/org/matsim/core/mobsim/qsim/qnetsimengine/DynamicHeadwayQueueWithBuffer.java +++ b/src/main/java/org/matsim/core/mobsim/qsim/qnetsimengine/DynamicHeadwayQueueWithBuffer.java @@ -1,25 +1,15 @@ -/* *********************************************************************** * - * project: org.matsim.* - * * - * *********************************************************************** * - * * - * copyright : (C) 2013 by the members listed in the COPYING, * - * LICENSE and WARRANTY file. * - * email : info at matsim dot org * - * * - * *********************************************************************** * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * See also COPYING, LICENSE and WARRANTY file * - * * - * *********************************************************************** */ - package org.matsim.core.mobsim.qsim.qnetsimengine; -import org.apache.log4j.Logger; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.Queue; + +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.apache.commons.lang3.tuple.Pair; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.PersonStuckEvent; @@ -27,6 +17,7 @@ import org.matsim.api.core.v01.network.Link; import org.matsim.core.api.experimental.events.LaneEnterEvent; import org.matsim.core.api.experimental.events.LaneLeaveEvent; +import org.matsim.core.config.groups.QSimConfigGroup; import org.matsim.core.config.groups.QSimConfigGroup.LinkDynamics; import org.matsim.core.config.groups.QSimConfigGroup.TrafficDynamics; import org.matsim.core.gbl.Gbl; @@ -36,7 +27,6 @@ import org.matsim.core.mobsim.qsim.interfaces.SignalGroupState; import org.matsim.core.mobsim.qsim.interfaces.SignalizeableItem; import org.matsim.core.mobsim.qsim.pt.TransitDriverAgent; -import org.matsim.core.mobsim.qsim.qnetsimengine.AbstractQLink.HandleTransitStopResult; import org.matsim.core.mobsim.qsim.qnetsimengine.QLinkImpl.LaneFactory; import org.matsim.core.mobsim.qsim.qnetsimengine.flow_efficiency.DefaultFlowEfficiencyCalculator; import org.matsim.core.mobsim.qsim.qnetsimengine.flow_efficiency.FlowEfficiencyCalculator; @@ -44,18 +34,11 @@ import org.matsim.core.mobsim.qsim.qnetsimengine.vehicleq.FIFOVehicleQ; import org.matsim.core.mobsim.qsim.qnetsimengine.vehicleq.PassingVehicleQ; import org.matsim.core.mobsim.qsim.qnetsimengine.vehicleq.VehicleQ; -import org.matsim.core.utils.misc.Time; import org.matsim.lanes.Lane; import org.matsim.vehicles.Vehicle; import org.matsim.vis.snapshotwriters.AgentSnapshotInfo; import org.matsim.vis.snapshotwriters.VisVehicle; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.Queue; - /** * Separating out the "lane" functionality from the "link" functionality. *

@@ -74,64 +57,18 @@ * @author nagel */ final class DynamicHeadwayQueueWithBuffer implements QLaneI, SignalizeableItem { - private static final Logger log = Logger.getLogger(DynamicHeadwayQueueWithBuffer.class); + private static final Logger log = LogManager.getLogger( DynamicHeadwayQueueWithBuffer.class ) ; - static final class Builder implements LaneFactory { - private VehicleQ vehicleQueue = new FIFOVehicleQ(); - private Id id = null; - private Double length = null; - private Double effectiveNumberOfLanes = null; - private Double flowCapacity_s = null; - private final NetsimEngineContext context; - private FlowEfficiencyCalculator flowEfficiencyCalculator; - - Builder(final NetsimEngineContext context) { - this.context = context; - if (context.qsimConfig.getLinkDynamics() == LinkDynamics.PassingQ || - context.qsimConfig.getLinkDynamics() == LinkDynamics.SeepageQ) { - this.vehicleQueue = new PassingVehicleQ(); - } - } - - void setVehicleQueue(VehicleQ vehicleQueue) { - this.vehicleQueue = vehicleQueue; - } - void setLaneId(Id id) { - this.id = id; - } - void setLength(Double length) { - this.length = length; - } - void setEffectiveNumberOfLanes(Double effectiveNumberOfLanes) { - this.effectiveNumberOfLanes = effectiveNumberOfLanes; - } - void setFlowCapacity_s (Double flowCapacity_s) { - this.flowCapacity_s = flowCapacity_s; - } - void setFlowEfficiencyCalculator(FlowEfficiencyCalculator flowEfficiencyCalculator) { - this.flowEfficiencyCalculator = flowEfficiencyCalculator; + @Override + public final void addFromWait(final QVehicle veh) { + //To protect against calling addToBuffer() without calling hasFlowCapacityLeft() first. + //This only could happen for addFromWait(), because it can be called from outside DynamicHeadwayQueueWithBuffer + if (flowcap_accumulate.getValue() <= 0.0 && veh.getVehicle().getType().getPcuEquivalents() > context.qsimConfig + .getPcuThresholdForFlowCapacityEasing()) { + throw new IllegalStateException("Buffer of link " + this.id + " has no space left!"); } - @Override - public DynamicHeadwayQueueWithBuffer createLane(AbstractQLink qLink) { - // a number of things I cannot configure before I have the qlink: - if (id==null) { - id = Id.create(qLink.getLink().getId(), Lane.class); - } - if (length==null) { - length = qLink.getLink().getLength(); - } - if (effectiveNumberOfLanes==null) { - effectiveNumberOfLanes = qLink.getLink().getNumberOfLanes(); - } - if (flowCapacity_s==null) { - flowCapacity_s = qLink.getLink().getFlowCapacityPerSec(); - } - if (flowEfficiencyCalculator == null) { - flowEfficiencyCalculator = new DefaultFlowEfficiencyCalculator(); - } - return new DynamicHeadwayQueueWithBuffer(qLink.getInternalInterface(), vehicleQueue, id, length, effectiveNumberOfLanes, flowCapacity_s, context, flowEfficiencyCalculator); - } + addToBuffer(veh); } /** @@ -143,8 +80,8 @@ public DynamicHeadwayQueueWithBuffer createLane(AbstractQLink qLink) { * changes. kai, sep'14 */ private static class FlowcapAccumulate { - private double timeStep = 0.;//Double.NEGATIVE_INFINITY; - private double value = 0.; + private double timeStep = 0.;//Double.NEGATIVE_INFINITY ; + private double value = 0. ; private double getTimeStep(){ return this.timeStep; } @@ -154,32 +91,33 @@ private void setTimeStep(double now) { private double getValue() { return value; } - private void setValue(double value) { + private void setValue(double value ) { this.value = value; } private void addValue(double value1, double now) { this.value += value1; - this.timeStep = now; + this.timeStep = now ; } } - private final FlowcapAccumulate flowcap_accumulate = new FlowcapAccumulate(); + private final FlowcapAccumulate flowcap_accumulate = new FlowcapAccumulate() ; // might be changed back to standard double after all of this was figured out. kai, sep'14 /** * true, i.e. green, if the link is not signalized */ - private boolean thisTimeStepGreen = true; + private boolean thisTimeStepGreen = true ; private double inverseFlowCapacityPerTimeStep; /** * The number of vehicles able to leave the buffer in one time step (usually 1s). */ private double flowCapacityPerTimeStep; - private double remainingHolesStorageCapacity = 0.0; + private double remainingHolesStorageCapacity = 0.0 ; - private final Queue holes = new LinkedList<>(); + private final Queue holes = new LinkedList<>(); /** the last time-step the front-most vehicle in the buffer was moved. Used for detecting dead-locks. */ - private double bufferLastMovedTime = Double.NEGATIVE_INFINITY ; + private double bufferLastMovedTime = Double.NEGATIVE_INFINITY ; + /** * The list of vehicles that have not yet reached the end of the link * according to the free travel speed of the link @@ -189,39 +127,54 @@ private void addValue(double value1, double now) { private double storageCapacity; private double usedStorageCapacity; /** - * Holds all vehicles that are ready to cross the outgoing intersection + * Holds all vehicles that are ready to cross the outgoing intersection and their capacity consumption.
+ * We store the capacity consumption as it is needed twice:
+ * (1) entry to the buffer (this is where it is computed and then stored)
+ * (2) update of the remaining flow capacity (where we account for all vehicles that are still in the buffer since previous time steps) - see {@link #subtractConsumptionOfVehiclesThatAreAlreadyInTheBuffer()}
*/ - private final Queue buffer = new LinkedList<>(); + private final Queue> buffer = new LinkedList<>() ; /** * null if the link is not signalized */ - private DefaultSignalizeableItem qSignalizedItem = null; + private DefaultSignalizeableItem qSignalizedItem = null ; /** * I think that it would be good to get rid of the qLink backpointer. Instead keep a reduced QLinkInternalInterface back * pointer, and give access only to reduced number of methods (in particular not the full Link information). kai, feb'18 * This is now done with the {@link AbstractQLink.QLinkInternalInterface}. kai, feb'18 */ - private final AbstractQLink.QLinkInternalInterface qLink; + private final DynamicHeadwayAbstractQLink.QLinkInternalInterface qLink; private final Id id; private static int spaceCapWarningCount = 0; final static double HOLE_SPEED_KM_H = 15.0; - private final double length; - private double unscaledFlowCapacity_s; - private double effectiveNumberOfLanes; + private final double length ; + private double unscaledFlowCapacity_s = Double.NaN ; + private double effectiveNumberOfLanes = Double.NaN ; + private double pcu; + /** + * Points to the latest vehicle that entered the buffer and the entry time. + */ + private Pair lastBufferEntry = null; - private final VisData visData = new VisDataImpl(); + /** + * Points to the latest vehicle that entered the queue and the entry time. + */ + private Pair lastQueueEntry = null; + + + private final VisData visData = new VisDataImpl() ; private final NetsimEngineContext context; - private double maxFlowFromFdiag = Double.POSITIVE_INFINITY; + private double maxInflowUsedInQsim = Double.POSITIVE_INFINITY ; + private double effectiveNumberOfLanesUsedInQsim = Double.POSITIVE_INFINITY ; - private double accumulatedInflowCap = 1.; + private double accumulatedInflowCap = 1. ; private final FlowEfficiencyCalculator flowEfficiencyCalculator; - private DynamicHeadwayQueueWithBuffer(AbstractQLink.QLinkInternalInterface qlink, final VehicleQ vehicleQueue, Id laneId, - double length, double effectiveNumberOfLanes, double flowCapacity_s, final NetsimEngineContext context, - FlowEfficiencyCalculator flowEfficiencyCalculator) { + private DynamicHeadwayQueueWithBuffer(DynamicHeadwayAbstractQLink.QLinkInternalInterface qlink, final VehicleQ vehicleQueue, Id laneId, + double length, double effectiveNumberOfLanes, double flowCapacity_s, final NetsimEngineContext context, + FlowEfficiencyCalculator flowEfficiencyCalculator) { // the general idea is to give this object no longer access to "everything". Objects get back pointers (here qlink), but they // do not present the back pointer to the outside. In consequence, this object can go up to qlink, but not any further. kai, mar'16 // Now I am even trying to get rid of the full qLink back pointer (since it allows, e.g., going back to Link). kai, feb'18 @@ -230,11 +183,11 @@ private DynamicHeadwayQueueWithBuffer(AbstractQLink.QLinkInternalInterface qlink this.flowEfficiencyCalculator = flowEfficiencyCalculator; this.qLink = qlink; - this.id = laneId; - this.context = context; - this.vehQueue = vehicleQueue; + this.id = laneId ; + this.context = context ; + this.vehQueue = vehicleQueue ; this.length = length; - this.unscaledFlowCapacity_s = flowCapacity_s; + this.unscaledFlowCapacity_s = flowCapacity_s ; this.effectiveNumberOfLanes = effectiveNumberOfLanes; // freespeedTravelTime = this.length / qlink.getLink().getFreespeed(); @@ -245,36 +198,21 @@ private DynamicHeadwayQueueWithBuffer(AbstractQLink.QLinkInternalInterface qlink this.calculateStorageCapacity(); flowcap_accumulate.setValue(flowCapacityPerTimeStep); - - if (context.qsimConfig.getTimeStepSize() < 1.) { - throw new RuntimeException("yyyy This will produce weird results because in at least one place " - + "(addFromUpstream(...)) everything is pulled to integer values. Aborting ... " - + "(This statement may no longer be correct; I think that the incriminating code was modified. So please test and remove" - + " the warning if it works. kai, sep'14"); - } - - } - - @Override - public final void addFromWait(final QVehicle veh) { - //To protect against calling addToBuffer() without calling hasFlowCapacityLeft() first. - //This only could happen for addFromWait(), because it can be called from outside QueueWithBuffer - if (flowcap_accumulate.getValue() <= 0.0 && veh.getVehicle().getType().getPcuEquivalents() > context.qsimConfig - .getPcuThresholdForFlowCapacityEasing()) { - throw new IllegalStateException("Buffer of link " + this.id + " has no space left!"); - } - - addToBuffer(veh); } private void addToBuffer(final QVehicle veh) { // yy might make sense to just accumulate to "zero" and go into negative when something is used up. // kai/mz/amit, mar'12 - double now = context.getSimTimer().getTimeOfDay(); - flowcap_accumulate.addValue(-getFlowCapacityConsumptionInEquivalents(veh), now); + double now = context.getSimTimer().getTimeOfDay() ; + + double flowConsumption = (lastBufferEntry == null) ? + getFlowCapacityConsumptionInEquivalents(veh, null, null) : getFlowCapacityConsumptionInEquivalents(veh, lastBufferEntry.getKey(), now - lastBufferEntry.getValue()); + this.flowcap_accumulate.addValue(-flowConsumption, now); + + buffer.add(new ImmutablePair<>(veh,flowConsumption)); + lastBufferEntry = new ImmutablePair<>(veh,now); - buffer.add(veh); if (buffer.size() == 1) { bufferLastMovedTime = now; // (if there is one vehicle in the buffer now, there were zero vehicles in the buffer before. in consequence, @@ -282,72 +220,147 @@ private void addToBuffer(final QVehicle veh) { // use the lastMovedTime that was (somehow) computed for that vehicle.) } final QNodeI toNode = qLink.getToNodeQ(); - if (toNode instanceof QNodeImpl) { - ((QNodeImpl) toNode).activateNode(); + if ( toNode instanceof AbstractQNode ) { + ((AbstractQNode) toNode).activateNode(); // yy for an "upstream" QLane, this activates the toNode too early. Yet I think I founds this // also in the original QLane code. kai, sep'13 } + + } + + /** + * Move vehicles from link to buffer, according to buffer capacity and + * departure time of vehicle. Also removes vehicles from lane if the vehicle + * arrived at its destination. + */ + private void moveQueueToBuffer() { + double now = context.getSimTimer().getTimeOfDay(); + + QVehicle veh; + while ((veh = peekFromVehQueue()) != null) { + //we have an original QueueLink behaviour + if (veh.getEarliestLinkExitTime() > now) { + return; + } + + MobsimDriverAgent driver = veh.getDriver(); + + if (driver instanceof TransitDriverAgent) { + AbstractQLink.HandleTransitStopResult handleTransitStop = qLink.handleTransitStop( + now, veh, (TransitDriverAgent) driver, this.qLink.getId() + ); + if (handleTransitStop == AbstractQLink.HandleTransitStopResult.accepted) { + // vehicle has been accepted into the transit vehicle queue of the link. + removeVehicleFromQueue(veh); + continue; + } else if (handleTransitStop == AbstractQLink.HandleTransitStopResult.rehandle) { + continue; // yy why "continue", and not "break" or "return"? Seems to me that this + // is currently only working because qLink.handleTransitStop(...) also increases the + // earliestLinkExitTime for the present vehicle. kai, oct'13 + // zz From my point of view it is exactly like described above. dg, mar'14 +// } else if (handleTransitStop == HandleTransitStopResult.continue_driving) { + // Do nothing, but go on.. + } + } + + // Check if veh has reached destination: + if (driver.isWantingToArriveOnCurrentLink()) { + if (qLink.letVehicleArrive(veh)) { + // remove _after_ processing the arrival to keep link active: + removeVehicleFromQueue(veh); + continue; + } else { // The current vehicle is not allowed to arrive, so it will block the link + return; + } + } + + /* is there still any flow capacity left? */ + if (!hasFlowCapacityLeft(veh)) { + return; + } + + removeVehicleFromQueue(veh); + addToBuffer(veh); //isn't prevVehicle always equal to veh here!? + + if (context.qsimConfig.isRestrictingSeepage() + && context.qsimConfig.getLinkDynamics() == LinkDynamics.SeepageQ + && context.qsimConfig.getSeepModes().contains(veh.getDriver().getMode())) { + noOfSeepModeBringFwd++; + } + } // end while } @Override public final boolean isAcceptingFromWait(QVehicle veh) { - return this.hasFlowCapacityLeft(veh); + return this.hasFlowCapacityLeft(veh) ; } private boolean hasFlowCapacityLeft(VisVehicle veh) { - if(context.qsimConfig.isUsingFastCapacityUpdate()){ + if(context.qsimConfig.isUsingFastCapacityUpdate() ){ updateFastFlowAccumulation(); } - return flowcap_accumulate.getValue() > 0.0 || veh.getVehicle().getType().getPcuEquivalents() <= context.qsimConfig.getPcuThresholdForFlowCapacityEasing(); + return flowcap_accumulate.getValue() > 0.0 || veh.getVehicle().getType() + .getPcuEquivalents() <= context.qsimConfig.getPcuThresholdForFlowCapacityEasing(); } private void updateFastFlowAccumulation(){ - double now = context.getSimTimer().getTimeOfDay(); + double now = context.getSimTimer().getTimeOfDay() ; + + double remainingFlowCapThisTimeStep = subtractConsumptionOfVehiclesThatAreAlreadyInTheBuffer(); - if(this.flowcap_accumulate.getTimeStep() < now - && this.flowcap_accumulate.getValue() < flowCapacityPerTimeStep - && isNotOfferingVehicle()){ + if( this.flowcap_accumulate.getTimeStep() < now + && this.flowcap_accumulate.getValue() < remainingFlowCapThisTimeStep){ double timeSteps = (now - flowcap_accumulate.getTimeStep()) / context.qsimConfig.getTimeStepSize(); double accumulateFlowCap = timeSteps * flowCapacityPerTimeStep; double newFlowCap = Math.min(flowcap_accumulate.getValue() + accumulateFlowCap, - flowCapacityPerTimeStep); + remainingFlowCapThisTimeStep); flowcap_accumulate.setValue(newFlowCap); - flowcap_accumulate.setTimeStep(now); + flowcap_accumulate.setTimeStep( now ); } } private void updateSlowFlowAccumulation(){ + double remainingFlowCapThisTimeStep = subtractConsumptionOfVehiclesThatAreAlreadyInTheBuffer(); + if (this.thisTimeStepGreen - && this.flowcap_accumulate.getValue() < flowCapacityPerTimeStep - && isNotOfferingVehicle()){ + && this.flowcap_accumulate.getValue() < remainingFlowCapThisTimeStep){ double newFlowCap = Math.min(flowcap_accumulate.getValue() + flowCapacityPerTimeStep, - flowCapacityPerTimeStep); + remainingFlowCapThisTimeStep); flowcap_accumulate.setValue(newFlowCap); } } + private double subtractConsumptionOfVehiclesThatAreAlreadyInTheBuffer() { + double remainingFlowCapThisTimeStep = flowCapacityPerTimeStep; + for (Pair vehEfficiencyPair : buffer) { + // Subtract size of vehicles that are already in the buffer (from previous time steps) + remainingFlowCapThisTimeStep -= vehEfficiencyPair.getValue(); + } + return remainingFlowCapThisTimeStep; + } + @Override public final void initBeforeSimStep() { - if(!context.qsimConfig.isUsingFastCapacityUpdate()){ + if(!context.qsimConfig.isUsingFastCapacityUpdate() ){ updateSlowFlowAccumulation(); } } - private static int wrnCnt=0; + private static int wrnCnt=0 ; private void calculateFlowCapacity() { // the following is not looking at time because it simply assumes that the lookups are "now". kai, feb'18 // I am currently not sure if this statement is correct. kai, feb'18 - double now = context.getSimTimer().getTimeOfDay(); - - flowCapacityPerTimeStep = this.unscaledFlowCapacity_s; -// flowCapacityPerTimeStep = this.qLink.getLink().getFlowCapacityPerSec(now); // we need the flow capacity per sim-tick and multiplied with flowCapFactor - flowCapacityPerTimeStep = flowCapacityPerTimeStep * context.qsimConfig.getTimeStepSize() * context.qsimConfig.getFlowCapFactor(); + flowCapacityPerTimeStep = unscaledFlowCapacity_s * context.qsimConfig.getTimeStepSize() * context.qsimConfig.getFlowCapFactor() ; inverseFlowCapacityPerTimeStep = 1.0 / flowCapacityPerTimeStep; + // start with the base assumption, might be adjusted below depending on the traffic dynamics + this.effectiveNumberOfLanesUsedInQsim = this.effectiveNumberOfLanes; + this.maxInflowUsedInQsim = this.flowCapacityPerTimeStep; + switch (context.qsimConfig.getTrafficDynamics()) { case queue: case withHoles: @@ -357,35 +370,87 @@ private void calculateFlowCapacity() { // congested branch: q = vhole * (rhojam - rho) // equal: rho * (vmax + vhole) = vhole * rhojam // rho(qmax) = vhole * rhojam / (vmax + vhole) - // qmax = vmax * rho(qmax) = rhojam / (1/vhole + 1/vmax); - this.maxFlowFromFdiag = (1/context.effectiveCellSize) / (1./(HOLE_SPEED_KM_H/3.6) + 1/this.qLink.getFreespeed()); + // qmax = vmax * rho(qmax) = rhojam / (1/vhole + 1/vmax) ; + // yyyyyy this should possibly be getFreespeed(now). But if that's the case, then maxFlowFromFdiag would // also have to be re-computed with each freespeed change. kai, feb'18 - if (this.maxFlowFromFdiag < flowCapacityPerTimeStep && wrnCnt<10) { - wrnCnt++; - log.warn("max flow from fdiag < requested flow cap; linkId=" + qLink.getId() + - "; req flow cap/h=" + 3600.*flowCapacityPerTimeStep/context.qsimConfig.getTimeStepSize() + - "; max flow from fdiag/h=" + 3600*maxFlowFromFdiag/context.qsimConfig.getTimeStepSize()); - if (wrnCnt==10) { - log.warn(Gbl.FUTURE_SUPPRESSED); + + final double maxFlowFromFdiag = (this.effectiveNumberOfLanes/context.effectiveCellSize) / ( 1./(HOLE_SPEED_KM_H/3.6) + 1/this.qLink.getFreespeed() ) ; + final double minimumNumberOfLanesFromFdiag = this.flowCapacityPerTimeStep * context.effectiveCellSize * ( 1./(HOLE_SPEED_KM_H/3.6) + 1/this.qLink.getFreespeed() ); + + QSimConfigGroup.InflowCapacitySetting inflowCapacitySetting = context.qsimConfig.getInflowCapacitySetting(); + + if(inflowCapacitySetting == QSimConfigGroup.InflowCapacitySetting.MAX_CAP_FOR_ONE_LANE){ + if (wrnCnt<10) { + wrnCnt++ ; + log.warn("you are using the maximum capacity for one lane as the inflow capacity. This is the old standard behavior of the qsim and probably leads to wrong results " + + " as it does not respect the actual number of lanes nor the user-defined flow capacity. Please consider using" + + "InflowCapacitySetting.INCREASE_NUMBER_OF_LANES or InflowCapacitySetting.REDUCE_INFLOW_CAPACITY instead."); + } + if ( wrnCnt==5 ) { //this verbose warning is only given 5 times + log.warn( Gbl.FUTURE_SUPPRESSED ) ; + } + + this.maxInflowUsedInQsim = (1/context.effectiveCellSize) / ( 1./(HOLE_SPEED_KM_H/3.6) + 1/this.qLink.getFreespeed() ) ; + // write out the modified qsim behavior as link attribute + qLink.getLink().getAttributes().putAttribute("maxInflowUsedInQsim", 3600* maxInflowUsedInQsim /context.qsimConfig.getTimeStepSize()); + + } else { + if ( maxFlowFromFdiag < flowCapacityPerTimeStep ){ //warnings + if (wrnCnt<10) { + wrnCnt++ ; + log.warn( "max flow from fdiag < flow cap in network file; linkId=" + qLink.getId() + + "; network file flow cap/h=" + 3600.*flowCapacityPerTimeStep/context.qsimConfig.getTimeStepSize() + + "; max flow from fdiag/h=" + 3600*maxFlowFromFdiag/context.qsimConfig.getTimeStepSize() ) ; + + log.warn( "number of lanes from fdiag > number of lanes in network file; linkId=" + qLink.getId() + + "; number of lanes in network file=" + this.effectiveNumberOfLanes + + "; number of lanes from fdiag=" + minimumNumberOfLanesFromFdiag ) ; + + if ( wrnCnt==10 ) { + log.warn( Gbl.FUTURE_SUPPRESSED ) ; + } + } + if (inflowCapacitySetting == QSimConfigGroup.InflowCapacitySetting.INFLOW_FROM_FDIAG) { + if (wrnCnt<10) { + log.warn("The flow capacity will be reduced. See link attribute 'maxInflowUsedInQsim' written into the output network."); + } + } else if (inflowCapacitySetting == QSimConfigGroup.InflowCapacitySetting.NR_OF_LANES_FROM_FDIAG) { + if (wrnCnt<10) { + log.warn("The number of lanes will be increased. See link attribute 'effectiveNumberOfLanesUsedInQsim' written into the output network."); + } + } + } + // now either correct the flow capacity or the number of lanes! + if (inflowCapacitySetting == QSimConfigGroup.InflowCapacitySetting.INFLOW_FROM_FDIAG) { + this.maxInflowUsedInQsim = maxFlowFromFdiag; + // write out the modified qsim behavior as link attribute + qLink.getLink().getAttributes().putAttribute("maxInflowUsedInQsim", 3600* maxInflowUsedInQsim /context.qsimConfig.getTimeStepSize()); + } else if (inflowCapacitySetting == QSimConfigGroup.InflowCapacitySetting.NR_OF_LANES_FROM_FDIAG) { + this.effectiveNumberOfLanesUsedInQsim = minimumNumberOfLanesFromFdiag; + // write out the modified qsim behavior as link attribute + qLink.getLink().getAttributes().putAttribute("effectiveNumberOfLanesUsedInQsim", effectiveNumberOfLanesUsedInQsim); + } else { + throw new RuntimeException("The approach "+ inflowCapacitySetting.toString()+" is not implemented yet."); } } break; + default: throw new RuntimeException("The traffic dynamics "+context.qsimConfig.getTrafficDynamics()+" is not implemented yet."); } -// log.debug("linkId=" + this.qLink.getLink().getId() + "; flowCapPerTimeStep=" + flowCapacityPerTimeStep + -// "; invFlowCapPerTimeStep=" + inverseFlowCapacityPerTimeStep + "; maxFlowFromFdiag=" + maxFlowFromFdiag); +// log.debug( "linkId=" + this.qLink.getLink().getId() + "; flowCapPerTimeStep=" + flowCapacityPerTimeStep + +// "; invFlowCapPerTimeStep=" + inverseFlowCapacityPerTimeStep + "; maxFlowFromFdiag=" + maxFlowFromFdiag ) ; } private void calculateStorageCapacity() { // The following is not adjusted for time-dependence!! kai, apr'16 // No, I think that it simply assumes that the lookups are "now". kai, feb'18 - double now = context.getSimTimer().getTimeOfDay(); +// double now = context.getSimTimer().getTimeOfDay() ; // first guess at storageCapacity: - storageCapacity = this.length * this.effectiveNumberOfLanes / context.effectiveCellSize * context.qsimConfig.getStorageCapFactor(); -// storageCapacity = this.length * this.qLink.getLink().getNumberOfLanes(now) / context.effectiveCellSize * context.qsimConfig.getStorageCapFactor(); + storageCapacity = this.length * this.effectiveNumberOfLanesUsedInQsim / context.effectiveCellSize * context.qsimConfig.getStorageCapFactor() ; +// storageCapacity = this.length * this.qLink.getLink().getNumberOfLanes(now) / context.effectiveCellSize * context.qsimConfig.getStorageCapFactor() ; // storage capacity needs to be at least enough to handle the cap_per_time_step: storageCapacity = Math.max(storageCapacity, getBufferStorageCapacity()); @@ -393,7 +458,7 @@ private void calculateStorageCapacity() { /* * If speed on link is relatively slow, then we need MORE cells than the above spaceCap to handle the flowCap. * Example: Assume freeSpeedTravelTime (aka freeTravelDuration) is 2 seconds. Than we need the spaceCap = TWO - * times the flowCap to handle the flowCap. + * times the flowCap per second to handle the flowCap. * * Will base these computations (for the time being) on the standard free speed; i.e. reductions in free speed * will also reduce the maximum flow. @@ -404,7 +469,9 @@ private void calculateStorageCapacity() { if (Double.isNaN(freespeedTravelTime)) { throw new IllegalStateException("Double.NaN is not a valid freespeed travel time for a link. Please check the attributes length and freespeed!"); } - double tempStorageCapacity = freespeedTravelTime * flowCapacityPerTimeStep; + + //this assumes that vehicles have the flowEfficiencyFactor of 1.0; the actual flow can be different + double tempStorageCapacity = freespeedTravelTime * unscaledFlowCapacity_s * context.qsimConfig.getFlowCapFactor(); // yy note: freespeedTravelTime may be Inf. In this case, storageCapacity will also be set to Inf. This can still be // interpreted, but it means that the link will act as an infinite sink. kai, nov'10 @@ -418,15 +485,18 @@ private void calculateStorageCapacity() { DynamicHeadwayQueueWithBuffer.spaceCapWarningCount++; } storageCapacity = tempStorageCapacity; + + // write out the modified qsim behavior as link attribute + qLink.getLink().getAttributes().putAttribute("storageCapacityUsedInQsim", storageCapacity); } /* About minStorCapForHoles: * () uncongested branch is q(rho) = rho * v_max * () congested branch is q(rho) = (rho - rho_jam) * v_holes - * () rho_maxflow is where these two meet, resulting in rho_maxflow = v_holes * rho_jam / (v_holes + v_max) - * () max flow is q(rho_maxflow), resulting in v_max * v_holes * rho_jam / (v_holes + v_max) + * () rho_maxflow is where these two meet, resulting in rho_maxflow = v_holes * rho_jam / ( v_holes + v_max ) + * () max flow is q(rho_maxflow), resulting in v_max * v_holes * rho_jam / ( v_holes + v_max ) * () Since everything else is given, rho_jam needs to be large enough so that q(rho_maxflow) can reach capacity, resulting in - * rho_jam >= capacity * (v_holes + v_max) / (v_max * v_holes); + * rho_jam >= capacity * (v_holes + v_max) / (v_max * v_holes) ; * () In consequence, storage capacity needs to be larger than curved_length * rho_jam . * */ @@ -437,19 +507,21 @@ private void calculateStorageCapacity() { case withHoles: case kinematicWaves: // final double minStorCapForHoles = 2. * flowCapacityPerTimeStep * context.getSimTimer().getSimTimestepSize(); - final double freeSpeed = qLink.getFreespeed(); // yyyyyy not clear why this is not time-dep. kai, feb'18 + final double freeSpeed = qLink.getFreespeed() ; // yyyyyy not clear why this is not time-dep. kai, feb'18 final double holeSpeed = HOLE_SPEED_KM_H/3.6; - final double minStorCapForHoles = length * flowCapacityPerTimeStep * (freeSpeed + holeSpeed) / freeSpeed / holeSpeed; - // final double minStorCapForHoles = 2.* length * flowCapacityPerTimeStep * (freeSpeed + holeSpeed) / freeSpeed / holeSpeed; + final double minStorCapForHoles = length * flowCapacityPerTimeStep * (freeSpeed + holeSpeed) / freeSpeed / holeSpeed ; + // final double minStorCapForHoles = 2.* length * flowCapacityPerTimeStep * (freeSpeed + holeSpeed) / freeSpeed / holeSpeed ; // I have no idea why the factor 2 needs to be there?!?! kai, apr'16 // I just removed the factor of 2 ... seems to work now without. kai, may'16 // yyyyyy (not thought through for TS != 1sec! (should use flow cap per second) kai, apr'16) - if (storageCapacity < minStorCapForHoles) { - if (spaceCapWarningCount <= 10) { - log.warn("storage capacity not sufficient for holes; increasing from " + storageCapacity + " to " + minStorCapForHoles); + if ( storageCapacity < minStorCapForHoles ) { + if ( spaceCapWarningCount <= 10 ) { + log.warn("storage capacity not sufficient for holes; increasing from " + storageCapacity + " to " + minStorCapForHoles ) ; DynamicHeadwayQueueWithBuffer.spaceCapWarningCount++; } - storageCapacity = minStorCapForHoles; + storageCapacity = minStorCapForHoles ; + // write out the modified qsim behavior as link attribute + qLink.getLink().getAttributes().putAttribute("storageCapacityUsedInQsim", storageCapacity); } remainingHolesStorageCapacity = this.storageCapacity; @@ -462,111 +534,95 @@ private void calculateStorageCapacity() { } private double getBufferStorageCapacity() { - return flowCapacityPerTimeStep;//this assumes that vehicles have the flowEfficiencyFactor of 1.0 + return flowCapacityPerTimeStep;//this assumes that vehicles have the flowEfficiencyFactor of 1.0 } @Override - public final boolean doSimStep() { + public final boolean doSimStep( ) { switch (context.qsimConfig.getTrafficDynamics()) { case queue: break; case withHoles: - this.processArrivalOfHoles(); + this.processArrivalOfHoles( ) ; break; case kinematicWaves: - this.accumulatedInflowCap = Math.min(accumulatedInflowCap + maxFlowFromFdiag, maxFlowFromFdiag); - this.processArrivalOfHoles(); + this.accumulatedInflowCap = Math.min(accumulatedInflowCap + maxInflowUsedInQsim, maxInflowUsedInQsim); + this.processArrivalOfHoles( ) ; break; - default: throw new RuntimeException("The traffic dynmics " + context.qsimConfig.getTrafficDynamics() + " is not implemented yet."); + default: throw new RuntimeException("The traffic dynmics "+context.qsimConfig.getTrafficDynamics()+" is not implemented yet."); } this.moveQueueToBuffer(); - return true; + return true ; } private void processArrivalOfHoles() { - double now = context.getSimTimer().getTimeOfDay(); - while (this.holes.size()>0 && this.holes.peek().getEarliestLinkExitTime() < now) { - Hole hole = this.holes.poll(); // ??? + double now = context.getSimTimer().getTimeOfDay() ; + while ( this.holes.size()>0 && this.holes.peek().getEarliestLinkExitTime() < now ) { + QueueWithBuffer.Hole hole = this.holes.poll(); // ??? this.remainingHolesStorageCapacity += hole.getSizeInEquivalents(); } } - /** - * Move vehicles from link to buffer, according to buffer capacity and - * departure time of vehicle. Also removes vehicles from lane if the vehicle - * arrived at its destination. - */ - private void moveQueueToBuffer() { + @Override + public final void addFromUpstream(final QVehicle veh) { double now = context.getSimTimer().getTimeOfDay(); - QVehicle veh; - while((veh = peekFromVehQueue()) !=null){ - //we have an original QueueLink behaviour - if (veh.getEarliestLinkExitTime() > now){ - return; + if (this.context.qsimConfig.isUseLanes()) { + if (hasMoreThanOneLane()) { + this.context.getEventsManager().processEvent(new LaneEnterEvent(now, veh.getId(), this.qLink.getId(), this.getId())); } + } - MobsimDriverAgent driver = veh.getDriver(); + // activate link since there is now action on it: + qLink.activateLink(); - if (driver instanceof TransitDriverAgent) { - HandleTransitStopResult handleTransitStop = qLink.handleTransitStop( - now, veh, (TransitDriverAgent) driver, this.qLink.getId() - ); - if (handleTransitStop == HandleTransitStopResult.accepted) { - // vehicle has been accepted into the transit vehicle queue of the link. - removeVehicleFromQueue(veh); - continue; - } else if (handleTransitStop == HandleTransitStopResult.rehandle) { - continue; // yy why "continue", and not "break" or "return"? Seems to me that this - // is currently only working because qLink.handleTransitStop(...) also increases the - // earliestLinkExitTime for the present vehicle. kai, oct'13 - // zz From my point of view it is exactly like described above. dg, mar'14 -// } else if (handleTransitStop == HandleTransitStopResult.continue_driving) { - // Do nothing, but go on.. - } - } + if (context.qsimConfig.isSeepModeStorageFree() && context.qsimConfig.getSeepModes().contains(veh.getVehicle().getType().getId().toString())) { + // do nothing + } else { + usedStorageCapacity += veh.getSizeInEquivalents(); + } - // Check if veh has reached destination: - if ((driver.isWantingToArriveOnCurrentLink())) { - letVehicleArrive(veh); - continue; - } + // compute and set earliest link exit time: +// double linkTravelTime = this.length / this.linkSpeedCalculator.getMaximumVelocity(veh, qLink.getLink(), now); + double linkTravelTime = this.length / this.qLink.getMaximumVelocityFromLinkSpeedCalculator(veh, now); + linkTravelTime = context.qsimConfig.getTimeStepSize() * Math.floor(linkTravelTime / context.qsimConfig.getTimeStepSize()); - /* is there still any flow capacity left? */ - if (!hasFlowCapacityLeft(veh)) { - return; - } + veh.setEarliestLinkExitTime(now + linkTravelTime); - // check for headways - if (! moveVehicleBasedOnHeadway(veh)){ - return; - } + // In theory, one could do something like + // final double discretizedEarliestLinkExitTime = timeStepSize * Math.ceil(veh.getEarliestLinkExitTime()/timeStepSize); + // double effectiveEntryTime = now - ( discretizedEarliestLinkExitTime - veh.getEarliestLinkExitTime() ) ; + // double earliestExitTime = effectiveEntryTime + linkTravelTime; + // We decided against this since this would effectively move the simulation to operating on true floating point time steps. For example, + // events could then have arbitrary floating point values (assuming one would use the "effectiveEntryTime" also for the event). + // Also, it could happen that vehicles with an earlier link exit time could be + // inserted and thus end up after vehicles with a later link exit time. theresa & kai, jun'14 - addToBuffer(veh); - removeVehicleFromQueue(veh); - if(context.qsimConfig.isRestrictingSeepage() - && context.qsimConfig.getLinkDynamics()==LinkDynamics.SeepageQ - && context.qsimConfig.getSeepModes().contains(veh.getDriver().getMode())) { - noOfSeepModeBringFwd++; - } - } // end while - } +// veh.setCurrentLink(qLink.getLink()); + this.qLink.setCurrentLinkToVehicle(veh); + vehQueue.add(veh); - private double lastVehMoveTime = 0.; - private boolean moveVehicleBasedOnHeadway(QVehicle veh){ - double now = context.getSimTimer().getTimeOfDay(); - boolean test = true; -// boolean test = (now-lastVehMoveTime) >= (double) ((AttributableVehicle)veh.getVehicle()).getAttributes().getAttribute("headway"); - if (test){ - lastVehMoveTime = now; - return true; + switch (context.qsimConfig.getTrafficDynamics()) { + case queue: + break; + case withHoles: + this.remainingHolesStorageCapacity -= veh.getSizeInEquivalents(); + break; + case kinematicWaves: + this.remainingHolesStorageCapacity -= veh.getSizeInEquivalents(); + double flowConsumption = (lastQueueEntry == null) ? + getFlowCapacityConsumptionInEquivalents(veh, null, null) : getFlowCapacityConsumptionInEquivalents(veh, lastQueueEntry.getKey(), now - lastQueueEntry.getValue()); + this.accumulatedInflowCap -= flowConsumption; + break; + default: + throw new RuntimeException("The traffic dynamics " + context.qsimConfig.getTrafficDynamics() + " is not implemented yet."); } -// return false; - throw new RuntimeException("Part of the code is commented at multiple places, thus, this functionality might not work. Find comments related to attributable vehicles, fix them first."); + + lastQueueEntry = new ImmutablePair<>(veh, now); } private void removeVehicleFromQueue(final QVehicle veh2Remove) { - double now = context.getSimTimer().getTimeOfDay(); + double now = context.getSimTimer().getTimeOfDay() ; // QVehicle veh = vehQueue.poll(); @@ -576,7 +632,7 @@ private void removeVehicleFromQueue(final QVehicle veh2Remove) { if(context.qsimConfig.getLinkDynamics()==LinkDynamics.SeepageQ && context.qsimConfig.isSeepModeStorageFree() - && context.qsimConfig.getSeepModes().contains(veh.getVehicle().getType().getId().toString())){ + && context.qsimConfig.getSeepModes().contains(veh.getVehicle().getType().getId().toString()) ){ // do nothing } else { usedStorageCapacity -= veh.getSizeInEquivalents(); @@ -587,56 +643,47 @@ private void removeVehicleFromQueue(final QVehicle veh2Remove) { break; case withHoles: case kinematicWaves: - DynamicHeadwayQueueWithBuffer.Hole hole = new DynamicHeadwayQueueWithBuffer.Hole(); - double ttimeOfHoles = length*3600./HOLE_SPEED_KM_H/1000.; - - // double offset = this.storageCapacity/this.flowCapacityPerTimeStep; - /* NOTE: Start with completely full link, i.e. N_storageCap cells filled. Now make light at end of link green, discharge with - * flowCapPerTS. After N_storageCap/flowCapPerTS, the link is empty. Which also means that the holes must have reached - * the upstream end of the link. I.e. speed_holes = length / (N_storageCap/flowCap) and - * ttime_holes = lenth/speed = N_storCap/flowCap. - * Say length=75m, storCap=10, flowCap=1/2sec. offset = 20sec. 75m/20sec = 225m/1min = 13.5km/h so this is normal. - * Say length=75m, storCap=20, flowCap=1/2sec. offset = 40sec. ... = 6.75km/h ... to low. Reason: unphysical parameters. - * (Parameters assume 2-lane road, which should have discharge of 1/sec. Or we have lots of tuk tuks, which have only half a vehicle - * length. Thus we incur the reaction time twice as often --> half speed of holes. - */ - - // double nLanes = 2. * flowCapacityPerTimeStep; // pseudo-lanes - // double ttimeOfHoles = 0.1 * this.storageCapacity/this.flowCapacityPerTimeStep/nLanes; - - hole.setEarliestLinkExitTime(now + 1.0*ttimeOfHoles + 0.0*MatsimRandom.getRandom().nextDouble()*ttimeOfHoles); + QueueWithBuffer.Hole hole = new QueueWithBuffer.Hole() ; + double ttimeOfHoles = length*3600./HOLE_SPEED_KM_H/1000. ; + + // double offset = this.storageCapacity/this.flowCapacityPerTimeStep ; + /* NOTE: Start with completely full link, i.e. N_storageCap cells filled. Now make light at end of link green, discharge with + * flowCapPerTS. After N_storageCap/flowCapPerTS, the link is empty. Which also means that the holes must have reached + * the upstream end of the link. I.e. speed_holes = length / (N_storageCap/flowCap) and + * ttime_holes = lenth/speed = N_storCap/flowCap. + * Say length=75m, storCap=10, flowCap=1/2sec. offset = 20sec. 75m/20sec = 225m/1min = 13.5km/h so this is normal. + * Say length=75m, storCap=20, flowCap=1/2sec. offset = 40sec. ... = 6.75km/h ... to low. Reason: unphysical parameters. + * (Parameters assume 2-lane road, which should have discharge of 1/sec. Or we have lots of tuk tuks, which have only half a vehicle + * length. Thus we incur the reaction time twice as often --> half speed of holes. + */ + + // double nLanes = 2. * flowCapacityPerTimeStep ; // pseudo-lanes + // double ttimeOfHoles = 0.1 * this.storageCapacity/this.flowCapacityPerTimeStep/nLanes ; + + hole.setEarliestLinkExitTime( now + 1.0*ttimeOfHoles + 0.0*MatsimRandom.getRandom().nextDouble()*ttimeOfHoles ) ; hole.setSizeInEquivalents(veh2Remove.getSizeInEquivalents()); - holes.add(hole); + holes.add( hole ) ; break; default: throw new RuntimeException("The traffic dynmics "+context.qsimConfig.getTrafficDynamics()+" is not implemented yet."); } } - private void letVehicleArrive(QVehicle veh) { - qLink.addParkedVehicle(veh); - qLink.letVehicleArrive(veh); - qLink.makeVehicleAvailableToNextDriver(veh); - - // remove _after_ processing the arrival to keep link active: - removeVehicleFromQueue(veh); - } - @Override public final boolean isActive() { - if(context.qsimConfig.isUsingFastCapacityUpdate()){ + if( context.qsimConfig.isUsingFastCapacityUpdate() ){ return (!this.vehQueue.isEmpty()) || (!this.isNotOfferingVehicle() && context.qsimConfig.isUseLanes()) // if lanes, the buffer needs to be active in order to move vehicles over an internal node - || (!this.holes.isEmpty()); + || ( !this.holes.isEmpty() ) ; } else { return (this.flowcap_accumulate.getValue() < flowCapacityPerTimeStep) // still accumulating, thus active || (!this.vehQueue.isEmpty()) // vehicles are on link, thus active || (!this.isNotOfferingVehicle() && context.qsimConfig.isUseLanes()) // if lanes, the buffer needs to be active in order to move vehicles over an internal node - || (!this.holes.isEmpty()); // need to process arrival of holes + || ( !this.holes.isEmpty() ); // need to process arrival of holes } } @Override - public final void setSignalStateAllTurningMoves(final SignalGroupState state) { + public final void setSignalStateAllTurningMoves( final SignalGroupState state) { qSignalizedItem.setSignalStateAllTurningMoves(state); thisTimeStepGreen = qSignalizedItem.hasGreenForAllToLinks(); @@ -650,25 +697,25 @@ public final double getSimulatedFlowCapacityPerTimeStep() { @Override public final boolean isAcceptingFromUpstream() { - boolean storageOk = usedStorageCapacity < storageCapacity; + boolean storageOk = usedStorageCapacity < storageCapacity ; - if (context.qsimConfig.getTrafficDynamics()==TrafficDynamics.queue) { - return storageOk; + if ( context.qsimConfig.getTrafficDynamics()==TrafficDynamics.queue ) { + return storageOk ; } // (continue only if HOLES and/or inflow constraint) - if (context.qsimConfig.getTrafficDynamics() != TrafficDynamics.queue - && remainingHolesStorageCapacity <= 0.) { + if ( context.qsimConfig.getTrafficDynamics() != TrafficDynamics.queue + && remainingHolesStorageCapacity <= 0. ) { // check the holes storage capacity if using holes only (amit, Aug 2016) - return false; + return false ; } // remainingHolesStorageCapacity is: // * initialized at linkStorageCapacity // * reduced by entering vehicles // * increased by holes arriving at upstream end of link - if (context.qsimConfig.getTrafficDynamics() != TrafficDynamics.kinematicWaves) { - return true; + if ( context.qsimConfig.getTrafficDynamics() != TrafficDynamics.kinematicWaves) { + return true ; } return this.accumulatedInflowCap > 0; @@ -681,7 +728,7 @@ public void recalcTimeVariantAttributes() { // yy might also make flow and storage self-detecting changes (not really that // much more expensive). kai, feb'18 -// log.debug("just entered recalcTimeVariantAttributes; now=" + this.context.getSimTimer().getTimeOfDay()); +// log.debug("just entered recalcTimeVariantAttributes; now=" + this.context.getSimTimer().getTimeOfDay() ) ; calculateFlowCapacity(); calculateStorageCapacity(); @@ -689,8 +736,8 @@ public void recalcTimeVariantAttributes() { } // @Override -// public final void changeSpeedMetersPerSecond(final double val) { -// this.freespeedTravelTime = this.length / val; +// public final void changeSpeedMetersPerSecond( final double val ) { +// this.freespeedTravelTime = this.length / val ; // if (Double.isNaN(freespeedTravelTime)) { // throw new IllegalStateException("Double.NaN is not a valid freespeed travel time for a link. Please check the attributes length and freespeed!"); // } @@ -702,9 +749,9 @@ public final QVehicle getVehicle(final Id vehicleId) { if (veh.getId().equals(vehicleId)) return veh; } - for (QVehicle veh : this.buffer) { - if (veh.getId().equals(vehicleId)) - return veh; + for (Pair vehEfficiencyPair : this.buffer) { + if (vehEfficiencyPair.getKey().getId().equals(vehicleId)) + return vehEfficiencyPair.getKey(); } return null; } @@ -715,37 +762,39 @@ public final Collection getAllVehicles() { * It will be more complicated for passingQueue. amit feb'16 */ Collection vehicles = new ArrayList<>(); - vehicles.addAll(buffer); + for (Pair pair : buffer) { + vehicles.add(pair.getKey()); + } vehicles.addAll(vehQueue); - return vehicles; + return vehicles ; } @Override public final QVehicle popFirstVehicle() { - double now = context.getSimTimer().getTimeOfDay(); + double now = context.getSimTimer().getTimeOfDay() ; QVehicle veh = removeFirstVehicle(); - if (this.context.qsimConfig.isUseLanes()) { - if ( hasMoreThanOneLane()) { - this.context.getEventsManager().processEvent(new LaneLeaveEvent(now, veh.getId(), this.qLink.getId(), this.getId())); + if (this.context.qsimConfig.isUseLanes() ) { + if ( hasMoreThanOneLane() ) { + this.context.getEventsManager().processEvent(new LaneLeaveEvent( now, veh.getId(), this.qLink.getId(), this.getId() )); } } return veh; } private final QVehicle removeFirstVehicle(){ - double now = context.getSimTimer().getTimeOfDay(); - QVehicle veh = buffer.poll(); + double now = context.getSimTimer().getTimeOfDay() ; + QVehicle veh = buffer.poll().getKey(); bufferLastMovedTime = now; // just in case there is another vehicle in the buffer that is now the new front-most - if(context.qsimConfig.isUsingFastCapacityUpdate()) { - flowcap_accumulate.setTimeStep(now - 1); + if( context.qsimConfig.isUsingFastCapacityUpdate() ) { + flowcap_accumulate.setTimeStep(now - context.qsimConfig.getTimeStepSize()); } return veh; } @Override - public final void setSignalStateForTurningMove(final SignalGroupState state, final Id toLinkId) { + public final void setSignalStateForTurningMove( final SignalGroupState state, final Id toLinkId) { if (!qLink.getToNode().getOutLinks().containsKey(toLinkId)){ - throw new IllegalArgumentException("ToLink " + toLinkId + " is not reachable from QLink Id " + this.id); + throw new IllegalArgumentException("ToLink " + toLinkId + " is not reachable from QLink Id " + this.id ); } qSignalizedItem.setSignalStateForTurningMove(state, toLinkId); @@ -784,20 +833,21 @@ public final boolean isNotOfferingVehicle() { public final void clearVehicles() { // yyyyyy right now it seems to me that one should rather just abort the agents and have the framework take care of the rest. kai, mar'16 - double now = context.getSimTimer().getTimeOfDay(); + double now = context.getSimTimer().getTimeOfDay() ; for (QVehicle veh : vehQueue) { - context.getEventsManager().processEvent(new VehicleAbortsEvent(now, veh.getId(), veh.getCurrentLink().getId())); - context.getEventsManager().processEvent(new PersonStuckEvent(now, veh.getDriver().getId(), veh.getCurrentLink().getId(), veh.getDriver().getMode())); + context.getEventsManager().processEvent( new VehicleAbortsEvent(now, veh.getId(), veh.getCurrentLink().getId())); + context.getEventsManager().processEvent( new PersonStuckEvent(now, veh.getDriver().getId(), veh.getCurrentLink().getId(), veh.getDriver().getMode())); context.getAgentCounter().incLost(); context.getAgentCounter().decLiving(); } vehQueue.clear(); - for (QVehicle veh : buffer) { - context.getEventsManager().processEvent(new VehicleAbortsEvent(now, veh.getId(), veh.getCurrentLink().getId())); - context.getEventsManager().processEvent(new PersonStuckEvent(now, veh.getDriver().getId(), veh.getCurrentLink().getId(), veh.getDriver().getMode())); + for (Pair bufferEntry : buffer) { + QVehicle veh = bufferEntry.getKey(); + context.getEventsManager().processEvent( new VehicleAbortsEvent(now, veh.getId(), veh.getCurrentLink().getId())); + context.getEventsManager().processEvent( new PersonStuckEvent(now, veh.getDriver().getId(), veh.getCurrentLink().getId(), veh.getDriver().getMode())); context.getAgentCounter().incLost(); context.getAgentCounter().decLiving(); @@ -808,57 +858,9 @@ public final void clearVehicles() { this.remainingHolesStorageCapacity = this.storageCapacity; } - @Override - public final void addFromUpstream(final QVehicle veh) { - double now = context.getSimTimer().getTimeOfDay(); - - if (this.context.qsimConfig.isUseLanes()) { - if ( hasMoreThanOneLane()) { - this.context.getEventsManager().processEvent(new LaneEnterEvent(now, veh.getId(), this.qLink.getId(), this.getId())); - } - } - - // activate link since there is now action on it: - qLink.activateLink(); - - if(context.qsimConfig.isSeepModeStorageFree() && context.qsimConfig.getSeepModes().contains(veh.getVehicle().getType().getId().toString())){ - // do nothing - } else { - usedStorageCapacity += veh.getSizeInEquivalents(); - } - - // compute and set earliest link exit time: -// double linkTravelTime = this.length / this.linkSpeedCalculator.getMaximumVelocity(veh, qLink.getLink(), now); - double linkTravelTime = this.length / this.qLink.getMaximumVelocityFromLinkSpeedCalculator(veh, now); - linkTravelTime = context.qsimConfig.getTimeStepSize() * Math.floor(linkTravelTime / context.qsimConfig.getTimeStepSize()); - - veh.setEarliestLinkExitTime(now + linkTravelTime); - - // In theory, one could do something like - // final double discretizedEarliestLinkExitTime = timeStepSize * Math.ceil(veh.getEarliestLinkExitTime()/timeStepSize); - // double effectiveEntryTime = now - (discretizedEarliestLinkExitTime - veh.getEarliestLinkExitTime()); - // double earliestExitTime = effectiveEntryTime + linkTravelTime; - // We decided against this since this would effectively move the simulation to operating on true floating point time steps. For example, - // events could then have arbitrary floating point values (assuming one would use the "effectiveEntryTime" also for the event). - // Also, it could happen that vehicles with an earlier link exit time could be - // inserted and thus end up after vehicles with a later link exit time. theresa & kai, jun'14 - -// veh.setCurrentLink(qLink.getLink()); - this.qLink.setCurrentLinkToVehicle(veh); - vehQueue.add(veh); - - switch (context.qsimConfig.getTrafficDynamics()) { - case queue: - break; - case withHoles: - this.remainingHolesStorageCapacity -= veh.getSizeInEquivalents(); - break; - case kinematicWaves: - this.remainingHolesStorageCapacity -= veh.getSizeInEquivalents(); - this.accumulatedInflowCap -= getFlowCapacityConsumptionInEquivalents(veh); - break; - default: throw new RuntimeException("The traffic dynmics "+context.qsimConfig.getTrafficDynamics()+" is not implemented yet."); - } + private double getFlowCapacityConsumptionInEquivalents(QVehicle vehicle, QVehicle prevVehicle, Double timeDiff) { + double flowEfficiency = flowEfficiencyCalculator.calculateFlowEfficiency(vehicle, prevVehicle, timeDiff, qLink.getLink(), id); + return vehicle.getSizeInEquivalents() / flowEfficiency; } private boolean hasMoreThanOneLane() { @@ -871,7 +873,7 @@ private boolean hasMoreThanOneLane() { @Override public final QLaneI.VisData getVisData() { - return this.visData ; + return this.visData ; } @Override @@ -879,37 +881,37 @@ public final QVehicle getFirstVehicle() { if (this.buffer.isEmpty()) { return this.vehQueue.peek(); } - return this.buffer.peek(); + return this.buffer.peek().getKey() ; } @Override public final double getLastMovementTimeOfFirstVehicle() { - return this.bufferLastMovedTime; + return this.bufferLastMovedTime ; } /** * Needs to be added _upstream_ of the regular stop location so that a possible second stop on the link can also be served. */ @Override - public final void addTransitSlightlyUpstreamOfStop(final QVehicle veh) { - this.vehQueue.addFirst(veh); + public final void addTransitSlightlyUpstreamOfStop( final QVehicle veh) { + this.vehQueue.addFirst(veh) ; } @Override - public final void setSignalized(final boolean isSignalized) { + public final void setSignalized( final boolean isSignalized) { qSignalizedItem = new DefaultSignalizeableItem(qLink.getToNode().getOutLinks().keySet()); } @Override - public final void changeUnscaledFlowCapacityPerSecond(final double val) { - this.unscaledFlowCapacity_s = val; + public final void changeUnscaledFlowCapacityPerSecond( final double val ) { + this.unscaledFlowCapacity_s = val ; // be defensive (might now be called twice): this.recalcTimeVariantAttributes(); } @Override - public final void changeEffectiveNumberOfLanes(final double val) { - this.effectiveNumberOfLanes = val; + public final void changeEffectiveNumberOfLanes( final double val ) { + this.effectiveNumberOfLanes = val ; // be defensive (might now be called twice): this.recalcTimeVariantAttributes(); } @@ -919,7 +921,7 @@ public final void changeEffectiveNumberOfLanes(final double val) { } static final class Hole implements QItem { - private double earliestLinkEndTime; + private double earliestLinkEndTime ; private double pcu; @Override @@ -928,7 +930,7 @@ public final double getEarliestLinkExitTime() { } @Override - public final void setEarliestLinkExitTime(double earliestLinkEndTime) { + public final void setEarliestLinkExitTime( double earliestLinkEndTime ) { this.earliestLinkEndTime = earliestLinkEndTime; } @@ -943,17 +945,17 @@ final void setSizeInEquivalents(double pcuFactorOfHole) { @Override public Vehicle getVehicle() { - return null; + return null ; } @Override public MobsimDriverAgent getDriver() { - return null; + return null ; } @Override public Id getId() { - return null; + return null ; } } @@ -963,7 +965,33 @@ class VisDataImpl implements QLaneI.VisData { @Override public final Collection addAgentSnapshotInfo(Collection positions, double now) { - throw new RuntimeException("not implemented yet."); + if ( !buffer.isEmpty() || !vehQueue.isEmpty() || !holes.isEmpty() ) { + Gbl.assertNotNull(positions); + Gbl.assertNotNull( context.snapshotInfoBuilder ); + if ( this.upstreamCoord==null ) { + this.upstreamCoord = qLink.getFromNode().getCoord() ; + } + if ( this.downstreamCoord==null ) { + this.downstreamCoord = qLink.getToNode().getCoord() ; + } + // vehicle positions are computed in snapshotInfoBuilder as a service: + positions = context.snapshotInfoBuilder.positionVehiclesAlongLine( + positions, + now, + getAllVehicles(), + length, + storageCapacity + getBufferStorageCapacity(), + this.upstreamCoord, + this.downstreamCoord, + inverseFlowCapacityPerTimeStep, + qLink.getFreespeed(now), +// NetworkUtils.getNumberOfLanesAsInt(now, qLink.getLink()), + qLink.getNumberOfLanesAsInt(now) , + holes + ); + + } + return positions ; } void setVisInfo(Coord upstreamCoord, Coord downstreamCoord) { @@ -971,18 +999,18 @@ void setVisInfo(Coord upstreamCoord, Coord downstreamCoord) { this.downstreamCoord = downstreamCoord; } } - + private int noOfSeepModeBringFwd = 0; private QVehicle peekFromVehQueue(){ - double now = context.getSimTimer().getTimeOfDay(); QVehicle returnVeh = vehQueue.peek(); - if(context.qsimConfig.getLinkDynamics()==LinkDynamics.SeepageQ) { - + if( context.qsimConfig.getLinkDynamics()==LinkDynamics.SeepageQ ) { + double now = context.getSimTimer().getTimeOfDay(); + int maxSeepModeAllowed = 4; - if(context.qsimConfig.isRestrictingSeepage() && noOfSeepModeBringFwd == maxSeepModeAllowed) { + if( context.qsimConfig.isRestrictingSeepage() && noOfSeepModeBringFwd == maxSeepModeAllowed) { noOfSeepModeBringFwd = 0; return returnVeh; } @@ -994,7 +1022,7 @@ private QVehicle peekFromVehQueue(){ while(it.hasNext()){ QVehicle veh = newVehQueue.poll(); - if(veh.getEarliestLinkExitTime()<=now && context.qsimConfig.getSeepModes().contains(veh.getDriver().getMode())) { + if( veh.getEarliestLinkExitTime()<=now && context.qsimConfig.getSeepModes().contains(veh.getDriver().getMode()) ) { returnVeh = veh; break; } @@ -1016,10 +1044,76 @@ public double getLoadIndicator() { return usedStorageCapacity; } - private double getFlowCapacityConsumptionInEquivalents(QVehicle vehicle) { -// throw new RuntimeException("Check...."); - double flowEfficiency = flowEfficiencyCalculator.calculateFlowEfficiency(vehicle, vehQueue.peek(), 0., qLink.getLink(), id); - return vehicle.getSizeInEquivalents() / flowEfficiency; + static final class Builder implements LaneFactory { + private final NetsimEngineContext context; + private VehicleQ vehicleQueue = new FIFOVehicleQ(); + private Id id = null; + private Double length = null; + private Double effectiveNumberOfLanes = null; + private Double flowCapacity_s = null; + private FlowEfficiencyCalculator flowEfficiencyCalculator; + private Double pcu = null; + + Builder(final NetsimEngineContext context) { + this.context = context; + if (context.qsimConfig.getLinkDynamics() == QSimConfigGroup.LinkDynamics.PassingQ || + context.qsimConfig.getLinkDynamics() == QSimConfigGroup.LinkDynamics.SeepageQ) { + this.vehicleQueue = new PassingVehicleQ(); + } + } + void setPcu(Double pcu) { + this.pcu = pcu; + } + + void setVehicleQueue(VehicleQ vehicleQueue) { + this.vehicleQueue = vehicleQueue; + } + + void setLaneId(Id id) { + this.id = id; + } + + void setLength(Double length) { + this.length = length; + } + + void setEffectiveNumberOfLanes(Double effectiveNumberOfLanes) { + this.effectiveNumberOfLanes = effectiveNumberOfLanes; + } + + void setFlowCapacity_s(Double flowCapacity_s) { + this.flowCapacity_s = flowCapacity_s; + } + + void setFlowEfficiencyCalculator(FlowEfficiencyCalculator flowEfficiencyCalculator) { + this.flowEfficiencyCalculator = flowEfficiencyCalculator; + } + + + public DynamicHeadwayQueueWithBuffer createDynnamicHeadwayLane(DynamicHeadwayAbstractQLink qLink) { + // a number of things I cannot configure before I have the qlink: + if (id == null) { + id = Id.create(qLink.getLink().getId(), Lane.class); + } + if (length == null) { + length = qLink.getLink().getLength(); + } + if (effectiveNumberOfLanes == null) { + effectiveNumberOfLanes = qLink.getLink().getNumberOfLanes(); + } + if (flowCapacity_s == null) { + flowCapacity_s = qLink.getLink().getFlowCapacityPerSec(); + } + if (flowEfficiencyCalculator == null) { + flowEfficiencyCalculator = new DefaultFlowEfficiencyCalculator(); + } + return new DynamicHeadwayQueueWithBuffer(qLink.getInternalInterface(), vehicleQueue, id, length, effectiveNumberOfLanes, flowCapacity_s, context, flowEfficiencyCalculator ) ; + } + + @Override + public QLaneI createLane(AbstractQLink abstractQLink) { + return null; + } } -} +} \ No newline at end of file diff --git a/src/main/java/org/matsim/core/mobsim/qsim/qnetsimengine/TrafficCharQNetworkFactory.java b/src/main/java/org/matsim/core/mobsim/qsim/qnetsimengine/TrafficCharQNetworkFactory.java index 74e7458d2..e1bfd2381 100644 --- a/src/main/java/org/matsim/core/mobsim/qsim/qnetsimengine/TrafficCharQNetworkFactory.java +++ b/src/main/java/org/matsim/core/mobsim/qsim/qnetsimengine/TrafficCharQNetworkFactory.java @@ -53,7 +53,6 @@ public final class TrafficCharQNetworkFactory implements QNetworkFactory { private final EventsManager events; private final Network network; private final Scenario scenario; -// private NetsimEngineContext context; private QNetsimEngineI.NetsimInternalInterface netsimEngine; private LinkSpeedCalculator linkSpeedCalculator = new DefaultLinkSpeedCalculator(); private TurnAcceptanceLogic turnAcceptanceLogic = new DefaultTurnAcceptanceLogic(); @@ -90,7 +89,7 @@ public QLinkI createNetsimLink(final Link link, final QNodeI toQueueNode) { String rT = (String) link.getAttributes().getAttribute(TrafficCharConfigGroup.ROAD_TYPE); NetsimEngineContext context = this.roadType2Contexts.get(rT); - QueueWithBuffer.Builder laneFactory = new QueueWithBuffer.Builder(context); + DynamicHeadwayQueueWithBuffer.Builder laneFactory = new DynamicHeadwayQueueWithBuffer.Builder(context); QLinkImpl.Builder linkBuilder = new QLinkImpl.Builder(context, netsimEngine); linkBuilder.setLaneFactory(laneFactory); linkBuilder.setLinkSpeedCalculator( linkSpeedCalculator ); diff --git a/src/main/java/playground/amit/Dehradun/GHNetworkDistanceCalculator.java b/src/main/java/playground/amit/Dehradun/GHNetworkDistanceCalculator.java index e20d3b3de..7a208d643 100644 --- a/src/main/java/playground/amit/Dehradun/GHNetworkDistanceCalculator.java +++ b/src/main/java/playground/amit/Dehradun/GHNetworkDistanceCalculator.java @@ -1,6 +1,6 @@ package playground.amit.Dehradun; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; @@ -17,7 +17,6 @@ import java.net.URL; import java.net.URLConnection; import java.util.Scanner; -import java.util.function.Predicate; /** * @author Amit, created on 20-09-2021 @@ -122,12 +121,12 @@ public static TripChar getDistanceInKmTimeInHr(Coord origin, Coord destination, if (origin==destination) { -// Logger.getLogger(GHNetworkDistanceCalculator.class).warn("Identical origin and destination."); +// LogManager.getLogger(GHNetworkDistanceCalculator.class).warn("Identical origin and destination."); return new TripChar(0.0,0.0); } if (mode == null ) { - Logger.getLogger(GHNetworkDistanceCalculator.class).warn("Transport mode is null. Setting to "+"car"); + LogManager.getLogger(GHNetworkDistanceCalculator.class).warn("Transport mode is null. Setting to "+"car"); mode = "car"; } else if (mode.equals("motorbike")) mode = "motorcycle"; else if (mode.equals("metro")) mode = "metro"; diff --git a/src/main/java/playground/amit/Dehradun/metro2021scenario/HaridwarRishikeshScenarioRunner.java b/src/main/java/playground/amit/Dehradun/metro2021scenario/HaridwarRishikeshScenarioRunner.java index 3508bb0ae..dec9d3808 100644 --- a/src/main/java/playground/amit/Dehradun/metro2021scenario/HaridwarRishikeshScenarioRunner.java +++ b/src/main/java/playground/amit/Dehradun/metro2021scenario/HaridwarRishikeshScenarioRunner.java @@ -1,6 +1,7 @@ package playground.amit.Dehradun.metro2021scenario; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import playground.amit.Dehradun.DMAZonesProcessor; import playground.amit.Dehradun.GHNetworkDistanceCalculator; @@ -14,7 +15,7 @@ */ public class HaridwarRishikeshScenarioRunner { - public static final Logger LOG = Logger.getLogger(HaridwarRishikeshScenarioRunner.class); + public static final Logger LOG = LogManager.getLogger(HaridwarRishikeshScenarioRunner.class); private static final String date = "15-12-2021_7-30"; public static final String OD_2_metro_trips_characteristics = FileUtils.SVN_PROJECT_DATA_DRIVE + "DehradunMetroArea_MetroNeo_data/atIITR/HR/OD2MetroTripChars_"+date+".txt"; diff --git a/src/main/java/playground/amit/Dehradun/metro2021scenario/Metro2021ScenarioASCCalibration.java b/src/main/java/playground/amit/Dehradun/metro2021scenario/Metro2021ScenarioASCCalibration.java index 443eb6e94..5d4b4176d 100644 --- a/src/main/java/playground/amit/Dehradun/metro2021scenario/Metro2021ScenarioASCCalibration.java +++ b/src/main/java/playground/amit/Dehradun/metro2021scenario/Metro2021ScenarioASCCalibration.java @@ -84,7 +84,7 @@ void run(String outputFile, Map, TripChar> od2metroTripChar){ List ascs_metro = new ArrayList<>(); for (int i = 0; i a default vehicle type is used - Log.warn("No person and no vehicle is given to calculate the link travel disutility. The default vehicle type is used to estimate emission disutility."); + logger.warn("No person and no vehicle is given to calculate the link travel disutility. The default vehicle type is used to estimate emission disutility."); emissionVehicle = VehicleUtils.getFactory().createVehicle(Id.createVehicleId("defaultVehicle"), VehicleUtils.getDefaultVehicleType()); } else { // a person is given -> use the vehicle for that person given in emissionModule diff --git a/src/main/java/playground/amit/InternalizationEmissionAndCongestion/InternalizeEmissionsCongestionControlerListener.java b/src/main/java/playground/amit/InternalizationEmissionAndCongestion/InternalizeEmissionsCongestionControlerListener.java index 374195049..cf7cbee4c 100644 --- a/src/main/java/playground/amit/InternalizationEmissionAndCongestion/InternalizeEmissionsCongestionControlerListener.java +++ b/src/main/java/playground/amit/InternalizationEmissionAndCongestion/InternalizeEmissionsCongestionControlerListener.java @@ -18,10 +18,9 @@ * *********************************************************************** */ package playground.amit.InternalizationEmissionAndCongestion; -import java.util.Set; - import com.google.inject.Inject; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.contrib.emissions.EmissionModule; @@ -37,18 +36,19 @@ import org.matsim.core.controler.listener.StartupListener; import org.matsim.core.events.algorithms.EventWriterXML; import org.matsim.core.scenario.MutableScenario; - import playground.vsp.airPollution.flatEmissions.EmissionCostModule; import playground.vsp.airPollution.flatEmissions.EmissionInternalizationHandler; import playground.vsp.congestion.handlers.CongestionHandlerImplV3; import playground.vsp.congestion.handlers.MarginalCongestionPricingHandler; import playground.vsp.congestion.handlers.TollHandler; +import java.util.Set; + /** * @author amit after Benjamin and Ihab */ public class InternalizeEmissionsCongestionControlerListener implements StartupListener, IterationStartsListener, IterationEndsListener, ShutdownListener { - private final Logger logger = Logger.getLogger(InternalizeEmissionsCongestionControlerListener.class); + private final Logger logger = LogManager.getLogger(InternalizeEmissionsCongestionControlerListener.class); private MatsimServices controler; @Inject private EmissionModule emissionModule; diff --git a/src/main/java/playground/amit/analysis/FileMerger.java b/src/main/java/playground/amit/analysis/FileMerger.java index 5e0bad607..bc9727de0 100644 --- a/src/main/java/playground/amit/analysis/FileMerger.java +++ b/src/main/java/playground/amit/analysis/FileMerger.java @@ -19,11 +19,13 @@ package playground.amit.analysis; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.matsim.core.utils.io.IOUtils; + import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; -import org.apache.log4j.Logger; -import org.matsim.core.utils.io.IOUtils; /** * Created by amit on 11.06.17. @@ -32,7 +34,7 @@ public class FileMerger { - private static final Logger LOG = Logger.getLogger(FileMerger.class); + private static final Logger LOG = LogManager.getLogger(FileMerger.class); public FileMerger(final String headerFileInitializer) { LOG.info("Header file will be written only once at start."); diff --git a/src/main/java/playground/amit/analysis/LegModeTimeOfDayDistribution.java b/src/main/java/playground/amit/analysis/LegModeTimeOfDayDistribution.java index e957bb84b..6854f7f6d 100644 --- a/src/main/java/playground/amit/analysis/LegModeTimeOfDayDistribution.java +++ b/src/main/java/playground/amit/analysis/LegModeTimeOfDayDistribution.java @@ -19,12 +19,8 @@ package playground.amit.analysis; -import java.io.BufferedWriter; -import java.util.ArrayList; -import java.util.List; -import java.util.SortedMap; -import java.util.TreeMap; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.events.PersonDepartureEvent; import org.matsim.api.core.v01.events.handler.PersonDepartureEventHandler; import org.matsim.core.api.experimental.events.EventsManager; @@ -36,12 +32,18 @@ import playground.amit.munich.utils.MunichPersonFilter.MunichUserGroup; import playground.vsp.analysis.modules.AbstractAnalysisModule; +import java.io.BufferedWriter; +import java.util.ArrayList; +import java.util.List; +import java.util.SortedMap; +import java.util.TreeMap; + /** * @author amit */ public class LegModeTimeOfDayDistribution extends AbstractAnalysisModule{ - public static final Logger LOG = Logger.getLogger(LegModeTimeOfDayDistribution.class); + public static final Logger LOG = LogManager.getLogger(LegModeTimeOfDayDistribution.class); private final LegModeTimeOfDayHandler lmtdh; private final String eventsFile ; private String outFilePrefix= ""; diff --git a/src/main/java/playground/amit/analysis/StuckAgentsFilter.java b/src/main/java/playground/amit/analysis/StuckAgentsFilter.java index e0f1e829c..3ef835893 100644 --- a/src/main/java/playground/amit/analysis/StuckAgentsFilter.java +++ b/src/main/java/playground/amit/analysis/StuckAgentsFilter.java @@ -18,12 +18,8 @@ * *********************************************************************** */ package playground.amit.analysis; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.PersonStuckEvent; import org.matsim.api.core.v01.events.handler.PersonStuckEventHandler; @@ -32,9 +28,13 @@ import org.matsim.core.events.EventsUtils; import org.matsim.core.events.MatsimEventsReader; import org.matsim.core.events.handler.EventHandler; - import playground.vsp.analysis.modules.AbstractAnalysisModule; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + /** * This class takes list of eventsFile as input and then returns set of all stuck (1) events and (2) persons. * @@ -42,7 +42,7 @@ */ public class StuckAgentsFilter extends AbstractAnalysisModule { - private static final Logger LOG = Logger.getLogger(StuckAgentsFilter.class); + private static final Logger LOG = LogManager.getLogger(StuckAgentsFilter.class); private final Set> stuckPersonsFromEventsFiles = new HashSet<>(); private final Set stuckEventsFromEventsFiles = new HashSet<>(); private final List eventsFiles; diff --git a/src/main/java/playground/amit/analysis/TripAndPersonCounter.java b/src/main/java/playground/amit/analysis/TripAndPersonCounter.java index 0406b146d..4c42c0eb2 100644 --- a/src/main/java/playground/amit/analysis/TripAndPersonCounter.java +++ b/src/main/java/playground/amit/analysis/TripAndPersonCounter.java @@ -18,12 +18,8 @@ * *********************************************************************** */ package playground.amit.analysis; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.events.PersonArrivalEvent; @@ -31,14 +27,18 @@ import org.matsim.api.core.v01.events.handler.PersonArrivalEventHandler; import org.matsim.api.core.v01.events.handler.PersonDepartureEventHandler; import org.matsim.api.core.v01.population.Person; - import playground.amit.utils.MapUtils; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + /** * @author amit */ public class TripAndPersonCounter implements PersonDepartureEventHandler, PersonArrivalEventHandler { - private static final Logger LOGGER = Logger.getLogger(TripAndPersonCounter.class); + private static final Logger LOGGER = LogManager.getLogger(TripAndPersonCounter.class); private final Map,Integer> personId2CarTripCounter; private final Map,Integer> personId2AllTripCounter; private final List> departureList; diff --git a/src/main/java/playground/amit/analysis/activity/ActivityType2DurationHandler.java b/src/main/java/playground/amit/analysis/activity/ActivityType2DurationHandler.java index fc32bd9c4..fc7c80bb9 100644 --- a/src/main/java/playground/amit/analysis/activity/ActivityType2DurationHandler.java +++ b/src/main/java/playground/amit/analysis/activity/ActivityType2DurationHandler.java @@ -25,7 +25,8 @@ import java.util.Map; import java.util.Set; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.ActivityEndEvent; import org.matsim.api.core.v01.events.ActivityStartEvent; @@ -42,7 +43,7 @@ * @author amit */ public class ActivityType2DurationHandler implements ActivityEndEventHandler, ActivityStartEventHandler { - public static final Logger LOG = Logger.getLogger(ActivityType2DurationHandler.class); + public static final Logger LOG = LogManager.getLogger(ActivityType2DurationHandler.class); private final Map, PersonActivityInfo> personId2ActInfo; private final double midNightTime; private final Set actTyps; diff --git a/src/main/java/playground/amit/analysis/activity/LegModeActivityEndTimeAndActDurationHandler.java b/src/main/java/playground/amit/analysis/activity/LegModeActivityEndTimeAndActDurationHandler.java index d47f97271..bf71880e9 100644 --- a/src/main/java/playground/amit/analysis/activity/LegModeActivityEndTimeAndActDurationHandler.java +++ b/src/main/java/playground/amit/analysis/activity/LegModeActivityEndTimeAndActDurationHandler.java @@ -18,16 +18,8 @@ * *********************************************************************** */ package playground.amit.analysis.activity; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.SortedMap; -import java.util.TreeMap; - -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.events.ActivityEndEvent; @@ -41,6 +33,8 @@ import org.matsim.api.core.v01.population.Person; import org.matsim.core.gbl.Gbl; +import java.util.*; + /** * Handles activity end and start events and returns the leg mode distribution data for activity end and activity duration. * @author amit @@ -49,7 +43,7 @@ public class LegModeActivityEndTimeAndActDurationHandler implements PersonDepartureEventHandler, ActivityEndEventHandler, ActivityStartEventHandler, PersonStuckEventHandler { - private final static Logger LOG = Logger.getLogger(LegModeActivityEndTimeAndActDurationHandler.class); + private final static Logger LOG = LogManager.getLogger(LegModeActivityEndTimeAndActDurationHandler.class); private SortedMap, List>> mode2PersonId2ActEndTimes = new TreeMap<>(); private SortedMap, List>> mode2PersonId2ActDurations = new TreeMap<>(); private final Map, SortedMap> personId2ActEndTimes = new HashMap<>(); diff --git a/src/main/java/playground/amit/analysis/activity/departureArrival/DepartureTimeHandler.java b/src/main/java/playground/amit/analysis/activity/departureArrival/DepartureTimeHandler.java index 73b9a0b78..9fb24118e 100644 --- a/src/main/java/playground/amit/analysis/activity/departureArrival/DepartureTimeHandler.java +++ b/src/main/java/playground/amit/analysis/activity/departureArrival/DepartureTimeHandler.java @@ -19,14 +19,7 @@ package playground.amit.analysis.activity.departureArrival; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.SortedMap; -import java.util.TreeMap; - -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.events.ActivityStartEvent; @@ -40,6 +33,8 @@ import org.matsim.api.core.v01.population.Person; import org.matsim.pt.PtConstants; +import java.util.*; + /** * (1) This excludes the departure of transit drivers. * (2) See followings @@ -145,7 +140,7 @@ private void storeMode(final double eventTime, final String legMode) { public void handleRemainingTransitUsers(){ if(!modesForTransitUsers.isEmpty()) { - Logger.getLogger(DepartureTimeHandler.class).warn("A few transit users are not handle due to stuckAndAbort. Handling them now."); + LogManager.getLogger(DepartureTimeHandler.class).warn("A few transit users are not handle due to stuckAndAbort. Handling them now."); for(Id pId : modesForTransitUsers.keySet()){ List modes = modesForTransitUsers.get(pId); String legMode = modes.contains(TransportMode.pt) ? TransportMode.pt : TransportMode.walk; diff --git a/src/main/java/playground/amit/analysis/activity/departureArrival/FilteredDepartureTimeHandler.java b/src/main/java/playground/amit/analysis/activity/departureArrival/FilteredDepartureTimeHandler.java index 84fd7339b..eab9709d8 100644 --- a/src/main/java/playground/amit/analysis/activity/departureArrival/FilteredDepartureTimeHandler.java +++ b/src/main/java/playground/amit/analysis/activity/departureArrival/FilteredDepartureTimeHandler.java @@ -19,10 +19,8 @@ package playground.amit.analysis.activity.departureArrival; -import java.util.Map; -import java.util.SortedMap; - -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.events.ActivityStartEvent; import org.matsim.api.core.v01.events.PersonDepartureEvent; import org.matsim.api.core.v01.events.PersonStuckEvent; @@ -31,9 +29,11 @@ import org.matsim.api.core.v01.events.handler.PersonDepartureEventHandler; import org.matsim.api.core.v01.events.handler.PersonStuckEventHandler; import org.matsim.api.core.v01.events.handler.TransitDriverStartsEventHandler; - import playground.amit.munich.utils.MunichPersonFilter; +import java.util.Map; +import java.util.SortedMap; + /** * @author amit */ @@ -44,7 +44,7 @@ public class FilteredDepartureTimeHandler implements PersonDepartureEventHandler private final DepartureTimeHandler delegate ; private final MunichPersonFilter pf = new MunichPersonFilter(); private final String userGroup ; - private static final Logger LOG = Logger.getLogger(FilteredDepartureTimeHandler.class); + private static final Logger LOG = LogManager.getLogger(FilteredDepartureTimeHandler.class); /** * @param userGroup diff --git a/src/main/java/playground/amit/analysis/activity/scoring/Person2ActivityPerformingWriter.java b/src/main/java/playground/amit/analysis/activity/scoring/Person2ActivityPerformingWriter.java index 138aaee4b..a9dcc7364 100644 --- a/src/main/java/playground/amit/analysis/activity/scoring/Person2ActivityPerformingWriter.java +++ b/src/main/java/playground/amit/analysis/activity/scoring/Person2ActivityPerformingWriter.java @@ -17,8 +17,8 @@ * * * *********************************************************************** */ package playground.amit.analysis.activity.scoring; - -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.events.Event; @@ -45,7 +45,7 @@ */ public class Person2ActivityPerformingWriter { - private static final Logger LOG = Logger.getLogger(Person2ActivityPerformingWriter.class); + private static final Logger LOG = LogManager.getLogger(Person2ActivityPerformingWriter.class); private static final String outputFilesDir = FileUtils.RUNS_SVN+"/detEval/emissionCongestionInternalization/output/1pct/run0/baseCaseCtd/"; private final Map,Map> personId2Act2UtilPerf = new HashMap<>(); private final Set actTypes = new HashSet<>(); diff --git a/src/main/java/playground/amit/analysis/congestion/CausedDelayAnalyzer.java b/src/main/java/playground/amit/analysis/congestion/CausedDelayAnalyzer.java index 2c9761ab6..b4727ec11 100644 --- a/src/main/java/playground/amit/analysis/congestion/CausedDelayAnalyzer.java +++ b/src/main/java/playground/amit/analysis/congestion/CausedDelayAnalyzer.java @@ -18,22 +18,22 @@ * *********************************************************************** */ package playground.amit.analysis.congestion; -import java.util.Map; -import java.util.Set; -import java.util.SortedMap; - -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.population.Person; import org.matsim.core.api.experimental.events.EventsManager; import org.matsim.core.events.EventsUtils; - import playground.amit.utils.AreaFilter; import playground.amit.utils.PersonFilter; import playground.vsp.congestion.events.CongestionEventsReader; +import java.util.Map; +import java.util.Set; +import java.util.SortedMap; + /** * Calculates the delay caused for each person by reading the marginal congestion events. * Additionally, returns the link delay and counts which can be used to get the (avg) toll, since a corresponding @@ -43,7 +43,7 @@ public class CausedDelayAnalyzer { - private final static Logger LOGGER = Logger.getLogger(CausedDelayAnalyzer.class); + private final static Logger LOGGER = LogManager.getLogger(CausedDelayAnalyzer.class); private final FilteredCausedDelayHandler handler; private final String eventsFile; diff --git a/src/main/java/playground/amit/analysis/congestion/ExperiencedDelayAnalyzer.java b/src/main/java/playground/amit/analysis/congestion/ExperiencedDelayAnalyzer.java index 4e69248e5..11ff5f6dc 100644 --- a/src/main/java/playground/amit/analysis/congestion/ExperiencedDelayAnalyzer.java +++ b/src/main/java/playground/amit/analysis/congestion/ExperiencedDelayAnalyzer.java @@ -18,12 +18,8 @@ * *********************************************************************** */ package playground.amit.analysis.congestion; -import java.io.BufferedWriter; -import java.io.IOException; -import java.util.Map; -import java.util.SortedMap; -import java.util.TreeMap; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; @@ -37,6 +33,12 @@ import playground.amit.utils.PersonFilter; import playground.vsp.congestion.handlers.CongestionHandlerImplV3; +import java.io.BufferedWriter; +import java.io.IOException; +import java.util.Map; +import java.util.SortedMap; +import java.util.TreeMap; + /** * This analyzer calculates delay from link enter and link leave events and therefore provides only experienced delay. *

In order to get the caused delay for each person, see {@link CausedDelayAnalyzer} @@ -45,7 +47,7 @@ */ public class ExperiencedDelayAnalyzer { - private final static Logger LOGGER = Logger.getLogger(ExperiencedDelayAnalyzer.class); + private final static Logger LOGGER = LogManager.getLogger(ExperiencedDelayAnalyzer.class); private final String eventsFile; private final FilteredExperienceDelayHandler congestionHandler; private final Scenario scenario; diff --git a/src/main/java/playground/amit/analysis/congestion/ExperiencedDelayHandler.java b/src/main/java/playground/amit/analysis/congestion/ExperiencedDelayHandler.java index 82077556c..20b265416 100644 --- a/src/main/java/playground/amit/analysis/congestion/ExperiencedDelayHandler.java +++ b/src/main/java/playground/amit/analysis/congestion/ExperiencedDelayHandler.java @@ -24,8 +24,8 @@ import java.util.Map; import java.util.SortedMap; import java.util.TreeMap; - -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -56,7 +56,7 @@ public class ExperiencedDelayHandler implements LinkEnterEventHandler, LinkLeaveEventHandler, PersonDepartureEventHandler, PersonArrivalEventHandler, VehicleEntersTrafficEventHandler, VehicleLeavesTrafficEventHandler, TransitDriverStartsEventHandler { - public final static Logger LOG = Logger.getLogger(ExperiencedDelayHandler.class); + public final static Logger LOG = LogManager.getLogger(ExperiencedDelayHandler.class); private final Vehicle2DriverEventHandler delegate = new Vehicle2DriverEventHandler(); diff --git a/src/main/java/playground/amit/analysis/congestion/FilteredCausedDelayHandler.java b/src/main/java/playground/amit/analysis/congestion/FilteredCausedDelayHandler.java index 9017737b2..8aed2eb0f 100644 --- a/src/main/java/playground/amit/analysis/congestion/FilteredCausedDelayHandler.java +++ b/src/main/java/playground/amit/analysis/congestion/FilteredCausedDelayHandler.java @@ -19,29 +19,29 @@ package playground.amit.analysis.congestion; -import java.util.Map; -import java.util.Set; -import java.util.SortedMap; - -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.api.core.v01.population.Person; - import playground.amit.utils.AreaFilter; import playground.amit.utils.PersonFilter; import playground.vsp.congestion.events.CongestionEvent; import playground.vsp.congestion.handlers.CongestionEventHandler; +import java.util.Map; +import java.util.Set; +import java.util.SortedMap; + /** * @author amit */ public class FilteredCausedDelayHandler implements CongestionEventHandler { - private static final Logger LOGGER = Logger.getLogger(FilteredCausedDelayHandler.class); + private static final Logger LOGGER = LogManager.getLogger(FilteredCausedDelayHandler.class); private final CausedDelayHandler delegate ; private final PersonFilter pf ; private final AreaFilter af; diff --git a/src/main/java/playground/amit/analysis/congestion/FilteredExperienceDelayHandler.java b/src/main/java/playground/amit/analysis/congestion/FilteredExperienceDelayHandler.java index 7e940e806..39155db6d 100644 --- a/src/main/java/playground/amit/analysis/congestion/FilteredExperienceDelayHandler.java +++ b/src/main/java/playground/amit/analysis/congestion/FilteredExperienceDelayHandler.java @@ -19,34 +19,22 @@ package playground.amit.analysis.congestion; -import java.util.Map; -import java.util.SortedMap; - -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; -import org.matsim.api.core.v01.events.LinkEnterEvent; -import org.matsim.api.core.v01.events.LinkLeaveEvent; -import org.matsim.api.core.v01.events.PersonArrivalEvent; -import org.matsim.api.core.v01.events.PersonDepartureEvent; -import org.matsim.api.core.v01.events.TransitDriverStartsEvent; -import org.matsim.api.core.v01.events.VehicleEntersTrafficEvent; -import org.matsim.api.core.v01.events.VehicleLeavesTrafficEvent; -import org.matsim.api.core.v01.events.handler.LinkEnterEventHandler; -import org.matsim.api.core.v01.events.handler.LinkLeaveEventHandler; -import org.matsim.api.core.v01.events.handler.PersonArrivalEventHandler; -import org.matsim.api.core.v01.events.handler.PersonDepartureEventHandler; -import org.matsim.api.core.v01.events.handler.TransitDriverStartsEventHandler; -import org.matsim.api.core.v01.events.handler.VehicleEntersTrafficEventHandler; -import org.matsim.api.core.v01.events.handler.VehicleLeavesTrafficEventHandler; +import org.matsim.api.core.v01.events.*; +import org.matsim.api.core.v01.events.handler.*; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.api.core.v01.population.Person; import org.matsim.core.events.algorithms.Vehicle2DriverEventHandler; - import playground.amit.utils.AreaFilter; import playground.amit.utils.PersonFilter; +import java.util.Map; +import java.util.SortedMap; + /** * @author amit */ @@ -54,7 +42,7 @@ public class FilteredExperienceDelayHandler implements LinkEnterEventHandler, LinkLeaveEventHandler, PersonDepartureEventHandler, PersonArrivalEventHandler, VehicleEntersTrafficEventHandler, VehicleLeavesTrafficEventHandler, TransitDriverStartsEventHandler { - private static final Logger LOGGER = Logger.getLogger(FilteredExperienceDelayHandler.class); + private static final Logger LOGGER = LogManager.getLogger(FilteredExperienceDelayHandler.class); private final ExperiencedDelayHandler delegate ; private final Vehicle2DriverEventHandler veh2DriverDelegate = new Vehicle2DriverEventHandler(); private final PersonFilter pf ; diff --git a/src/main/java/playground/amit/analysis/emission/AirPollutionExposureAnalysisControlerListener.java b/src/main/java/playground/amit/analysis/emission/AirPollutionExposureAnalysisControlerListener.java index 5cb0d7d43..7fed5951f 100644 --- a/src/main/java/playground/amit/analysis/emission/AirPollutionExposureAnalysisControlerListener.java +++ b/src/main/java/playground/amit/analysis/emission/AirPollutionExposureAnalysisControlerListener.java @@ -19,12 +19,9 @@ package playground.amit.analysis.emission; -import java.io.BufferedWriter; -import java.io.File; -import java.io.IOException; -import java.util.Map; - -import org.apache.log4j.Logger; +import com.google.inject.Inject; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.contrib.emissions.events.EmissionEventsReader; import org.matsim.core.api.experimental.events.EventsManager; import org.matsim.core.config.groups.ControlerConfigGroup; @@ -35,22 +32,24 @@ import org.matsim.core.events.EventsUtils; import org.matsim.core.events.MatsimEventsReader; import org.matsim.core.utils.io.IOUtils; - -import com.google.inject.Inject; - import playground.amit.analysis.emission.experienced.ExperiencedEmissionCostHandler; import playground.amit.utils.MapUtils; import playground.vsp.airPollution.exposure.GridTools; import playground.vsp.airPollution.exposure.IntervalHandler; import playground.vsp.airPollution.exposure.ResponsibilityGridTools; +import java.io.BufferedWriter; +import java.io.File; +import java.io.IOException; +import java.util.Map; + /** * Created by amit on 01/12/2016. */ public class AirPollutionExposureAnalysisControlerListener implements ShutdownListener { - private static final Logger LOG = Logger.getLogger(AirPollutionExposureAnalysisControlerListener.class); + private static final Logger LOG = LogManager.getLogger(AirPollutionExposureAnalysisControlerListener.class); @Inject private OutputDirectoryHierarchy controlerIO; diff --git a/src/main/java/playground/amit/analysis/emission/EmissionLinkAnalyzer.java b/src/main/java/playground/amit/analysis/emission/EmissionLinkAnalyzer.java index c4a25631a..63f40d45d 100644 --- a/src/main/java/playground/amit/analysis/emission/EmissionLinkAnalyzer.java +++ b/src/main/java/playground/amit/analysis/emission/EmissionLinkAnalyzer.java @@ -18,7 +18,8 @@ * *********************************************************************** */ package playground.amit.analysis.emission; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; @@ -49,7 +50,7 @@ //TODO :clean it. public class EmissionLinkAnalyzer extends AbstractAnalysisModule { - private static final Logger LOG = Logger.getLogger(EmissionLinkAnalyzer.class); + private static final Logger LOG = LogManager.getLogger(EmissionLinkAnalyzer.class); private final String emissionEventsFile; private final FilteredWarmEmissionHandler warmHandler; private final FilteredColdEmissionHandler coldHandler; diff --git a/src/main/java/playground/amit/analysis/emission/EmissionsPerLinkColdEventHandler.java b/src/main/java/playground/amit/analysis/emission/EmissionsPerLinkColdEventHandler.java index db6a13159..27040997d 100644 --- a/src/main/java/playground/amit/analysis/emission/EmissionsPerLinkColdEventHandler.java +++ b/src/main/java/playground/amit/analysis/emission/EmissionsPerLinkColdEventHandler.java @@ -19,7 +19,8 @@ * *********************************************************************** */ package playground.amit.analysis.emission; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.contrib.emissions.Pollutant; @@ -37,8 +38,7 @@ */ public class EmissionsPerLinkColdEventHandler implements ColdEmissionEventHandler { - private static final Logger logger = Logger - .getLogger(EmissionsPerLinkColdEventHandler.class); + private static final Logger logger = LogManager.getLogger(EmissionsPerLinkColdEventHandler.class); Map, Map>> time2coldEmissionsTotal = new HashMap<>(); diff --git a/src/main/java/playground/amit/analysis/emission/EmissionsPerLinkWarmEventHandler.java b/src/main/java/playground/amit/analysis/emission/EmissionsPerLinkWarmEventHandler.java index d25caf844..f95c63d00 100644 --- a/src/main/java/playground/amit/analysis/emission/EmissionsPerLinkWarmEventHandler.java +++ b/src/main/java/playground/amit/analysis/emission/EmissionsPerLinkWarmEventHandler.java @@ -19,7 +19,8 @@ * *********************************************************************** */ package playground.amit.analysis.emission; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.contrib.emissions.Pollutant; @@ -35,7 +36,7 @@ * */ public class EmissionsPerLinkWarmEventHandler implements WarmEmissionEventHandler{ - private static final Logger logger = Logger.getLogger(EmissionsPerLinkWarmEventHandler.class); + private static final Logger logger = LogManager.getLogger(EmissionsPerLinkWarmEventHandler.class); Map, Map>> time2warmEmissionsTotal = new HashMap<>(); Map, Double>> time2linkIdLeaveCount = new HashMap<>(); diff --git a/src/main/java/playground/amit/analysis/emission/caused/CausedEmissionCostHandler.java b/src/main/java/playground/amit/analysis/emission/caused/CausedEmissionCostHandler.java index 0c06d865d..95df9a908 100644 --- a/src/main/java/playground/amit/analysis/emission/caused/CausedEmissionCostHandler.java +++ b/src/main/java/playground/amit/analysis/emission/caused/CausedEmissionCostHandler.java @@ -18,10 +18,8 @@ * *********************************************************************** */ package playground.amit.analysis.emission.caused; -import java.util.HashMap; -import java.util.Map; -import java.util.stream.Collectors; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.VehicleEntersTrafficEvent; import org.matsim.api.core.v01.events.VehicleLeavesTrafficEvent; @@ -39,6 +37,10 @@ import playground.amit.utils.PersonFilter; import playground.vsp.airPollution.flatEmissions.EmissionCostModule; +import java.util.HashMap; +import java.util.Map; +import java.util.stream.Collectors; + /** * Emission costs (flat emission cost module is used). * @@ -47,7 +49,7 @@ public class CausedEmissionCostHandler implements VehicleEntersTrafficEventHandler, VehicleLeavesTrafficEventHandler, WarmEmissionEventHandler, ColdEmissionEventHandler, EmissionCostHandler{ - private static final Logger LOG = Logger.getLogger(CausedEmissionCostHandler.class); + private static final Logger LOG = LogManager.getLogger(CausedEmissionCostHandler.class); private final EmissionCostModule emissionCostModule; private final Map, Double> vehicleId2ColdEmissCosts = new HashMap<>(); diff --git a/src/main/java/playground/amit/analysis/emission/experienced/ExperiencedEmissionCostHandler.java b/src/main/java/playground/amit/analysis/emission/experienced/ExperiencedEmissionCostHandler.java index 0f5fddc7b..93467a132 100644 --- a/src/main/java/playground/amit/analysis/emission/experienced/ExperiencedEmissionCostHandler.java +++ b/src/main/java/playground/amit/analysis/emission/experienced/ExperiencedEmissionCostHandler.java @@ -23,8 +23,8 @@ import java.util.Map; import java.util.Set; import java.util.stream.Collectors; - -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.VehicleEntersTrafficEvent; import org.matsim.api.core.v01.events.handler.VehicleEntersTrafficEventHandler; @@ -51,7 +51,7 @@ public class ExperiencedEmissionCostHandler implements VehicleEntersTrafficEventHandler, WarmEmissionEventHandler, ColdEmissionEventHandler, EmissionCostHandler{ - private static final Logger LOG = Logger.getLogger(ExperiencedEmissionCostHandler.class); + private static final Logger LOG = LogManager.getLogger(ExperiencedEmissionCostHandler.class); private final Map, Double>> vehicleId2ColdEmissCosts = new HashMap<>(); private final Map, Double>> vehicleId2WarmEmissCosts = new HashMap<>(); diff --git a/src/main/java/playground/amit/analysis/emission/filtering/FilteredColdEmissionHandler.java b/src/main/java/playground/amit/analysis/emission/filtering/FilteredColdEmissionHandler.java index 7288a3c97..8592db5bd 100644 --- a/src/main/java/playground/amit/analysis/emission/filtering/FilteredColdEmissionHandler.java +++ b/src/main/java/playground/amit/analysis/emission/filtering/FilteredColdEmissionHandler.java @@ -18,9 +18,8 @@ * *********************************************************************** */ package playground.amit.analysis.emission.filtering; -import java.util.HashMap; -import java.util.Map; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.VehicleEntersTrafficEvent; import org.matsim.api.core.v01.events.VehicleLeavesTrafficEvent; @@ -38,12 +37,15 @@ import playground.amit.utils.AreaFilter; import playground.amit.utils.PersonFilter; +import java.util.HashMap; +import java.util.Map; + /** * @author amit */ public class FilteredColdEmissionHandler implements VehicleEntersTrafficEventHandler, VehicleLeavesTrafficEventHandler, ColdEmissionEventHandler{ - private static final Logger LOGGER = Logger.getLogger(FilteredColdEmissionHandler.class.getName()); + private static final Logger LOGGER = LogManager.getLogger(FilteredColdEmissionHandler.class.getName()); private final EmissionsPerLinkColdEventHandler delegate; private final PersonFilter pf ; diff --git a/src/main/java/playground/amit/analysis/emission/filtering/FilteredEmissionPersonEventHandler.java b/src/main/java/playground/amit/analysis/emission/filtering/FilteredEmissionPersonEventHandler.java index d27cde93a..8df55cc80 100644 --- a/src/main/java/playground/amit/analysis/emission/filtering/FilteredEmissionPersonEventHandler.java +++ b/src/main/java/playground/amit/analysis/emission/filtering/FilteredEmissionPersonEventHandler.java @@ -18,11 +18,8 @@ * *********************************************************************** */ package playground.amit.analysis.emission.filtering; -import java.util.HashMap; -import java.util.Map; -import java.util.stream.Collectors; - -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.VehicleEntersTrafficEvent; import org.matsim.api.core.v01.events.VehicleLeavesTrafficEvent; @@ -36,17 +33,20 @@ import org.matsim.contrib.emissions.events.WarmEmissionEvent; import org.matsim.contrib.emissions.events.WarmEmissionEventHandler; import org.matsim.vehicles.Vehicle; - import playground.amit.analysis.emission.EmissionPersonEventHandler; import playground.amit.utils.AreaFilter; import playground.amit.utils.PersonFilter; +import java.util.HashMap; +import java.util.Map; +import java.util.stream.Collectors; + /** * @author amit */ public class FilteredEmissionPersonEventHandler implements ColdEmissionEventHandler, WarmEmissionEventHandler, VehicleEntersTrafficEventHandler, VehicleLeavesTrafficEventHandler { - private static final Logger LOGGER = Logger.getLogger(FilteredEmissionPersonEventHandler.class.getName()); + private static final Logger LOGGER = LogManager.getLogger(FilteredEmissionPersonEventHandler.class.getName()); private final Map, Id> vehicleId2PersonId2 = new HashMap<>(); private final EmissionPersonEventHandler delegate; diff --git a/src/main/java/playground/amit/analysis/emission/filtering/FilteredWarmEmissionHandler.java b/src/main/java/playground/amit/analysis/emission/filtering/FilteredWarmEmissionHandler.java index 6aaa8c41b..0168138a8 100644 --- a/src/main/java/playground/amit/analysis/emission/filtering/FilteredWarmEmissionHandler.java +++ b/src/main/java/playground/amit/analysis/emission/filtering/FilteredWarmEmissionHandler.java @@ -18,9 +18,8 @@ * *********************************************************************** */ package playground.amit.analysis.emission.filtering; -import java.util.HashMap; -import java.util.Map; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.VehicleEntersTrafficEvent; import org.matsim.api.core.v01.events.VehicleLeavesTrafficEvent; @@ -38,12 +37,15 @@ import playground.amit.utils.AreaFilter; import playground.amit.utils.PersonFilter; +import java.util.HashMap; +import java.util.Map; + /** * @author amit */ public class FilteredWarmEmissionHandler implements VehicleEntersTrafficEventHandler, VehicleLeavesTrafficEventHandler, WarmEmissionEventHandler { - private static final Logger LOGGER = Logger.getLogger(FilteredWarmEmissionHandler.class.getName()); + private static final Logger LOGGER = LogManager.getLogger(FilteredWarmEmissionHandler.class.getName()); private final EmissionsPerLinkWarmEventHandler delegate; private final PersonFilter pf ; diff --git a/src/main/java/playground/amit/analysis/linkVolume/FilteredLinkVolumeHandler.java b/src/main/java/playground/amit/analysis/linkVolume/FilteredLinkVolumeHandler.java index 18b666792..65e2f5325 100644 --- a/src/main/java/playground/amit/analysis/linkVolume/FilteredLinkVolumeHandler.java +++ b/src/main/java/playground/amit/analysis/linkVolume/FilteredLinkVolumeHandler.java @@ -19,9 +19,8 @@ package playground.amit.analysis.linkVolume; -import java.util.List; -import java.util.Map; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.LinkLeaveEvent; import org.matsim.api.core.v01.events.VehicleEntersTrafficEvent; @@ -35,6 +34,9 @@ import org.matsim.vehicles.Vehicle; import playground.amit.utils.PersonFilter; +import java.util.List; +import java.util.Map; + /** * Created by amit on 02/01/2017. */ @@ -42,7 +44,7 @@ public class FilteredLinkVolumeHandler implements LinkLeaveEventHandler, VehicleEntersTrafficEventHandler, VehicleLeavesTrafficEventHandler { - private static final Logger LOGGER = Logger.getLogger(FilteredLinkVolumeHandler.class); + private static final Logger LOGGER = LogManager.getLogger(FilteredLinkVolumeHandler.class); private final LinkVolumeHandler delegate; private final Vehicle2DriverEventHandler veh2DriverDelegate = new Vehicle2DriverEventHandler(); diff --git a/src/main/java/playground/amit/analysis/linkVolume/LinkVolumeHandler.java b/src/main/java/playground/amit/analysis/linkVolume/LinkVolumeHandler.java index b7c4c67a9..31c78306e 100644 --- a/src/main/java/playground/amit/analysis/linkVolume/LinkVolumeHandler.java +++ b/src/main/java/playground/amit/analysis/linkVolume/LinkVolumeHandler.java @@ -18,12 +18,8 @@ * *********************************************************************** */ package playground.amit.analysis.linkVolume; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.LinkLeaveEvent; import org.matsim.api.core.v01.events.VehicleEntersTrafficEvent; @@ -41,12 +37,17 @@ import playground.amit.mixedTraffic.MixedTrafficVehiclesUtils; import playground.amit.utils.PersonFilter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + /** * @author amit */ public class LinkVolumeHandler implements LinkLeaveEventHandler, VehicleEntersTrafficEventHandler, VehicleLeavesTrafficEventHandler { - private static final Logger LOG = Logger.getLogger(LinkVolumeHandler.class); + private static final Logger LOG = LogManager.getLogger(LinkVolumeHandler.class); private final Map, Map> linkId2Time2Count = new HashMap<>(); private final Map, Map> linkId2Time2PCUVol = new HashMap<>(); private final Map, Map>>> linkId2Time2Persons = new HashMap<>(); diff --git a/src/main/java/playground/amit/analysis/modalShare/ModalShareEventHandler.java b/src/main/java/playground/amit/analysis/modalShare/ModalShareEventHandler.java index 6667f567e..6c4214a98 100644 --- a/src/main/java/playground/amit/analysis/modalShare/ModalShareEventHandler.java +++ b/src/main/java/playground/amit/analysis/modalShare/ModalShareEventHandler.java @@ -19,13 +19,7 @@ package playground.amit.analysis.modalShare; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.SortedMap; -import java.util.TreeMap; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.events.ActivityStartEvent; @@ -39,6 +33,8 @@ import org.matsim.api.core.v01.population.Person; import org.matsim.core.router.StageActivityTypeIdentifier; +import java.util.*; + /** * If someone starts with transit_walk leg, and do not use pt before starting a regular act (home/work/leis/shop); it is walk * else it is pt mode. @@ -108,7 +104,7 @@ private void storeMode(String legMode) { } private void handleRemainingTransitUsers(){ - Logger.getLogger(ModalShareEventHandler.class).warn("A few transit users are not handle due to stuckAndAbort. Handling them now."); + LogManager.getLogger(ModalShareEventHandler.class).warn("A few transit users are not handle due to stuckAndAbort. Handling them now."); for(Id pId : person2Modes.keySet()){ String legMode = getMainMode(person2Modes.get(pId)); storeMode(legMode); diff --git a/src/main/java/playground/amit/analysis/modeSwitcherRetainer/ModeSwitcherInfoCollector.java b/src/main/java/playground/amit/analysis/modeSwitcherRetainer/ModeSwitcherInfoCollector.java index 9a97090ca..1d9976c89 100644 --- a/src/main/java/playground/amit/analysis/modeSwitcherRetainer/ModeSwitcherInfoCollector.java +++ b/src/main/java/playground/amit/analysis/modeSwitcherRetainer/ModeSwitcherInfoCollector.java @@ -18,12 +18,14 @@ * *********************************************************************** */ package playground.amit.analysis.modeSwitcherRetainer; -import java.util.ArrayList; -import java.util.List; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; +import java.util.ArrayList; +import java.util.List; + /** * A class to store all information of mode switchers/retainers * @author amit @@ -31,7 +33,7 @@ class ModeSwitcherInfoCollector { - private static final Logger LOG = Logger.getLogger(ModeSwitcherInfoCollector.class); + private static final Logger LOG = LogManager.getLogger(ModeSwitcherInfoCollector.class); private final List> personIds = new ArrayList<>(); private double firstIterationStat = 0.; diff --git a/src/main/java/playground/amit/analysis/modeSwitcherRetainer/ModeSwitchersTripDistance.java b/src/main/java/playground/amit/analysis/modeSwitcherRetainer/ModeSwitchersTripDistance.java index 67a2e8a43..df74fad65 100644 --- a/src/main/java/playground/amit/analysis/modeSwitcherRetainer/ModeSwitchersTripDistance.java +++ b/src/main/java/playground/amit/analysis/modeSwitcherRetainer/ModeSwitchersTripDistance.java @@ -18,15 +18,8 @@ * *********************************************************************** */ package playground.amit.analysis.modeSwitcherRetainer; -import java.io.BufferedWriter; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.SortedMap; -import java.util.TreeMap; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.Person; @@ -42,6 +35,9 @@ import playground.amit.utils.LoadMyScenarios; import playground.amit.utils.PersonFilter; +import java.io.BufferedWriter; +import java.util.*; + /** * This will first find mode switchers and then returns trip distances in groups. @@ -51,7 +47,7 @@ public class ModeSwitchersTripDistance { - private static final Logger LOG = Logger.getLogger(ModeSwitchersTripDistance.class); + private static final Logger LOG = LogManager.getLogger(ModeSwitchersTripDistance.class); public ModeSwitchersTripDistance(){ this(null, null, TripDistanceType.ROUTE_DISTANCE); diff --git a/src/main/java/playground/amit/analysis/modeSwitcherRetainer/ModeSwitchersTripTime.java b/src/main/java/playground/amit/analysis/modeSwitcherRetainer/ModeSwitchersTripTime.java index a6ee07f94..c958f4db6 100644 --- a/src/main/java/playground/amit/analysis/modeSwitcherRetainer/ModeSwitchersTripTime.java +++ b/src/main/java/playground/amit/analysis/modeSwitcherRetainer/ModeSwitchersTripTime.java @@ -18,9 +18,8 @@ * *********************************************************************** */ package playground.amit.analysis.modeSwitcherRetainer; -import java.io.BufferedWriter; -import java.util.*; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.Person; @@ -31,6 +30,9 @@ import playground.amit.utils.LoadMyScenarios; import playground.amit.utils.PersonFilter; +import java.io.BufferedWriter; +import java.util.*; + /** *This will first find mode switchers and then returns trip times in groups. *

@@ -39,7 +41,7 @@ public class ModeSwitchersTripTime { - private static final Logger LOG = Logger.getLogger(ModeSwitchersTripTime.class); + private static final Logger LOG = LogManager.getLogger(ModeSwitchersTripTime.class); public ModeSwitchersTripTime(){ this(null, null); diff --git a/src/main/java/playground/amit/analysis/spatial/GeneralGrid.java b/src/main/java/playground/amit/analysis/spatial/GeneralGrid.java index 9945b4996..25484154f 100644 --- a/src/main/java/playground/amit/analysis/spatial/GeneralGrid.java +++ b/src/main/java/playground/amit/analysis/spatial/GeneralGrid.java @@ -26,7 +26,8 @@ import java.util.HashMap; import java.util.Map; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.GeometryFactory; @@ -48,7 +49,7 @@ */ public class GeneralGrid{ - private final static Logger LOG = Logger.getLogger(GeneralGrid.class); + private final static Logger LOG = LogManager.getLogger(GeneralGrid.class); private Geometry geometry; private QuadTree qt; diff --git a/src/main/java/playground/amit/analysis/spatial/SpatialDataInputs.java b/src/main/java/playground/amit/analysis/spatial/SpatialDataInputs.java index f0f29d7bd..0ad8143b3 100644 --- a/src/main/java/playground/amit/analysis/spatial/SpatialDataInputs.java +++ b/src/main/java/playground/amit/analysis/spatial/SpatialDataInputs.java @@ -18,13 +18,14 @@ * *********************************************************************** */ package playground.amit.analysis.spatial; -import java.io.File; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.opengis.referencing.crs.CoordinateReferenceSystem; - import playground.amit.analysis.spatial.GeneralGrid.GridType; import playground.amit.utils.LoadMyScenarios; +import java.io.File; + /** * All inputs parameters required for spatial analysis are listed and set here. * @author amit @@ -34,7 +35,7 @@ public class SpatialDataInputs { public enum LinkWeightMethod {line, point} - public final static Logger LOG = Logger.getLogger(SpatialDataInputs.class); + public final static Logger LOG = LogManager.getLogger(SpatialDataInputs.class); private final LinkWeightMethod linkWeigthMethod; diff --git a/src/main/java/playground/amit/analysis/toll/FilteredTollHandler.java b/src/main/java/playground/amit/analysis/toll/FilteredTollHandler.java index 1a2e9a185..a01267b12 100644 --- a/src/main/java/playground/amit/analysis/toll/FilteredTollHandler.java +++ b/src/main/java/playground/amit/analysis/toll/FilteredTollHandler.java @@ -19,44 +19,32 @@ package playground.amit.analysis.toll; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; -import java.util.SortedMap; - -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.locationtech.jts.geom.Geometry; import org.matsim.api.core.v01.Id; -import org.matsim.api.core.v01.events.LinkLeaveEvent; -import org.matsim.api.core.v01.events.PersonDepartureEvent; -import org.matsim.api.core.v01.events.PersonMoneyEvent; -import org.matsim.api.core.v01.events.VehicleEntersTrafficEvent; -import org.matsim.api.core.v01.events.VehicleLeavesTrafficEvent; -import org.matsim.api.core.v01.events.handler.LinkLeaveEventHandler; -import org.matsim.api.core.v01.events.handler.PersonDepartureEventHandler; -import org.matsim.api.core.v01.events.handler.PersonMoneyEventHandler; -import org.matsim.api.core.v01.events.handler.VehicleEntersTrafficEventHandler; -import org.matsim.api.core.v01.events.handler.VehicleLeavesTrafficEventHandler; +import org.matsim.api.core.v01.events.*; +import org.matsim.api.core.v01.events.handler.*; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.api.core.v01.population.Person; import org.matsim.core.events.algorithms.Vehicle2DriverEventHandler; import org.matsim.core.utils.gis.ShapeFileReader; import org.opengis.feature.simple.SimpleFeature; - import playground.amit.munich.utils.MunichPersonFilter; import playground.amit.utils.geometry.GeometryUtils; import playground.vsp.congestion.events.CongestionEvent; import playground.vsp.congestion.handlers.CongestionEventHandler; +import java.util.*; + /** * @author amit */ public class FilteredTollHandler implements PersonMoneyEventHandler, PersonDepartureEventHandler, LinkLeaveEventHandler, CongestionEventHandler, VehicleEntersTrafficEventHandler, VehicleLeavesTrafficEventHandler { - private static final Logger LOGGER = Logger.getLogger(FilteredTollHandler.class.getName()); + private static final Logger LOGGER = LogManager.getLogger(FilteredTollHandler.class.getName()); private final TollInfoHandler delegate; private final Vehicle2DriverEventHandler veh2DriverDelegate = new Vehicle2DriverEventHandler(); diff --git a/src/main/java/playground/amit/analysis/toll/TollAnalyzer.java b/src/main/java/playground/amit/analysis/toll/TollAnalyzer.java index c98b2e732..fcd34045f 100644 --- a/src/main/java/playground/amit/analysis/toll/TollAnalyzer.java +++ b/src/main/java/playground/amit/analysis/toll/TollAnalyzer.java @@ -18,16 +18,8 @@ * *********************************************************************** */ package playground.amit.analysis.toll; -import java.io.BufferedWriter; -import java.io.File; -import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.SortedMap; -import java.util.TreeMap; - -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Network; import org.matsim.api.core.v01.population.Person; @@ -36,18 +28,22 @@ import org.matsim.core.events.MatsimEventsReader; import org.matsim.core.events.handler.EventHandler; import org.matsim.core.utils.io.IOUtils; - import playground.amit.munich.utils.MunichPersonFilter.MunichUserGroup; import playground.amit.utils.LoadMyScenarios; import playground.amit.utils.MapUtils; import playground.vsp.analysis.modules.AbstractAnalysisModule; +import java.io.BufferedWriter; +import java.io.File; +import java.io.IOException; +import java.util.*; + /** * @author amit */ public class TollAnalyzer extends AbstractAnalysisModule { - private static final Logger LOG = Logger.getLogger(TollAnalyzer.class); + private static final Logger LOG = LogManager.getLogger(TollAnalyzer.class); private final String eventsFile; private final FilteredTollHandler handler; diff --git a/src/main/java/playground/amit/analysis/toll/TripTollHandler.java b/src/main/java/playground/amit/analysis/toll/TripTollHandler.java index 585c13415..24e1c23a3 100644 --- a/src/main/java/playground/amit/analysis/toll/TripTollHandler.java +++ b/src/main/java/playground/amit/analysis/toll/TripTollHandler.java @@ -18,15 +18,8 @@ * *********************************************************************** */ package playground.amit.analysis.toll; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.SortedMap; -import java.util.TreeMap; - -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.events.PersonArrivalEvent; @@ -38,12 +31,14 @@ import org.matsim.api.core.v01.population.Person; import org.matsim.core.gbl.Gbl; +import java.util.*; + /** * @author amit */ public class TripTollHandler implements PersonMoneyEventHandler, PersonDepartureEventHandler, PersonArrivalEventHandler { - private static final Logger LOG = Logger.getLogger(TripTollHandler.class); + private static final Logger LOG = LogManager.getLogger(TripTollHandler.class); private final double timeBinSize; private int nonCarWarning= 0; diff --git a/src/main/java/playground/amit/analysis/tripDistance/FilteredTripRouteDistanceHandler.java b/src/main/java/playground/amit/analysis/tripDistance/FilteredTripRouteDistanceHandler.java index 4def97753..3dace46bd 100644 --- a/src/main/java/playground/amit/analysis/tripDistance/FilteredTripRouteDistanceHandler.java +++ b/src/main/java/playground/amit/analysis/tripDistance/FilteredTripRouteDistanceHandler.java @@ -19,12 +19,8 @@ package playground.amit.analysis.tripDistance; -import java.io.BufferedWriter; -import java.io.IOException; -import java.util.List; -import java.util.Map; -import java.util.SortedMap; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.*; import org.matsim.api.core.v01.events.handler.*; @@ -40,6 +36,12 @@ import playground.amit.utils.LoadMyScenarios; import playground.amit.utils.PersonFilter; +import java.io.BufferedWriter; +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.SortedMap; + /** * Created by amit on 31/12/2016. */ @@ -47,7 +49,7 @@ public class FilteredTripRouteDistanceHandler implements PersonDepartureEventHandler, LinkLeaveEventHandler, PersonArrivalEventHandler, VehicleEntersTrafficEventHandler, VehicleLeavesTrafficEventHandler { - private static final Logger LOGGER = Logger.getLogger(FilteredTripRouteDistanceHandler.class); + private static final Logger LOGGER = LogManager.getLogger(FilteredTripRouteDistanceHandler.class); private final Vehicle2DriverEventHandler veh2DriverDelegate = new Vehicle2DriverEventHandler(); private final TripRouteDistanceInTimeBinHandler delegate; diff --git a/src/main/java/playground/amit/analysis/tripDistance/LegModeBeelineDistanceDistributionFromPlansAnalyzer.java b/src/main/java/playground/amit/analysis/tripDistance/LegModeBeelineDistanceDistributionFromPlansAnalyzer.java index 5bd3b6637..b625b0cd2 100644 --- a/src/main/java/playground/amit/analysis/tripDistance/LegModeBeelineDistanceDistributionFromPlansAnalyzer.java +++ b/src/main/java/playground/amit/analysis/tripDistance/LegModeBeelineDistanceDistributionFromPlansAnalyzer.java @@ -19,29 +19,13 @@ * *********************************************************************** */ package playground.amit.analysis.tripDistance; -import java.io.BufferedWriter; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.SortedMap; -import java.util.SortedSet; -import java.util.TreeMap; -import java.util.TreeSet; -import java.util.stream.Collectors; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; -import org.matsim.api.core.v01.population.Activity; -import org.matsim.api.core.v01.population.Leg; -import org.matsim.api.core.v01.population.Person; -import org.matsim.api.core.v01.population.Plan; -import org.matsim.api.core.v01.population.PlanElement; -import org.matsim.api.core.v01.population.Population; -import org.matsim.api.core.v01.population.Route; +import org.matsim.api.core.v01.population.*; import org.matsim.core.events.handler.EventHandler; import org.matsim.core.population.PopulationUtils; import org.matsim.core.utils.geometry.CoordUtils; @@ -50,6 +34,10 @@ import playground.amit.utils.PersonFilter; import playground.vsp.analysis.modules.AbstractAnalysisModule; +import java.io.BufferedWriter; +import java.util.*; +import java.util.stream.Collectors; + /** * Provides leg mode distance distribution, distances are calculated from routes of selected plans * unlike playground.vsp.analysis.modules.legModeDistanceDistribution where beeline distance is calculated @@ -58,7 +46,7 @@ * @author amit */ public class LegModeBeelineDistanceDistributionFromPlansAnalyzer extends AbstractAnalysisModule{ - private final static Logger LOG = Logger.getLogger(LegModeBeelineDistanceDistributionFromPlansAnalyzer.class); + private final static Logger LOG = LogManager.getLogger(LegModeBeelineDistanceDistributionFromPlansAnalyzer.class); private Scenario scenario; private final List distanceClasses; diff --git a/src/main/java/playground/amit/analysis/tripDistance/LegModeBeelineDistanceDistributionHandler.java b/src/main/java/playground/amit/analysis/tripDistance/LegModeBeelineDistanceDistributionHandler.java index 41359f0ed..b16f40ef4 100644 --- a/src/main/java/playground/amit/analysis/tripDistance/LegModeBeelineDistanceDistributionHandler.java +++ b/src/main/java/playground/amit/analysis/tripDistance/LegModeBeelineDistanceDistributionHandler.java @@ -19,8 +19,8 @@ package playground.amit.analysis.tripDistance; -import java.util.*; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.PersonArrivalEvent; @@ -31,13 +31,15 @@ import org.matsim.api.core.v01.population.Person; import org.matsim.core.utils.geometry.CoordUtils; +import java.util.*; + /** * Created by amit on 20/10/16. */ public class LegModeBeelineDistanceDistributionHandler implements PersonDepartureEventHandler, PersonArrivalEventHandler { - private static final Logger LOG = Logger.getLogger(LegModeBeelineDistanceDistributionHandler.class); + private static final Logger LOG = LogManager.getLogger(LegModeBeelineDistanceDistributionHandler.class); private final SortedMap, List>> mode2PersonId2distances = new TreeMap<>(); diff --git a/src/main/java/playground/amit/analysis/tripDistance/LegModeRouteDistanceDistributionAnalyzer.java b/src/main/java/playground/amit/analysis/tripDistance/LegModeRouteDistanceDistributionAnalyzer.java index 31444a8cf..0b8bb93e0 100644 --- a/src/main/java/playground/amit/analysis/tripDistance/LegModeRouteDistanceDistributionAnalyzer.java +++ b/src/main/java/playground/amit/analysis/tripDistance/LegModeRouteDistanceDistributionAnalyzer.java @@ -18,16 +18,8 @@ * *********************************************************************** */ package playground.amit.analysis.tripDistance; -import java.io.BufferedWriter; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.SortedMap; -import java.util.SortedSet; -import java.util.TreeMap; -import java.util.TreeSet; - -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.Person; @@ -39,6 +31,9 @@ import playground.amit.munich.utils.MunichPersonFilter; import playground.vsp.analysis.modules.AbstractAnalysisModule; +import java.io.BufferedWriter; +import java.util.*; + /** * @author amit */ @@ -46,7 +41,7 @@ public class LegModeRouteDistanceDistributionAnalyzer extends AbstractAnalysisMo private final List distanceClasses; private SortedSet usedModes; - private final static Logger LOG = Logger.getLogger(LegModeRouteDistanceDistributionAnalyzer.class); + private final static Logger LOG = LogManager.getLogger(LegModeRouteDistanceDistributionAnalyzer.class); private final SortedMap> mode2DistanceClass2LegCount ; private SortedMap, List>> mode2PersonId2dist; diff --git a/src/main/java/playground/amit/analysis/tripDistance/ModeFilterTripDistanceHandler.java b/src/main/java/playground/amit/analysis/tripDistance/ModeFilterTripDistanceHandler.java index e7641389c..e3ede9f72 100644 --- a/src/main/java/playground/amit/analysis/tripDistance/ModeFilterTripDistanceHandler.java +++ b/src/main/java/playground/amit/analysis/tripDistance/ModeFilterTripDistanceHandler.java @@ -19,8 +19,8 @@ package playground.amit.analysis.tripDistance; -import java.util.*; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.*; import org.matsim.api.core.v01.events.handler.*; @@ -28,6 +28,11 @@ import org.matsim.api.core.v01.population.Person; import org.matsim.core.events.algorithms.Vehicle2DriverEventHandler; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.SortedMap; + /** * Created by amit on 11/10/16. */ @@ -36,7 +41,7 @@ public class ModeFilterTripDistanceHandler implements PersonDepartureEventHandler, PersonArrivalEventHandler, LinkLeaveEventHandler, VehicleEntersTrafficEventHandler, VehicleLeavesTrafficEventHandler{ - private static final Logger LOG = Logger.getLogger(ModeFilterTripDistanceHandler.class); + private static final Logger LOG = LogManager.getLogger(ModeFilterTripDistanceHandler.class); private final TripRouteDistanceInTimeBinHandler delegate ; private final String mode2Consider; private final Map,String> personId2mode = new HashMap<>(); // person id -- mode diff --git a/src/main/java/playground/amit/analysis/tripDistance/TravelDistanceHandler.java b/src/main/java/playground/amit/analysis/tripDistance/TravelDistanceHandler.java index b9acab91e..20e26b671 100644 --- a/src/main/java/playground/amit/analysis/tripDistance/TravelDistanceHandler.java +++ b/src/main/java/playground/amit/analysis/tripDistance/TravelDistanceHandler.java @@ -19,13 +19,8 @@ package playground.amit.analysis.tripDistance; -import java.io.BufferedWriter; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import java.util.SortedMap; -import java.util.TreeMap; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.LinkLeaveEvent; import org.matsim.api.core.v01.events.VehicleEntersTrafficEvent; @@ -44,12 +39,19 @@ import playground.amit.munich.utils.MunichPersonFilter; import playground.amit.utils.*; +import java.io.BufferedWriter; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.SortedMap; +import java.util.TreeMap; + /** * @author amit */ public class TravelDistanceHandler implements LinkLeaveEventHandler, VehicleEntersTrafficEventHandler, VehicleLeavesTrafficEventHandler { - private static final Logger LOGGER = Logger.getLogger(TravelDistanceHandler.class.getName()); + private static final Logger LOGGER = LogManager.getLogger(TravelDistanceHandler.class.getName()); private final Vehicle2DriverEventHandler veh2DriverDelegate = new Vehicle2DriverEventHandler(); private final PersonFilter pf ; diff --git a/src/main/java/playground/amit/analysis/tripDistance/TripDistanceHandler.java b/src/main/java/playground/amit/analysis/tripDistance/TripDistanceHandler.java index 4e43e6c36..db2e82117 100644 --- a/src/main/java/playground/amit/analysis/tripDistance/TripDistanceHandler.java +++ b/src/main/java/playground/amit/analysis/tripDistance/TripDistanceHandler.java @@ -28,7 +28,8 @@ import java.util.SortedSet; import java.util.TreeMap; import java.util.TreeSet; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -56,7 +57,7 @@ */ public class TripDistanceHandler implements PersonDepartureEventHandler, LinkLeaveEventHandler, PersonArrivalEventHandler, TeleportationArrivalEventHandler, VehicleEntersTrafficEventHandler, VehicleLeavesTrafficEventHandler { - private final static Logger LOG = Logger.getLogger(TripDistanceHandler.class); + private final static Logger LOG = LogManager.getLogger(TripDistanceHandler.class); private final Network network; private final SortedMap, List>> mode2PersonId2distances = new TreeMap<>(); diff --git a/src/main/java/playground/amit/analysis/tripDistance/TripRouteDistanceInTimeBinHandler.java b/src/main/java/playground/amit/analysis/tripDistance/TripRouteDistanceInTimeBinHandler.java index eeb4a9cf8..e75b80da8 100644 --- a/src/main/java/playground/amit/analysis/tripDistance/TripRouteDistanceInTimeBinHandler.java +++ b/src/main/java/playground/amit/analysis/tripDistance/TripRouteDistanceInTimeBinHandler.java @@ -19,7 +19,8 @@ package playground.amit.analysis.tripDistance; import java.util.*; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.*; import org.matsim.api.core.v01.events.handler.*; @@ -38,7 +39,7 @@ public class TripRouteDistanceInTimeBinHandler implements PersonDepartureEventHandler, PersonArrivalEventHandler, LinkLeaveEventHandler, VehicleEntersTrafficEventHandler, VehicleLeavesTrafficEventHandler { - private static final Logger LOG = Logger.getLogger(TripRouteDistanceInTimeBinHandler.class); + private static final Logger LOG = LogManager.getLogger(TripRouteDistanceInTimeBinHandler.class); private final SortedMap,Double> personId2TripDepartTimeBin = new TreeMap<>(); private final SortedMap,Integer>> timeBin2Person2TripsCount = new TreeMap<>(); private final SortedMap,List>> timeBin2Person2TripsDistance = new TreeMap<>(); diff --git a/src/main/java/playground/amit/analysis/tripTime/LegModeTripTimeDistributionAnalyzer.java b/src/main/java/playground/amit/analysis/tripTime/LegModeTripTimeDistributionAnalyzer.java index bd49806be..6433c46c6 100644 --- a/src/main/java/playground/amit/analysis/tripTime/LegModeTripTimeDistributionAnalyzer.java +++ b/src/main/java/playground/amit/analysis/tripTime/LegModeTripTimeDistributionAnalyzer.java @@ -20,7 +20,8 @@ import java.io.BufferedWriter; import java.util.*; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.core.api.experimental.events.EventsManager; @@ -41,7 +42,7 @@ public class LegModeTripTimeDistributionAnalyzer extends AbstractAnalysisModule private final List timeClasses = new ArrayList<>(); private final SortedSet usedModes = new TreeSet<>(); - private static final Logger LOG = Logger.getLogger(LegModeTripTimeDistributionAnalyzer.class); + private static final Logger LOG = LogManager.getLogger(LegModeTripTimeDistributionAnalyzer.class); private final SortedMap> mode2timeClass2LegCount = new TreeMap<>(); private final SortedMap, List>> mode2PersonId2tripTimes = new TreeMap<>(); diff --git a/src/main/java/playground/amit/analysis/userBenefits/MyUserBenefitsAnalyzer.java b/src/main/java/playground/amit/analysis/userBenefits/MyUserBenefitsAnalyzer.java index 0815b594b..17b5af2c0 100644 --- a/src/main/java/playground/amit/analysis/userBenefits/MyUserBenefitsAnalyzer.java +++ b/src/main/java/playground/amit/analysis/userBenefits/MyUserBenefitsAnalyzer.java @@ -19,12 +19,8 @@ package playground.amit.analysis.userBenefits; -import java.io.BufferedWriter; -import java.io.IOException; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.core.events.handler.EventHandler; @@ -35,6 +31,12 @@ import playground.vsp.analysis.modules.userBenefits.UserBenefitsCalculator; import playground.vsp.analysis.modules.userBenefits.WelfareMeasure; +import java.io.BufferedWriter; +import java.io.IOException; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + /** * This module calculates the logsum for each user and the sum of all user logsums in monetary units. * Furthermore, it analyzes users with no valid plan, that are not considered for the logsum calculation. @@ -44,7 +46,7 @@ */ public class MyUserBenefitsAnalyzer extends AbstractAnalysisModule{ - private static final Logger LOG = Logger.getLogger(UserBenefitsAnalyzer.class); + private static final Logger LOG = LogManager.getLogger(UserBenefitsAnalyzer.class); private MutableScenario scenario; private UserBenefitsCalculator userWelfareCalculator; diff --git a/src/main/java/playground/amit/analysis/userBenefits/UserBenefitsAndTotalWelfare.java b/src/main/java/playground/amit/analysis/userBenefits/UserBenefitsAndTotalWelfare.java index cd989421e..0195c5762 100644 --- a/src/main/java/playground/amit/analysis/userBenefits/UserBenefitsAndTotalWelfare.java +++ b/src/main/java/playground/amit/analysis/userBenefits/UserBenefitsAndTotalWelfare.java @@ -18,12 +18,8 @@ * *********************************************************************** */ package playground.amit.analysis.userBenefits; -import java.io.BufferedWriter; -import java.io.IOException; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.Person; @@ -33,17 +29,21 @@ import org.matsim.core.events.handler.EventHandler; import org.matsim.core.scenario.MutableScenario; import org.matsim.core.utils.io.IOUtils; - import playground.amit.utils.LoadMyScenarios; import playground.vsp.analysis.modules.monetaryTransferPayments.MonetaryPaymentsAnalyzer; import playground.vsp.analysis.modules.userBenefits.WelfareMeasure; +import java.io.BufferedWriter; +import java.io.IOException; +import java.util.List; +import java.util.Map; + /** * @author amit */ public class UserBenefitsAndTotalWelfare { - public static final Logger LOGGER = Logger.getLogger(UserBenefitsAndTotalWelfare.class); + public static final Logger LOGGER = LogManager.getLogger(UserBenefitsAndTotalWelfare.class); private final String outputDir; private static final WelfareMeasure WM = WelfareMeasure.SELECTED; private MutableScenario sc; diff --git a/src/main/java/playground/amit/berlin/berlinBVG09/BerlinEmissionVehicleFromEvents.java b/src/main/java/playground/amit/berlin/berlinBVG09/BerlinEmissionVehicleFromEvents.java index d9f832c69..157a61d5e 100644 --- a/src/main/java/playground/amit/berlin/berlinBVG09/BerlinEmissionVehicleFromEvents.java +++ b/src/main/java/playground/amit/berlin/berlinBVG09/BerlinEmissionVehicleFromEvents.java @@ -20,9 +20,8 @@ package playground.amit.berlin.berlinBVG09; -import java.util.HashMap; -import java.util.Map; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.TransitDriverStartsEvent; import org.matsim.api.core.v01.events.VehicleEntersTrafficEvent; @@ -36,12 +35,15 @@ import org.matsim.vehicles.*; import playground.amit.utils.FileUtils; +import java.util.HashMap; +import java.util.Map; + /** * @author benjamin * */ public class BerlinEmissionVehicleFromEvents implements VehicleEntersTrafficEventHandler, TransitDriverStartsEventHandler { - private static final Logger LOGGER = Logger.getLogger(BerlinEmissionVehicleFromEvents.class); + private static final Logger LOGGER = LogManager.getLogger(BerlinEmissionVehicleFromEvents.class); private final BerlinTransitVehicleTypeIdentifier berlinTransitVehicleTypeIdentifier; private final Map,Id> transitDriver2TransitVehicle = new HashMap<>(); diff --git a/src/main/java/playground/amit/berlin/berlinBVG09/BerlinEmissionVehicleFromPlans.java b/src/main/java/playground/amit/berlin/berlinBVG09/BerlinEmissionVehicleFromPlans.java index a944ecb11..67b71a391 100644 --- a/src/main/java/playground/amit/berlin/berlinBVG09/BerlinEmissionVehicleFromPlans.java +++ b/src/main/java/playground/amit/berlin/berlinBVG09/BerlinEmissionVehicleFromPlans.java @@ -19,8 +19,8 @@ * *********************************************************************** */ package playground.amit.berlin.berlinBVG09; - -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.Person; @@ -35,7 +35,7 @@ * */ public class BerlinEmissionVehicleFromPlans { - private static final Logger logger = Logger.getLogger(BerlinEmissionVehicleFromEvents.class); + private static final Logger logger = LogManager.getLogger(BerlinEmissionVehicleFromEvents.class); private final String populationFile = FileUtils.RUNS_SVN+"/berlin-bvg09/bvg.run189.10pct/ITERS/it.100/bvg.run189.10pct.100.plans.filtered.selected.xml.gz"; private final String netFile = FileUtils.RUNS_SVN+"/berlin-bvg09/bvg.run189.10pct/emissionsRelatedFiles/rev554B-bvg00-0.1sample.network_withRoadTypes.xml"; diff --git a/src/main/java/playground/amit/berlin/berlinBVG09/BerlinPersonFilter.java b/src/main/java/playground/amit/berlin/berlinBVG09/BerlinPersonFilter.java index 46bb3fd1c..20b02e100 100644 --- a/src/main/java/playground/amit/berlin/berlinBVG09/BerlinPersonFilter.java +++ b/src/main/java/playground/amit/berlin/berlinBVG09/BerlinPersonFilter.java @@ -19,14 +19,16 @@ package playground.amit.berlin.berlinBVG09; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import playground.amit.utils.PersonFilter; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + /** * Created by amit on 11.06.17. */ @@ -34,7 +36,7 @@ public class BerlinPersonFilter implements PersonFilter { - private static final Logger LOGGER = Logger.getLogger(BerlinPersonFilter.class); + private static final Logger LOGGER = LogManager.getLogger(BerlinPersonFilter.class); public enum BerlinUserGroup { carUsers_berlin, carUsers_brandenburger, carUsers_tourists, carUsers_airport, diff --git a/src/main/java/playground/amit/berlin/berlinBVG09/BerlinTransitVehicleTypeIdentifier.java b/src/main/java/playground/amit/berlin/berlinBVG09/BerlinTransitVehicleTypeIdentifier.java index 11cbf429a..84c3a667c 100644 --- a/src/main/java/playground/amit/berlin/berlinBVG09/BerlinTransitVehicleTypeIdentifier.java +++ b/src/main/java/playground/amit/berlin/berlinBVG09/BerlinTransitVehicleTypeIdentifier.java @@ -23,7 +23,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.contrib.emissions.HbefaVehicleCategory; @@ -44,7 +45,7 @@ public enum BerlinTransitEmissionVehicleType { BUS_AS_HGV, TRAINS_AS_ZERO_EMISSIONS } - private static final Logger LOGGER = Logger.getLogger(BerlinTransitVehicleTypeIdentifier.class); + private static final Logger LOGGER = LogManager.getLogger(BerlinTransitVehicleTypeIdentifier.class); private final Map>> vehicleCategoryToVehicleTypeList = new HashMap<>(); private Vehicles transitVehicles; private final Map, BerlinTransitEmissionVehicleType> transitVehicleType2BerlinVehicleType = new HashMap<>(); diff --git a/src/main/java/playground/amit/clustering/ClusterAlgorithm.java b/src/main/java/playground/amit/clustering/ClusterAlgorithm.java index 06bce7343..595d84c0f 100644 --- a/src/main/java/playground/amit/clustering/ClusterAlgorithm.java +++ b/src/main/java/playground/amit/clustering/ClusterAlgorithm.java @@ -19,15 +19,17 @@ package playground.amit.clustering; -import java.awt.*; -import java.util.*; -import java.util.List; -import javax.swing.*; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.jfree.chart.ChartPanel; import org.matsim.core.utils.charts.XYScatterChart; import playground.amit.utils.NumberUtils; +import javax.swing.*; +import java.awt.*; +import java.util.List; +import java.util.*; + /** * * If weight of all points is 1, it is called as K-Mean cluster algorithm @@ -53,7 +55,7 @@ public enum ClusterType { */ K_MEANS } - private static final Logger LOGGER = Logger.getLogger(ClusterAlgorithm.class); + private static final Logger LOGGER = LogManager.getLogger(ClusterAlgorithm.class); private final int numberOfClusters; private final BoundingBox boundingBox; diff --git a/src/main/java/playground/amit/congestionPricing/testExamples/handlers/CongestionTestExamples.java b/src/main/java/playground/amit/congestionPricing/testExamples/handlers/CongestionTestExamples.java index 7d5b7b239..482a75831 100644 --- a/src/main/java/playground/amit/congestionPricing/testExamples/handlers/CongestionTestExamples.java +++ b/src/main/java/playground/amit/congestionPricing/testExamples/handlers/CongestionTestExamples.java @@ -18,12 +18,7 @@ * *********************************************************************** */ package playground.amit.congestionPricing.testExamples.handlers; -import java.util.ArrayList; -import java.util.List; -import java.util.SortedMap; -import java.util.TreeMap; - -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.events.LinkEnterEvent; @@ -39,12 +34,16 @@ import org.matsim.core.mobsim.qsim.QSim; import org.matsim.core.mobsim.qsim.QSimBuilder; import org.matsim.core.utils.collections.Tuple; - import playground.vsp.congestion.events.CongestionEvent; import playground.vsp.congestion.handlers.CongestionEventHandler; import playground.vsp.congestion.handlers.CongestionHandlerImplV3; import playground.vsp.congestion.handlers.CongestionHandlerImplV4; +import java.util.ArrayList; +import java.util.List; +import java.util.SortedMap; +import java.util.TreeMap; + /** * @author amit */ @@ -153,7 +152,7 @@ public void handleEvent(CongestionEvent event) { if(congestionPricingImpl.equalsIgnoreCase("v3")) { events.addHandler(new CongestionHandlerImplV3(events, sc)); - Logger.getLogger(CongestionTestExamples.class).warn("The analysis table is generated using events and thus there are some delays unaccounted in implV3."); + LogManager.getLogger(CongestionTestExamples.class).warn("The analysis table is generated using events and thus there are some delays unaccounted in implV3."); } else if(congestionPricingImpl.equalsIgnoreCase("v4")) events.addHandler(new CongestionHandlerImplV4(events, sc)); // else if(congestionPricingImpl.equalsIgnoreCase("v6")) events.addHandler(new CongestionHandlerImplV6(events, sc)); diff --git a/src/main/java/playground/amit/congestionPricing/testExamples/handlers/TestNetworkExperiment.java b/src/main/java/playground/amit/congestionPricing/testExamples/handlers/TestNetworkExperiment.java index ac6ff6495..df1125837 100644 --- a/src/main/java/playground/amit/congestionPricing/testExamples/handlers/TestNetworkExperiment.java +++ b/src/main/java/playground/amit/congestionPricing/testExamples/handlers/TestNetworkExperiment.java @@ -27,7 +27,8 @@ import java.util.Map; import java.util.Set; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -66,7 +67,7 @@ * @author amit */ class TestNetworkExperiment { - final Logger log = Logger.getLogger(TestNetworkExperiment.class); + final Logger log = LogManager.getLogger(TestNetworkExperiment.class); public static void main(String[] args) { diff --git a/src/main/java/playground/amit/emissions/flatEmissions/EmissionModalTravelDisutilityCalculator.java b/src/main/java/playground/amit/emissions/flatEmissions/EmissionModalTravelDisutilityCalculator.java index 5b13f6d65..60d3eabe5 100644 --- a/src/main/java/playground/amit/emissions/flatEmissions/EmissionModalTravelDisutilityCalculator.java +++ b/src/main/java/playground/amit/emissions/flatEmissions/EmissionModalTravelDisutilityCalculator.java @@ -19,11 +19,8 @@ package playground.amit.emissions.flatEmissions; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; - -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.population.Person; @@ -37,16 +34,19 @@ import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleUtils; import org.matsim.vehicles.Vehicles; - import playground.vsp.airPollution.flatEmissions.EmissionCostModule; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + /** * @author benjamin * */ class EmissionModalTravelDisutilityCalculator implements TravelDisutility { - public static final Logger LOGGER = Logger.getLogger(EmissionModalTravelDisutilityCalculator.class); + public static final Logger LOGGER = LogManager.getLogger(EmissionModalTravelDisutilityCalculator.class); private final TravelDisutility travelDisutility; private final TravelTime travelTime; diff --git a/src/main/java/playground/amit/emissions/onRoadExposure/OnRoadExposureCalculator.java b/src/main/java/playground/amit/emissions/onRoadExposure/OnRoadExposureCalculator.java index 9e856a032..d54545c71 100644 --- a/src/main/java/playground/amit/emissions/onRoadExposure/OnRoadExposureCalculator.java +++ b/src/main/java/playground/amit/emissions/onRoadExposure/OnRoadExposureCalculator.java @@ -19,11 +19,13 @@ package playground.amit.emissions.onRoadExposure; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.matsim.contrib.emissions.Pollutant; + +import javax.inject.Inject; import java.util.Map; import java.util.stream.Collectors; -import javax.inject.Inject; -import org.apache.log4j.Logger; -import org.matsim.contrib.emissions.Pollutant; /** * Created by amit on 08.11.17. @@ -31,7 +33,7 @@ public class OnRoadExposureCalculator { - private static final Logger LOGGER = Logger.getLogger(OnRoadExposureCalculator.class); + private static final Logger LOGGER = LogManager.getLogger(OnRoadExposureCalculator.class); private final OnRoadExposureConfigGroup config; diff --git a/src/main/java/playground/amit/emissions/onRoadExposure/OnRoadExposureTable.java b/src/main/java/playground/amit/emissions/onRoadExposure/OnRoadExposureTable.java index 360e79763..6472e6ee5 100644 --- a/src/main/java/playground/amit/emissions/onRoadExposure/OnRoadExposureTable.java +++ b/src/main/java/playground/amit/emissions/onRoadExposure/OnRoadExposureTable.java @@ -22,7 +22,8 @@ import java.util.*; import java.util.stream.Collectors; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.population.Person; @@ -34,7 +35,7 @@ public class OnRoadExposureTable { - private static final Logger LOG = Logger.getLogger(OnRoadExposureTable.class); + private static final Logger LOG = LogManager.getLogger(OnRoadExposureTable.class); private Map, List> personInfo = new HashMap<>(); /** diff --git a/src/main/java/playground/amit/fundamentalDiagrams/RunFDDataExample.java b/src/main/java/playground/amit/fundamentalDiagrams/RunFDDataExample.java index 776f3eec0..42900cc42 100644 --- a/src/main/java/playground/amit/fundamentalDiagrams/RunFDDataExample.java +++ b/src/main/java/playground/amit/fundamentalDiagrams/RunFDDataExample.java @@ -25,6 +25,7 @@ import org.matsim.core.controler.Controler; import org.matsim.core.scenario.ScenarioUtils; import playground.amit.fundamentalDiagrams.core.FDModule; +import playground.shivam.trafficChar.core.TrafficCharConfigGroup; /** * Created by amit on 16/02/2017. diff --git a/src/main/java/playground/amit/fundamentalDiagrams/RunFDTrafficCharExample.java b/src/main/java/playground/amit/fundamentalDiagrams/RunFDTrafficCharExample.java index cb57bac8a..596014271 100644 --- a/src/main/java/playground/amit/fundamentalDiagrams/RunFDTrafficCharExample.java +++ b/src/main/java/playground/amit/fundamentalDiagrams/RunFDTrafficCharExample.java @@ -22,6 +22,8 @@ import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; +import org.matsim.api.core.v01.network.Link; +import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.groups.ChangeModeConfigGroup; import org.matsim.core.config.groups.QSimConfigGroup; @@ -60,7 +62,6 @@ public static void main(String[] args) { String outFolder ="/1lane/"; scenario.getConfig().controler().setOutputDirectory(myDir+outFolder); - QSimConfigGroup qsim = scenario.getConfig().qsim(); List mainModes = Arrays.asList("car", "bicycle"); qsim.setMainModes(mainModes); @@ -84,11 +85,10 @@ public static void main(String[] args) { trafficCharConfigGroup.addQSimConfigGroup(TrafficCharConfigGroup.ROAD_TYPE_DEFAULT, scenario.getConfig().qsim()); -// scenario.getConfig().getModules().put(TrafficCharConfigGroup.GROUP_NAME, trafficCharConfigGroup); + scenario.getConfig().getModules().put(TrafficCharConfigGroup.GROUP_NAME, trafficCharConfigGroup); Controler controler = new Controler(scenario); - controler.addOverridingModule(new FDModule(scenario)); + controler.addOverridingModule(new FDModule(scenario, "PassingQ")); controler.run(); - } } diff --git a/src/main/java/playground/amit/fundamentalDiagrams/core/FDModule.java b/src/main/java/playground/amit/fundamentalDiagrams/core/FDModule.java index e79f91cd0..b41bdbec9 100644 --- a/src/main/java/playground/amit/fundamentalDiagrams/core/FDModule.java +++ b/src/main/java/playground/amit/fundamentalDiagrams/core/FDModule.java @@ -22,7 +22,8 @@ import java.util.Arrays; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.core.LoggerContext; @@ -33,6 +34,7 @@ import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; +import org.matsim.api.core.v01.network.NetworkFactory; import org.matsim.api.core.v01.population.PopulationWriter; import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.ConfigWriter; @@ -61,7 +63,7 @@ public class FDModule extends AbstractModule { - public static final Logger LOG = Logger.getLogger(FDModule.class); + public static final Logger LOG = LogManager.getLogger(FDModule.class); public static final double MAX_ACT_END_TIME = 1800.; @@ -73,15 +75,13 @@ public class FDModule extends AbstractModule { private String[] travelModes; private final FDConfigGroup FDConfigGroup; - public FDModule(final Scenario scenario){ + public FDModule(final Scenario scenario, String linkDynamics){ FDConfigGroup = ConfigUtils.addOrGetModule(scenario.getConfig(), FDConfigGroup.class); fdNetworkGenerator = new FDNetworkGenerator(FDConfigGroup); this.scenario = scenario; fdNetworkGenerator.createNetwork(this.scenario.getNetwork()); - if (scenario.getConfig().getModules().containsKey(TrafficCharConfigGroup.GROUP_NAME)) - changeLinkDynamicsOnNetwork(this.scenario.getNetwork()); - + changeLinkDynamics(scenario.getNetwork(), linkDynamics); checkForConsistencyAndInitialize(); setUpConfig(); @@ -90,16 +90,27 @@ public FDModule(final Scenario scenario){ new MatsimVehicleWriter(scenario.getVehicles()).writeFile(this.runDir+"/output_vehicles.xml"); new PopulationWriter(scenario.getPopulation()).write(this.runDir + "/output_plans.xml"); } + public FDModule(final Scenario scenario){ + FDConfigGroup = ConfigUtils.addOrGetModule(scenario.getConfig(), FDConfigGroup.class); + fdNetworkGenerator = new FDNetworkGenerator(FDConfigGroup); + this.scenario = scenario; + fdNetworkGenerator.createNetwork(this.scenario.getNetwork()); + checkForConsistencyAndInitialize(); + setUpConfig(); - private void changeLinkDynamicsOnNetwork(Network network) { + new ConfigWriter(scenario.getConfig()).write(this.runDir+"/output_config.xml"); + new NetworkWriter(scenario.getNetwork()).write(this.runDir+"/output_network.xml"); + new MatsimVehicleWriter(scenario.getVehicles()).writeFile(this.runDir+"/output_vehicles.xml"); + new PopulationWriter(scenario.getPopulation()).write(this.runDir + "/output_plans.xml"); + } + private void changeLinkDynamics(Network network, String linkDynamics) { for (Link link: network.getLinks().values()) { if (link.getId().equals(Id.createLinkId("1")) | link.getId().equals(Id.createLinkId("2"))) - link.getAttributes().putAttribute(TrafficCharConfigGroup.ROAD_TYPE, "PassingQ"); + link.getAttributes().putAttribute(TrafficCharConfigGroup.ROAD_TYPE, linkDynamics); else link.getAttributes().putAttribute(TrafficCharConfigGroup.ROAD_TYPE, TrafficCharConfigGroup.ROAD_TYPE_DEFAULT); } } - private void checkForConsistencyAndInitialize(){ this.runDir = scenario.getConfig().controler().getOutputDirectory(); if(runDir==null) throw new RuntimeException("Location to write data for FD is not set. Aborting..."); @@ -163,7 +174,7 @@ else if (this.travelModes.length==1 && this.travelModes[0].equals("truck")) //TODO probably, following is not required anymore. // if ( scenario.getConfig().network().isTimeVariantNetwork() ) { // Network netImpl = scenario.getNetwork(); -// netImpl.getFactory().setLinkFactory(new VariableIntervalTimeVariantLinkFactory()); +// netImpl.getFactory().(new VariableIntervalTimeVariantLinkFactory()); // } StrategyConfigGroup.StrategySettings ss = new StrategyConfigGroup.StrategySettings(); diff --git a/src/main/java/playground/amit/fundamentalDiagrams/dynamicPCU/areaSpeedRatioMethod/RunDynamicPCUExample.java b/src/main/java/playground/amit/fundamentalDiagrams/dynamicPCU/areaSpeedRatioMethod/RunDynamicPCUExample.java index e8d0bcbaf..a8d3bd109 100644 --- a/src/main/java/playground/amit/fundamentalDiagrams/dynamicPCU/areaSpeedRatioMethod/RunDynamicPCUExample.java +++ b/src/main/java/playground/amit/fundamentalDiagrams/dynamicPCU/areaSpeedRatioMethod/RunDynamicPCUExample.java @@ -19,8 +19,6 @@ package playground.amit.fundamentalDiagrams.dynamicPCU.areaSpeedRatioMethod; -import java.util.Arrays; -import java.util.List; import org.apache.commons.lang.StringUtils; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -41,6 +39,10 @@ import playground.amit.fundamentalDiagrams.dynamicPCU.areaSpeedRatioMethod.estimation.ChandraSikdarPCUUpdator; import playground.amit.fundamentalDiagrams.dynamicPCU.areaSpeedRatioMethod.projectedArea.VehicleProjectedAreaRatio; import playground.amit.mixedTraffic.MixedTrafficVehiclesUtils; +import playground.shivam.trafficChar.core.TrafficCharConfigGroup; + +import java.util.Arrays; +import java.util.List; /** * Created by amit on 29.06.17. @@ -54,9 +56,9 @@ public static void main(String[] args) { boolean updatePCU = true; PCUMethod pcuMethod = PCUMethod.SPEED_AREA_RATIO; - String parentDir = "../../svnit/outputFiles/mixedModes/passing/staticPCU/"; + String parentDir = "output/staticPCU/"; if(updatePCU) { - parentDir = "../../svnit/outputFiles/mixedModes/passing/dynamicPCU/"+pcuMethod+"/"; + parentDir = "output/dynamicPCU/"+pcuMethod+"/"; } Config config = ConfigUtils.createConfig(); @@ -90,8 +92,18 @@ public static void main(String[] args) { vehicles.addVehicleType(veh); } + TrafficCharConfigGroup trafficCharConfigGroup = new TrafficCharConfigGroup(); + QSimConfigGroup qSimConfigGroupPassingQ = new QSimConfigGroup(); + qSimConfigGroupPassingQ.setLinkDynamics(QSimConfigGroup.LinkDynamics.FIFO); + trafficCharConfigGroup.addQSimConfigGroup("FIFO", qSimConfigGroupPassingQ); + + trafficCharConfigGroup.addQSimConfigGroup(TrafficCharConfigGroup.ROAD_TYPE_DEFAULT, scenario.getConfig().qsim()); + + scenario.getConfig().getModules().put(TrafficCharConfigGroup.GROUP_NAME, trafficCharConfigGroup); + + Controler controler = new Controler(scenario); - controler.addOverridingModule(new FDModule(scenario)); + controler.addOverridingModule(new FDModule(scenario, "FIFO")); controler.addOverridingModule(new AbstractModule() { @Override public void install() { @@ -107,4 +119,5 @@ public void install() { FDUtils.cleanOutputDir(scenario.getConfig().controler().getOutputDirectory()); } + } \ No newline at end of file diff --git a/src/main/java/playground/amit/fundamentalDiagrams/dynamicPCU/areaSpeedRatioMethod/estimation/ChandraSikdarPCUUpdator.java b/src/main/java/playground/amit/fundamentalDiagrams/dynamicPCU/areaSpeedRatioMethod/estimation/ChandraSikdarPCUUpdator.java index 022b52f9c..31bffdc22 100644 --- a/src/main/java/playground/amit/fundamentalDiagrams/dynamicPCU/areaSpeedRatioMethod/estimation/ChandraSikdarPCUUpdator.java +++ b/src/main/java/playground/amit/fundamentalDiagrams/dynamicPCU/areaSpeedRatioMethod/estimation/ChandraSikdarPCUUpdator.java @@ -83,8 +83,9 @@ public class ChandraSikdarPCUUpdator implements VehicleEntersTrafficEventHandler private final FDConfigGroup fdConfigGroup; @Inject - public ChandraSikdarPCUUpdator(final Scenario scenario, final FDNetworkGenerator fdNetworkGenerator - , FDDataContainer fdDataContainer, FDStabilityTester fdStabilityTester, FDConfigGroup fdConfigGroup){ + public ChandraSikdarPCUUpdator(final Scenario scenario, final FDNetworkGenerator fdNetworkGenerator, + FDDataContainer fdDataContainer, FDStabilityTester fdStabilityTester, + FDConfigGroup fdConfigGroup){ this.scenario = scenario; this.fdDataContainer = fdDataContainer; this.fdStabilityTester = fdStabilityTester; @@ -127,7 +128,7 @@ public void handleEvent(LinkLeaveEvent event) { addVehicleTypeToPCU(mode, PCUMethod.SPEED_AREA_RATIO, pcu); } { - // AREA_SPEED_RATIO_method + // HEADWAY_RATIO_method double pcu = NumberUtils.round(calculateHeadwayPCU(mode), 3); addVehicleTypeToPCU(mode, PCUMethod.HEADWAY_RATIO, pcu); @@ -182,11 +183,11 @@ private double getAreaRatio(String mode){ // if ( EnumUtils.isValidEnum(VehicleProjectedAreaRatio.class, mode) ){ // return VehicleProjectedAreaRatio.getProjectedAreaRatio(mode); // } else { - return (double) ( scenario.getVehicles() - .getVehicleTypes() - .get(Id.create(mode, VehicleType.class))).getAttributes() - .getAttribute( - projected_area_ratio); + return (double) (scenario.getVehicles() + .getVehicleTypes() + .get(Id.create(mode, VehicleType.class)) + ).getAttributes() + .getAttribute(projected_area_ratio); // } } diff --git a/src/main/java/playground/amit/fundamentalDiagrams/dynamicPCU/surveyData/RunSurveyData.java b/src/main/java/playground/amit/fundamentalDiagrams/dynamicPCU/surveyData/RunSurveyData.java index 901263c1a..7a67af382 100644 --- a/src/main/java/playground/amit/fundamentalDiagrams/dynamicPCU/surveyData/RunSurveyData.java +++ b/src/main/java/playground/amit/fundamentalDiagrams/dynamicPCU/surveyData/RunSurveyData.java @@ -19,7 +19,6 @@ package playground.amit.fundamentalDiagrams.dynamicPCU.surveyData; -import java.util.List; import com.google.inject.Key; import com.google.inject.name.Names; import org.matsim.api.core.v01.Id; @@ -42,6 +41,8 @@ import playground.amit.fundamentalDiagrams.dynamicPCU.PCUMethod; import playground.amit.fundamentalDiagrams.dynamicPCU.areaSpeedRatioMethod.estimation.ChandraSikdarPCUUpdator; +import java.util.List; + /** * Created by amit on 23.05.18. */ diff --git a/src/main/java/playground/amit/mixedTraffic/patnaIndia/OnRoadExposure/PatnaOnRoadExposure.java b/src/main/java/playground/amit/mixedTraffic/patnaIndia/OnRoadExposure/PatnaOnRoadExposure.java index eb51304e3..4edf98721 100644 --- a/src/main/java/playground/amit/mixedTraffic/patnaIndia/OnRoadExposure/PatnaOnRoadExposure.java +++ b/src/main/java/playground/amit/mixedTraffic/patnaIndia/OnRoadExposure/PatnaOnRoadExposure.java @@ -19,18 +19,8 @@ package playground.amit.mixedTraffic.patnaIndia.OnRoadExposure; -import java.io.BufferedWriter; -import java.io.File; -import java.io.IOException; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; -import java.util.stream.Collectors; - -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.locationtech.jts.geom.Geometry; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -49,7 +39,6 @@ import org.matsim.core.utils.gis.ShapeFileReader; import org.matsim.core.utils.io.IOUtils; import org.opengis.feature.simple.SimpleFeature; - import playground.amit.emissions.onRoadExposure.OnRoadExposureConfigGroup; import playground.amit.emissions.onRoadExposure.OnRoadExposureHandler; import playground.amit.emissions.onRoadExposure.OnRoadExposureTable.OnRoadTripExposureInfo; @@ -59,6 +48,12 @@ import playground.amit.utils.FileUtils; import playground.amit.utils.LoadMyScenarios; +import java.io.BufferedWriter; +import java.io.File; +import java.io.IOException; +import java.util.*; +import java.util.stream.Collectors; + /** * Created by amit on 17.11.17. */ @@ -70,7 +65,7 @@ public class PatnaOnRoadExposure { private static final CoordinateTransformation ct = TransformationFactory.getCoordinateTransformation(PatnaUtils.EPSG, TransformationFactory.WGS84); private static final String networkFile = ""; - private static final Logger LOG = Logger.getLogger(PatnaOnRoadExposure.class); + private static final Logger LOG = LogManager.getLogger(PatnaOnRoadExposure.class); private static final boolean writeEmissionEventsFirst = false; // private static final String data_dates [] = {"none","_22Nov2017","_22Jan2018","_22Mar2018","_22May2018"}; diff --git a/src/main/java/playground/amit/mixedTraffic/patnaIndia/OnRoadExposure/PatnaOnlineEmissionsWriter.java b/src/main/java/playground/amit/mixedTraffic/patnaIndia/OnRoadExposure/PatnaOnlineEmissionsWriter.java index f7bd9977e..49b922889 100644 --- a/src/main/java/playground/amit/mixedTraffic/patnaIndia/OnRoadExposure/PatnaOnlineEmissionsWriter.java +++ b/src/main/java/playground/amit/mixedTraffic/patnaIndia/OnRoadExposure/PatnaOnlineEmissionsWriter.java @@ -71,7 +71,7 @@ public static void main(String[] args) { config.vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); EmissionsConfigGroup ecg = ConfigUtils.addOrGetModule(config, EmissionsConfigGroup.class); -// ecg.setUsingDetailedEmissionCalculation(false); + ecg.setUsingDetailedEmissionCalculationStringSetter(false); ecg.setUsingVehicleTypeIdAsVehicleDescription(false); ecg.setAverageColdEmissionFactorsFile(avgColdEmissFile); ecg.setAverageWarmEmissionFactorsFile(avgWarmEmissFile); diff --git a/src/main/java/playground/amit/mixedTraffic/patnaIndia/analysis/PatnaModalShareSubPop.java b/src/main/java/playground/amit/mixedTraffic/patnaIndia/analysis/PatnaModalShareSubPop.java index b5b2473a3..ae7ac2e15 100644 --- a/src/main/java/playground/amit/mixedTraffic/patnaIndia/analysis/PatnaModalShareSubPop.java +++ b/src/main/java/playground/amit/mixedTraffic/patnaIndia/analysis/PatnaModalShareSubPop.java @@ -18,27 +18,27 @@ * *********************************************************************** */ package playground.amit.mixedTraffic.patnaIndia.analysis; -import java.io.BufferedWriter; -import java.util.SortedMap; -import java.util.TreeMap; - -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Scenario; import org.matsim.core.utils.io.IOUtils; - import playground.amit.analysis.modalShare.ModalShareFromEvents; import playground.amit.analysis.modalShare.ModalShareFromPlans; import playground.amit.mixedTraffic.patnaIndia.utils.PatnaPersonFilter; import playground.amit.mixedTraffic.patnaIndia.utils.PatnaPersonFilter.PatnaUserGroup; import playground.amit.utils.LoadMyScenarios; +import java.io.BufferedWriter; +import java.util.SortedMap; +import java.util.TreeMap; + /** * @author amit */ public class PatnaModalShareSubPop { - private final static Logger LOG = Logger.getLogger(PatnaModalShareSubPop.class); + private final static Logger LOG = LogManager.getLogger(PatnaModalShareSubPop.class); private final SortedMap> userGrp2Mode2Legs = new TreeMap<>(); private final SortedMap> userGrp2ModalSplit = new TreeMap<>(); diff --git a/src/main/java/playground/amit/mixedTraffic/patnaIndia/covidWork/DiscountedPTFareHandler.java b/src/main/java/playground/amit/mixedTraffic/patnaIndia/covidWork/DiscountedPTFareHandler.java index 89e246225..e906988d1 100644 --- a/src/main/java/playground/amit/mixedTraffic/patnaIndia/covidWork/DiscountedPTFareHandler.java +++ b/src/main/java/playground/amit/mixedTraffic/patnaIndia/covidWork/DiscountedPTFareHandler.java @@ -19,11 +19,9 @@ package playground.amit.mixedTraffic.patnaIndia.covidWork; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Logger; +import com.google.inject.Inject; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.events.Event; @@ -34,11 +32,12 @@ import org.matsim.core.api.experimental.events.EventsManager; import org.matsim.core.api.experimental.events.TeleportationArrivalEvent; import org.matsim.core.api.experimental.events.handler.TeleportationArrivalEventHandler; - -import com.google.inject.Inject; - import playground.amit.mixedTraffic.patnaIndia.utils.PatnaUtils; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + /** * The fare calculation is taken from KumarEtc2004PTCost. * @@ -47,7 +46,7 @@ public class DiscountedPTFareHandler implements PersonDepartureEventHandler, TeleportationArrivalEventHandler{ - public static final Logger logger = Logger.getLogger(DiscountedPTFareHandler.class); + public static final Logger logger = LogManager.getLogger(DiscountedPTFareHandler.class); private final Map,String> person2mode = new HashMap<>(); //peak is 7 to 10 and 15 to 18; in the form of 1 to 24. diff --git a/src/main/java/playground/amit/mixedTraffic/patnaIndia/covidWork/FilterDemandBasedOnTripPurpose.java b/src/main/java/playground/amit/mixedTraffic/patnaIndia/covidWork/FilterDemandBasedOnTripPurpose.java index 4682550eb..a8b182a5e 100644 --- a/src/main/java/playground/amit/mixedTraffic/patnaIndia/covidWork/FilterDemandBasedOnTripPurpose.java +++ b/src/main/java/playground/amit/mixedTraffic/patnaIndia/covidWork/FilterDemandBasedOnTripPurpose.java @@ -1,6 +1,7 @@ package playground.amit.mixedTraffic.patnaIndia.covidWork; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.GeometryFactory; @@ -21,7 +22,7 @@ */ public class FilterDemandBasedOnTripPurpose { - private final Logger logger = Logger.getLogger(FilterDemandBasedOnTripPurpose.class); + private final Logger logger = LogManager.getLogger(FilterDemandBasedOnTripPurpose.class); private static final Random random = MatsimRandom.getRandom(); private final Collection features; diff --git a/src/main/java/playground/amit/mixedTraffic/patnaIndia/covidWork/MyChangeTripMode.java b/src/main/java/playground/amit/mixedTraffic/patnaIndia/covidWork/MyChangeTripMode.java index a7d671d59..9ecea50ed 100644 --- a/src/main/java/playground/amit/mixedTraffic/patnaIndia/covidWork/MyChangeTripMode.java +++ b/src/main/java/playground/amit/mixedTraffic/patnaIndia/covidWork/MyChangeTripMode.java @@ -21,9 +21,9 @@ public class MyChangeTripMode implements Provider { private final GlobalConfigGroup globalConfigGroup; private final ChangeModeConfigGroup changeLegModeConfigGroup; - private Provider tripRouterProvider; - private ActivityFacilities activityFacilities; - private TimeInterpretation timeInterpretation; + private final Provider tripRouterProvider; + private final ActivityFacilities activityFacilities; + private final TimeInterpretation timeInterpretation; @Inject protected MyChangeTripMode(GlobalConfigGroup globalConfigGroup, ChangeModeConfigGroup changeLegModeConfigGroup, ActivityFacilities activityFacilities, Provider tripRouterProvider, TimeInterpretation timeInterpretation) { diff --git a/src/main/java/playground/amit/mixedTraffic/patnaIndia/covidWork/PatnaCovidPolicyControler.java b/src/main/java/playground/amit/mixedTraffic/patnaIndia/covidWork/PatnaCovidPolicyControler.java index c5d32a18d..1ddd2eda7 100644 --- a/src/main/java/playground/amit/mixedTraffic/patnaIndia/covidWork/PatnaCovidPolicyControler.java +++ b/src/main/java/playground/amit/mixedTraffic/patnaIndia/covidWork/PatnaCovidPolicyControler.java @@ -1,6 +1,6 @@ package playground.amit.mixedTraffic.patnaIndia.covidWork; - -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; import org.matsim.core.config.Config; @@ -44,7 +44,7 @@ public class PatnaCovidPolicyControler { - public static final Logger logger = Logger.getLogger(PatnaCovidPolicyControler.class); + public static final Logger logger = LogManager.getLogger(PatnaCovidPolicyControler.class); // private static final String wfh_walk = "WFHwalk"; public static void main(String[] args) { diff --git a/src/main/java/playground/amit/mixedTraffic/patnaIndia/covidWork/wfh/PatnaWFHCalibrationControler.java b/src/main/java/playground/amit/mixedTraffic/patnaIndia/covidWork/wfh/PatnaWFHCalibrationControler.java index c69eabe12..268ed3314 100644 --- a/src/main/java/playground/amit/mixedTraffic/patnaIndia/covidWork/wfh/PatnaWFHCalibrationControler.java +++ b/src/main/java/playground/amit/mixedTraffic/patnaIndia/covidWork/wfh/PatnaWFHCalibrationControler.java @@ -1,6 +1,6 @@ package playground.amit.mixedTraffic.patnaIndia.covidWork.wfh; - -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.population.*; @@ -33,7 +33,7 @@ public class PatnaWFHCalibrationControler { - public static final Logger logger = Logger.getLogger(PatnaWFHCalibrationControler.class); + public static final Logger logger = LogManager.getLogger(PatnaWFHCalibrationControler.class); // private static final String wfh_walk = "WFHwalk"; public static void main(String[] args) { diff --git a/src/main/java/playground/amit/mixedTraffic/patnaIndia/covidWork/wfh/WFHCounterControlerListner.java b/src/main/java/playground/amit/mixedTraffic/patnaIndia/covidWork/wfh/WFHCounterControlerListner.java index a3943caf3..636dc97f8 100644 --- a/src/main/java/playground/amit/mixedTraffic/patnaIndia/covidWork/wfh/WFHCounterControlerListner.java +++ b/src/main/java/playground/amit/mixedTraffic/patnaIndia/covidWork/wfh/WFHCounterControlerListner.java @@ -1,6 +1,7 @@ package playground.amit.mixedTraffic.patnaIndia.covidWork.wfh; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.population.*; import org.matsim.core.config.groups.ControlerConfigGroup; import org.matsim.core.controler.OutputDirectoryHierarchy; @@ -22,7 +23,7 @@ */ public class WFHCounterControlerListner implements IterationEndsListener, ShutdownListener { - public static final Logger LOGGER = Logger.getLogger(WFHCounterControlerListner.class); + public static final Logger LOGGER = LogManager.getLogger(WFHCounterControlerListner.class); public static final String FILENAME = "workFromHomeStats"; diff --git a/src/main/java/playground/amit/mixedTraffic/patnaIndia/covidWork/wfh/WFHPricing.java b/src/main/java/playground/amit/mixedTraffic/patnaIndia/covidWork/wfh/WFHPricing.java index 1bd719fb1..926f782bb 100644 --- a/src/main/java/playground/amit/mixedTraffic/patnaIndia/covidWork/wfh/WFHPricing.java +++ b/src/main/java/playground/amit/mixedTraffic/patnaIndia/covidWork/wfh/WFHPricing.java @@ -1,7 +1,8 @@ package playground.amit.mixedTraffic.patnaIndia.covidWork.wfh; import com.google.inject.Inject; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.*; import org.matsim.api.core.v01.events.handler.ActivityEndEventHandler; @@ -28,7 +29,7 @@ */ public class WFHPricing implements ActivityStartEventHandler, ActivityEndEventHandler, AfterMobsimListener { - private final static Logger LOGGER = Logger.getLogger(WFHPricing.class); + private final static Logger LOGGER = LogManager.getLogger(WFHPricing.class); private final String TYPE = "PENALTY_WORKING_HOME"; private final String PARTNER = "SELF"; diff --git a/src/main/java/playground/amit/mixedTraffic/patnaIndia/covidWork/wfh/WorkFromHomeModule.java b/src/main/java/playground/amit/mixedTraffic/patnaIndia/covidWork/wfh/WorkFromHomeModule.java index 9c50abc4f..f97949050 100644 --- a/src/main/java/playground/amit/mixedTraffic/patnaIndia/covidWork/wfh/WorkFromHomeModule.java +++ b/src/main/java/playground/amit/mixedTraffic/patnaIndia/covidWork/wfh/WorkFromHomeModule.java @@ -42,14 +42,12 @@ public void install() { Scenario sc; @Inject Provider tripRouterProvider ; - @Inject - TimeInterpretation timeInterpretation; @Override public PlanStrategy get() { final PlanStrategyImpl.Builder builder = new PlanStrategyImpl.Builder(new RandomPlanSelector<>()); builder.addStrategyModule(new WorkFromHome(sc.getConfig().global(), actTypes, wfhMode)); - builder.addStrategyModule(new ReRoute(sc, tripRouterProvider, timeInterpretation)); + builder.addStrategyModule(new ReRoute(sc, tripRouterProvider, TimeInterpretation.create(this.sc.getConfig()))); return builder.build(); } }); diff --git a/src/main/java/playground/amit/mixedTraffic/patnaIndia/evac/EvacuationPatnaScenarioGenerator.java b/src/main/java/playground/amit/mixedTraffic/patnaIndia/evac/EvacuationPatnaScenarioGenerator.java index 7e2c1f045..a26f35d9b 100644 --- a/src/main/java/playground/amit/mixedTraffic/patnaIndia/evac/EvacuationPatnaScenarioGenerator.java +++ b/src/main/java/playground/amit/mixedTraffic/patnaIndia/evac/EvacuationPatnaScenarioGenerator.java @@ -63,7 +63,6 @@ import org.matsim.core.utils.geometry.geotools.MGC; import org.matsim.core.utils.geometry.transformations.TransformationFactory; import org.matsim.core.utils.gis.ShapeFileReader; -import org.matsim.evacuationgui.utils.ScenarioCRSTransformation; import org.matsim.facilities.FacilitiesUtils; import org.matsim.utils.objectattributes.attributable.Attributes; import org.opengis.feature.simple.SimpleFeature; @@ -93,7 +92,7 @@ public class EvacuationPatnaScenarioGenerator { private final Id safeLinkId = Id.createLinkId("safeLink_Patna"); private Scenario scenario; - private Geometry evavcuationArea; + private Geometry evacuationArea; public static void main(String[] args) { new EvacuationPatnaScenarioGenerator().run(); @@ -124,7 +123,7 @@ private void createConfig() { config.global().setCoordinateSystem("EPSG:7759"); - ScenarioCRSTransformation.transform(this.scenario, "EPSG:7759"); + config.travelTimeCalculator().setTraveltimeBinSize(900); config.qsim().setSnapshotPeriod(5 * 60); @@ -229,18 +228,17 @@ public void install() { private void createEvacNetwork(Scenario sc) { - //read shape file and get area ShapeFileReader reader = new ShapeFileReader(); // String areaShapeFile = "area_epsg24345.shp"; Collection features = reader.readFileAndInitialize("input/evacTest/patna_polygon_7759.shp"); - evavcuationArea = (Geometry) features.iterator().next().getDefaultGeometry(); + evacuationArea = (Geometry) features.iterator().next().getDefaultGeometry(); // GeometryUtils.getGeometryFromListOfFeatures() // will create a network connecting with safe node. // Amit, I added this cast to prevent compilation errors. // Preferably, evacuationgui needs to be adapted to the more recent version of geotools. michal mar'19 - EvacuationNetworkGenerator net = new EvacuationNetworkGenerator(sc, evavcuationArea, safeLinkId); + EvacuationNetworkGenerator net = new EvacuationNetworkGenerator(sc, evacuationArea, safeLinkId); net.run(); //since the original network is multi-mode, the new links should also allow all modes @@ -294,7 +292,7 @@ private void createEvacPopulation(Scenario sc) { //check if the person is in the area shape, if not leave them out - if (actCoord != null && !evavcuationArea.contains(MGC.coord2Point(actCoord))) { + if (actCoord != null && !evacuationArea.contains(MGC.coord2Point(actCoord))) { continue; } diff --git a/src/main/java/playground/amit/mixedTraffic/patnaIndia/heat/AverageBicycleDurationCollector.java b/src/main/java/playground/amit/mixedTraffic/patnaIndia/heat/AverageBicycleDurationCollector.java index 490d66465..bb8011481 100644 --- a/src/main/java/playground/amit/mixedTraffic/patnaIndia/heat/AverageBicycleDurationCollector.java +++ b/src/main/java/playground/amit/mixedTraffic/patnaIndia/heat/AverageBicycleDurationCollector.java @@ -1,6 +1,6 @@ package playground.amit.mixedTraffic.patnaIndia.heat; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -95,7 +95,7 @@ public void handleEvent(PersonDepartureEvent personDepartureEvent) { @Override public void handleEvent(PersonStuckEvent personStuckEvent) { - Logger.getLogger(AverageBicycleDurationCollector.class).error("Stuck and abort event :"+personStuckEvent.toString()); + LogManager.getLogger(AverageBicycleDurationCollector.class).error("Stuck and abort event :"+personStuckEvent.toString()); } private void processData(Scenario scenario){ diff --git a/src/main/java/playground/amit/mixedTraffic/patnaIndia/heat/ModalTripDurationTripCountCollector.java b/src/main/java/playground/amit/mixedTraffic/patnaIndia/heat/ModalTripDurationTripCountCollector.java index b4aa8077c..060bc8261 100644 --- a/src/main/java/playground/amit/mixedTraffic/patnaIndia/heat/ModalTripDurationTripCountCollector.java +++ b/src/main/java/playground/amit/mixedTraffic/patnaIndia/heat/ModalTripDurationTripCountCollector.java @@ -1,6 +1,6 @@ package playground.amit.mixedTraffic.patnaIndia.heat; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.events.PersonArrivalEvent; @@ -117,7 +117,7 @@ public void reset(int iteration) { @Override public void handleEvent(PersonStuckEvent personStuckEvent) { - Logger.getLogger(ModalTripDurationTripCountCollector.class).error("Stuck and abort event :"+personStuckEvent.toString()); + LogManager.getLogger(ModalTripDurationTripCountCollector.class).error("Stuck and abort event :"+personStuckEvent.toString()); } private void processData(Scenario scenario){ diff --git a/src/main/java/playground/amit/mixedTraffic/patnaIndia/input/extDemand/OuterCordonCadytsControler.java b/src/main/java/playground/amit/mixedTraffic/patnaIndia/input/extDemand/OuterCordonCadytsControler.java index 8a8f633f5..4a6bba62c 100644 --- a/src/main/java/playground/amit/mixedTraffic/patnaIndia/input/extDemand/OuterCordonCadytsControler.java +++ b/src/main/java/playground/amit/mixedTraffic/patnaIndia/input/extDemand/OuterCordonCadytsControler.java @@ -18,11 +18,7 @@ * *********************************************************************** */ package playground.amit.mixedTraffic.patnaIndia.input.extDemand; -import java.io.File; -import java.util.HashSet; -import java.util.Map; -import javax.inject.Inject; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Network; @@ -47,22 +43,13 @@ import org.matsim.core.scoring.ScoringFunction; import org.matsim.core.scoring.ScoringFunctionFactory; import org.matsim.core.scoring.SumScoringFunction; -import org.matsim.core.scoring.functions.CharyparNagelActivityScoring; -import org.matsim.core.scoring.functions.CharyparNagelAgentStuckScoring; -import org.matsim.core.scoring.functions.CharyparNagelLegScoring; -import org.matsim.core.scoring.functions.ScoringParameters; -import org.matsim.core.scoring.functions.ScoringParametersForPerson; -import org.matsim.core.scoring.functions.SubpopulationScoringParameters; +import org.matsim.core.scoring.functions.*; import org.matsim.core.utils.collections.CollectionUtils; import org.matsim.core.utils.io.IOUtils; import org.matsim.counts.Counts; import org.matsim.vehicles.VehicleWriterV1; import org.matsim.vehicles.Vehicles; -import playground.vsp.analysis.modules.modalAnalyses.modalShare.ModalShareControlerListener; -import playground.vsp.analysis.modules.modalAnalyses.modalShare.ModalShareEventHandler; import playground.amit.analysis.modalShare.ModalShareFromEvents; -import playground.vsp.analysis.modules.modalAnalyses.modalTripTime.ModalTravelTimeControlerListener; -import playground.vsp.analysis.modules.modalAnalyses.modalTripTime.ModalTripTravelTimeHandler; import playground.amit.mixedTraffic.counts.CountsInserter; import playground.amit.mixedTraffic.patnaIndia.input.joint.JointCalibrationControler; import playground.amit.mixedTraffic.patnaIndia.input.others.PatnaVehiclesGenerator; @@ -71,10 +58,19 @@ import playground.amit.mixedTraffic.patnaIndia.utils.OuterCordonUtils; import playground.amit.mixedTraffic.patnaIndia.utils.PatnaUtils; import playground.amit.utils.plans.SelectedPlansFilter; +import playground.vsp.analysis.modules.modalAnalyses.modalShare.ModalShareControlerListener; +import playground.vsp.analysis.modules.modalAnalyses.modalShare.ModalShareEventHandler; +import playground.vsp.analysis.modules.modalAnalyses.modalTripTime.ModalTravelTimeControlerListener; +import playground.vsp.analysis.modules.modalAnalyses.modalTripTime.ModalTripTravelTimeHandler; import playground.vsp.cadyts.multiModeCadyts.ModalCountsCadytsContext; import playground.vsp.cadyts.multiModeCadyts.ModalCountsLinkIdentifier; import playground.vsp.cadyts.multiModeCadyts.MultiModalCountsCadytsModule; +import javax.inject.Inject; +import java.io.File; +import java.util.HashSet; +import java.util.Map; + /** * @author amit */ @@ -157,7 +153,7 @@ public void install() { int lastIt = controler.getConfig().controler().getLastIteration(); for (int index =firstIt+1; index distanceClasses = new ArrayList<>(Arrays.asList( 2000, 4000, 6000, 8000, 10000, 20000000 // last dist class sufficiently high )); diff --git a/src/main/java/playground/amit/mixedTraffic/patnaIndia/input/urban/scenarioSetup/PatnaDemandImputer.java b/src/main/java/playground/amit/mixedTraffic/patnaIndia/input/urban/scenarioSetup/PatnaDemandImputer.java index c2dd708d6..22bb063a7 100644 --- a/src/main/java/playground/amit/mixedTraffic/patnaIndia/input/urban/scenarioSetup/PatnaDemandImputer.java +++ b/src/main/java/playground/amit/mixedTraffic/patnaIndia/input/urban/scenarioSetup/PatnaDemandImputer.java @@ -19,32 +19,25 @@ package playground.amit.mixedTraffic.patnaIndia.input.urban.scenarioSetup; -import java.io.BufferedReader; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.SortedMap; -import java.util.TreeMap; - -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.core.utils.io.IOUtils; - import playground.amit.mixedTraffic.patnaIndia.input.urban.scenarioSetup.PatnaCalibrationUtils.PatnaDemandLabels; import playground.amit.mixedTraffic.patnaIndia.utils.PatnaUtils; import playground.amit.utils.MapUtils; import playground.amit.utils.RandomNumberUtils; +import java.io.BufferedReader; +import java.io.IOException; +import java.util.*; + /** * @author amit */ public class PatnaDemandImputer { - public static final Logger LOG = Logger.getLogger(PatnaCalibrationUtils.class); + public static final Logger LOG = LogManager.getLogger(PatnaCalibrationUtils.class); final Map mode2counter = new HashMap<>(); final Map inc2counter = new HashMap<>(); diff --git a/src/main/java/playground/amit/mixedTraffic/patnaIndia/policies/analysis/PatnaEmissionsWriter.java b/src/main/java/playground/amit/mixedTraffic/patnaIndia/policies/analysis/PatnaEmissionsWriter.java index cb0fc82f6..7650654e2 100644 --- a/src/main/java/playground/amit/mixedTraffic/patnaIndia/policies/analysis/PatnaEmissionsWriter.java +++ b/src/main/java/playground/amit/mixedTraffic/patnaIndia/policies/analysis/PatnaEmissionsWriter.java @@ -63,7 +63,7 @@ public static void main(String[] args) { private void writeEmissionEventsFile(final String outputDir){ EmissionsConfigGroup ecg = new EmissionsConfigGroup(); -// ecg.setUsingDetailedEmissionCalculation(false); + ecg.setUsingDetailedEmissionCalculationStringSetter(false); ecg.setUsingVehicleTypeIdAsVehicleDescription(false); ecg.setAverageColdEmissionFactorsFile(avgColdEmissFile); ecg.setAverageWarmEmissionFactorsFile(avgWarmEmissFile); diff --git a/src/main/java/playground/amit/mixedTraffic/patnaIndia/policies/bikeTrack/BikeConnectorControlerListener.java b/src/main/java/playground/amit/mixedTraffic/patnaIndia/policies/bikeTrack/BikeConnectorControlerListener.java index ffe9e39b1..ac5be2de6 100644 --- a/src/main/java/playground/amit/mixedTraffic/patnaIndia/policies/bikeTrack/BikeConnectorControlerListener.java +++ b/src/main/java/playground/amit/mixedTraffic/patnaIndia/policies/bikeTrack/BikeConnectorControlerListener.java @@ -19,12 +19,8 @@ package playground.amit.mixedTraffic.patnaIndia.policies.bikeTrack; -import java.io.BufferedWriter; -import java.io.IOException; -import java.util.*; -import java.util.stream.Collectors; -import javax.inject.Inject; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -54,6 +50,12 @@ import playground.amit.analysis.linkVolume.ModeFilterLinkVolumeHandler; import playground.amit.mixedTraffic.patnaIndia.utils.PatnaUtils; +import javax.inject.Inject; +import java.io.BufferedWriter; +import java.io.IOException; +import java.util.*; +import java.util.stream.Collectors; + /** * The idea is to first connect the proposed bike track to regular network by all possible connectors * and then start removing one by one connector. @@ -63,7 +65,7 @@ class BikeConnectorControlerListener implements StartupListener, IterationStartsListener, IterationEndsListener, ShutdownListener { - private static final Logger LOG = Logger.getLogger(PatnaBikeTrackConnectionControler.class); + private static final Logger LOG = LogManager.getLogger(PatnaBikeTrackConnectionControler.class); private static final List allowedModes = Arrays.asList(TransportMode.bike); private final int numberOfBikeConnectorsRequired; @@ -225,7 +227,6 @@ private PlanAlgorithm getRouter() { // new RandomizingTimeDistanceTravelDisutilityFactory(TransportMode.bike, scenario.getConfig().planCalcScore()).createTravelDisutility(travelTime)); final TripRouter tripRouter = routerFactory.build(this.scenario).get(); - final TimeInterpretation timeInterpretation = TimeInterpretation.create(this.scenario.getConfig()); - return new PlanRouter(tripRouter, timeInterpretation); + return new PlanRouter(tripRouter, TimeInterpretation.create(this.scenario.getConfig())); } } \ No newline at end of file diff --git a/src/main/java/playground/amit/mixedTraffic/patnaIndia/simTime/PatnaSimulationTimeWriter.java b/src/main/java/playground/amit/mixedTraffic/patnaIndia/simTime/PatnaSimulationTimeWriter.java index 887e1be05..0f44300c1 100644 --- a/src/main/java/playground/amit/mixedTraffic/patnaIndia/simTime/PatnaSimulationTimeWriter.java +++ b/src/main/java/playground/amit/mixedTraffic/patnaIndia/simTime/PatnaSimulationTimeWriter.java @@ -18,7 +18,8 @@ * *********************************************************************** */ package playground.amit.mixedTraffic.patnaIndia.simTime; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.PopulationWriter; import org.matsim.core.config.Config; @@ -51,7 +52,7 @@ public class PatnaSimulationTimeWriter { - private static final Logger LOG = Logger.getLogger(PatnaSimulationTimeWriter.class); + private static final Logger LOG = LogManager.getLogger(PatnaSimulationTimeWriter.class); private static final int [] randomSeeds = {4711, 6835, 1847, 4144, 4628, 2632, 5982, 3218, 5736, 7573,4389, 1344} ; private static String runDir = FileUtils.RUNS_SVN+"/patnaIndia/run110/"; private static String inputFilesDir = runDir+"/inputs/"; diff --git a/src/main/java/playground/amit/mixedTraffic/patnaIndia/utils/PatnaPersonFilter.java b/src/main/java/playground/amit/mixedTraffic/patnaIndia/utils/PatnaPersonFilter.java index 373999d1b..f64d1c1ff 100644 --- a/src/main/java/playground/amit/mixedTraffic/patnaIndia/utils/PatnaPersonFilter.java +++ b/src/main/java/playground/amit/mixedTraffic/patnaIndia/utils/PatnaPersonFilter.java @@ -18,21 +18,24 @@ * *********************************************************************** */ package playground.amit.mixedTraffic.patnaIndia.utils; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.core.gbl.Gbl; import playground.amit.utils.PersonFilter; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + /** * @author amit */ public class PatnaPersonFilter implements PersonFilter{ - private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(PatnaPersonFilter.class); + private static final Logger LOG = LogManager.getLogger(PatnaPersonFilter.class); public enum PatnaUserGroup { urban, commuter, through diff --git a/src/main/java/playground/amit/mixedTraffic/qPositionPlots/AgentPositionWriter.java b/src/main/java/playground/amit/mixedTraffic/qPositionPlots/AgentPositionWriter.java index 39276cb9c..da2d874f8 100644 --- a/src/main/java/playground/amit/mixedTraffic/qPositionPlots/AgentPositionWriter.java +++ b/src/main/java/playground/amit/mixedTraffic/qPositionPlots/AgentPositionWriter.java @@ -18,10 +18,8 @@ * *********************************************************************** */ package playground.amit.mixedTraffic.qPositionPlots; -import java.io.BufferedWriter; -import java.io.File; -import java.util.*; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -45,6 +43,10 @@ import org.matsim.vis.snapshotwriters.TransimsSnapshotWriter.Labels; import playground.amit.utils.LoadMyScenarios; +import java.io.BufferedWriter; +import java.io.File; +import java.util.*; + /** * 1) Create Transims snapshot file from events or use existing file. * 2) read events @@ -56,7 +58,7 @@ public class AgentPositionWriter { - private final static Logger LOGGER = Logger.getLogger(AgentPositionWriter.class); + private final static Logger LOGGER = LogManager.getLogger(AgentPositionWriter.class); private final static boolean IS_WRITING_TRANSIM_FILE = false; private final double linkLength = 1000; private final double trackLength = 3000; diff --git a/src/main/java/playground/amit/mixedTraffic/qPositionPlots/AgentPositionWriterOld.java b/src/main/java/playground/amit/mixedTraffic/qPositionPlots/AgentPositionWriterOld.java index ae85e3fa0..88204d244 100644 --- a/src/main/java/playground/amit/mixedTraffic/qPositionPlots/AgentPositionWriterOld.java +++ b/src/main/java/playground/amit/mixedTraffic/qPositionPlots/AgentPositionWriterOld.java @@ -18,11 +18,8 @@ * *********************************************************************** */ package playground.amit.mixedTraffic.qPositionPlots; -import java.io.BufferedWriter; -import java.io.File; -import java.util.*; - -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.events.PersonDepartureEvent; @@ -40,9 +37,12 @@ import org.matsim.core.utils.io.tabularFileParser.TabularFileParserConfig; import org.matsim.run.Events2Snapshot; import org.matsim.vis.snapshotwriters.TransimsSnapshotWriter.Labels; - import playground.amit.utils.LoadMyScenarios; +import java.io.BufferedWriter; +import java.io.File; +import java.util.*; + /** * 1) Create Transims snapshot file from events or use given Transims snapshot file. * 2) Read events to get mode information @@ -62,7 +62,7 @@ @Deprecated public class AgentPositionWriterOld { - private final static Logger LOGGER = Logger.getLogger(AgentPositionWriterOld.class); + private final static Logger LOGGER = LogManager.getLogger(AgentPositionWriterOld.class); private final static boolean IS_WRITING_TRANSIM_FILE = false; private final double trackLength = 3000; private final double maxSpeed = 60/3.6; diff --git a/src/main/java/playground/amit/mixedTraffic/qPositionPlots/QPositionDataWriterForR.java b/src/main/java/playground/amit/mixedTraffic/qPositionPlots/QPositionDataWriterForR.java index d567118aa..73fb7d9c6 100644 --- a/src/main/java/playground/amit/mixedTraffic/qPositionPlots/QPositionDataWriterForR.java +++ b/src/main/java/playground/amit/mixedTraffic/qPositionPlots/QPositionDataWriterForR.java @@ -18,12 +18,8 @@ * *********************************************************************** */ package playground.amit.mixedTraffic.qPositionPlots; -import java.io.BufferedWriter; -import java.io.IOException; -import java.util.Map; -import java.util.SortedMap; - -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.Person; @@ -32,9 +28,13 @@ import org.matsim.core.events.MatsimEventsReader; import org.matsim.core.utils.collections.Tuple; import org.matsim.core.utils.io.IOUtils; - import playground.amit.utils.LoadMyScenarios; +import java.io.BufferedWriter; +import java.io.IOException; +import java.util.Map; +import java.util.SortedMap; + /** * @author amit */ @@ -52,7 +52,7 @@ public class QPositionDataWriterForR { private Tuple, Double> lastDepartedPerson = new Tuple<>(null, 0.); private final boolean isWritingDataAfterDepartureOfLastPerson = false; - private final static Logger LOG = Logger.getLogger(QPositionDataWriterForR.class); + private final static Logger LOG = LogManager.getLogger(QPositionDataWriterForR.class); public void run(){ scenario = LoadMyScenarios.loadScenarioFromNetwork(networkFile); diff --git a/src/main/java/playground/amit/mixedTraffic/qPositionPlots/QueuePositionCalculationHandler.java b/src/main/java/playground/amit/mixedTraffic/qPositionPlots/QueuePositionCalculationHandler.java index 36bd044df..db8e09af4 100644 --- a/src/main/java/playground/amit/mixedTraffic/qPositionPlots/QueuePositionCalculationHandler.java +++ b/src/main/java/playground/amit/mixedTraffic/qPositionPlots/QueuePositionCalculationHandler.java @@ -18,39 +18,27 @@ * *********************************************************************** */ package playground.amit.mixedTraffic.qPositionPlots; -import java.util.HashMap; -import java.util.Map; -import java.util.Queue; -import java.util.SortedMap; -import java.util.TreeMap; - -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; -import org.matsim.api.core.v01.events.LinkEnterEvent; -import org.matsim.api.core.v01.events.LinkLeaveEvent; -import org.matsim.api.core.v01.events.PersonDepartureEvent; -import org.matsim.api.core.v01.events.VehicleEntersTrafficEvent; -import org.matsim.api.core.v01.events.VehicleLeavesTrafficEvent; -import org.matsim.api.core.v01.events.handler.LinkEnterEventHandler; -import org.matsim.api.core.v01.events.handler.LinkLeaveEventHandler; -import org.matsim.api.core.v01.events.handler.PersonDepartureEventHandler; -import org.matsim.api.core.v01.events.handler.VehicleEntersTrafficEventHandler; -import org.matsim.api.core.v01.events.handler.VehicleLeavesTrafficEventHandler; +import org.matsim.api.core.v01.events.*; +import org.matsim.api.core.v01.events.handler.*; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.population.Person; import org.matsim.core.events.algorithms.Vehicle2DriverEventHandler; import org.matsim.core.utils.collections.Tuple; - import playground.amit.mixedTraffic.MixedTrafficVehiclesUtils; import playground.amit.mixedTraffic.qPositionPlots.LinkPersonInfoContainer.PersonPositionChecker; +import java.util.*; + /** * @author amit */ public class QueuePositionCalculationHandler implements LinkLeaveEventHandler, LinkEnterEventHandler, PersonDepartureEventHandler, VehicleLeavesTrafficEventHandler, VehicleEntersTrafficEventHandler { - private static final Logger LOG = Logger.getLogger(QueuePositionCalculationHandler.class); + private static final Logger LOG = LogManager.getLogger(QueuePositionCalculationHandler.class); private final Map,LinkPersonInfoContainer> linkid2Container = new HashMap<>(); private final Vehicle2DriverEventHandler delegate = new Vehicle2DriverEventHandler(); private final Map,SortedMap> person2startTime2PersonQPos = new HashMap<>(); diff --git a/src/main/java/playground/amit/mixedTraffic/seepage/SeepageSchematicPlotter.java b/src/main/java/playground/amit/mixedTraffic/seepage/SeepageSchematicPlotter.java index 00757f401..d1877f5f7 100644 --- a/src/main/java/playground/amit/mixedTraffic/seepage/SeepageSchematicPlotter.java +++ b/src/main/java/playground/amit/mixedTraffic/seepage/SeepageSchematicPlotter.java @@ -21,7 +21,8 @@ import java.util.*; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.junit.Assert; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -63,7 +64,7 @@ * */ public class SeepageSchematicPlotter { - static private final Logger log = Logger.getLogger( SeepageSchematicPlotter.class); + static private final Logger log = LogManager.getLogger( SeepageSchematicPlotter.class); public static void main(String [] args){ diff --git a/src/main/java/playground/amit/mixedTraffic/seepage/TestSetUp/AverageLinkFlowHandler.java b/src/main/java/playground/amit/mixedTraffic/seepage/TestSetUp/AverageLinkFlowHandler.java index 06b586642..4c75b35f3 100644 --- a/src/main/java/playground/amit/mixedTraffic/seepage/TestSetUp/AverageLinkFlowHandler.java +++ b/src/main/java/playground/amit/mixedTraffic/seepage/TestSetUp/AverageLinkFlowHandler.java @@ -18,13 +18,8 @@ * *********************************************************************** */ package playground.amit.mixedTraffic.seepage.TestSetUp; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.LinkEnterEvent; import org.matsim.api.core.v01.events.LinkLeaveEvent; @@ -35,6 +30,8 @@ import org.matsim.core.events.EventsUtils; import org.matsim.core.events.MatsimEventsReader; +import java.util.*; + /** * @author amit @@ -43,7 +40,7 @@ public class AverageLinkFlowHandler implements LinkEnterEventHandler, LinkLeaveE private final Map,List> enterTimes = new HashMap<>(); private final Map,List> leaveTimes = new HashMap<>(); - public static final Logger LOG = Logger.getLogger(AverageLinkFlowHandler.class); + public static final Logger LOG = LogManager.getLogger(AverageLinkFlowHandler.class); public static void main(String[] args) { String outputDir = "/Users/amit/Documents/repos/shared-svn/projects/mixedTraffic/seepage/xt_1Link/seepage/"; diff --git a/src/main/java/playground/amit/mixedTraffic/snapshot/MyPositionSnapShotWriter.java b/src/main/java/playground/amit/mixedTraffic/snapshot/MyPositionSnapShotWriter.java index 04988b75a..66d09879e 100644 --- a/src/main/java/playground/amit/mixedTraffic/snapshot/MyPositionSnapShotWriter.java +++ b/src/main/java/playground/amit/mixedTraffic/snapshot/MyPositionSnapShotWriter.java @@ -19,15 +19,8 @@ package playground.amit.mixedTraffic.snapshot; -import java.awt.geom.Point2D; -import java.io.BufferedWriter; -import java.io.IOException; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; -import javax.inject.Inject; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -40,6 +33,15 @@ import org.matsim.vis.snapshotwriters.SnapshotWriter; import playground.amit.utils.NumberUtils; +import javax.inject.Inject; +import java.awt.geom.Point2D; +import java.io.BufferedWriter; +import java.io.IOException; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; + /** * @author amit */ @@ -50,7 +52,7 @@ public class MyPositionSnapShotWriter implements SnapshotWriter { private double currentTime = -1; private final Scenario scenario; private final Map, Id> person2link = new HashMap<>(); - private final static Logger LOG = Logger.getLogger(MyPositionSnapShotWriter.class); + private final static Logger LOG = LogManager.getLogger(MyPositionSnapShotWriter.class); public enum Labels { TIME, VEHICLE, LINK_ID, DISTANCE_FROM_FROMNODE, SPEED } diff --git a/src/main/java/playground/amit/munich/analysis/UtilPerformingExperiment.java b/src/main/java/playground/amit/munich/analysis/UtilPerformingExperiment.java index dee8a0159..81b638a88 100644 --- a/src/main/java/playground/amit/munich/analysis/UtilPerformingExperiment.java +++ b/src/main/java/playground/amit/munich/analysis/UtilPerformingExperiment.java @@ -18,14 +18,8 @@ * *********************************************************************** */ package playground.amit.munich.analysis; -import java.io.BufferedWriter; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.SortedMap; -import java.util.TreeMap; - -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.Person; @@ -35,11 +29,13 @@ import org.matsim.core.events.MatsimEventsReader; import org.matsim.core.events.handler.EventHandler; import org.matsim.core.utils.io.IOUtils; - import playground.amit.analysis.activity.LegModeActivityEndTimeAndActDurationHandler; import playground.amit.utils.LoadMyScenarios; import playground.vsp.analysis.modules.AbstractAnalysisModule; +import java.io.BufferedWriter; +import java.util.*; + /** * @author amit */ @@ -48,7 +44,7 @@ public class UtilPerformingExperiment extends AbstractAnalysisModule { private final LegModeActivityEndTimeAndActDurationHandler actDurationUtilHandler; private final String eventsFile; private final String outputDir; - private static final Logger LOG = Logger.getLogger(UtilPerformingExperiment.class); + private static final Logger LOG = LogManager.getLogger(UtilPerformingExperiment.class); private final Map actType2TypicalDuration ; private double marginalUtilPerformingSec ; diff --git a/src/main/java/playground/amit/munich/analysis/userGroup/EmissionsPerPersonPerUserGroup.java b/src/main/java/playground/amit/munich/analysis/userGroup/EmissionsPerPersonPerUserGroup.java index bfb8b71ce..bfa3600ca 100644 --- a/src/main/java/playground/amit/munich/analysis/userGroup/EmissionsPerPersonPerUserGroup.java +++ b/src/main/java/playground/amit/munich/analysis/userGroup/EmissionsPerPersonPerUserGroup.java @@ -19,20 +19,13 @@ * *********************************************************************** */ package playground.amit.munich.analysis.userGroup; -import java.io.BufferedWriter; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.SortedMap; -import java.util.TreeMap; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.Person; -import org.matsim.contrib.emissions.Pollutant; import org.matsim.contrib.emissions.EmissionUtils; +import org.matsim.contrib.emissions.Pollutant; import org.matsim.core.scenario.MutableScenario; import org.matsim.core.utils.io.IOUtils; import playground.amit.munich.utils.MunichPersonFilter; @@ -41,6 +34,9 @@ import playground.vsp.airPollution.flatEmissions.EmissionCostFactors; import playground.vsp.analysis.modules.emissionsAnalyzer.EmissionsAnalyzer; +import java.io.BufferedWriter; +import java.util.*; + import static org.matsim.contrib.emissions.Pollutant.*; /** @@ -50,7 +46,7 @@ */ public class EmissionsPerPersonPerUserGroup { - public static final Logger LOG = Logger.getLogger(EmissionsPerPersonPerUserGroup.class); + public static final Logger LOG = LogManager.getLogger(EmissionsPerPersonPerUserGroup.class); private int lastIteration; private final String outputDir; private SortedMap> userGroupToEmissions; diff --git a/src/main/java/playground/amit/munich/analysis/userGroup/ExperiencedDelaysUserGroup.java b/src/main/java/playground/amit/munich/analysis/userGroup/ExperiencedDelaysUserGroup.java index b91294174..d2299fdc5 100644 --- a/src/main/java/playground/amit/munich/analysis/userGroup/ExperiencedDelaysUserGroup.java +++ b/src/main/java/playground/amit/munich/analysis/userGroup/ExperiencedDelaysUserGroup.java @@ -18,13 +18,8 @@ * *********************************************************************** */ package playground.amit.munich.analysis.userGroup; -import java.io.BufferedWriter; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import java.util.SortedMap; -import java.util.TreeMap; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -35,6 +30,13 @@ import playground.amit.munich.utils.MunichPersonFilter.MunichUserGroup; import playground.amit.utils.LoadMyScenarios; +import java.io.BufferedWriter; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.SortedMap; +import java.util.TreeMap; + /** * A class to get absolute experienced delays and delays costs per user group. * @author amit @@ -48,7 +50,7 @@ public ExperiencedDelaysUserGroup(String outputDir) { } private int lastIteration; - public static final Logger logger = Logger.getLogger(ExperiencedDelaysUserGroup.class); + public static final Logger logger = LogManager.getLogger(ExperiencedDelaysUserGroup.class); private final String outputDir; private SortedMap userGroupToDelays; diff --git a/src/main/java/playground/amit/munich/analysis/userGroup/ModalSplitUserGroup.java b/src/main/java/playground/amit/munich/analysis/userGroup/ModalSplitUserGroup.java index bd832b318..92f209f10 100644 --- a/src/main/java/playground/amit/munich/analysis/userGroup/ModalSplitUserGroup.java +++ b/src/main/java/playground/amit/munich/analysis/userGroup/ModalSplitUserGroup.java @@ -18,22 +18,24 @@ * *********************************************************************** */ package playground.amit.munich.analysis.userGroup; -import java.io.BufferedWriter; -import java.util.SortedMap; -import java.util.TreeMap; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.core.utils.io.IOUtils; import playground.amit.analysis.modalShare.ModalShareFromEvents; import playground.amit.munich.utils.MunichPersonFilter; import playground.amit.munich.utils.MunichPersonFilter.MunichUserGroup; import playground.amit.utils.FileUtils; +import java.io.BufferedWriter; +import java.util.SortedMap; +import java.util.TreeMap; + /** * @author amit */ public class ModalSplitUserGroup { - private final static Logger LOG = Logger.getLogger(ModalSplitUserGroup.class); + private final static Logger LOG = LogManager.getLogger(ModalSplitUserGroup.class); private final SortedMap> userGrp2Mode2Legs = new TreeMap<>(); private final SortedMap> userGrp2ModalSplit = new TreeMap<>(); diff --git a/src/main/java/playground/amit/munich/analysis/userGroup/RouteDistancePerUserGroup.java b/src/main/java/playground/amit/munich/analysis/userGroup/RouteDistancePerUserGroup.java index da89c3163..fb5c33050 100644 --- a/src/main/java/playground/amit/munich/analysis/userGroup/RouteDistancePerUserGroup.java +++ b/src/main/java/playground/amit/munich/analysis/userGroup/RouteDistancePerUserGroup.java @@ -18,14 +18,8 @@ * *********************************************************************** */ package playground.amit.munich.analysis.userGroup; -import java.io.BufferedWriter; -import java.io.File; -import java.util.List; -import java.util.Map; -import java.util.SortedMap; -import java.util.TreeMap; - -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -35,12 +29,18 @@ import org.matsim.core.events.EventsUtils; import org.matsim.core.events.MatsimEventsReader; import org.matsim.core.utils.io.IOUtils; - import playground.amit.analysis.tripDistance.TripDistanceHandler; import playground.amit.munich.utils.MunichPersonFilter; import playground.amit.munich.utils.UserGroupUtilsExtended; import playground.amit.utils.LoadMyScenarios; +import java.io.BufferedWriter; +import java.io.File; +import java.util.List; +import java.util.Map; +import java.util.SortedMap; +import java.util.TreeMap; + /** * @author amit */ @@ -55,7 +55,7 @@ public RouteDistancePerUserGroup() { userGrpToBoxPlotData = new TreeMap<>(); } - private final Logger logger = Logger.getLogger(RouteDistancePerUserGroup.class); + private final Logger logger = LogManager.getLogger(RouteDistancePerUserGroup.class); private final String outputDir = "../../../../repos/runs-svn/detEval/emissionCongestionInternalization/otherRuns/output/1pct/run10/policies/backcasting/exposure/25ExI/"; private final String configFile = outputDir+"/output_config.xml"; private final int lastIteration = LoadMyScenarios.getLastIteration(configFile); diff --git a/src/main/java/playground/amit/munich/analysis/userGroup/TravelTimePerUserGroup.java b/src/main/java/playground/amit/munich/analysis/userGroup/TravelTimePerUserGroup.java index 2aff4c0c5..125b00a99 100644 --- a/src/main/java/playground/amit/munich/analysis/userGroup/TravelTimePerUserGroup.java +++ b/src/main/java/playground/amit/munich/analysis/userGroup/TravelTimePerUserGroup.java @@ -18,14 +18,8 @@ * *********************************************************************** */ package playground.amit.munich.analysis.userGroup; -import java.io.BufferedWriter; -import java.io.File; -import java.util.List; -import java.util.Map; -import java.util.SortedMap; -import java.util.TreeMap; - -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -37,6 +31,13 @@ import playground.amit.munich.utils.UserGroupUtilsExtended; import playground.amit.utils.LoadMyScenarios; +import java.io.BufferedWriter; +import java.io.File; +import java.util.List; +import java.util.Map; +import java.util.SortedMap; +import java.util.TreeMap; + /** * @author amit */ @@ -58,7 +59,7 @@ public TravelTimePerUserGroup() { private final ModalTravelTimeAnalyzer travelTimeAnalyzer; private final Scenario sc; - private static final Logger LOGGER = Logger.getLogger(TravelTimePerUserGroup.class); + private static final Logger LOGGER = LogManager.getLogger(TravelTimePerUserGroup.class); private Map, List>> mode2PersonId2TravelTimes; private final String outputDir = "../../../../repos/runs-svn/detEval/emissionCongestionInternalization/otherRuns/output/1pct/run10/policies/backcasting/exposure/25ExI/"; diff --git a/src/main/java/playground/amit/munich/analysis/userGroup/UserBenefitsAndTotalWelfarePerUserGroup.java b/src/main/java/playground/amit/munich/analysis/userGroup/UserBenefitsAndTotalWelfarePerUserGroup.java index 1a7ef97af..134702cb3 100644 --- a/src/main/java/playground/amit/munich/analysis/userGroup/UserBenefitsAndTotalWelfarePerUserGroup.java +++ b/src/main/java/playground/amit/munich/analysis/userGroup/UserBenefitsAndTotalWelfarePerUserGroup.java @@ -18,15 +18,8 @@ * *********************************************************************** */ package playground.amit.munich.analysis.userGroup; -import java.io.BufferedWriter; -import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.SortedMap; -import java.util.TreeMap; - -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.Person; @@ -36,7 +29,6 @@ import org.matsim.core.events.handler.EventHandler; import org.matsim.core.scenario.MutableScenario; import org.matsim.core.utils.io.IOUtils; - import playground.amit.analysis.userBenefits.MyUserBenefitsAnalyzer; import playground.amit.munich.utils.MunichPersonFilter; import playground.amit.munich.utils.MunichPersonFilter.MunichUserGroup; @@ -45,13 +37,17 @@ import playground.vsp.analysis.modules.monetaryTransferPayments.MonetaryPaymentsAnalyzer; import playground.vsp.analysis.modules.userBenefits.WelfareMeasure; +import java.io.BufferedWriter; +import java.io.IOException; +import java.util.*; + /** * A class to get user benefits and user welfare_money for each user group. * @author amit */ public class UserBenefitsAndTotalWelfarePerUserGroup { - public static final Logger LOG = Logger.getLogger(UserBenefitsAndTotalWelfarePerUserGroup.class); + public static final Logger LOG = LogManager.getLogger(UserBenefitsAndTotalWelfarePerUserGroup.class); private final String outputDir; private Map, Double> personId2UserWelfareUtils; private Map, Double> personId2MonetarizedUserWelfare; diff --git a/src/main/java/playground/amit/munich/analysis/userGroup/toll/PeakHourTripDistanceAnalyzer.java b/src/main/java/playground/amit/munich/analysis/userGroup/toll/PeakHourTripDistanceAnalyzer.java index 9c499b019..31f56aac1 100644 --- a/src/main/java/playground/amit/munich/analysis/userGroup/toll/PeakHourTripDistanceAnalyzer.java +++ b/src/main/java/playground/amit/munich/analysis/userGroup/toll/PeakHourTripDistanceAnalyzer.java @@ -18,9 +18,8 @@ * *********************************************************************** */ package playground.amit.munich.analysis.userGroup.toll; -import java.io.BufferedWriter; -import java.util.*; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Network; @@ -37,6 +36,9 @@ import playground.amit.utils.ListUtils; import playground.amit.utils.LoadMyScenarios; +import java.io.BufferedWriter; +import java.util.*; + /** * @author amit */ @@ -51,7 +53,7 @@ public class PeakHourTripDistanceAnalyzer { private final Map,Integer> person2TripCountsOffPkHr = new HashMap<>(); private final SortedMap> usrGrp2Dists = new TreeMap<>(); private final SortedMap> usrGrp2TripCounts = new TreeMap<>(); - private static final Logger LOG = Logger.getLogger(PeakHourTripDistanceAnalyzer.class); + private static final Logger LOG = LogManager.getLogger(PeakHourTripDistanceAnalyzer.class); public PeakHourTripDistanceAnalyzer(Network network, double simulationEndTime, int noOfTimeBins) { LOG.warn("Peak hours are assumed as 07:00-10:00 and 15:00-18:00 by looking on the travel demand for BAU scenario."); diff --git a/src/main/java/playground/amit/munich/analysis/userGroup/toll/PeakHourTripTollAnalyzer.java b/src/main/java/playground/amit/munich/analysis/userGroup/toll/PeakHourTripTollAnalyzer.java index 94904301b..707c489e9 100644 --- a/src/main/java/playground/amit/munich/analysis/userGroup/toll/PeakHourTripTollAnalyzer.java +++ b/src/main/java/playground/amit/munich/analysis/userGroup/toll/PeakHourTripTollAnalyzer.java @@ -18,17 +18,8 @@ * *********************************************************************** */ package playground.amit.munich.analysis.userGroup.toll; -import java.io.BufferedWriter; -import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.SortedMap; -import java.util.TreeMap; - -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.core.api.experimental.events.EventsManager; @@ -36,19 +27,22 @@ import org.matsim.core.events.MatsimEventsReader; import org.matsim.core.utils.collections.Tuple; import org.matsim.core.utils.io.IOUtils; - import playground.amit.analysis.toll.TripTollHandler; import playground.amit.munich.utils.MunichPersonFilter; import playground.amit.munich.utils.MunichPersonFilter.MunichUserGroup; import playground.amit.utils.ListUtils; import playground.amit.utils.LoadMyScenarios; +import java.io.BufferedWriter; +import java.io.File; +import java.util.*; + /** * @author amit */ public class PeakHourTripTollAnalyzer { - private static final Logger LOG = Logger.getLogger(PeakHourTripTollAnalyzer.class); + private static final Logger LOG = LogManager.getLogger(PeakHourTripTollAnalyzer.class); private final TripTollHandler tollHandler ; private final List pkHrs = new ArrayList<>(Arrays.asList(8., 9., 10., 16., 17., 18.)); // => 7-10 and 15-18 diff --git a/src/main/java/playground/amit/munich/analysis/userGroup/toll/PeakHourTripTollPerKmAnalyzer.java b/src/main/java/playground/amit/munich/analysis/userGroup/toll/PeakHourTripTollPerKmAnalyzer.java index e90f50276..e87149e12 100644 --- a/src/main/java/playground/amit/munich/analysis/userGroup/toll/PeakHourTripTollPerKmAnalyzer.java +++ b/src/main/java/playground/amit/munich/analysis/userGroup/toll/PeakHourTripTollPerKmAnalyzer.java @@ -18,10 +18,8 @@ * *********************************************************************** */ package playground.amit.munich.analysis.userGroup.toll; -import java.io.BufferedWriter; -import java.io.File; -import java.util.*; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Network; @@ -40,13 +38,17 @@ import playground.amit.utils.ListUtils; import playground.amit.utils.LoadMyScenarios; +import java.io.BufferedWriter; +import java.io.File; +import java.util.*; + /** * @author amit */ public class PeakHourTripTollPerKmAnalyzer { - private static final Logger LOG = Logger.getLogger(PeakHourTripTollPerKmAnalyzer.class); + private static final Logger LOG = LogManager.getLogger(PeakHourTripTollPerKmAnalyzer.class); private final TripTollHandler tollHandler ; private final ModeFilterTripDistanceHandler distHandler; diff --git a/src/main/java/playground/amit/munich/calibration/LegModeRouteDistancDistribution.java b/src/main/java/playground/amit/munich/calibration/LegModeRouteDistancDistribution.java index 2058db875..0b416207d 100644 --- a/src/main/java/playground/amit/munich/calibration/LegModeRouteDistancDistribution.java +++ b/src/main/java/playground/amit/munich/calibration/LegModeRouteDistancDistribution.java @@ -18,14 +18,16 @@ * *********************************************************************** */ package playground.amit.munich.calibration; -import java.io.File; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Scenario; import playground.amit.analysis.tripDistance.LegModeRouteDistanceDistributionAnalyzer; import playground.amit.munich.utils.MunichPersonFilter; import playground.amit.utils.LoadMyScenarios; import playground.vsp.analysis.modules.legModeDistanceDistribution.LegModeDistanceDistribution; +import java.io.File; + /** * @author amit */ @@ -33,7 +35,7 @@ public class LegModeRouteDistancDistribution { private final static String RUN_DIR = "../../../repos/runs-svn/detEval/emissionCongestionInternalization/output/1pct/run10/policies/"; private final static String [] RUNS_CASES = {"bau","ei","ci","eci","10ei"}; - private static final Logger LOG = Logger.getLogger(LegModeRouteDistancDistribution.class); + private static final Logger LOG = LogManager.getLogger(LegModeRouteDistancDistribution.class); public static void main(String[] args) { LegModeRouteDistancDistribution ms= new LegModeRouteDistancDistribution(); diff --git a/src/main/java/playground/amit/munich/controlerListener/CongestionCostCollector.java b/src/main/java/playground/amit/munich/controlerListener/CongestionCostCollector.java index 111ccd326..786e15226 100644 --- a/src/main/java/playground/amit/munich/controlerListener/CongestionCostCollector.java +++ b/src/main/java/playground/amit/munich/controlerListener/CongestionCostCollector.java @@ -18,24 +18,24 @@ * *********************************************************************** */ package playground.amit.munich.controlerListener; -import java.util.HashMap; -import java.util.Map; - -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.population.Person; import org.matsim.core.scenario.MutableScenario; - import playground.vsp.congestion.events.CongestionEvent; import playground.vsp.congestion.handlers.CongestionEventHandler; +import java.util.HashMap; +import java.util.Map; + /** * @author amit */ public class CongestionCostCollector implements CongestionEventHandler { - private final static Logger LOG = Logger.getLogger(CongestionCostCollector.class); + private final static Logger LOG = LogManager.getLogger(CongestionCostCollector.class); private final double vttsCar; private double amountSum = 0.; diff --git a/src/main/java/playground/amit/munich/controlerListener/MyEmissionCongestionMoneyEventControlerListener.java b/src/main/java/playground/amit/munich/controlerListener/MyEmissionCongestionMoneyEventControlerListener.java index 33c93146d..afae5d362 100644 --- a/src/main/java/playground/amit/munich/controlerListener/MyEmissionCongestionMoneyEventControlerListener.java +++ b/src/main/java/playground/amit/munich/controlerListener/MyEmissionCongestionMoneyEventControlerListener.java @@ -18,12 +18,9 @@ * *********************************************************************** */ package playground.amit.munich.controlerListener; -import java.io.BufferedWriter; -import java.util.HashMap; -import java.util.Map; - import com.google.inject.Inject; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.population.Person; @@ -34,18 +31,21 @@ import org.matsim.core.controler.listener.StartupListener; import org.matsim.core.scenario.MutableScenario; import org.matsim.core.utils.io.IOUtils; - import playground.amit.analysis.congestion.ExperiencedDelayHandler; import playground.amit.analysis.emission.caused.CausedEmissionCostHandler; import playground.vsp.airPollution.flatEmissions.EmissionCostModule; import playground.vsp.analysis.modules.monetaryTransferPayments.MoneyEventHandler; +import java.io.BufferedWriter; +import java.util.HashMap; +import java.util.Map; + /** * @author amit */ public class MyEmissionCongestionMoneyEventControlerListener implements StartupListener, IterationEndsListener{ - public static final Logger log =Logger.getLogger(MyEmissionCongestionMoneyEventControlerListener.class); + public static final Logger log =LogManager.getLogger(MyEmissionCongestionMoneyEventControlerListener.class); private Map, Double> pId2WarmEmissionsCosts= new HashMap<>(); private Map, Double> pId2CongestionCosts= new HashMap<>(); diff --git a/src/main/java/playground/amit/munich/inputs/ActivityClassifier.java b/src/main/java/playground/amit/munich/inputs/ActivityClassifier.java index 05aeb6aa1..0cf18d5a8 100644 --- a/src/main/java/playground/amit/munich/inputs/ActivityClassifier.java +++ b/src/main/java/playground/amit/munich/inputs/ActivityClassifier.java @@ -18,29 +18,22 @@ * *********************************************************************** */ package playground.amit.munich.inputs; -import java.util.List; -import java.util.SortedMap; -import java.util.TreeMap; - -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Scenario; -import org.matsim.api.core.v01.population.Activity; -import org.matsim.api.core.v01.population.Leg; -import org.matsim.api.core.v01.population.Person; -import org.matsim.api.core.v01.population.Plan; -import org.matsim.api.core.v01.population.PlanElement; -import org.matsim.api.core.v01.population.Population; -import org.matsim.api.core.v01.population.PopulationFactory; -import org.matsim.api.core.v01.population.PopulationWriter; +import org.matsim.api.core.v01.population.*; import org.matsim.core.config.ConfigUtils; import org.matsim.core.gbl.Gbl; import org.matsim.core.scenario.ScenarioUtils; import org.matsim.core.utils.collections.Tuple; - import playground.amit.munich.utils.MunichPersonFilter; import playground.amit.munich.utils.MunichPersonFilter.MunichUserGroup; +import java.util.List; +import java.util.SortedMap; +import java.util.TreeMap; + /** * It classifies activities into sub-activities for Munich scenario by assuming stated activities as typical duration. * Typical duration is rounded to lower hour value (1 h time bin). @@ -57,7 +50,7 @@ public ActivityClassifier(Scenario scenario) { //TODO : might make more sense if I check above for all intermediate activities as well. } - public static final Logger LOG = Logger.getLogger(ActivityClassifier.class.getSimpleName()); + public static final Logger LOG = LogManager.getLogger(ActivityClassifier.class.getSimpleName()); private final Scenario sc ; private int zeroDurCount =0; private final SortedMap actType2TypDur; diff --git a/src/main/java/playground/amit/munich/runControlers/SubPopMunichControler.java b/src/main/java/playground/amit/munich/runControlers/SubPopMunichControler.java index fc84eeaa2..a0c93b4f5 100644 --- a/src/main/java/playground/amit/munich/runControlers/SubPopMunichControler.java +++ b/src/main/java/playground/amit/munich/runControlers/SubPopMunichControler.java @@ -18,12 +18,7 @@ * *********************************************************************** */ package playground.amit.munich.runControlers; -import java.io.File; -import java.util.HashSet; -import java.util.Set; -import javax.inject.Inject; -import javax.inject.Provider; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; @@ -38,7 +33,6 @@ import org.matsim.core.replanning.PlanStrategy; import org.matsim.core.replanning.PlanStrategyImpl.Builder; import org.matsim.core.replanning.modules.ReRoute; -import org.matsim.core.replanning.modules.SubtourModeChoice; import org.matsim.core.replanning.selectors.RandomPlanSelector; import org.matsim.core.replanning.strategies.DefaultPlanStrategiesModule; import org.matsim.core.router.TripRouter; @@ -61,6 +55,12 @@ import playground.vsp.congestion.handlers.TollHandler; import playground.vsp.congestion.routing.TollDisutilityCalculatorFactory; +import javax.inject.Inject; +import javax.inject.Provider; +import java.io.File; +import java.util.HashSet; +import java.util.Set; + /** * @author amit */ @@ -110,13 +110,10 @@ public void install() { Scenario sc; @Inject Provider tripRouterProvider; - @Inject - TimeInterpretation timeInterpretation; - @Override public PlanStrategy get() { final Builder builder = new Builder(new RandomPlanSelector<>()); - builder.addStrategyModule(new ReRoute(sc, tripRouterProvider, timeInterpretation)); + builder.addStrategyModule(new ReRoute(sc, tripRouterProvider, TimeInterpretation.create(this.sc.getConfig()))); return builder.build(); } }); @@ -134,8 +131,7 @@ public void install() { Scenario sc; @Inject Provider tripRouterProvider; - @Inject - TimeInterpretation timeInterpretation; + @Override public PlanStrategy get() { final Builder builder = new Builder(new RandomPlanSelector<>()); @@ -146,7 +142,7 @@ public PlanStrategy get() { // false, // 0.0, //prob, 0.0 for backward compatiblity // tripRouterProvider)); - builder.addStrategyModule(new ReRoute(sc, tripRouterProvider, timeInterpretation)); + builder.addStrategyModule(new ReRoute(sc, tripRouterProvider, TimeInterpretation.create(this.sc.getConfig()))); return builder.build(); } }); @@ -227,7 +223,7 @@ public void install() { String OUTPUT_DIR = config.controler().getOutputDirectory(); for (int index =firstIt+1; index ()); //TODO following line is commented. See, what's changed. Amit 19.09.2020 // builder.addStrategyModule(new SubtourModeChoice(sc.getConfig().global().getNumberOfThreads(), availableModes, chainBasedModes, false, 0.0, tripRouterProvider)); - builder.addStrategyModule(new ReRoute(sc, tripRouterProvider, timeInterpretation)); + builder.addStrategyModule(new ReRoute(sc, tripRouterProvider, TimeInterpretation.create(this.sc.getConfig()))); return builder.build(); } }); @@ -125,7 +124,7 @@ public PlanStrategy get() { EmissionsConfigGroup ecg = new EmissionsConfigGroup(); controler.getConfig().addModule(ecg); -// ecg.setUsingDetailedEmissionCalculation(true); + // ecg.setUsingDetailedEmissionCalculation(true); String hbefaDirectory; diff --git a/src/main/java/playground/amit/munich/utils/MunichPersonFilter.java b/src/main/java/playground/amit/munich/utils/MunichPersonFilter.java index be24df6d3..4c1389201 100644 --- a/src/main/java/playground/amit/munich/utils/MunichPersonFilter.java +++ b/src/main/java/playground/amit/munich/utils/MunichPersonFilter.java @@ -18,24 +18,25 @@ * *********************************************************************** */ package playground.amit.munich.utils; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Population; import org.matsim.core.config.ConfigUtils; import org.matsim.core.scenario.ScenarioUtils; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + /** * @author amit */ public class MunichPersonFilter implements playground.amit.utils.PersonFilter{ - private static final Logger LOG = Logger.getLogger(MunichPersonFilter.class); + private static final Logger LOG = LogManager.getLogger(MunichPersonFilter.class); public enum MunichUserGroup {Urban, Rev_Commuter, Freight} public MunichPersonFilter (){} diff --git a/src/main/java/playground/amit/munich/utils/UserGroupUtilsExtended.java b/src/main/java/playground/amit/munich/utils/UserGroupUtilsExtended.java index f677a2201..e932d452a 100644 --- a/src/main/java/playground/amit/munich/utils/UserGroupUtilsExtended.java +++ b/src/main/java/playground/amit/munich/utils/UserGroupUtilsExtended.java @@ -19,7 +19,8 @@ package playground.amit.munich.utils; import java.util.*; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Population; @@ -29,7 +30,7 @@ * @author amit */ public class UserGroupUtilsExtended { - private final Logger logger = Logger.getLogger(UserGroupUtilsExtended.class); + private final Logger logger = LogManager.getLogger(UserGroupUtilsExtended.class); public SortedMap calculateTravelMode2Mean(Map, Double>> inputMap, Population relavantPop){ this.logger.info("Calculating mean(average) ..."); diff --git a/src/main/java/playground/amit/opdyts/ModeChoiceObjectiveFunction.java b/src/main/java/playground/amit/opdyts/ModeChoiceObjectiveFunction.java index f24a591fd..160cd5917 100644 --- a/src/main/java/playground/amit/opdyts/ModeChoiceObjectiveFunction.java +++ b/src/main/java/playground/amit/opdyts/ModeChoiceObjectiveFunction.java @@ -54,7 +54,7 @@ // * // */ //public class ModeChoiceObjectiveFunction implements ObjectiveFunction { -// private static final Logger log = Logger.getLogger( ModeChoiceObjectiveFunction.class ); +// private static final Logger log = LogManager.getLogger( ModeChoiceObjectiveFunction.class ); // // private final MainModeIdentifier mainModeIdentifier ; // diff --git a/src/main/java/playground/amit/opdyts/ModeChoiceRandomizer.java b/src/main/java/playground/amit/opdyts/ModeChoiceRandomizer.java index 8d6de9992..b7d44c003 100644 --- a/src/main/java/playground/amit/opdyts/ModeChoiceRandomizer.java +++ b/src/main/java/playground/amit/opdyts/ModeChoiceRandomizer.java @@ -39,7 +39,7 @@ // */ // //public final class ModeChoiceRandomizer implements DecisionVariableRandomizer { -// private static final Logger log = Logger.getLogger(ModeChoiceRandomizer.class); +// private static final Logger log = LogManager.getLogger(ModeChoiceRandomizer.class); // // public enum ASCRandomizerStyle { // axial_randomVariation, // combinations like (0,+), (0,-), (+,0), (-,0) diff --git a/src/main/java/playground/amit/opdyts/ObjectiveFunctionEvaluator.java b/src/main/java/playground/amit/opdyts/ObjectiveFunctionEvaluator.java index 8ae95a701..a7695a7ed 100644 --- a/src/main/java/playground/amit/opdyts/ObjectiveFunctionEvaluator.java +++ b/src/main/java/playground/amit/opdyts/ObjectiveFunctionEvaluator.java @@ -19,15 +19,17 @@ package playground.amit.opdyts; +import com.google.inject.Inject; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.matsim.contrib.analysis.kai.Databins; +import org.matsim.core.config.groups.StrategyConfigGroup; + import java.util.Arrays; import java.util.Map; import java.util.SortedMap; import java.util.TreeMap; import java.util.stream.Collectors; -import com.google.inject.Inject; -import org.apache.log4j.Logger; -import org.matsim.contrib.analysis.kai.Databins; -import org.matsim.core.config.groups.StrategyConfigGroup; /** * Created by amit on 28/11/2016. @@ -35,7 +37,7 @@ public class ObjectiveFunctionEvaluator { - private static final Logger log = Logger.getLogger(ObjectiveFunctionEvaluator.class); + private static final Logger log = LogManager.getLogger(ObjectiveFunctionEvaluator.class); private final SortedMap mode2share = new TreeMap<>(); public enum ObjectiveFunctionType { diff --git a/src/main/java/playground/amit/opdyts/OpdytsModeChoiceUtils.java b/src/main/java/playground/amit/opdyts/OpdytsModeChoiceUtils.java index d75731a7c..28537a49e 100644 --- a/src/main/java/playground/amit/opdyts/OpdytsModeChoiceUtils.java +++ b/src/main/java/playground/amit/opdyts/OpdytsModeChoiceUtils.java @@ -19,10 +19,9 @@ package playground.amit.opdyts; -import java.io.File; -import java.io.IOException; import com.google.common.io.Files; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.core.config.groups.StrategyConfigGroup; import org.matsim.core.config.groups.StrategyConfigGroup.StrategySettings; import org.matsim.core.controler.events.ShutdownEvent; @@ -30,6 +29,9 @@ import org.matsim.core.replanning.strategies.DefaultPlanStrategiesModule.DefaultSelector; import org.matsim.core.replanning.strategies.DefaultPlanStrategiesModule.DefaultStrategy; import org.matsim.core.utils.io.IOUtils; + +import java.io.File; +import java.io.IOException; //import playground.amit.opdyts.patna.networkModesOnly.PatnaNetworkModesOpdytsCalibrator; /** @@ -37,7 +39,7 @@ */ public class OpdytsModeChoiceUtils { - private static final Logger log = Logger.getLogger(OpdytsModeChoiceUtils.class); + private static final Logger log = LogManager.getLogger(OpdytsModeChoiceUtils.class); /* * random replanning probability is the probability that @@ -94,7 +96,7 @@ public void notifyShutdown(ShutdownEvent event) { try { Files.copy(new File(sourceFile), new File(sinkFile)); } catch (IOException e) { -// Logger.getLogger(PatnaNetworkModesOpdytsCalibrator.class).warn("Data is not copied. Reason : " + e); +// LogManager.getLogger(PatnaNetworkModesOpdytsCalibrator.class).warn("Data is not copied. Reason : " + e); } } { diff --git a/src/main/java/playground/amit/opdyts/equil/MatsimOpdytsEquilIntegration.java b/src/main/java/playground/amit/opdyts/equil/MatsimOpdytsEquilIntegration.java index 2aeb76cd7..d401c32c0 100644 --- a/src/main/java/playground/amit/opdyts/equil/MatsimOpdytsEquilIntegration.java +++ b/src/main/java/playground/amit/opdyts/equil/MatsimOpdytsEquilIntegration.java @@ -177,7 +177,7 @@ // try { // Files.copy(new File(sourceFile), new File(sinkFile)); // } catch (IOException e) { -// Logger.getLogger(MatsimOpdytsEquilIntegration.class).warn("Data is not copied. Reason : " + e); +// LogManager.getLogger(MatsimOpdytsEquilIntegration.class).warn("Data is not copied. Reason : " + e); // } // } // { @@ -186,7 +186,7 @@ // try { // Files.copy(new File(sourceFile), new File(sinkFile)); // } catch (IOException e) { -// Logger.getLogger(MatsimOpdytsEquilIntegration.class).warn("Data is not copied. Reason : " + e); +// LogManager.getLogger(MatsimOpdytsEquilIntegration.class).warn("Data is not copied. Reason : " + e); // } // } // } diff --git a/src/main/java/playground/amit/opdyts/equil/MatsimOpdytsEquilMixedTrafficIntegration.java b/src/main/java/playground/amit/opdyts/equil/MatsimOpdytsEquilMixedTrafficIntegration.java index ba956af59..e59093b7c 100644 --- a/src/main/java/playground/amit/opdyts/equil/MatsimOpdytsEquilMixedTrafficIntegration.java +++ b/src/main/java/playground/amit/opdyts/equil/MatsimOpdytsEquilMixedTrafficIntegration.java @@ -159,7 +159,7 @@ // try { // Files.copy(new File(sourceFile), new File(sinkFile)); // } catch (IOException e) { -// Logger.getLogger(MatsimOpdytsEquilMixedTrafficIntegration.class).warn("Data is not copied. Reason : " + e); +// LogManager.getLogger(MatsimOpdytsEquilMixedTrafficIntegration.class).warn("Data is not copied. Reason : " + e); // } // } // } diff --git a/src/main/java/playground/amit/opdyts/patna/allModes/PatnaZoneIdentifier.java b/src/main/java/playground/amit/opdyts/patna/allModes/PatnaZoneIdentifier.java index 273d3498a..6652af9c7 100644 --- a/src/main/java/playground/amit/opdyts/patna/allModes/PatnaZoneIdentifier.java +++ b/src/main/java/playground/amit/opdyts/patna/allModes/PatnaZoneIdentifier.java @@ -19,15 +19,8 @@ package playground.amit.opdyts.patna.allModes; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; - -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.GeometryFactory; @@ -45,7 +38,6 @@ import org.matsim.core.utils.geometry.transformations.TransformationFactory; import org.matsim.core.utils.gis.ShapeFileReader; import org.opengis.feature.simple.SimpleFeature; - import playground.amit.analysis.spatial.GeneralGrid; import playground.amit.clustering.BoundingBox; import playground.amit.clustering.Cluster; @@ -56,13 +48,16 @@ import playground.amit.utils.FileUtils; import playground.amit.utils.LoadMyScenarios; +import java.util.*; +import java.util.stream.Collectors; + /** * Created by amit on 15.06.17. */ public final class PatnaZoneIdentifier { - private static final Logger LOGGER = Logger.getLogger(PatnaZoneIdentifier.class); + private static final Logger LOGGER = LogManager.getLogger(PatnaZoneIdentifier.class); //BEGIN_EXAMPLE public static void main(String[] args) { diff --git a/src/main/java/playground/amit/opdyts/patna/networkModesOnly/PatnaBaseCaseControler.java b/src/main/java/playground/amit/opdyts/patna/networkModesOnly/PatnaBaseCaseControler.java index 80211de4f..413b8428c 100644 --- a/src/main/java/playground/amit/opdyts/patna/networkModesOnly/PatnaBaseCaseControler.java +++ b/src/main/java/playground/amit/opdyts/patna/networkModesOnly/PatnaBaseCaseControler.java @@ -19,10 +19,8 @@ package playground.amit.opdyts.patna.networkModesOnly; -import java.io.File; -import java.util.Arrays; -import java.util.List; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Scenario; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; @@ -30,14 +28,18 @@ import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy; import org.matsim.core.scenario.ScenarioUtils; -import playground.vsp.analysis.modules.modalAnalyses.modalShare.ModalShareControlerListener; -import playground.vsp.analysis.modules.modalAnalyses.modalShare.ModalShareEventHandler; -import playground.vsp.analysis.modules.modalAnalyses.modalTripTime.ModalTravelTimeControlerListener; -import playground.vsp.analysis.modules.modalAnalyses.modalTripTime.ModalTripTravelTimeHandler; import playground.amit.opdyts.DistanceDistribution; import playground.amit.opdyts.OpdytsScenario; import playground.amit.opdyts.analysis.OpdytsModalStatsControlerListener; import playground.amit.utils.FileUtils; +import playground.vsp.analysis.modules.modalAnalyses.modalShare.ModalShareControlerListener; +import playground.vsp.analysis.modules.modalAnalyses.modalShare.ModalShareEventHandler; +import playground.vsp.analysis.modules.modalAnalyses.modalTripTime.ModalTravelTimeControlerListener; +import playground.vsp.analysis.modules.modalAnalyses.modalTripTime.ModalTripTravelTimeHandler; + +import java.io.File; +import java.util.Arrays; +import java.util.List; /** * Created by amit on 22.05.17. @@ -45,7 +47,7 @@ public class PatnaBaseCaseControler { - public static final Logger LOGGER = Logger.getLogger(PatnaBaseCaseControler.class); + public static final Logger LOGGER = LogManager.getLogger(PatnaBaseCaseControler.class); private enum PatnaBestDecisionVariable { REPORTED_BEST, // (from GF) reported as best overall decision variable in opdyts.log diff --git a/src/main/java/playground/amit/opdyts/patna/networkModesOnly/PatnaNetworkModeCheckForBaseCase.java b/src/main/java/playground/amit/opdyts/patna/networkModesOnly/PatnaNetworkModeCheckForBaseCase.java index c66fdd5e5..d17ce1a6d 100644 --- a/src/main/java/playground/amit/opdyts/patna/networkModesOnly/PatnaNetworkModeCheckForBaseCase.java +++ b/src/main/java/playground/amit/opdyts/patna/networkModesOnly/PatnaNetworkModeCheckForBaseCase.java @@ -19,9 +19,8 @@ package playground.amit.opdyts.patna.networkModesOnly; -import java.util.Arrays; -import java.util.List; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Scenario; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; @@ -29,13 +28,16 @@ import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy; import org.matsim.core.scenario.ScenarioUtils; +import playground.amit.opdyts.OpdytsScenario; +import playground.amit.opdyts.analysis.OpdytsModalStatsControlerListener; +import playground.amit.utils.FileUtils; import playground.vsp.analysis.modules.modalAnalyses.modalShare.ModalShareControlerListener; import playground.vsp.analysis.modules.modalAnalyses.modalShare.ModalShareEventHandler; import playground.vsp.analysis.modules.modalAnalyses.modalTripTime.ModalTravelTimeControlerListener; import playground.vsp.analysis.modules.modalAnalyses.modalTripTime.ModalTripTravelTimeHandler; -import playground.amit.opdyts.OpdytsScenario; -import playground.amit.opdyts.analysis.OpdytsModalStatsControlerListener; -import playground.amit.utils.FileUtils; + +import java.util.Arrays; +import java.util.List; /** * Created by amit on 12.06.17. @@ -44,7 +46,7 @@ public class PatnaNetworkModeCheckForBaseCase { - private static final Logger LOGGER = Logger.getLogger(PatnaNetworkModeCheckForBaseCase.class); + private static final Logger LOGGER = LogManager.getLogger(PatnaNetworkModeCheckForBaseCase.class); public static void main(String[] args) { diff --git a/src/main/java/playground/amit/opdyts/plots/BestSolutionVsDecisionVariableChart.java b/src/main/java/playground/amit/opdyts/plots/BestSolutionVsDecisionVariableChart.java index 750c32af4..b32e29baa 100644 --- a/src/main/java/playground/amit/opdyts/plots/BestSolutionVsDecisionVariableChart.java +++ b/src/main/java/playground/amit/opdyts/plots/BestSolutionVsDecisionVariableChart.java @@ -19,17 +19,19 @@ package playground.amit.opdyts.plots; -import java.awt.*; -import java.io.BufferedReader; -import java.io.IOException; -import java.util.*; -import java.util.List; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.core.utils.charts.XYScatterChart; import org.matsim.core.utils.collections.Tuple; import org.matsim.core.utils.io.IOUtils; import playground.amit.utils.FileUtils; +import java.awt.*; +import java.io.BufferedReader; +import java.io.IOException; +import java.util.List; +import java.util.*; + /** * A class to extract the currentBestDevisionVariable and currentBestObjectiveFunction. * @@ -38,7 +40,7 @@ public class BestSolutionVsDecisionVariableChart { - private static final Logger LOGGER = Logger.getLogger(BestSolutionVsDecisionVariableChart.class); + private static final Logger LOGGER = LogManager.getLogger(BestSolutionVsDecisionVariableChart.class); public BestSolutionVsDecisionVariableChart(final Collection modesToGetASC) { this.modesToGetASC = modesToGetASC; diff --git a/src/main/java/playground/amit/opdyts/plots/OpdytsConvergenceChart.java b/src/main/java/playground/amit/opdyts/plots/OpdytsConvergenceChart.java index c5cf20728..85a411101 100644 --- a/src/main/java/playground/amit/opdyts/plots/OpdytsConvergenceChart.java +++ b/src/main/java/playground/amit/opdyts/plots/OpdytsConvergenceChart.java @@ -19,17 +19,19 @@ package playground.amit.opdyts.plots; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.matsim.core.utils.charts.XYScatterChart; +import org.matsim.core.utils.collections.Tuple; +import org.matsim.core.utils.io.IOUtils; +import playground.amit.utils.FileUtils; + import java.awt.*; import java.io.BufferedReader; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import org.apache.log4j.Logger; -import org.matsim.core.utils.charts.XYScatterChart; -import org.matsim.core.utils.collections.Tuple; -import org.matsim.core.utils.io.IOUtils; -import playground.amit.utils.FileUtils; /** * A class to extract the currentBestDevisionVariable and currentBestObjectiveFunction. @@ -39,7 +41,7 @@ public class OpdytsConvergenceChart { - private static final Logger LOGGER = Logger.getLogger(OpdytsConvergenceChart.class); + private static final Logger LOGGER = LogManager.getLogger(OpdytsConvergenceChart.class); private final String rawVale = "Raw Objective Function Value"; private final String avgValue = "Averaged Objective Function Value"; diff --git a/src/main/java/playground/amit/pt/connectionScan/ConnectionScanRouter.java b/src/main/java/playground/amit/pt/connectionScan/ConnectionScanRouter.java index 767c13a3c..daf0e31ee 100644 --- a/src/main/java/playground/amit/pt/connectionScan/ConnectionScanRouter.java +++ b/src/main/java/playground/amit/pt/connectionScan/ConnectionScanRouter.java @@ -26,7 +26,6 @@ import org.matsim.core.router.RoutingRequest; import org.matsim.facilities.Facility; import org.matsim.pt.router.TransitRouter; -import org.matsim.utils.objectattributes.attributable.Attributes; /** * Created by amit on 16.05.17. @@ -34,6 +33,10 @@ public class ConnectionScanRouter implements TransitRouter { +// @Override +// public List calcRoute( Facility fromFacility, Facility toFacility, double departureTime, Person person) { +// return null; +// } @Override public List calcRoute(RoutingRequest routingRequest) { diff --git a/src/main/java/playground/amit/templates/ASCFromModalSplitCalibrator.java b/src/main/java/playground/amit/templates/ASCFromModalSplitCalibrator.java index ceac11bcc..070efb3cb 100644 --- a/src/main/java/playground/amit/templates/ASCFromModalSplitCalibrator.java +++ b/src/main/java/playground/amit/templates/ASCFromModalSplitCalibrator.java @@ -19,14 +19,9 @@ package playground.amit.templates; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map.Entry; -import java.util.SortedMap; -import java.util.TreeMap; import com.google.inject.Inject; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Scenario; import org.matsim.core.config.Config; import org.matsim.core.controler.events.IterationEndsEvent; @@ -35,8 +30,11 @@ import org.matsim.core.controler.listener.IterationEndsListener; import org.matsim.core.controler.listener.IterationStartsListener; import org.matsim.core.controler.listener.StartupListener; -import playground.vsp.analysis.modules.modalAnalyses.modalShare.ModalShareEventHandler; import playground.amit.utils.MapUtils; +import playground.vsp.analysis.modules.modalAnalyses.modalShare.ModalShareEventHandler; + +import java.util.*; +import java.util.Map.Entry; /** * This is just a template which needs to be updated before use. For e.g. run it @@ -46,7 +44,7 @@ public class ASCFromModalSplitCalibrator implements StartupListener, IterationStartsListener, IterationEndsListener { - private static final Logger LOG = Logger.getLogger(ASCFromModalSplitCalibrator.class); + private static final Logger LOG = LogManager.getLogger(ASCFromModalSplitCalibrator.class); private final SortedMap initialMode2share = new TreeMap<>(); // if empty, take from it.0 private SortedMap previousASC ; // all zeros diff --git a/src/main/java/playground/amit/templates/ManualRouteAssignerExample.java b/src/main/java/playground/amit/templates/ManualRouteAssignerExample.java index aca264f70..083c9cf04 100644 --- a/src/main/java/playground/amit/templates/ManualRouteAssignerExample.java +++ b/src/main/java/playground/amit/templates/ManualRouteAssignerExample.java @@ -19,21 +19,12 @@ package playground.amit.templates; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; -import org.matsim.api.core.v01.population.Activity; -import org.matsim.api.core.v01.population.Leg; -import org.matsim.api.core.v01.population.Person; -import org.matsim.api.core.v01.population.Plan; -import org.matsim.api.core.v01.population.PlanElement; +import org.matsim.api.core.v01.population.*; import org.matsim.core.population.algorithms.PersonPrepareForSim; import org.matsim.core.population.algorithms.PlanAlgorithm; import org.matsim.core.router.PlanRouter; @@ -42,12 +33,16 @@ import org.matsim.core.router.costcalculators.RandomizingTimeDistanceTravelDisutilityFactory; import org.matsim.core.router.util.TravelTime; import org.matsim.core.trafficmonitoring.FreeSpeedTravelTime; - import org.matsim.core.utils.timing.TimeInterpretation; import playground.amit.mixedTraffic.patnaIndia.router.FreeSpeedTravelTimeForBike; import playground.amit.mixedTraffic.patnaIndia.router.FreeSpeedTravelTimeForTruck; import playground.amit.utils.LoadMyScenarios; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + /** * Created by amit on 28/09/16. */ @@ -61,7 +56,7 @@ public class ManualRouteAssignerExample { private void reassignRoutes() { - Logger.getLogger(ManualRouteAssignerExample.class).info("Routes of all bike plans will be re-assinged."); + LogManager.getLogger(ManualRouteAssignerExample.class).info("Routes of all bike plans will be re-assinged."); // following is required to get the routes (or links) from base network and not from the running scenario network. Scenario scNetwork = LoadMyScenarios.loadScenarioFromNetwork(this.initialNetwork); @@ -79,8 +74,7 @@ private void reassignRoutes() { routerFactory.setTravelDisutility(new RandomizingTimeDistanceTravelDisutilityFactory(mode, scenario.getConfig()).createTravelDisutility(tt)); final TripRouter tripRouter = routerFactory.build(scNetwork).get(); - final TimeInterpretation timeInterpretation = TimeInterpretation.create(scNetwork.getConfig()); - PlanAlgorithm router = new PlanRouter(tripRouter, timeInterpretation); + PlanAlgorithm router = new PlanRouter(tripRouter, TimeInterpretation.create(this.scenario.getConfig())); PersonPrepareForSim pp4s = new PersonPrepareForSim(router, scNetwork); mode2routers.put(mode, pp4s); diff --git a/src/main/java/playground/amit/utils/AreaFilter.java b/src/main/java/playground/amit/utils/AreaFilter.java index 5b9f7dc2a..759270186 100644 --- a/src/main/java/playground/amit/utils/AreaFilter.java +++ b/src/main/java/playground/amit/utils/AreaFilter.java @@ -19,16 +19,15 @@ package playground.amit.utils; -import java.util.Collection; - -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; import org.locationtech.jts.geom.Geometry; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.network.Link; import org.matsim.core.utils.gis.ShapeFileReader; - import playground.amit.utils.geometry.GeometryUtils; +import java.util.Collection; + /** * @author amit */ @@ -50,7 +49,7 @@ public AreaFilter (final String shapeFile){ */ public AreaFilter (){ this.features = GeometryUtils.getSimplifiedGeometries( ShapeFileReader.getAllFeatures(MUNICH_SHAPE_FILE) ); - Logger.getLogger(AreaFilter.class).info("Reading Munich city area shape file..."); + LogManager.getLogger(AreaFilter.class).info("Reading Munich city area shape file..."); } public boolean isCellInsideShape(final Coord cellCentroid) { diff --git a/src/main/java/playground/amit/utils/FileUtils.java b/src/main/java/playground/amit/utils/FileUtils.java index f459c82b4..e81556ca8 100644 --- a/src/main/java/playground/amit/utils/FileUtils.java +++ b/src/main/java/playground/amit/utils/FileUtils.java @@ -19,11 +19,13 @@ package playground.amit.utils; -import java.io.File; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.core.utils.io.IOUtils; import playground.amit.mixedTraffic.patnaIndia.input.joint.JointCalibrationControler; +import java.io.File; + /** * I think, after introduction of URL and for uniformity, pass absolute path. * Because, relative paths are converted to new uri and then url using new File(" ").getAbsoluteFile() rather than @@ -35,7 +37,7 @@ public final class FileUtils { - public static final Logger LOGGER = Logger.getLogger(FileUtils.class); + public static final Logger LOGGER = LogManager.getLogger(FileUtils.class); public static final String RUNS_SVN = System.getProperty("user.name").equalsIgnoreCase("amit") ? "C:/Users/Amit Agarwal/Google Drive/iitr_gmail_drive/project_data/" : "../../runs-svn/"; public static final String SHARED_SVN = System.getProperty("user.name").equalsIgnoreCase("amit") ? "C:/Users/Amit Agarwal/Google Drive/iitr_gmail_drive/project_data/" : "../../shared-svn/"; @@ -51,7 +53,7 @@ public static void deleteIntermediateIterations(final String outputDir, final in for (int index =firstIteration+1; index divide(final List list1, final List l double e =0; if(list1.get(ii) == 0. && list2.get(ii)==0.) e = 0.; else if(list2.get(ii)==0.) { - Logger.getLogger(ListUtils.class).warn("Denominator is zero which should result in Inf but setting it zero. If you dont want that, modify the static method."); + LogManager.getLogger(ListUtils.class).warn("Denominator is zero which should result in Inf but setting it zero. If you dont want that, modify the static method."); e=0; } else e = list1.get(ii) / list2.get(ii); @@ -95,7 +96,7 @@ public static List subtract(final List list1, final List if(list1 == null || list2 == null ) throw new NullPointerException("Either of the lists is null. Aborting ..."); else if (list1.isEmpty() && list2.isEmpty() ) ; else if (list1.size() != list2.size()) { - Logger.getLogger(ListUtils.class).warn("Sizes of the lists are not equal. It will still subtract."); + LogManager.getLogger(ListUtils.class).warn("Sizes of the lists are not equal. It will still subtract."); if(list1.size() > list2.size()) { for(int ii = list2.size(); ii < list1.size(); ii++){ list2.set(ii, 0.); diff --git a/src/main/java/playground/amit/utils/LoadMyScenarios.java b/src/main/java/playground/amit/utils/LoadMyScenarios.java index 25369892f..69fbae4f5 100644 --- a/src/main/java/playground/amit/utils/LoadMyScenarios.java +++ b/src/main/java/playground/amit/utils/LoadMyScenarios.java @@ -18,14 +18,15 @@ * *********************************************************************** */ package playground.amit.utils; -import java.io.File; - -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Scenario; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigReader; import org.matsim.core.scenario.ScenarioUtils; +import java.io.File; + /** * return different scenarios used in almost every analysis code. * @author amit @@ -34,7 +35,7 @@ public final class LoadMyScenarios { private LoadMyScenarios(){} - private final static Logger LOG = Logger.getLogger(LoadMyScenarios.class); + private final static Logger LOG = LogManager.getLogger(LoadMyScenarios.class); /** * Returns scenario specified plans, network and config file. diff --git a/src/main/java/playground/amit/utils/RandomNumberUtils.java b/src/main/java/playground/amit/utils/RandomNumberUtils.java index bf4c24b5e..b73f2a027 100644 --- a/src/main/java/playground/amit/utils/RandomNumberUtils.java +++ b/src/main/java/playground/amit/utils/RandomNumberUtils.java @@ -19,18 +19,13 @@ package playground.amit.utils; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Map.Entry; -import java.util.Random; -import java.util.SortedMap; -import java.util.TreeMap; - -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.core.gbl.MatsimRandom; +import java.util.*; +import java.util.Map.Entry; + /** * A class to generate pseudo random numbers for given discrete probability distribution and * other distributions. @@ -45,7 +40,7 @@ public class RandomNumberUtils { private static final Random rnd = MatsimRandom.getRandom(); - private static final Logger LOG = Logger.getLogger(RandomNumberUtils.class); + private static final Logger LOG = LogManager.getLogger(RandomNumberUtils.class); private RandomNumberUtils(){} diff --git a/src/main/java/playground/amit/utils/VehicleUtils.java b/src/main/java/playground/amit/utils/VehicleUtils.java index 1041b6d8f..c288f3acf 100644 --- a/src/main/java/playground/amit/utils/VehicleUtils.java +++ b/src/main/java/playground/amit/utils/VehicleUtils.java @@ -19,7 +19,8 @@ package playground.amit.utils; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Scenario; import org.matsim.vehicles.MatsimVehicleReader; import org.matsim.vehicles.VehicleType; @@ -32,7 +33,7 @@ public final class VehicleUtils { - private static final Logger LOGGER = Logger.getLogger(VehicleUtils.class); + private static final Logger LOGGER = LogManager.getLogger(VehicleUtils.class); public static void addVehiclesToScenarioFromVehicleFile(final String vehiclesFile, final Scenario scenario){ Vehicles vehs = org.matsim.vehicles.VehicleUtils.createVehiclesContainer(); diff --git a/src/main/java/playground/amit/utils/plans/OutputPlansConsistencyCheck.java b/src/main/java/playground/amit/utils/plans/OutputPlansConsistencyCheck.java index 4e69e7b7a..e7a47927f 100644 --- a/src/main/java/playground/amit/utils/plans/OutputPlansConsistencyCheck.java +++ b/src/main/java/playground/amit/utils/plans/OutputPlansConsistencyCheck.java @@ -28,7 +28,8 @@ import java.util.Map; import java.util.SortedMap; import java.util.TreeMap; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.Activity; import org.matsim.api.core.v01.population.Leg; @@ -55,7 +56,7 @@ * @author amit */ public class OutputPlansConsistencyCheck { - private static final Logger LOG = Logger.getLogger(OutputPlansConsistencyCheck.class); + private static final Logger LOG = LogManager.getLogger(OutputPlansConsistencyCheck.class); private final Scenario sc; private final Map>> person2PlanIndex2ActivityTypes = new HashMap<>(); diff --git a/src/main/java/playground/amit/utils/plans/SelectedPlansFilter.java b/src/main/java/playground/amit/utils/plans/SelectedPlansFilter.java index c1a6ae537..abda9fae4 100644 --- a/src/main/java/playground/amit/utils/plans/SelectedPlansFilter.java +++ b/src/main/java/playground/amit/utils/plans/SelectedPlansFilter.java @@ -18,7 +18,8 @@ * *********************************************************************** */ package playground.amit.utils.plans; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.*; import org.matsim.core.config.ConfigUtils; @@ -33,7 +34,7 @@ */ public class SelectedPlansFilter { - private static final Logger LOG = Logger.getLogger(SelectedPlansFilter.class); + private static final Logger LOG = LogManager.getLogger(SelectedPlansFilter.class); private final static String RUN_DIR = FileUtils.SHARED_SVN+"/projects/detailedEval/matsim-input-files/"; private final static String INPUT_PLANS = RUN_DIR + "/population_1pct_v2_baseCaseOutputPlans.xml.gz"; diff --git a/src/main/java/playground/shivam/Dadar/evacuation/RunDadarEvacScenario.java b/src/main/java/playground/shivam/Dadar/evacuation/RunDadarEvacScenario.java index 25cfe842a..443671369 100644 --- a/src/main/java/playground/shivam/Dadar/evacuation/RunDadarEvacScenario.java +++ b/src/main/java/playground/shivam/Dadar/evacuation/RunDadarEvacScenario.java @@ -1,38 +1,54 @@ package playground.shivam.Dadar.evacuation; +import org.geotools.geometry.jts.JTS; +import org.geotools.referencing.CRS; import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.Point; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.api.core.v01.network.NetworkWriter; import org.matsim.api.core.v01.population.*; -import org.matsim.contrib.osm.networkReader.LinkProperties; -import org.matsim.contrib.osm.networkReader.OsmTags; import org.matsim.contrib.osm.networkReader.SupersonicOsmNetworkReader; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; +import org.matsim.core.config.ConfigWriter; import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; -import org.matsim.core.config.groups.PlansConfigGroup; +import org.matsim.core.config.groups.QSimConfigGroup; import org.matsim.core.config.groups.StrategyConfigGroup; -import org.matsim.core.controler.Controler; -import org.matsim.core.controler.OutputDirectoryHierarchy; +import org.matsim.core.controler.*; +import org.matsim.core.controler.events.IterationStartsEvent; +import org.matsim.core.controler.listener.ControlerListener; +import org.matsim.core.controler.listener.IterationStartsListener; import org.matsim.core.gbl.MatsimRandom; +import org.matsim.core.network.NetworkUtils; import org.matsim.core.network.algorithms.NetworkCleaner; import org.matsim.core.replanning.strategies.DefaultPlanStrategiesModule; +import org.matsim.core.router.DefaultRoutingModules; +import org.matsim.core.router.DijkstraFactory; +import org.matsim.core.router.TripRouter; +import org.matsim.core.router.costcalculators.OnlyTimeDependentTravelDisutility; import org.matsim.core.scenario.ScenarioUtils; -import org.matsim.core.utils.geometry.CoordinateTransformation; +import org.matsim.core.trafficmonitoring.FreeSpeedTravelTime; import org.matsim.core.utils.geometry.geotools.MGC; import org.matsim.core.utils.geometry.transformations.TransformationFactory; import org.matsim.core.utils.gis.ShapeFileReader; +import org.matsim.evacuationgui.scenariogenerator.EvacuationNetworkGenerator; +import org.matsim.facilities.FacilitiesUtils; +import org.matsim.utils.objectattributes.attributable.Attributes; import org.opengis.feature.simple.SimpleFeature; -import playground.amit.Dehradun.DehradunUtils; +import org.opengis.referencing.FactoryException; +import org.opengis.referencing.operation.TransformException; import playground.amit.Dehradun.OD; -import playground.amit.Dehradun.ODWriter; import playground.amit.jaipur.plans.ODMatrixGenerator; +import playground.amit.mixedTraffic.patnaIndia.utils.PatnaUtils; +import playground.amit.utils.LoadMyScenarios; import playground.amit.utils.geometry.GeometryUtils; +import playground.vsp.analysis.modules.modalAnalyses.modalTripTime.ModalTravelTimeControlerListener; +import playground.vsp.analysis.modules.modalAnalyses.modalTripTime.ModalTripTravelTimeHandler; import java.util.*; import java.util.function.BiPredicate; @@ -42,28 +58,156 @@ * @author Shivam */ public class RunDadarEvacScenario { - private static final String filesPath = "C:\\Users\\amit2\\Downloads\\evacDadar\\evacDadar\\"; - private static final String boundaryShapeFile = filesPath+"boundaryDadar.shp"; -// private static final String boundaryShapeFile = "input/evacDadar/boundaryDadar.shp"; - public static final String ORIGIN_ACTIVITY = "origin"; - public static final String DESTINATION_ACTIVITY = "destination"; + private static final String filesPath = "input/evacDadar/"; + private static final String boundaryShapeFileWGS84 = filesPath + "boundaryDadar.shp"; + private static final String zonesShapeFile = filesPath + "zonesDadar.shp"; + // private static final String boundaryShapeFile = "input/evacDadar/boundaryDadar.shp"; + private static final String ORIGIN_ACTIVITY = "origin"; + private static final String DESTINATION_ACTIVITY = "destination"; - public static final String outputMATSimNetworkFile = filesPath+"dadar-network_smaller.xml.gz"; - public static final String ODMatrixFile = filesPath+"dadar_od_10_10_22.csv"; - public static final String plansFile = filesPath+"dadar-plans.xml.gz"; + private static final String outputMATSimNetworkFile = filesPath + "dadar-network_smaller.xml.gz"; + private static final String outputEvacNetworkFile = filesPath + "dadar_evac_network.xml.gz"; + private static final String ODMatrixFile = filesPath + "dadar_od_10_10_22.csv"; - public static void main(String[] args) { - // getMATSimNetworkFromOSM(); -// getPlansFromOD(); + private static final String outputMATSimPlansFile = filesPath + "dadar-plans.xml.gz"; - Config config = ConfigUtils.createConfig(); - config.network().setInputFile(outputMATSimNetworkFile); - config.plans().setInputFile(plansFile); + private static final String outputEvacPlansFile = filesPath + "dadar_evac_plans.xml.gz"; + private Set dadarModes = EnumSet.allOf(DadarUtils.DadarTrafficCountMode2023.class).stream().map(DadarUtils.DadarTrafficCountMode2023::toString).collect(Collectors.toSet()); + + private Scenario scenario; + private static Geometry evacuationArea; + private final Id safeLinkId = Id.createLinkId("safeLink_Dadar"); + + public void run() { + createDadarNetworkFromOSM(); + scenario = LoadMyScenarios.loadScenarioFromNetwork(outputMATSimNetworkFile); + + createDadarEvacNetwork(scenario); + + createPlansFromDadarOD(); + + createDadarEvacPopulation(LoadMyScenarios.loadScenarioFromPlans(outputMATSimPlansFile)); + + createDadarEvacConfig(); + } + + private void createDadarEvacPopulation(Scenario scenarioPop) { + Population dadarPop = scenarioPop.getPopulation(); + PopulationFactory popFact = dadarPop.getFactory(); + + Population evacPop = this.scenario.getPopulation(); + + Person evacPerson; + for (Person person : dadarPop.getPersons().values()) { + PlanElement actPe = person.getSelectedPlan().getPlanElements().get(0); // first plan element is of activity + Activity homeExisting = (Activity) actPe; + Link link; + Coord actCoord = homeExisting.getCoord(); + + link = NetworkUtils.getNearestLink(scenario.getNetwork(), homeExisting.getCoord()); + Activity home = popFact.createActivityFromLinkId(homeExisting.getType(), link.getId()); + + //check if the person is in the area shape, if not leave them out + + if (actCoord != null && !evacuationArea.contains(MGC.coord2Point(actCoord))) + continue; + + // also exclude any home activity starting on link which is not included in evac network + if (!scenario.getNetwork().getLinks().containsKey(home.getLinkId())) + continue; + + evacPerson = popFact.createPerson(person.getId()); + Plan planOut = popFact.createPlan(); + evacPerson.addPlan(planOut); + + planOut.addActivity(home); + home.setEndTime(9 * 3600); + + PlanElement legPe = person.getSelectedPlan().getPlanElements().get(1); + Leg leg = popFact.createLeg(((Leg) legPe).getMode()); + planOut.addLeg(leg); + + Activity evacAct = popFact.createActivityFromLinkId("evac", safeLinkId); + planOut.addActivity(evacAct); + + if (dadarModes.contains(leg.getMode())) { + TripRouter.Builder builder = new TripRouter.Builder(scenario.getConfig()); + builder.setRoutingModule( + leg.getMode(), + DefaultRoutingModules.createPureNetworkRouter( + leg.getMode(), + popFact, + scenario.getNetwork(), + new DijkstraFactory().createPathCalculator(scenario.getNetwork(), + new OnlyTimeDependentTravelDisutility(new FreeSpeedTravelTime()), + new FreeSpeedTravelTime()) + ) + ); + List routeInfo = builder.build().calcRoute( + leg.getMode(), + FacilitiesUtils.toFacility(home, null), + FacilitiesUtils.toFacility(evacAct, null), + home.getEndTime().seconds(), + evacPerson, + new Attributes()); + + Route route = ((Leg) routeInfo.get(0)).getRoute(); + route.setStartLinkId(home.getLinkId()); + route.setEndLinkId(evacAct.getLinkId()); + + leg.setRoute(route); + leg.setTravelTime(((Leg) routeInfo.get(0)).getTravelTime().seconds()); + } + else + continue; + evacPop.addPerson(evacPerson); + } + new PopulationWriter(evacPop).write(outputEvacPlansFile); + } + + private void createDadarEvacNetwork(Scenario scenario) { + // TODO: right now we are testing the whole network as evac zone + Geometry transformEvacuationArea = (Geometry) ShapeFileReader.getAllFeatures(boundaryShapeFileWGS84).iterator().next().getDefaultGeometry();// --> EPSG:7767 + + try { + evacuationArea = JTS.transform(transformEvacuationArea, CRS.findMathTransform(MGC.getCRS(TransformationFactory.WGS84), MGC.getCRS(DadarUtils.Dadar_EPSG), true)); + } catch (TransformException | FactoryException e) { + throw new RuntimeException("Transformation isn't successful" + e); + } + + EvacuationNetworkGenerator net = new EvacuationNetworkGenerator(scenario, evacuationArea, safeLinkId); + net.run(); + + for (Link l : scenario.getNetwork().getLinks().values()) { + Set allowedModes = new HashSet<>(dadarModes); + l.setAllowedModes(allowedModes); + } + + new NetworkWriter(scenario.getNetwork()).write(outputEvacNetworkFile); + } + + private void createDadarEvacConfig() { + Config config = scenario.getConfig(); + config.network().setInputFile(outputEvacNetworkFile); + config.plans().setInputFile(outputEvacPlansFile); config.controler().setLastIteration(10); - config.controler().setOutputDirectory(filesPath+"output"); + config.controler().setOutputDirectory(filesPath + "output"); config.controler().setDumpDataAtEnd(true); config.controler().setCreateGraphs(true); config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); + config.vspExperimental().setWritingOutputEvents(true); + + // config.global().setCoordinateSystem(DadarUtils.Dadar_EPSG); + + // TODO: testing with half flow + config.qsim().setStorageCapFactor(0.5); + config.qsim().setFlowCapFactor(0.5); + + config.qsim().setSnapshotPeriod(5 * 60); + config.qsim().setEndTime(30 * 3600); + config.qsim().setLinkDynamics(QSimConfigGroup.LinkDynamics.PassingQ); + config.qsim().setMainModes(dadarModes); + config.qsim().setTrafficDynamics(QSimConfigGroup.TrafficDynamics.withHoles); //TODO we are using 0.5 just to see some congestion. config.qsim().setFlowCapFactor(0.5); @@ -80,7 +224,12 @@ public static void main(String[] args) { destinationAct.setScoringThisActivityAtAll(false); pcg.addActivityParams(destinationAct); + PlanCalcScoreConfigGroup.ActivityParams evacAct = new PlanCalcScoreConfigGroup.ActivityParams("evac"); + evacAct.setTypicalDuration(3600); + config.planCalcScore().addActivityParams(evacAct); + StrategyConfigGroup scg = config.strategy(); + StrategyConfigGroup.StrategySettings reRoute = new StrategyConfigGroup.StrategySettings(); reRoute.setStrategyName(DefaultPlanStrategiesModule.DefaultStrategy.ReRoute); reRoute.setWeight(0.2); @@ -91,21 +240,63 @@ public static void main(String[] args) { tam.setWeight(0.1); scg.addStrategySettings(tam); +// StrategyConfigGroup.StrategySettings ceb = new StrategyConfigGroup.StrategySettings(); +// ceb.setStrategyName(DefaultPlanStrategiesModule.DefaultSelector.ChangeExpBeta); +// scg.addStrategySettings(ceb); + +// StrategyConfigGroup.StrategySettings modeChoice = new StrategyConfigGroup.StrategySettings(); +// tam.setStrategyName(DefaultPlanStrategiesModule.DefaultStrategy.ChangeSingleTripMode); +// tam.setWeight(0.1); +// scg.addStrategySettings(tam); + + config.strategy().setFractionOfIterationsToDisableInnovation(0.75); + Scenario scenario = ScenarioUtils.loadScenario(config); - //clean the network - new NetworkCleaner().run(scenario.getNetwork()); + + new ConfigWriter(config).write(filesPath + "config.xml"); Controler controler = new Controler(scenario); + + + controler.addOverridingModule(new AbstractModule() { + @Override + public void install() { + + addTravelTimeBinding("bike").to(networkTravelTime()); + addTravelDisutilityFactoryBinding("bike").to(carTravelDisutilityFactoryKey()); + + addTravelTimeBinding("motorbike").to(networkTravelTime()); + addTravelDisutilityFactoryBinding("motorbike").to(carTravelDisutilityFactoryKey()); + + addControlerListenerBinding().toInstance(new IterationStartsListener() { + @Override + public void notifyIterationStarts(IterationStartsEvent event) { + if (event.getIteration() == 8) { + System.out.println(event.getIteration()); + } + } + }); + } + }); + + controler.addOverridingModule(new AbstractModule() { // ploting modal share over iterations + @Override + public void install() { + this.bind(ModalTripTravelTimeHandler.class); + this.addControlerListenerBinding().to(ModalTravelTimeControlerListener.class); + } + }); controler.run(); } - private static void getPlansFromOD() { -// String ODMatrixFile = "input/evacDadar/dadar_od_10_10_22.csv"; - + public static void main(String[] args) { + new RunDadarEvacScenario().run(); + } + private void createPlansFromDadarOD() { Map, OD> remaining_OD = ODMatrixGenerator.generateOD(ODMatrixFile); - Collection features = ShapeFileReader.getAllFeatures(boundaryShapeFile); + Collection zones = ShapeFileReader.getAllFeatures(zonesShapeFile); Config config = ConfigUtils.createConfig(); Scenario scenario = ScenarioUtils.loadScenario(config); @@ -117,20 +308,20 @@ private static void getPlansFromOD() { String destinationID = od.getDestination(); double numberOfTrips = od.getNumberOfTrips(); - if (numberOfTrips ==0 ) continue; + if (numberOfTrips == 0) continue; - SimpleFeature origin_feature = null; - SimpleFeature destination_feature = null; + SimpleFeature origin_zone = null; + SimpleFeature destination_zone = null; - for (SimpleFeature feature : features) { + for (SimpleFeature zone : zones) { String zone_key = "name"; - String zoneID = String.valueOf(feature.getAttribute(zone_key)); - if (origin_feature == null && zoneID.equals(originID)) origin_feature = feature; - else if (destination_feature == null && zoneID.equals(destinationID)) destination_feature = feature; + String zoneID = String.valueOf(zone.getAttribute(zone_key)); + if (origin_zone == null && zoneID.equals(originID)) origin_zone = zone; + else if (destination_zone == null && zoneID.equals(destinationID)) destination_zone = zone; } - if (origin_feature == null || destination_feature == null) { - System.out.println("Either of the origin zone " + originID + " or destination zone "+destinationID+" is null."); + if (origin_zone == null || destination_zone == null) { + System.out.println("Either of the origin zone " + originID + " or destination zone " + destinationID + " is null."); continue; } @@ -138,8 +329,8 @@ private static void getPlansFromOD() { // create matsim plans --> origin coord, destination coord, time, mode, - Point originPoint = GeometryUtils.getRandomPointInsideFeature(origin_feature); - Point destinationPoint = GeometryUtils.getRandomPointInsideFeature(destination_feature); + Point originPoint = GeometryUtils.getRandomPointInsideFeature(origin_zone); + Point destinationPoint = GeometryUtils.getRandomPointInsideFeature(destination_zone); Coord origin = DadarUtils.transformation.transform(MGC.point2Coord(originPoint)); Coord destination = DadarUtils.transformation.transform(MGC.point2Coord(destinationPoint)); @@ -163,26 +354,24 @@ private static void getPlansFromOD() { } } - new PopulationWriter(population).write(plansFile); - + new PopulationWriter(population).write(outputMATSimPlansFile); } - private static void getMATSimNetworkFromOSM() { - Set modes = EnumSet.allOf(DadarUtils.DadarTrafficCountMode2023.class).stream().map(DadarUtils.DadarTrafficCountMode2023::toString).collect(Collectors.toSet()); - - - String inputOSMFile = filesPath+"dadar.osm.pbf"; - - - Collection features = ShapeFileReader.getAllFeatures(boundaryShapeFile); + /** + * Creates a Network from OSM + * + * @return path of MATSIm network + */ + private void createDadarNetworkFromOSM() { + String inputOSMFile = filesPath + "dadar.osm.pbf"; - Geometry geometry = (Geometry) features.iterator().next().getDefaultGeometry(); // --> WGS:84 + Geometry wholeGeometry = (Geometry) ShapeFileReader.getAllFeatures(boundaryShapeFileWGS84).iterator().next().getDefaultGeometry(); // --> WGS:84 BiPredicate includeLinkAtCoordWithHierarchy = (cord, hierarchyLevel) -> { if (hierarchyLevel <= 4) return true; //keep all roads upto level 4. else - return (hierarchyLevel <= 5 && geometry.contains(MGC.coord2Point(DadarUtils.transformation.transform(cord)))); + return (hierarchyLevel <= 5 && wholeGeometry.contains(MGC.coord2Point(DadarUtils.transformation.transform(cord)))); }; Network network = (new SupersonicOsmNetworkReader.Builder()) @@ -199,11 +388,12 @@ private static void getMATSimNetworkFromOSM() { // .addOverridingLinkProperties(OsmTags.TERTIARY_LINK, new LinkProperties(LinkProperties.LEVEL_TERTIARY, 2, 4, 600, false)) .setIncludeLinkAtCoordWithHierarchy(includeLinkAtCoordWithHierarchy) .setAfterLinkCreated((link, osmTags, isReversed) -> { - link.setAllowedModes(modes); + link.setAllowedModes(dadarModes); }) .build() .read(inputOSMFile); + new NetworkCleaner().run(network); new NetworkWriter(network).write(outputMATSimNetworkFile); } } diff --git a/src/main/java/playground/shivam/signals/RunAdaptiveSignalSimpleNetwork.java b/src/main/java/playground/shivam/signals/RunAdaptiveSignalSimpleNetwork.java new file mode 100644 index 000000000..dad69e706 --- /dev/null +++ b/src/main/java/playground/shivam/signals/RunAdaptiveSignalSimpleNetwork.java @@ -0,0 +1,425 @@ +package playground.shivam.signals; + +import org.matsim.api.core.v01.Coord; +import org.matsim.api.core.v01.Id; +import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.network.Link; +import org.matsim.api.core.v01.network.Network; +import org.matsim.api.core.v01.network.NetworkFactory; +import org.matsim.api.core.v01.population.Activity; +import org.matsim.api.core.v01.population.Person; +import org.matsim.api.core.v01.population.Plan; +import org.matsim.api.core.v01.population.Population; +import org.matsim.contrib.signals.SignalSystemsConfigGroup; +import org.matsim.contrib.signals.analysis.MixedTrafficDelayAnalysisTool; +import org.matsim.contrib.signals.analysis.MixedTrafficSignalAnalysisTool; +import org.matsim.contrib.signals.builder.MixedTrafficSignals; +import org.matsim.contrib.signals.controller.laemmerFix.LaemmerConfigGroup; +import org.matsim.contrib.signals.controller.laemmerFix.MixedTrafficLaemmerSignalController; +import org.matsim.contrib.signals.data.SignalsData; +import org.matsim.contrib.signals.data.SignalsDataLoader; +import org.matsim.contrib.signals.data.signalcontrol.v20.SignalControlData; +import org.matsim.contrib.signals.data.signalcontrol.v20.SignalControlDataFactory; +import org.matsim.contrib.signals.data.signalcontrol.v20.SignalControlDataFactoryImpl; +import org.matsim.contrib.signals.data.signalgroups.v20.SignalGroupData; +import org.matsim.contrib.signals.data.signalgroups.v20.SignalGroupsData; +import org.matsim.contrib.signals.data.signalsystems.v20.*; +import org.matsim.contrib.signals.model.Signal; +import org.matsim.contrib.signals.model.SignalGroup; +import org.matsim.contrib.signals.model.SignalSystem; +import org.matsim.core.config.Config; +import org.matsim.core.config.ConfigUtils; +import org.matsim.core.config.groups.ChangeModeConfigGroup; +import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.QSimConfigGroup; +import org.matsim.core.config.groups.StrategyConfigGroup; +import org.matsim.core.controler.AbstractModule; +import org.matsim.core.controler.Controler; +import org.matsim.core.controler.OutputDirectoryHierarchy; +import org.matsim.core.gbl.MatsimRandom; +import org.matsim.core.replanning.strategies.DefaultPlanStrategiesModule; +import org.matsim.core.scenario.ScenarioUtils; +import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; +import org.matsim.vehicles.Vehicles; +import org.matsim.vis.otfvis.OTFVisConfigGroup; +import playground.amit.mixedTraffic.MixedTrafficVehiclesUtils; + +import java.io.BufferedWriter; +import java.io.FileWriter; +import java.io.IOException; +import java.util.*; + +public class RunAdaptiveSignalSimpleNetwork { + private final Controler controler; + static String outputDirectory = "output/RunAdaptiveSignalSimpleNetwork/"; + public RunAdaptiveSignalSimpleNetwork() { + final Config config = defineConfig(); + final Scenario scenario = defineScenario(config); + controler = new Controler(scenario); + + /* the signals extensions works for planbased, sylvia and laemmer signal controller + * by default and is pluggable for your own signal controller like this: */ + (new MixedTrafficSignals.Configurator(this.controler)).addSignalControllerFactory(MixedTrafficLaemmerSignalController.IDENTIFIER, + MixedTrafficLaemmerSignalController.LaemmerFactory.class); + } + + public static void main(String[] args) { + new RunAdaptiveSignalSimpleNetwork().run(); + } + + private static void createNetwork(Scenario scenario) { + Network net = scenario.getNetwork(); + NetworkFactory fac = net.getFactory(); + + net.addNode(fac.createNode(Id.createNodeId(1), new Coord(-2000, 0))); + net.addNode(fac.createNode(Id.createNodeId(2), new Coord(-1000, 0))); + net.addNode(fac.createNode(Id.createNodeId(3), new Coord(0, 0))); + net.addNode(fac.createNode(Id.createNodeId(4), new Coord(1000, 0))); + net.addNode(fac.createNode(Id.createNodeId(5), new Coord(2000, 0))); + net.addNode(fac.createNode(Id.createNodeId(6), new Coord(0, 2000))); + net.addNode(fac.createNode(Id.createNodeId(7), new Coord(0, 1000))); + net.addNode(fac.createNode(Id.createNodeId(8), new Coord(0, -1000))); + net.addNode(fac.createNode(Id.createNodeId(9), new Coord(0, -2000))); + + String[] links = {"1_2", "2_1", "2_3", "3_2", "3_4", "4_3", "4_5", "5_4", + "6_7", "7_6", "7_3", "3_7", "3_8", "8_3", "8_9", "9_8"}; + + for (String linkId : links) { + String fromNodeId = linkId.split("_")[0]; + String toNodeId = linkId.split("_")[1]; + Link link = fac.createLink(Id.createLinkId(linkId), + net.getNodes().get(Id.createNodeId(fromNodeId)), + net.getNodes().get(Id.createNodeId(toNodeId))); + link.setAllowedModes(Set.of("car", "truck")); + link.setCapacity(7200); + link.setLength(1000); + link.setFreespeed(10); + net.addLink(link); + } + } + + private static void createPopulation(Scenario scenario) { + Population population = scenario.getPopulation(); + + String[] odRelations = {"1_2-4_5", "4_5-2_1", "6_7-8_9", "9_8-7_6"}; + + for (String od : odRelations) { + String fromLinkId = od.split("-")[0]; + String toLinkId = od.split("-")[1]; + + for (int i = 0; i < 1800; i++) { + // create a person + Person person = population.getFactory().createPerson(Id.createPersonId(od + "-" + i)); + population.addPerson(person); + + // create a plan for the person that contains all this + // information + Plan plan = population.getFactory().createPlan(); + person.addPlan(plan); + + // create a start activity at the from link + Activity homeAct = population.getFactory().createActivityFromLinkId("dummy", Id.createLinkId(fromLinkId)); + // distribute agents uniformly during one hour. + homeAct.setEndTime(i); + plan.addActivity(homeAct); + + // create a dummy leg + plan.addLeg(population.getFactory().createLeg(getTravelMode(MatsimRandom.getLocalInstance().nextInt(100)))); + + // create a work activity at the to link + Activity workAct = population.getFactory().createActivityFromLinkId("dummy", Id.createLinkId(toLinkId)); + plan.addActivity(workAct); + } + } + } + + private static String getTravelMode(int number) { + if (number < 60) return "car"; + else return "truck"; + } + + public void run() { +// controler.addOverridingModule(new OTFVisWithSignalsLiveModule()); + SignalsData signalsData = (SignalsData) controler.getScenario().getScenarioElement(SignalsData.ELEMENT_NAME); + List> signalSystemIds = new ArrayList<>(signalsData.getSignalGroupsData().getSignalGroupDataBySignalSystemId().keySet()); + List> signalIds = new ArrayList<>(); + List signalData = new ArrayList<>(); + + List> signalGroupIds = new ArrayList<>(); + Map, Id> linkId2signalId = new HashMap<>(); + Map, Id> signalId2signalGroupId = new HashMap<>(); + Map, Id> linkId2signalGroupId = new HashMap<>(); + + MixedTrafficSignalAnalysisTool signalAnalyzer = new MixedTrafficSignalAnalysisTool(); + controler.addOverridingModule(new AbstractModule() { + @Override + public void install() { + this.addEventHandlerBinding().toInstance(signalAnalyzer); + this.addControlerListenerBinding().toInstance(signalAnalyzer); + } + }); + // add general analysis tools + MixedTrafficDelayAnalysisTool delayAnalysis = new MixedTrafficDelayAnalysisTool(controler.getScenario().getNetwork(), controler.getScenario().getVehicles()); + controler.addOverridingModule(new AbstractModule() { + @Override + public void install() { + this.addEventHandlerBinding().toInstance(delayAnalysis); + } + }); + + controler.run(); + for (var signalSystemId : signalSystemIds) { + Map, SignalGroupData> signalGroupDataBySystemId = signalsData.getSignalGroupsData().getSignalGroupDataBySystemId(signalSystemId); + signalGroupDataBySystemId.values().forEach(signalGroupData -> signalIds.addAll(new ArrayList<>(signalGroupData.getSignalIds()))); + signalGroupIds.addAll(signalsData.getSignalGroupsData().getSignalGroupDataBySignalSystemId().get(signalSystemId).keySet()); + signalsData.getSignalSystemsData().getSignalSystemData().values().forEach(signalSystemData -> signalData.addAll(signalSystemData.getSignalData().values())); + signalGroupDataBySystemId.values().forEach(signalGroupData -> signalGroupData.getSignalIds().forEach(signalId -> signalId2signalGroupId.put(signalId, signalGroupData.getId()))); + } + signalData.forEach(signalD -> linkId2signalId.put(signalD.getLinkId(), signalD.getId())); + linkId2signalId.forEach((linkId, signalId) -> linkId2signalGroupId.put(linkId, signalId2signalGroupId.get(signalId))); + + + Map, Double>> greenTimePerCycle = signalAnalyzer.getSummedBygoneSignalGreenTimesPerCycle(); + Map, Double>> delayPerCycle = delayAnalysis.getSummedBygoneDelayPerCycle(); + Map, Map, Double>>> flowPerCycle = delayAnalysis.getSummedBygoneFlowPerLinkPerVehicleTypePerCycle(); + + writeResult(outputDirectory + "greenTimesPerCycle.csv", List.of(new String[]{"cycle_time", "signal_group", "link_ids", "green_time"}), false); + + for (var outerEntry : greenTimePerCycle.entrySet()) { + for (var innerEntry : outerEntry.getValue().entrySet()) { + List> linkIds = new ArrayList<>(); + StringBuilder stringBuilder = new StringBuilder(); + for (var linkSignalGroupId : linkId2signalGroupId.entrySet()) { + if (linkSignalGroupId.getValue().equals(innerEntry.getKey())) + linkIds.add(linkSignalGroupId.getKey()); + } + for (var linkId: linkIds) + stringBuilder.append(linkId).append("|"); + writeResult(outputDirectory + "greenTimesPerCycle.csv", List.of(new String[]{outerEntry.getKey().toString(), innerEntry.getKey().toString(), stringBuilder.substring(0, stringBuilder.length() - 1), String.valueOf(innerEntry.getValue())}), true); + } + } + + writeResult(outputDirectory + "delayPerCycle.csv", List.of(new String[]{"cycle_time", "link_id", "delay"}), false); + + for (var outerEntry : delayPerCycle.entrySet()) { + for (var innerEntry : outerEntry.getValue().entrySet()) { + writeResult(outputDirectory + "delayPerCycle.csv", List.of(new String[]{outerEntry.getKey().toString(), innerEntry.getKey().toString(), String.valueOf(innerEntry.getValue())}), true); + } + } + + List flowColumns = new ArrayList(); + flowColumns.add("cycle_time"); + List> linkIdList = new ArrayList<>(controler.getScenario().getNetwork().getLinks().keySet()); + Collections.sort(linkIdList); + for (var linkId: linkIdList) { + for (var vehicleType: controler.getScenario().getVehicles().getVehicleTypes().keySet()) { + String linkIdWithVehicleType = linkId.toString() + "_" + vehicleType.toString(); + flowColumns.add(linkIdWithVehicleType); + } + } + writeResult(outputDirectory + "flowPerCycle.csv", flowColumns, false); + Map, Double> emptyFlow = new HashMap<>(); + // filling non-present linkIds + for (var vehicleType: controler.getScenario().getVehicles().getVehicleTypes().keySet()) { + emptyFlow.putIfAbsent(vehicleType, 0.0); + } + + for (var linkId: controler.getScenario().getNetwork().getLinks().keySet()) { + for (var outerEntry : flowPerCycle.entrySet()) { + flowPerCycle.get(outerEntry.getKey()).putIfAbsent(linkId, emptyFlow); + } + } + for (var outerEntry : flowPerCycle.entrySet()) { + List linkIdWithFlowValues = new ArrayList<>(); + linkIdWithFlowValues.add(outerEntry.getKey().toString()); + for (var innerEntry : outerEntry.getValue().entrySet()) { + for (var innerInnerEntry: innerEntry.getValue().entrySet()) { + linkIdWithFlowValues.add(innerInnerEntry.getValue().toString()); + } + } + writeResult(outputDirectory + "flowPerCycle.csv", linkIdWithFlowValues, true); + } + } + + private static Scenario defineScenario(Config config) { + Scenario scenario = ScenarioUtils.loadScenario(config); + // add missing scenario elements + SignalSystemsConfigGroup signalsConfigGroup = ConfigUtils.addOrGetModule(config, SignalSystemsConfigGroup.GROUP_NAME, SignalSystemsConfigGroup.class); + signalsConfigGroup.setUseSignalSystems(true); + scenario.addScenarioElement(SignalsData.ELEMENT_NAME, new SignalsDataLoader(config).loadSignalsData()); + + createNetwork(scenario); + createPopulation(scenario); + createSignals(scenario); + Vehicles vehicles = scenario.getVehicles(); + + List mainModes = Arrays.asList("car", "truck"); + for (String mode : mainModes) { + VehicleType veh = VehicleUtils.createVehicleType(Id.create(mode, VehicleType.class)); + veh.setPcuEquivalents(MixedTrafficVehiclesUtils.getPCU(mode)); + veh.setMaximumVelocity(MixedTrafficVehiclesUtils.getSpeed(mode)); + veh.setLength(MixedTrafficVehiclesUtils.getLength(mode)); + veh.setLength(MixedTrafficVehiclesUtils.getStuckTime(mode)); + veh.setNetworkMode(mode); + vehicles.addVehicleType(veh); + } + return scenario; + } + + private static Config defineConfig() { + Config config = ConfigUtils.createConfig(); + + config.controler().setOutputDirectory(outputDirectory); + + config.controler().setLastIteration(10); + config.travelTimeCalculator().setMaxTime(18000); + config.qsim().setStartTime(0.0D); + config.qsim().setEndTime(18000.0D); + config.qsim().setSnapshotStyle(QSimConfigGroup.SnapshotStyle.withHoles); + config.qsim().setUsingFastCapacityUpdate(false); + config.qsim().setLinkDynamics(QSimConfigGroup.LinkDynamics.PassingQ); + config.qsim().setVehiclesSource(QSimConfigGroup.VehiclesSource.modeVehicleTypesFromVehiclesData); + + PlanCalcScoreConfigGroup.ActivityParams dummyAct = new PlanCalcScoreConfigGroup.ActivityParams("dummy"); + dummyAct.setTypicalDuration(12 * 3600); + config.planCalcScore().addActivityParams(dummyAct); + { + StrategyConfigGroup.StrategySettings strat = new StrategyConfigGroup.StrategySettings(); + strat.setStrategyName(DefaultPlanStrategiesModule.DefaultSelector.ChangeExpBeta); + strat.setWeight(0.0); + strat.setDisableAfter(config.controler().getLastIteration()); + config.strategy().addStrategySettings(strat); + } + // from Jaipur controller + PlanCalcScoreConfigGroup.ModeParams car = new PlanCalcScoreConfigGroup.ModeParams("car"); + car.setMarginalUtilityOfTraveling(-6.0); + car.setConstant(-0.5); + config.planCalcScore().addModeParams(car); + + PlanCalcScoreConfigGroup.ModeParams truck = new PlanCalcScoreConfigGroup.ModeParams("truck"); // using default for them. + truck.setConstant(-1.0); + truck.setMarginalUtilityOfTraveling(-7.0); + config.planCalcScore().addModeParams(truck); + + QSimConfigGroup qsim = config.qsim(); + List mainModes = Arrays.asList("car", "truck"); + qsim.setMainModes(mainModes); + + ChangeModeConfigGroup changeTripMode = config.changeMode(); + changeTripMode.setModes(new String[]{"car", "truck"}); + config.plansCalcRoute().setNetworkModes(mainModes); + + + OTFVisConfigGroup otfvisConfig = ConfigUtils.addOrGetModule(config, OTFVisConfigGroup.class); + otfvisConfig.setDrawTime(true); + + LaemmerConfigGroup laemmerConfigGroup = ConfigUtils.addOrGetModule(config, LaemmerConfigGroup.GROUP_NAME, LaemmerConfigGroup.class); + laemmerConfigGroup.setDesiredCycleTime(90); + laemmerConfigGroup.setMinGreenTime(5); + laemmerConfigGroup.setActiveRegime(LaemmerConfigGroup.Regime.COMBINED); + config.getModules().put(LaemmerConfigGroup.GROUP_NAME, laemmerConfigGroup); + + config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); + config.controler().setWriteEventsInterval(config.controler().getLastIteration()); + config.controler().setWritePlansInterval(config.controler().getLastIteration()); + config.vspExperimental().setWritingOutputEvents(true); + config.planCalcScore().setWriteExperiencedPlans(true); + + return config; + } + + + public static void writeResult(String filename, List values, boolean append) { + FileWriter csvwriter; + BufferedWriter bufferedWriter = null; + try { + csvwriter = new FileWriter(filename, append); + bufferedWriter = new BufferedWriter(csvwriter); + StringJoiner stringJoiner = new StringJoiner(","); + for (var value: values) { + stringJoiner.add(value); + } + bufferedWriter.write(stringJoiner.toString()); + bufferedWriter.newLine(); + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + assert bufferedWriter != null; + bufferedWriter.flush(); + } catch (IOException e) { + e.printStackTrace(); + } + try { + bufferedWriter.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + private static void createSignals(Scenario scenario) { + SignalsData signalsData = (SignalsData) scenario.getScenarioElement(SignalsData.ELEMENT_NAME); + SignalSystemsData signalSystems = signalsData.getSignalSystemsData(); + + SignalSystemsDataFactory sysFac = new SignalSystemsDataFactoryImpl(); + + SignalGroupsData signalGroups = signalsData.getSignalGroupsData(); + + SignalControlData signalControl = signalsData.getSignalControlData(); + + SignalControlDataFactory conFac = new SignalControlDataFactoryImpl(); + + // create signal system + Id signalSystemId = Id.create("SignalSystem1", SignalSystem.class); + SignalSystemData signalSystem = sysFac.createSignalSystemData(signalSystemId); + signalSystems.addSignalSystemData(signalSystem); + + // create a signal for every inLink + for (Id inLinkId : scenario.getNetwork().getNodes().get(Id.createNodeId(3)).getInLinks().keySet()) { + SignalData signal = sysFac.createSignalData(Id.create("Signal" + inLinkId, Signal.class)); + signalSystem.addSignalData(signal); + signal.setLinkId(inLinkId); + } + + // group signals with non conflicting streams + Id signalGroupId2_3 = Id.create("SignalGroup2_3", SignalGroup.class); + SignalGroupData signalGroup2_3 = signalGroups.getFactory() + .createSignalGroupData(signalSystemId, signalGroupId2_3); + signalGroup2_3.addSignalId(Id.create("Signal2_3", Signal.class)); + signalGroups.addSignalGroupData(signalGroup2_3); + + Id signalGroupId4_3 = Id.create("SignalGroup4_3", SignalGroup.class); + SignalGroupData signalGroup4_3 = signalGroups.getFactory() + .createSignalGroupData(signalSystemId, signalGroupId4_3); + signalGroup4_3.addSignalId(Id.create("Signal4_3", Signal.class)); + signalGroups.addSignalGroupData(signalGroup4_3); + + Id signalGroupId7_3 = Id.create("SignalGroup7_3", SignalGroup.class); + SignalGroupData signalGroup7_3 = signalGroups.getFactory() + .createSignalGroupData(signalSystemId, signalGroupId7_3); + signalGroup7_3.addSignalId(Id.create("Signal7_3", Signal.class)); + signalGroups.addSignalGroupData(signalGroup7_3); + + Id signalGroupId8_3 = Id.create("SignalGroup8_3", SignalGroup.class); + SignalGroupData signalGroup8_3 = signalGroups.getFactory() + .createSignalGroupData(signalSystemId, signalGroupId8_3); + signalGroup8_3.addSignalId(Id.create("Signal8_3", Signal.class)); + signalGroups.addSignalGroupData(signalGroup8_3); + + // create the signal control + SignalSystemControllerData signalSystemControl = conFac.createSignalSystemControllerData(signalSystemId); + signalSystemControl.setControllerIdentifier(MixedTrafficLaemmerSignalController.IDENTIFIER); + signalControl.addSignalSystemControllerData(signalSystemControl); + + // create a plan for the signal system (with defined cycle time and offset 0) +// SignalPlanData signalPlan = SignalUtils.createSignalPlan(conFac, 60, 0, Id.create("SignalPlan1", SignalPlan.class)); +// signalSystemControl.addSignalPlanData(signalPlan); +// +// // specify signal group settings for both signal groups +// signalPlan.addSignalGroupSettings(SignalUtils.createSetting4SignalGroup(conFac, signalGroupId1, 0, 5)); +// signalPlan.addSignalGroupSettings(SignalUtils.createSetting4SignalGroup(conFac, signalGroupId2, 10, 55)); +// signalPlan.setOffset(0); + } +} diff --git a/src/main/java/playground/shivam/signals/RunFixedMixedTrafficSignalSimpleIntersection.java b/src/main/java/playground/shivam/signals/RunFixedMixedTrafficSignalSimpleIntersection.java new file mode 100644 index 000000000..f4d13693e --- /dev/null +++ b/src/main/java/playground/shivam/signals/RunFixedMixedTrafficSignalSimpleIntersection.java @@ -0,0 +1,534 @@ +package playground.shivam.signals; + +import org.matsim.api.core.v01.Coord; +import org.matsim.api.core.v01.Id; +import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.events.PersonStuckEvent; +import org.matsim.api.core.v01.events.handler.PersonStuckEventHandler; +import org.matsim.api.core.v01.network.Link; +import org.matsim.api.core.v01.network.Network; +import org.matsim.api.core.v01.network.NetworkFactory; +import org.matsim.api.core.v01.network.NetworkWriter; +import org.matsim.api.core.v01.population.*; +import org.matsim.contrib.otfvis.OTFVis; +import org.matsim.contrib.signals.SignalSystemsConfigGroup; +import org.matsim.contrib.signals.builder.Signals; +import org.matsim.contrib.signals.controller.fixedTime.DefaultPlanbasedSignalSystemController; +import org.matsim.contrib.signals.data.SignalsData; +import org.matsim.contrib.signals.data.SignalsScenarioWriter; +import org.matsim.contrib.signals.data.signalcontrol.v20.SignalControlData; +import org.matsim.contrib.signals.data.signalcontrol.v20.SignalControlDataFactory; +import org.matsim.contrib.signals.data.signalcontrol.v20.SignalPlanData; +import org.matsim.contrib.signals.data.signalgroups.v20.SignalGroupsData; +import org.matsim.contrib.signals.data.signalsystems.v20.SignalSystemControllerData; +import org.matsim.contrib.signals.data.signalsystems.v20.SignalSystemData; +import org.matsim.contrib.signals.data.signalsystems.v20.SignalSystemsData; +import org.matsim.contrib.signals.data.signalsystems.v20.SignalSystemsDataFactory; +import org.matsim.contrib.signals.model.Signal; +import org.matsim.contrib.signals.model.SignalGroup; +import org.matsim.contrib.signals.model.SignalSystem; +import org.matsim.contrib.signals.otfvis.OTFVisWithSignalsLiveModule; +import org.matsim.contrib.signals.utils.SignalUtils; +import org.matsim.core.api.experimental.events.EventsManager; +import org.matsim.core.config.Config; +import org.matsim.core.config.ConfigUtils; +import org.matsim.core.config.ConfigWriter; +import org.matsim.core.config.groups.ChangeModeConfigGroup; +import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.QSimConfigGroup; +import org.matsim.core.config.groups.StrategyConfigGroup; +import org.matsim.core.controler.Controler; +import org.matsim.core.controler.OutputDirectoryHierarchy; +import org.matsim.core.controler.PrepareForSimUtils; +import org.matsim.core.events.EventsUtils; +import org.matsim.core.gbl.MatsimRandom; +import org.matsim.core.mobsim.qsim.QSim; +import org.matsim.core.mobsim.qsim.QSimBuilder; +import org.matsim.core.replanning.strategies.DefaultPlanStrategiesModule; +import org.matsim.core.scenario.ScenarioUtils; +import org.matsim.lanes.*; +import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; +import org.matsim.vehicles.Vehicles; +import org.matsim.vis.otfvis.OTFClientLive; +import org.matsim.vis.otfvis.OTFVisConfigGroup; +import org.matsim.vis.otfvis.OnTheFlyServer; +import playground.amit.mixedTraffic.MixedTrafficVehiclesUtils; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.*; + +public class RunFixedMixedTrafficSignalSimpleIntersection { + private Controler controler; + static String outputDirectory = "output/RunFixedMixedTrafficSignalSimpleIntersection/"; + + private static final double LANE_LENGTH = 500; + private static final int LANE_CAPACITY = 1000; + private static final int NO_LANES = 1; + private static final double LINK_LENGTH = 1000; + + private static final int LINK_CAPACITY = 1000; + private int CYCLE = 120; + private final int ONSET = 0; + private final int DROPPING = 60; + + private final int AGENTS_PER_LEFT_APPROACH = 200; + // seconds + private final int OFFSET_LEFT_APPROACH = 60; + private final int DROPPING_LEFT_APPROACH = 80; + private final int AGENTS_PER_TOP_APPROACH = 800; + private final int OFFSET_TOP_APPROACH = 20; + private final int DROPPING_TOP_APPROACH = 100; + private final int AGENTS_PER_RIGHT_APPROACH = 400; + private final int OFFSET_RIGHT_APPROACH = 60; + private final int DROPPING_RIGHT_APPROACH = 100; + private final int AGENTS_PER_BOTTOM_APPROACH = 600; + private final int OFFSET_BOTTOM_APPROACH = 10; + private final int DROPPING_BOTTOM_APPROACH = 70; + + public RunFixedMixedTrafficSignalSimpleIntersection() throws IOException { + final Config config = defineConfig(); + final Scenario scenario = defineScenario(config); + + controler = new Controler(scenario); + + Signals.configure(controler); + + } + + public static void main(String[] args) throws IOException { + RunFixedMixedTrafficSignalSimpleIntersection fixedMixedTrafficSignalSimpleIntersection = new RunFixedMixedTrafficSignalSimpleIntersection(); + fixedMixedTrafficSignalSimpleIntersection.run(false); + } + + private void run(boolean startOtfvis) { + + EventsManager manager = EventsUtils.createEventsManager(); + + PrepareForSimUtils.createDefaultPrepareForSim(controler.getScenario()).run(); + QSim qSim = new QSimBuilder(controler.getScenario().getConfig()).useDefaults().build(controler.getScenario(), manager); + + if (startOtfvis) { + + // otfvis configuration. There is more you can do here than via file! +// final OTFVisConfigGroup otfVisConfig = ConfigUtils.addOrGetModule(qSim.getScenario().getConfig(), OTFVisConfigGroup.GROUP_NAME, OTFVisConfigGroup.class); +// otfVisConfig.setDrawTransitFacilities(false) ; // this DOES work +// otfVisConfig.setColoringScheme(OTFVisConfigGroup.ColoringScheme.byId); +// +// OnTheFlyServer server = OTFVis.startServerAndRegisterWithQSim(controler.getScenario().getConfig(), controler.getScenario(), manager, qSim); +// OTFClientLive.run(controler.getScenario().getConfig(), server); + + // add the module that start the otfvis visualization with signals + controler.addOverridingModule(new OTFVisWithSignalsLiveModule()); + } + //qSim.run(); + controler.run(); + } + + private Scenario defineScenario(Config config) { + Scenario scenario = ScenarioUtils.loadScenario(config); + // add missing scenario elements + SignalSystemsConfigGroup signalSystemsConfigGroup = ConfigUtils.addOrGetModule(config, SignalSystemsConfigGroup.GROUP_NAME, SignalSystemsConfigGroup.class); + signalSystemsConfigGroup.setUseSignalSystems(true); + SignalsData signalsData = SignalUtils.createSignalsData(signalSystemsConfigGroup); + scenario.addScenarioElement(SignalsData.ELEMENT_NAME, signalsData); +// scenario.addScenarioElement(SignalsData.ELEMENT_NAME, new SignalsDataLoader(config).loadSignalsData()); + + this.createNetwork(scenario); + this.createPopulation(scenario); + Vehicles vehicles = scenario.getVehicles(); + + List mainModes = Arrays.asList("car", "truck"); + for (String mode : mainModes) { + VehicleType veh = VehicleUtils.createVehicleType(Id.create(mode, VehicleType.class)); + veh.setPcuEquivalents(MixedTrafficVehiclesUtils.getPCU(mode)); + veh.setMaximumVelocity(MixedTrafficVehiclesUtils.getSpeed(mode)); + veh.setLength(MixedTrafficVehiclesUtils.getLength(mode)); + veh.setLength(MixedTrafficVehiclesUtils.getStuckTime(mode)); + veh.setNetworkMode(mode); + vehicles.addVehicleType(veh); + } + // create lanes for the scenario + this.createLanes(scenario); + + /* fill the SignalsData object with information: + * signal systems - specify signalized intersections + * signal groups - specify signals that always have the same signal control + * signal control - specify cycle time, onset and dropping time, offset... for all signal groups */ + this.createGroupsAndSystem(signalsData.getSignalSystemsData(), signalsData.getSignalGroupsData()); + this.createSystemControl(signalsData.getSignalControlData(), Id.create("3", SignalSystem.class), + ONSET, DROPPING); + + // set output files + scenario.getConfig().network().setLaneDefinitionsFile(outputDirectory + "lane_definitions_v2.0.xml"); + signalSystemsConfigGroup.setSignalSystemFile(outputDirectory + "signal_systems.xml"); + signalSystemsConfigGroup.setSignalGroupsFile(outputDirectory + "signal_groups.xml"); + signalSystemsConfigGroup.setSignalControlFile(outputDirectory + "signal_control.xml"); + + // write lanes to file + LanesWriter writerDelegate = new LanesWriter(scenario.getLanes()); + writerDelegate.write(config.network().getLaneDefinitionsFile()); + + // write signal information to file + SignalsScenarioWriter signalsWriter = new SignalsScenarioWriter(); + signalsWriter.setSignalSystemsOutputFilename(signalSystemsConfigGroup.getSignalSystemFile()); + signalsWriter.setSignalGroupsOutputFilename(signalSystemsConfigGroup.getSignalGroupsFile()); + signalsWriter.setSignalControlOutputFilename(signalSystemsConfigGroup.getSignalControlFile()); + signalsWriter.writeSignalsData(scenario); + + return scenario; + } + + private void createSystemControl(SignalControlData control, Id signalSystemId, + int onset, int dropping) { + SignalControlDataFactory fac = control.getFactory(); + + // create and add signal control for the given system id + SignalSystemControllerData controller = fac.createSignalSystemControllerData(signalSystemId); + control.addSignalSystemControllerData(controller); + controller.setControllerIdentifier(DefaultPlanbasedSignalSystemController.IDENTIFIER); + + // create and add signal plan with defined cycle time and offset 0 + SignalPlanData plan = SignalUtils.createSignalPlan(fac, CYCLE, 0); + controller.addSignalPlanData(plan); + + // create and add control settings for signal groups + plan.addSignalGroupSettings(SignalUtils.createSetting4SignalGroup(fac, + Id.create("1", SignalGroup.class), OFFSET_LEFT_APPROACH, DROPPING_LEFT_APPROACH)); + plan.addSignalGroupSettings(SignalUtils.createSetting4SignalGroup(fac, + Id.create("2", SignalGroup.class), OFFSET_LEFT_APPROACH, DROPPING_LEFT_APPROACH)); + plan.addSignalGroupSettings(SignalUtils.createSetting4SignalGroup(fac, + Id.create("3", SignalGroup.class), OFFSET_LEFT_APPROACH, DROPPING_LEFT_APPROACH)); + plan.addSignalGroupSettings(SignalUtils.createSetting4SignalGroup(fac, + Id.create("4", SignalGroup.class), OFFSET_TOP_APPROACH, DROPPING_TOP_APPROACH)); + plan.addSignalGroupSettings(SignalUtils.createSetting4SignalGroup(fac, + Id.create("5", SignalGroup.class), OFFSET_TOP_APPROACH, DROPPING_TOP_APPROACH)); + plan.addSignalGroupSettings(SignalUtils.createSetting4SignalGroup(fac, + Id.create("6", SignalGroup.class), OFFSET_TOP_APPROACH, DROPPING_TOP_APPROACH)); + plan.addSignalGroupSettings(SignalUtils.createSetting4SignalGroup(fac, + Id.create("7", SignalGroup.class), OFFSET_RIGHT_APPROACH, DROPPING_RIGHT_APPROACH)); + plan.addSignalGroupSettings(SignalUtils.createSetting4SignalGroup(fac, + Id.create("8", SignalGroup.class), OFFSET_RIGHT_APPROACH, DROPPING_RIGHT_APPROACH)); + plan.addSignalGroupSettings(SignalUtils.createSetting4SignalGroup(fac, + Id.create("9", SignalGroup.class), OFFSET_RIGHT_APPROACH, DROPPING_RIGHT_APPROACH)); + plan.addSignalGroupSettings(SignalUtils.createSetting4SignalGroup(fac, + Id.create("10", SignalGroup.class), OFFSET_BOTTOM_APPROACH, DROPPING_BOTTOM_APPROACH)); + plan.addSignalGroupSettings(SignalUtils.createSetting4SignalGroup(fac, + Id.create("11", SignalGroup.class), OFFSET_BOTTOM_APPROACH, DROPPING_BOTTOM_APPROACH)); + plan.addSignalGroupSettings(SignalUtils.createSetting4SignalGroup(fac, + Id.create("12", SignalGroup.class), OFFSET_BOTTOM_APPROACH, DROPPING_BOTTOM_APPROACH)); + } + + + private void createPopulation(Scenario scenario) { + Population population = scenario.getPopulation(); + + String[] odRelations = {"1_2-7_6-L", "1_2-4_5-L", "1_2-8_9-L", "6_7-4_5-T", "6_7-8_9-T", "6_7-2_1-T", + "5_4-8_9-R", "5_4-2_1-R", "5_4-7_6-R", "9_8-2_1-B", "9_8-7_6-B", "9_8-4_5-B",}; + + + for (String od : odRelations) { + String fromLinkId = od.split("-")[0]; + String toLinkId = od.split("-")[1]; + + String approach = od.split("-")[2]; + int agentsPerApproach; + int offset; + + if (approach.equalsIgnoreCase("L")) { + agentsPerApproach = AGENTS_PER_LEFT_APPROACH; + offset = OFFSET_LEFT_APPROACH; + } + else if (approach.equalsIgnoreCase("T")) { + agentsPerApproach = AGENTS_PER_TOP_APPROACH; + offset = OFFSET_TOP_APPROACH; + } + else if (approach.equalsIgnoreCase("R")) { + agentsPerApproach = AGENTS_PER_RIGHT_APPROACH; + offset = OFFSET_RIGHT_APPROACH; + } + else { + agentsPerApproach = AGENTS_PER_BOTTOM_APPROACH; + offset = OFFSET_BOTTOM_APPROACH; + } + for (int i = 0; i < agentsPerApproach; i++) { + // create a person + Person person = population.getFactory().createPerson(Id.createPersonId(od + "-" + i)); + + // create a plan for the person that contains all this + // information + Plan plan = population.getFactory().createPlan(); + + // create a start activity at the from link + Activity homeAct = population.getFactory().createActivityFromLinkId("dummy", Id.createLinkId(fromLinkId)); + // distribute agents uniformly during one hour. + homeAct.setEndTime(i + offset); + plan.addActivity(homeAct); + + // create a dummy leg + plan.addLeg(population.getFactory().createLeg(getTravelMode(MatsimRandom.getLocalInstance().nextInt(100)))); + + // create a work activity at the to link + Activity workAct = population.getFactory().createActivityFromLinkId("dummy", Id.createLinkId(toLinkId)); + plan.addActivity(workAct); + + person.addPlan(plan); + population.addPerson(person); + } + } + new PopulationWriter(population).write(outputDirectory + "population.xml.gz"); + } + + private static String getTravelMode(int number) { + if (number <= 60) return "car"; + else return "truck"; + } + + private Config defineConfig() throws IOException { + Config config = ConfigUtils.createConfig(); + + // create the path to the output directory if it does not exist yet + Files.createDirectories(Paths.get(outputDirectory)); + + config.controler().setOutputDirectory(outputDirectory); + config.controler().setLastIteration(50); + + config.travelTimeCalculator().setMaxTime(5 * 60 * 60); + + config.qsim().setStartTime(0); + config.qsim().setEndTime(5 * 60 * 60); + config.qsim().setSnapshotStyle(QSimConfigGroup.SnapshotStyle.withHoles); + config.qsim().setTrafficDynamics(QSimConfigGroup.TrafficDynamics.withHoles); + config.qsim().setNodeOffset(20.0); + config.qsim().setUsingFastCapacityUpdate(false); + config.qsim().setLinkDynamics(QSimConfigGroup.LinkDynamics.PassingQ); + config.qsim().setVehiclesSource(QSimConfigGroup.VehiclesSource.modeVehicleTypesFromVehiclesData); + + config.qsim().setUseLanes(true); + + PlanCalcScoreConfigGroup.ActivityParams dummyAct = new PlanCalcScoreConfigGroup.ActivityParams("dummy"); + dummyAct.setTypicalDuration(12 * 3600); + config.planCalcScore().addActivityParams(dummyAct); + { + StrategyConfigGroup.StrategySettings strat = new StrategyConfigGroup.StrategySettings(); + strat.setStrategyName(DefaultPlanStrategiesModule.DefaultSelector.ChangeExpBeta); + strat.setWeight(0.0); + strat.setDisableAfter(config.controler().getLastIteration()); + config.strategy().addStrategySettings(strat); + } + // from Jaipur controller + PlanCalcScoreConfigGroup.ModeParams car = new PlanCalcScoreConfigGroup.ModeParams("car"); + car.setMarginalUtilityOfTraveling(-6.0); + car.setConstant(-0.5); + config.planCalcScore().addModeParams(car); + + PlanCalcScoreConfigGroup.ModeParams truck = new PlanCalcScoreConfigGroup.ModeParams("truck"); // using default for them. + truck.setConstant(-1.0); + truck.setMarginalUtilityOfTraveling(-7.0); + config.planCalcScore().addModeParams(truck); + + QSimConfigGroup qsim = config.qsim(); + List mainModes = Arrays.asList("car", "truck"); + qsim.setMainModes(mainModes); + + ChangeModeConfigGroup changeTripMode = config.changeMode(); + changeTripMode.setModes(new String[]{"car", "truck"}); + config.plansCalcRoute().setNetworkModes(mainModes); + + + config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); + config.controler().setWriteEventsInterval(config.controler().getLastIteration()); + config.controler().setWritePlansInterval(config.controler().getLastIteration()); + + config.vspExperimental().setWritingOutputEvents(true); + config.planCalcScore().setWriteExperiencedPlans(true); + + //write config to file + String configFile = outputDirectory + "config.xml"; + ConfigWriter configWriter = new ConfigWriter(config); + configWriter.write(configFile); + + + return config; + } + + private void createGroupsAndSystem(SignalSystemsData signalSystemsData, SignalGroupsData signalGroupsData) { + SignalSystemData sys = signalSystemsData.getFactory().createSignalSystemData(Id.create("3", SignalSystem.class)); + signalSystemsData.addSignalSystemData(sys); + SignalSystemsDataFactory factory = signalSystemsData.getFactory(); + + SignalUtils.createAndAddSignal(sys, factory, Id.create("1", Signal.class), Id.createLinkId("2_3"), + Arrays.asList(Id.create("2_3.l", Lane.class))); + SignalUtils.createAndAddSignal(sys, factory, Id.create("2", Signal.class), Id.createLinkId("2_3"), + Arrays.asList(Id.create("2_3.s", Lane.class))); + SignalUtils.createAndAddSignal(sys, factory, Id.create("3", Signal.class), Id.createLinkId("2_3"), + Arrays.asList(Id.create("2_3.r", Lane.class))); + + SignalUtils.createAndAddSignal(sys, factory, Id.create("4", Signal.class), Id.createLinkId("7_3"), + Arrays.asList(Id.create("7_3.l", Lane.class))); + SignalUtils.createAndAddSignal(sys, factory, Id.create("5", Signal.class), Id.createLinkId("7_3"), + Arrays.asList(Id.create("7_3.s", Lane.class))); + SignalUtils.createAndAddSignal(sys, factory, Id.create("6", Signal.class), Id.createLinkId("7_3"), + Arrays.asList(Id.create("7_3.r", Lane.class))); + + SignalUtils.createAndAddSignal(sys, factory, Id.create("7", Signal.class), Id.createLinkId("4_3"), + Arrays.asList(Id.create("4_3.l", Lane.class))); + SignalUtils.createAndAddSignal(sys, factory, Id.create("8", Signal.class), Id.createLinkId("4_3"), + Arrays.asList(Id.create("4_3.s", Lane.class))); + SignalUtils.createAndAddSignal(sys, factory, Id.create("9", Signal.class), Id.createLinkId("4_3"), + Arrays.asList(Id.create("4_3.r", Lane.class))); + + SignalUtils.createAndAddSignal(sys, factory, Id.create("10", Signal.class), Id.createLinkId("8_3"), + Arrays.asList(Id.create("8_3.l", Lane.class))); + SignalUtils.createAndAddSignal(sys, factory, Id.create("11", Signal.class), Id.createLinkId("8_3"), + Arrays.asList(Id.create("8_3.s", Lane.class))); + SignalUtils.createAndAddSignal(sys, factory, Id.create("12", Signal.class), Id.createLinkId("8_3"), + Arrays.asList(Id.create("8_3.r", Lane.class))); + + // create a signal group for every signal + SignalUtils.createAndAddSignalGroups4Signals(signalGroupsData, sys); + } + + private void createLanes(Scenario scenario) { + Lanes lanes = scenario.getLanes(); + LanesFactory factory = lanes.getFactory(); + + // create lanes for link 2_3 + LanesToLinkAssignment lanesForLink23 = factory + .createLanesToLinkAssignment(Id.createLinkId("2_3")); + lanes.addLanesToLinkAssignment(lanesForLink23); + + // original lane, i.e. lane that starts at the link from node and leads to all other lanes of the link + LanesUtils.createAndAddLane(lanesForLink23, factory, + Id.create("2_3.ol", Lane.class), LANE_CAPACITY, LINK_LENGTH, 0, NO_LANES, + null, Arrays.asList(Id.create("2_3.l", Lane.class), Id.create("2_3.s", Lane.class), Id.create("2_3.r", Lane.class))); + + // left turning lane (alignment 1) + LanesUtils.createAndAddLane(lanesForLink23, factory, + Id.create("2_3.l", Lane.class), LANE_CAPACITY, LANE_LENGTH, 1, NO_LANES, + Collections.singletonList(Id.create("3_7", Link.class)), null); + + // straight lane (alignment 1) + LanesUtils.createAndAddLane(lanesForLink23, factory, + Id.create("2_3.s", Lane.class), LANE_CAPACITY, LANE_LENGTH, 0, NO_LANES, + Collections.singletonList(Id.create("3_4", Link.class)), null); + + // right turning lane (alignment -1) + LanesUtils.createAndAddLane(lanesForLink23, factory, + Id.create("2_3.r", Lane.class), LANE_CAPACITY, LANE_LENGTH, -1, NO_LANES, + Collections.singletonList(Id.create("3_8", Link.class)), null); + + + // create lanes for link 7_3 + LanesToLinkAssignment lanesForLink73 = factory + .createLanesToLinkAssignment(Id.createLinkId("7_3")); + lanes.addLanesToLinkAssignment(lanesForLink73); + + // original lane, i.e. lane that starts at the link from node and leads to all other lanes of the link + LanesUtils.createAndAddLane(lanesForLink73, factory, + Id.create("7_3.ol", Lane.class), LANE_CAPACITY, LINK_LENGTH, 0, NO_LANES, + null, Arrays.asList(Id.create("7_3.l", Lane.class), Id.create("7_3.s", Lane.class), Id.create("7_3.r", Lane.class))); + + // left turning lane (alignment 1) + LanesUtils.createAndAddLane(lanesForLink73, factory, + Id.create("7_3.l", Lane.class), LANE_CAPACITY, LANE_LENGTH, 1, NO_LANES, + Collections.singletonList(Id.create("3_4", Link.class)), null); + + // straight lane (alignment 0) + LanesUtils.createAndAddLane(lanesForLink73, factory, + Id.create("7_3.s", Lane.class), LANE_CAPACITY, LANE_LENGTH, 0, NO_LANES, + Collections.singletonList(Id.create("3_8", Link.class)), null); + + // right turning lane (alignment -1) + LanesUtils.createAndAddLane(lanesForLink73, factory, + Id.create("7_3.r", Lane.class), LANE_CAPACITY, LANE_LENGTH, -1, NO_LANES, + Collections.singletonList(Id.create("3_2", Link.class)), null); + + + // create lanes for link 4_3 + LanesToLinkAssignment lanesForLink43 = factory + .createLanesToLinkAssignment(Id.createLinkId("4_3")); + lanes.addLanesToLinkAssignment(lanesForLink43); + + // original lane, i.e. lane that starts at the link from node and leads to all other lanes of the link + LanesUtils.createAndAddLane(lanesForLink43, factory, + Id.create("4_3.ol", Lane.class), LANE_CAPACITY, LINK_LENGTH, 0, NO_LANES, + null, Arrays.asList(Id.create("4_3.l", Lane.class), Id.create("4_3.s", Lane.class), Id.create("4_3.r", Lane.class))); + + // left turning lane (alignment 1) + LanesUtils.createAndAddLane(lanesForLink43, factory, + Id.create("4_3.l", Lane.class), LANE_CAPACITY, LANE_LENGTH, 1, NO_LANES, + Collections.singletonList(Id.create("3_8", Link.class)), null); + + // straight lane (alignment 1) + LanesUtils.createAndAddLane(lanesForLink43, factory, + Id.create("4_3.s", Lane.class), LANE_CAPACITY, LANE_LENGTH, 0, NO_LANES, + Collections.singletonList(Id.create("3_2", Link.class)), null); + + // right turning lane (alignment -1) + LanesUtils.createAndAddLane(lanesForLink43, factory, + Id.create("4_3.r", Lane.class), LANE_CAPACITY, LANE_LENGTH, -1, NO_LANES, + Collections.singletonList(Id.create("3_7", Link.class)), null); + + + // create lanes for link 8_3 + LanesToLinkAssignment lanesForLink83 = factory + .createLanesToLinkAssignment(Id.createLinkId("8_3")); + lanes.addLanesToLinkAssignment(lanesForLink83); + + // original lane, i.e. lane that starts at the link from node and leads to all other lanes of the link + LanesUtils.createAndAddLane(lanesForLink83, factory, + Id.create("8_3.ol", Lane.class), LANE_CAPACITY, LINK_LENGTH, 0, NO_LANES, + null, Arrays.asList(Id.create("8_3.l", Lane.class), Id.create("8_3.s", Lane.class), Id.create("8_3.r", Lane.class))); + + // left turning lane (alignment 1) + LanesUtils.createAndAddLane(lanesForLink83, factory, + Id.create("8_3.l", Lane.class), LANE_CAPACITY, LANE_LENGTH, 1, NO_LANES, + Collections.singletonList(Id.create("3_2", Link.class)), null); + + // straight lane (alignment 1) + LanesUtils.createAndAddLane(lanesForLink83, factory, + Id.create("8_3.s", Lane.class), LANE_CAPACITY, LANE_LENGTH, 0, NO_LANES, + Collections.singletonList(Id.create("3_7", Link.class)), null); + + // right turning lane (alignment -1) + LanesUtils.createAndAddLane(lanesForLink83, factory, + Id.create("8_3.r", Lane.class), LANE_CAPACITY, LANE_LENGTH, -1, NO_LANES, + Collections.singletonList(Id.create("3_4", Link.class)), null); + } + + private void createNetwork(Scenario scenario) { + Network net = scenario.getNetwork(); + NetworkFactory fac = net.getFactory(); + + net.addNode(fac.createNode(Id.createNodeId(1), new Coord(-2000, 0))); + net.addNode(fac.createNode(Id.createNodeId(2), new Coord(-1000, 0))); + net.addNode(fac.createNode(Id.createNodeId(3), new Coord(0, 0))); + net.addNode(fac.createNode(Id.createNodeId(4), new Coord(1000, 0))); + net.addNode(fac.createNode(Id.createNodeId(5), new Coord(2000, 0))); + net.addNode(fac.createNode(Id.createNodeId(6), new Coord(0, 2000))); + net.addNode(fac.createNode(Id.createNodeId(7), new Coord(0, 1000))); + net.addNode(fac.createNode(Id.createNodeId(8), new Coord(0, -1000))); + net.addNode(fac.createNode(Id.createNodeId(9), new Coord(0, -2000))); + + String[] links = {"1_2", "2_1", "2_3", "3_2", "3_4", "4_3", "4_5", "5_4", + "6_7", "7_6", "7_3", "3_7", "3_8", "8_3", "8_9", "9_8"}; + + for (String linkId : links) { + String fromNodeId = linkId.split("_")[0]; + String toNodeId = linkId.split("_")[1]; + Link link = fac.createLink(Id.createLinkId(linkId), + net.getNodes().get(Id.createNodeId(fromNodeId)), + net.getNodes().get(Id.createNodeId(toNodeId))); + link.setAllowedModes(Set.of("car", "truck")); + + link.setCapacity(LINK_CAPACITY); + link.setLength(LINK_LENGTH); + link.setFreespeed(10); + net.addLink(link); + } + new NetworkWriter(net).write(outputDirectory + "network.xml.gz"); + } +} diff --git a/src/main/java/playground/shivam/trafficChar/core/TrafficCharConfigGroup.java b/src/main/java/playground/shivam/trafficChar/core/TrafficCharConfigGroup.java index 90fbab569..f04412063 100644 --- a/src/main/java/playground/shivam/trafficChar/core/TrafficCharConfigGroup.java +++ b/src/main/java/playground/shivam/trafficChar/core/TrafficCharConfigGroup.java @@ -19,7 +19,8 @@ package playground.shivam.trafficChar.core; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.core.config.Config; import org.matsim.core.config.ReflectiveConfigGroup; import org.matsim.core.config.groups.QSimConfigGroup; @@ -35,7 +36,7 @@ public static TrafficCharConfigGroup get(Config config) { return (TrafficCharConfigGroup) config.getModules().get(TrafficCharConfigGroup.GROUP_NAME); } - private static final Logger log = Logger.getLogger(TrafficCharConfigGroup.class); + private static final Logger log = LogManager.getLogger(TrafficCharConfigGroup.class); public static final String GROUP_NAME = "trafficChar"; public static final String ROAD_TYPE = "roadType"; diff --git a/src/test/java/playground/amit/ModeChoiceWithMultipleSubpopulationIT.java b/src/test/java/playground/amit/ModeChoiceWithMultipleSubpopulationIT.java index 3ae88687d..a5067e06e 100644 --- a/src/test/java/playground/amit/ModeChoiceWithMultipleSubpopulationIT.java +++ b/src/test/java/playground/amit/ModeChoiceWithMultipleSubpopulationIT.java @@ -135,13 +135,13 @@ public void install() { final String[] availableModes = {"car", "motorbike"}; @Inject Scenario sc; @Inject Provider tripRouterProvider ; - @Inject TimeInterpretation timeInterpretation; + @Override public PlanStrategy get() { final PlanStrategyImpl.Builder builder = new PlanStrategyImpl.Builder(new RandomPlanSelector<>()); builder.addStrategyModule(new TripsToLegsModule(tripRouterProvider, sc.getConfig().global())); builder.addStrategyModule(new ChangeLegMode(sc.getConfig().global().getNumberOfThreads(), availableModes, true, false)); - builder.addStrategyModule(new ReRoute(sc, tripRouterProvider, timeInterpretation)); + builder.addStrategyModule(new ReRoute(sc, tripRouterProvider, TimeInterpretation.create(this.sc.getConfig()))); return builder.build(); } }); diff --git a/src/test/java/playground/amit/emissions/exposure/ExposurePricingIT.java b/src/test/java/playground/amit/emissions/exposure/ExposurePricingIT.java index 9d1d3ffc6..9cd77b9e6 100644 --- a/src/test/java/playground/amit/emissions/exposure/ExposurePricingIT.java +++ b/src/test/java/playground/amit/emissions/exposure/ExposurePricingIT.java @@ -25,7 +25,8 @@ import java.util.Collection; import java.util.List; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.junit.Assert; import org.junit.Ignore; import org.junit.Rule; @@ -70,7 +71,7 @@ */ @RunWith(Parameterized.class) public class ExposurePricingIT { - private Logger logger = Logger.getLogger(ExposurePricingIT.class); + private Logger logger = LogManager.getLogger(ExposurePricingIT.class); private Double xMin = 0.0; diff --git a/src/test/java/playground/amit/emissions/flatEmissions/EquilMixedTrafficEmissionIT.java b/src/test/java/playground/amit/emissions/flatEmissions/EquilMixedTrafficEmissionIT.java index 189233293..c3d32048f 100644 --- a/src/test/java/playground/amit/emissions/flatEmissions/EquilMixedTrafficEmissionIT.java +++ b/src/test/java/playground/amit/emissions/flatEmissions/EquilMixedTrafficEmissionIT.java @@ -20,7 +20,8 @@ package playground.amit.emissions.flatEmissions; import com.google.inject.name.Names; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.junit.Assert; import org.junit.Ignore; import org.junit.Rule; @@ -76,7 +77,7 @@ public class EquilMixedTrafficEmissionIT { @Rule public final MatsimTestUtils helper = new MatsimTestUtils(); - private static final Logger logger = Logger.getLogger(EquilMixedTrafficEmissionIT.class); + private static final Logger logger = LogManager.getLogger(EquilMixedTrafficEmissionIT.class); private final String classOutputDir = "test/output/" + EquilMixedTrafficEmissionIT.class.getCanonicalName().replace('.', '/') + "/"; diff --git a/src/test/java/playground/amit/emissions/onRoadExposure/OnRoadExposureForMixedTrafficTest.java b/src/test/java/playground/amit/emissions/onRoadExposure/OnRoadExposureForMixedTrafficTest.java index c4fb80124..454b98152 100644 --- a/src/test/java/playground/amit/emissions/onRoadExposure/OnRoadExposureForMixedTrafficTest.java +++ b/src/test/java/playground/amit/emissions/onRoadExposure/OnRoadExposureForMixedTrafficTest.java @@ -19,7 +19,8 @@ package playground.amit.emissions.onRoadExposure; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.junit.Assert; import org.junit.Ignore; import org.junit.Rule; @@ -61,7 +62,7 @@ public class OnRoadExposureForMixedTrafficTest { @Rule public final MatsimTestUtils helper = new MatsimTestUtils(); - private static final Logger logger = Logger.getLogger(OnRoadExposureForMixedTrafficTest.class); + private static final Logger logger = LogManager.getLogger(OnRoadExposureForMixedTrafficTest.class); private final boolean isConsideringCO2Costs = false; // no local exposure for co2 diff --git a/src/test/java/playground/amit/opdyts/ModeChoiceObjectiveFunctionTest.java b/src/test/java/playground/amit/opdyts/ModeChoiceObjectiveFunctionTest.java index ff400ecc6..c10b037af 100644 --- a/src/test/java/playground/amit/opdyts/ModeChoiceObjectiveFunctionTest.java +++ b/src/test/java/playground/amit/opdyts/ModeChoiceObjectiveFunctionTest.java @@ -6,7 +6,6 @@ //import java.util.TreeMap; //import floetteroed.opdyts.ObjectiveFunction; //import floetteroed.opdyts.SimulatorState; -//import org.apache.log4j.Logger; //import org.junit.Rule; //import org.junit.Test; //import org.matsim.api.core.v01.Coord; @@ -35,7 +34,7 @@ //import org.matsim.testcases.MatsimTestUtils; // //public class ModeChoiceObjectiveFunctionTest { -// private static final Logger log = Logger.getLogger(ModeChoiceObjectiveFunctionTest.class ) ; +// private static final Logger log = LogManager.getLogger(ModeChoiceObjectiveFunctionTest.class ) ; // // @Rule // public final MatsimTestUtils helper = new MatsimTestUtils();