-
Notifications
You must be signed in to change notification settings - Fork 0
Home
The source code in this repository is written in a combination of Python (>3.6) and Java (> 8). We will work with pip, maven and virtualenv (optional).
Clone the contents of this repository to your local machine:
git clone https://github.com/aicenter/agentpolis-demo.git
Clone agentpolis project.
git clone https://github.com/aicenter/agentpolis.git
Clone roadmaptools.
git clone https://github.com/aicenter/roadmap-processing.git
The source code will be in a 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 creating 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 apdemo_virtenv
To activate the newly created virtual environment, run (Linux):
source apdemo_virtenv/bin/activate
or for windows:
.\apdemo_virtenv\Scripts\activate
On most Windows computeres some core python packages cannot be installed via pip. Instead, download their wheel packages and instal them manually. You can download the wheels here: https://www.lfd.uci.edu/~gohlke/pythonlibs/. Of course you need to select the correct version - for example for numpy, python 3.7 runned on Windows 64bit download numpy‑1.16.0rc1+mkl‑cp37‑cp37m‑win_amd64.whl. Manual requiremnent list
- numpy
- shapely
After downloading install it via pip from the folder where the wheel is:
pip install (file name of wheel)
Next we will need to install roadmaptools and agentpolis python packages. Go to the directory where your cloned projects are.
-
install roadmaptools python package:
pip install roadmap-processing/
-
go to agentpolis directory and install agentpolis python package:
cd agentpolis/python pip install .
In case of failure of the roadmaptools installation, you might need to install libspatialindex library, which is essential for rtree library:
sudo apt-get install -y libspatialindex-dev
Next, we will need to download map from OSM database and obtain a collection of geoJSON files that are used to specify the structure of road network in Agentpolis. The steps needed to get the map and to obtain the geoJSON input files for Agentpolis from OSM data file are implemented in in process_map.py
script. The following command will download the OSM map and generate geoJSON input files in data
directory:
python process_map.py
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 compile
A single simulation run can be executed using Maven as
mvn exec:java -Dexec.mainClass="cz.cvut.fel.aic.apdemo.DemoSimulation"
or in PowerShell
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.
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 max-speed: Press "Ctrl+*"
- Simulate in real-time: Press "*"
- Simulate as fast as possible: Press Ctrl+"*"
- Manage visual layers: Open the "Show layers management" bar and select the layers to show/hide and change their order