Post

Simulation of road traffic using SUMO and OSM

Traffic simulation is the mathematical model of transportation system using computer software for better understanding, desing and operation of the system. Traffic simulation can be used to simulate road transportation (ground transportation), rail transportation, air transportation and other utility network simulations. There are many softwares available to simulate traffic such as Quadstone paramics, VISSUM, VISSIM, AIMSUN which are paid and Matsim, SUMO, Repast, MAINSIM which are free.

SUMO stands for Simulation of Urban Mobility is a open source, high portable road traffic simulation software. SUMO is licensed under GPL.

OpenStreetMap (OSM) is a project to create free editable maps of the world. Same as Wikipedia, the content on OSM is generated by the people like us and made available to people freely. OSM was created by Steve Coast in 2004.

Requirements

  1. Python (download it from here).
  2. SUMO (download it from here).
  3. Text editor like notepad or notepad++
  4. Web browser
  5. Working internet connection

Installing python

  1. Double click on the downloaded file to initiate installation.

  2. Select install for all users.

    python

  3. Select a directory for python. You can leave the default values as it is.

    python

  4. In customize python, scroll down to the bottom, click on the option “add python.exe to path” and select option “will be installed on the local drive”.

    python

Installing SUMO

  1. Double click on the downloaded file to initialize the installation.

  2. Accept the end user agreement.

    sumo

  3. Check “set SUMO_HOME and adapt PATH and PYTHONPATH”.

    sumo

  4. Click next and then install.

Download a map from openstreetmap.org

  1. Create a directory “map” on the desktop

  2. Head to openstreetmap.org.

  3. Search for the area or location or city.

  4. Click on “Export” in the top left corner.

    osm

  5. Then again click on export icon as shown below.

    osm

  6. When prompted to save, save it with the name map in previously created map directory. The file will be saved with .osm extension.

    osm

  7. Download this zip file from here and extract its content into map directory. The content of map directory will be map.osm, typemap.xml and map.sumo.cfg.

  8. Open a command prompt and navigate to map directory.

  9. Run following command in the command prompt. Success will be displayed at the end if the command is successful.

    1
    
     netconvert --osm-files map.osm -o map.net.xml
    
  10. Run following command in the command prompt

    1
    
    polyconvert --net-file map.net.xml --osm-files map.osm --type-file typemap.xml -o map.poly.xml
    
  11. Run the following two commands one by one to trace random paths for simulation.

    1
    2
    
    randomTrips.py -n map.net.xml -e 100 -l
    randomTrips.py -n map.net.xml -r map.rou.xml -e 100 -l
    
  12. Now run the following code which will open SUMO GUI with current working file

    1
    
    sumo-gui map.sumo.cfg
    

    osm

  13. In the SUMO GUI, set delay time, select “real world” from the drop down where it says “standard” and then click on “play” button. When the simulation is running you can view the results by zooming into the map.

    osm

    osm

Note: You can download all the files from here, extract it and run the last command in the command prompt with extracted directory as current working directory.

This post is licensed under CC BY 4.0 by the author.