Skip to content
praveale edited this page Dec 22, 2018 · 45 revisions

Prerequisites

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 16.04, those can be installed, e.g., through the package manager as follows:

sudo apt-get install default-jdk python maven python-pip python-virtualenv 

Note: On Ubuntu 14.04, Java 8 is not in standard software repository and must be installed separately.

Getting started

Downloading source code

Clone the contents of this repository to your local machine:

git clone https://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

Preparing python virtual environment(optional)

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 ademo_virtenv 

To activate the newly created virtual environment, run:

source ademo_virtenv/bin/activate

Installing requirements

install all the dependencies required using pip:

pip install -r requirements.txt 

pip install tqdm gpx_lite numpy shapely scipy overpass

On most Windows computeres NumPy and SciPy packages cannot be installed via pip. Instead, download their wheel packages for your python version and 32/64 bit Windows into your current directory. For example, for python 3.7 runned on Windows 64bit, select numpy‑1.16.0rc1+mkl‑cp37‑cp37m‑win_amd64.whl. You can download wheels here: https://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy https://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy After downloading install them via pip:

pip install (file name of wheels)

Processing OSM data

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 file and generates geoJSON input files in data directory:

  python process_map.py map data

Running simulation

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.DemoSimulation"

A visualization window will pop-up. You will see a map of Prague with a number of vehicles driving between randomly generated points.

Agentpolis visualization

Controlling visualization

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"

Clone this wiki locally