Sumopy Userman v01 Contrib
Sumopy Userman v01 Contrib
Abstract
This document describes the capabilities and basic usage of the
software SUMOPy. SUMOPy is intended to expand the user-base
of the traffic micro-simulator SUMO (Simulation of Urban MO-
bility http://sumo.dlr.de/wiki/Main_Page) by providing a user-
friendly, yet flexible simulation suite.
A further scope of SUMOPy is to manage the huge amount of data
necessary to run complex multi-modal simulations. This includes
different demand generation models as well as a large range of
modes, such as road transport, public transport, and bicycles. In
the future also modes like self-driving cars and Personal Rapid
Transit (PRT) will be supported.
SUMOPy consists of a GUI interface, network editor as well as a
simple to use scripting language which facilitates the use of SUMO.
Contents
1 Introduction 3
2 Installation 3
2.1 Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.2 Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2 Installation
SUMOPy is a directory with python scripts. It is sufficient to un-
zip the latest version and copy it in a directory of your choice. Since
SUMO-0.28, SUMOPy is inside the SUMO distribution and located in
SUMOHOME/tools/contributed.
However, SUMOPy makes extensive use of Python packages which need
to be installed before. The required packages to be installed are:
1. Python 2.7
2. numpy-1.10 or newer
3. wxPython2.8 or wxPython2.9 (wxPython3.x is currently not prop-
erly working with PyOpenGL-3.0.x)
4. PyOpenGL-3.0.x
2.1 Windows
matplotlib-1.4.3-cp27-none-win32.whl
basemap-1.0.8-cp27-none-win32.whl
PIL-1.1.7.win32-py2.7.exe
2.2 Linux
Python 2.7 comes with most Linux operating systems. All required ad-
ditional packages are available in repositories:
python-numpy
python-wxgtk2.8
python-opengl
python-imaging
python-matplotlib
python-mpltoolkits.basemap
However, often Python 3.x is installed along the older version and may
be the default Python interpreter. So make sure you run the sumopy
scripts with Python 2.7
sudo rm /etc/apt/sources.list.d/wily-copies.list
Figure 2: Creating a new scenario from SUMO xml files. Please note
that the scenario short-name must be identical to the root-name of the
xml files.
pressing the Run button, network, buildings and routes will be imported.
In case the trip file demo.trip.xml exists, it will also be imported.
In the same way it is possible to crate an empty scenario under menu
Scenario>New....
The network can be examined with the network editor. The initial editing
tool allows to click on the different network elements and retrieve the
respective information in the object browser.
With the zoom-buttons (+,-) located below the network editor, different
zoom levels can be obtained The 1:1 button zooms the network to fit
approximately the boundaries of the window. Next to the zoom button
is a button which pops up a menu when pressed. From this menu, the
network elements to be drawn can be selected or un-selected.
The following mouse-key combination allow to navigate the network:
Figure 3: SUMO simulation dialog. Here all output data options are
marked.
The simulation parameters are self-explaining, just hover with the mouse
over the parameter name. The default parameters are typically suit-
able to run a first simulation. Select one of the output options in
order to obtain specific simulation results. Regarding outputs, the
Output Sampling Time for the different outputs may be of interest. If
you observe in the simulations that vehicles get blocked at junctions for
no obvious reason, then it is possible to resolve conflicts by setting the
Teleport to a positive time (i.e. 10s).
After pressing the run button, the SUMO-GUI interface pops up, ready
for simulation, as shown in Fig. 4. Adjust delay time and press the Start
button. At the end of the simulation, confirm OK and close the SUMO-
GUI window. Simulation results are now imported into SUMOPy and
are ready to be examined, visualized and exported in various formats.
The results can be viewed in table format and graphically, see Fig. 5.
In the object browse, the results per trip and the results per edge can
be viewed. Both, trip and edge oriented result-table can be exported in
As explained in Sec. 3.1, networks can be created from SUMO XML files,
or a binary file can be loaded. Both operations can be performed from
the commend line.
The wizard, shown in Fig. 7 helps to download the squared tiles which
cover the network area. The resolution can be defined by setting the tile
width (and height) in meters. The tile size in pixel is maximum 1280
(using the Google Map server). The resolution is then tile size/tile width
in pixel per meter.
Attention: it is highly recommended to press the Apply Button prior
to downloading the maps. This will calculate the number of tiles which
are going to be downloaded. This is important to know, because Google
maps prevent IPs from downloading too many maps of an area. Therefore
do not exceed ≈ 300 tiles! Note further that, dependent on the perfor-
mance of your computer, netedit may run into problems to handle too
large map areas.
After the maps are downloaded, netedit can be called with
Network>Edit with netedit on map
in order to edit the SUMO network on a map.
will aboard the current zone drawing. Currently zones must be convex,
otherwise edge detection problems occur.
Important notice Only edges which are located entirely inside a zone
are considered part of a zone. Only edges inside a zone are considered
for departure or arrival of vehicles in the respective zone. After creating
the zones you can identify all edges in each zone by selecting menu item
Landuse>Zones>Identify zone edges
It is possible to see all zone edges and and change zone names by using
the information tool and by clicking on the green zone border. Zones
are accessible under scenario.demand.zones. Zones can also be deleted
with the Delete tool of the network editor.
Zone-to-Zone flow Zone-to-Zone flows can be added by selecting the menu item
definition:
Demand>Zone-to-zone demand>Add zone-to-zone flows
An “Add OD flow wizard” will pop up as shown in Fig. 9. On this
wizard, specify the time interval (in entire seconds) and the transport
mode. On the menu of the wizard select Edit>Add OD-flow to table.
Then a new row will appear in the table. Enter the zones of origin and
destination and the respective number of trips between them.
Instead of entering the OD flows manually, the wizard offers also the
possible to import an OD-flows from a CSV file. Select from the wizard
menu:
File>Import CSV ...
and choose a CSV file from the file-dialog window. The CSV file must
have the following format:
<zone name origin 1>, <zone name destination 1>,<trip number 1>
<zone name origin 2>, <zone name destination 2>,<trip number 2>
...
Once the OD flows are all entered, press Save flows. The scale factor
can be used to multiply the entered trips with a constant (default 1)
when saving. The demand flows are now saved to SUMOPy and can be
browsed and modified under
scenario.demand.odintervals
Trip generation: Generate trips from OD flows, selecting menu item
Demand>Zone-to-zone demand>Generate trips from flows
The generated trips can be browsed and modified under
scenario.demand.trips
Routing: Perform a shortest path routing, for each trip by selecting
Demand>Trips and router>Routing
The generated route can be browsed under
scenario.demand.trips.routes
With this method, SUMO’s duarouter is used to perform the routing.
Note that each trip is now linked to a route (see ID route column in
trips). If there is no route means that the edge in the zone of origin is
probably not connected to the edge in the zone of destination 4 . The
router does not route pedestrians. Their exact route will be determined
only during simulation.
The scenario is now ready to be simulated by selecting
Simulation>Sumo>export routes and simulate...
4 there can be several reasons for this, usually the destination edge is in access-
restricted areas, or there are one-way roads, impeding access. Actually this should
not happen too often, as the disaggregation algorithm should verify accessibility
dialog is similar to the OD-flow wizard explained in Sec. 3.4.1 and allows
to import traffic counts, and associate them with a time interval and a
transport mode.
The Turnflow File to be imported contains the traffic counts of both
flow types, generating flows and turnflows. The turnflow file has the
following format:
<ID1>, <count 1>, <ID11>, <count 11>, <ID12>, <count 12>, ...
<ID2>, <count 2>, <ID21>, <count 21>, <ID22>, <count 22>, ...
...
This notation has the following meaning:
<IDa> means the SUMO edge ID of edge a, where edge a is the edge
entering a node.
<IDab> means the SUMO edge ID of edge ab, where edge ab is the edge
outgoing from the node which edge a enters.
<count a> means the number of vehicles leaving edge a, in case the edge
is generating flows, otherwise this count is zero.
<count ab> means the number of vehicles from edge a turning into edge b.
All counts in this file refer to the mode and time interval specified in the
dialog box.
The turnflow file for the example network in Fig. 10, could look like this:
3, 1000
12, 800, 4, 200, 7, 600
8, 0, 9, 800, 2, 400
Figure 12: Object browser showing an edge. You can copy the SUMO
Edge ID from the respective field.
there, copy the SOMO edge ID and paste it into your turnflow text file.
Defining destination zones: Optionally define destination zones. Within the turnflow demand model
destination zones define edges where vehicle routes end. This may be
necessary in order to prevent vehicles of making a loop on the network
outside the study area and reentering the study area. Destination zones
for turnflows are created in the same way as Traffic assignment Zones,
see Fig. 8.
Routing flows and Generate directly route from flows and turn-flows information by selecting
turn-flows: menu item
Demand>Turnflows>Turnflows to routes
This process is using SUMO’s JTROUTER and will generate both trips
and routes. The scenario is now ready to be simulated by selecting
Simulation>Sumo>export routes and simulate...
Proceed as described in Sec. 3.1.5.
A test file for turnflows is located in
SUMOHOME/tools/contributed/sumopy/testscenario/demo_dem_tf_car
References
[Krajzewicz (2003)] D. Krajzewicz, M. Hartinger, G. Hertkorn, P. Mieth,
C. Rössel, P. Wagner, J. Ringel. The ”Simulation of Urban MObil-
ity” package: An open source traffic simulation. In 2003 European
Simulation and Modeling Conference (2003)