-
Notifications
You must be signed in to change notification settings - Fork 0
Home
The source code in this repository is written in combination of Python (>2.7) and Java (> 8). We will work with pip, wget, maven and virtualenv (optional). On Ubuntu Linux, those can be installed through, e.g., through the package manager:
sudo apt-get install default-jdk python maven python-pip python-virtualenv
On Ubuntu 14.04, Java 8 is not in standard software repository and must be installed separately.
Clone this contents of this repository to your local machine:
git clone git@github.com:aicenter/agentpolis-demo.git
The source code will be in directory called agentpolis-demo. The subsequent commands must be executed in this directory. We will change the working directory:
cd agentpolis-demo
Virtualenv is a tool that allows to create Python environments that are isolated from the rest of the system. We will need to install several third party libraries, it is a good idea to do it in an isolated environment to avoid possible incompatibilities with the packages already installed in the system. To create a new virtual environment, whose configuration will be stored in ademo_virtenv directory, run:
virtualenv -p python2.7 --no-site-packages ademo_virtenv
To activate the newly created virtual environment, run:
source ademo_virtenv/bin/activate
Now install all the dependencies required in the virtual environment using pip:
pip install -r requirements.txt
To prepare a transport simulation of some specific urban area, we first need to download OSM data for that area. One way to obtain such data is to use one of 200 ready-made Metro Extracts offered by Mapzen. One of the smallest is the extract of Valencia, Spain. The OSM data for Valencia can be downloaded in bz2-compressed OSM XML format, e.g., using wget as follows:
wget https://s3.amazonaws.com/metro-extracts.mapzen.com/valencia_spain.osm.bz2 -O map.osm.bz2
The compressed OSM data will be in map.osm.bz2 file. We will need to decompress the file to get raw XML data, e.g., as follows:
bzip2 -d map.osm.bz2
After the process of decompressing has finished, the OSM data will be in file map.osm.
Next, we will need to process the OSM data to obtain a collection of geoJSON files that are used to specify the structure of road network in Agentpolis. The steps needed to obtain the geoJSON input files for Agentpolis from OSM data file are implemented in in process_map.py script. The following command will use OSM data from map.osm file and generates geoJSON input files in data directory:
python process_map.py map.osm data
Finally, we prepared a simple urban traffic scenario that will be executed in the given road network. The scenario is implemented in Java and can be compiled through Maven:
mvn clean compile -U
A single simulation run can be executed using Maven as
mvn exec:java -Dexec.mainClass="cz.cvut.fel.aic.apdemo.OnDemandVehiclesSimulation"
A visualization window will pop-up. You will see a map of Valencia with a number of vehicles driving between randomly generated points.

When the visualization window appears, you can control the visualization and the progress of simulation as follows:
- Move the viewport: Drag with right mouse button pressed
- Zoom in/out: Rotate mouse wheel
- Pause/unpause simulation: Press SPACE
- Speed-up simulation: Press "+"
- Slow-down simulation: Press "-"
- Simulate in real-time: Press "*"
- Simulate as fast as possible: Press Ctrl+"*"
- Show/hide roadmap: Press "h"