Tools/Routes
The tools' names accord to their function.
Contents
randomDepart.py
By using this script we can increase the throughput (in terms of input vehicle volume accommodated by SUMO network in fixed time interval). By using this script you can calibrate different traffic parameter based on the real traffic pattern (exponential distribution is closed to real pattern).
"randomDepart" is a python script which takes input as a route file and generates the modified route file with depart times based on an exponential distribution. Each invocation generates a new traffic pattern.
How to Use: Go to the command prompt (supportable for python2X)
For assistance:
./randomDepart.py -h
or
./randomDepart.py --help
For using:
./randomDepart.py -r <route-xml-file> [-d] [-o <output-xml-file>]
or
./randomDepart.py --route-file <route-xml-file> [--depart-lane] \ [--output-route-file <output-xml-file>]
where values within brackets ([]) are optional.
Description
"randomDepart" is designed to reduce overall complexity and increase traffic efficiency. Although it has some constraints it is useful for transportation modeling.
Mandatory fields in the input route file are:
<routes> <vehicle id="" type="" depart=""> <route edges=""/> </vehicle> ... </routes>
These are the parameter considered based on the necessity for calibration of traffic parameter.
One optional parameter is DEPRTLANE which you can also override at the time of modification with option -d if this option is optional argument, if provided then DEPARTLANE=FREE for all lanes will be set otherwise FALSE.
The last parameter is output file [optional if not provided DEFAULT is "out.rou.xml", will be generated]. so the output file may be in the form-
<routes> <vehicle id="" type="" depart="" [departLane=""]> <route edges=""/> </vehicle> ... </routes>
Dump: you can also take the dump of modified depart time in excel file by just enabling the commented part in the python script. the all necessary things you need is xlwt package to write into excel file.
Acknowledgements
The script was written by Ashutosh Bajpai.
routecheck.py
Allows to verify whether routes within the given route-file(s) are valid for the given network. Call(s):
routecheck.py <net> <vehicletypes> [-f|--fix] <routes>+
routecheck.py <net> <vehicletypes+routes>
If a route is broken (a diconnected), the tool writes something like the following to cout: Template:Warning
If --fix (-f) is given, routes are tried to be repaired (assuming only one link is missing). The name of the output file(s) is generated by appending ".fixed". These file contain repaired routes (if it was possible), each appended link is written in comments after the vehicle.
Known caveats
- The tool does not deal with vehicle types; it only checks whether routes are connected
- When working in --fix-mode a vehicle type file must be given
- No tests for dealing with networks that have internal edges
routes_Join.py
Joins routes belonging to two networks. A map file with the following syntax is read first:
<EDGE_ID>-><EDGE_ID>
It describes at which edges the networks overlapped and which edge was kept in the resulting one. Vehicles from both given route files starting at the first of those edges will be at first not regarded, but their routes are kept in memory. All other vehicles are kept, but if they pass one of the mapped edges, the route is continued by choosing a random route from the list of previously discarded ones which start at the corresponding edge.
routes_Join.py <prefix#1> <routes#1> <prefix#2> <routes#2> <mapfile>
- <prefix#1>: The prefix to use for vehicles from the first routes file
- <routes#1>: The first routes file
- <prefix#2>: The prefix to use for vehicles from the second routes file
- <routes#2>: The second routes file
- <mapfile>: The edge mapping
Attention! The routes are not sorted in time!
sort_routes.py
This script sorts the vehicles in the given route file by their depart time. If the option --big is supplied, a slow but memory efficent algorithm is used.
<SUMO_HOME>/tools/route/sort_routes.py input.rou.xml -o output.rou.xml
cutRoutes.py
This script cuts down routes from a large scenario to a sub-scenario. This assumes the existence of a big scenario (orig.net.xml and orig.rou.xml). The goal is to simulate only a smaller part of the network (reduced.net.xml) keeping all of the routes that pass through the reduced network. Output can be a route file or a trip file. Depending on the given options the new departure times can be computed from exitTimes (see SUMO option --vehroute-output.exit-times), extrapolated from the original network or simply copied from the original departure times. If the option --big is supplied, a slow but memory efficent algorithm is used for sorting the output by departure time. Example usage
<SUMO_HOME>/tools/route/cutRoutes.py reduced.net.xml orig.rou.xml --routes-output output.rou.xml --orig-net orig.net.xml
routeStats.py
Compute a length-histogram for all routes in a given route file. Alternatively, compute the difference in lengths for two route files with the same vehicles. Routes must be child elements of <vehicle>-elements. Output for plotting may also be generated (see --help).
<SUMO_HOME>/tools/route/routeStats.py myNet.net.xml myRoutes.rou.xml
When setting option --attribute depart a histogram on departure times (or departure time differences) is generated instead.
route2poly.py
Transform routes into polygons for visualization in SUMO-GUI. Using the options --hue, --saturation, --brightness the colors can be controlled. Each of these options supports values from [0, 1] as well as the special value random.
<SUMO_HOME>/tools/route/route2poly.py myNet.net.xml myRoutes.rou.xml
route2sel.py
Transform routes into an edge selection file which contains all edges used in any of the routes, trips or person plans. This file may be used for visualization in SUMO-GUI or pruning a network via NETCONVERT.
<SUMO_HOME>/tools/route2sel.py myRoutes.rou.xml -o usedEdges.txt
netconvert --net-file myNet.net.xml --keep-edges.input-file usedEdges.txt --output reduced.net.xml
route_departOffset
Shifts the departure times of <vehicle>, <trip>, and <flow> elements by a specified amount. When setting the option --depart-edges Edge1,Edge2,..., only vehicles that depart on one of the given edges are affected.
<SUMO_HOME>/tools/route/route_departOffset.py --input-file myRoutes.rou.xml --output-file shifted.rou.xml --depart-offset 900
The option --depart-interval a,b,c,d shifts all departures within the interval [a,b[ to the interval [c,d[.
<SUMO_HOME>/tools/route/route_departOffset.py --input-file myRoutes.rou.xml --output-file shifted.rou.xml --depart-interval 3600,7200,0,500
showDepartsAndArrivalsPerEdge
Generates a visualization file for investigating traffic patterns in a route file.
<SUMO_HOME>/tools/showDepartsAndArrivalsPerEdge.py myRoutes.rou.xml --output-file results.xml
The generated file result.xml can be loaded in SUMO-GUI using the following options
sumo-gui --weights-file result.xml --weight-attribute departed -n myNet.net.xml
The number of departures for each edge can the be used for coloring the edges by changing the edge visualization settings to color by loaded weight. Alternatively the option --weight-attribute arrived may be used to color by arrivals.
When investigating routes that pass a particular edge or intersection, the input routes may be filtered using the option --subpart <STRING>:
<SUMO_HOME>/tools/showDepartsAndArrivalsPerEdge.py myRoutes.rou.xml --output-file results.xml --subpart edge3,edge4,edge5
This will only generate results for routes that contain the edge sequence edge3 edge4 edge5.