Get started
Using METS-R in docker
To use the METS-R with docker, you need install docker and clone the all_docker branch in METS-R_HPC first:
Use
git clone https://github.com/umnilab/METS-R_HPC.git
to clone the repository;Use
cd METS-R_HPC
to navigate to the repository directory;
Then, you need to:
Create a Python environment (
conda create --name myenv python=3.8
) and download all requirements specified in requirements.txt using:pip install -r requirements.txt
Update the
carla_dir
variable inconfigs/runcosimCARLAT5_docker.json
to point to your CARLA version, note the Python’s carla package version in Step 1 should match with your CARLA version.Go to the subfolder named
docker
and run:docker build -t postgres postgres
Test using:
python cosim_example.py -r configs/run_cosim_CARLAT5_docker.json -v
Note: in Windows, you would need to use the latest docker, and tick the allow host network feature.
Several APIs are developed to query and control the Co-simulation. See Interactive APIs for more details.
Standalone mode
Download and install Eclipse IDE with Repast Simphony 2.7 from here.
Clone the METS-R repository using git to a target folder.
git clone https://github.com/umnilab/METS-R_SIM.git
Open Eclipse and go to File -> Open Projects from File System…
In the Import Projects from File System or Archive window click on Directory and open the METS_R directory you cloned in Step 2.
Check METS_R and click Finish. This should open the METS-R SIM project in Eclipse as shown in the following figure.
Load the METS_R SIM project in Eclipse
Go to the laucher folder in the project explorer, then right click
METS_R Model.launch
and select Run as -> METS-R Model to start the simulation.You should see the below Repast Symphony simulation window (After specifying the first time, you can also use the Run button in the Eclipse toolbar).
Click on the Start Run button in the pop-up window to begin the simulation.
The simulation outputs can be found in the agg_output folder, and the vehicle trajectories is in the trajectory_output folder.
You can check the configuration file (
METS_R/data/Data.properties
) for options available in the simulation.
Asynchronized mode
Configure METS-R SIM by following the steps in setting up the standalone mode.
Download the METSR_HPC code to use the HPC module.
git clone git@github.com:umnilab/METSR_HPC.git cd METSR_HPC
Set up a Python (version = 3.8) environment and install the packages in &requirements.txt&.
View the HPC configuration JSON file in
configs/
. Currently, you need to modify therun_hpc_NYC_[ubuntu/win].json
file with the configurations:java_path
- set the absolute path of your JAVA installation.sim_dir
- the absolute path of METS_R SIM directory.repast_plugin_dir
- absolute path pf your repast plugin installation.synchronized
- set it to false when using asynchronized mode.
Finally, run
python hpc_example.py -s 0 -c 0 -tf 2000 -bf 40 -df 0.1
-s 0
means the scenario index is 0. The available indexes are 0,1,2 and 3 when the full demand folder is provided.-c 0
denotes that the case index is 0. It can range from 0 to 9 when the full demand folder is provided.-tf 2000
means the EV taxi fleet size is 2000.-bf 40
means the EV bus fleet size is 40.-df 0.1
means the demand factor is 10%.
This will start the simulation in the background. All the files related
to each simulation run will be stored in the output/
folder.
Synchronized mode
You can run the synchronized mode in the following four ways
HPC with operational algorithms
Following the instructure in configuring asynchronized mode until Step 4.
Modify the
run_hpc_NYC_[ubuntu/win].json
file to setsynchronized
to be true.Install docker for hosting Kafka brokers and databases.
Go to the
METS-R HPC/docker
directory, rundocker build -t postgres postgres
Go back to
METS-R HPC/
, runpython hpc_example.py -s 0 -c 0 -tf 2000 -df 0.1 -e -b
-e
enables the eco-routing.-b
turns on the dynamic transit scheduling.
Some other options are
-co
allows taxi and bus transferring.-eb
enables eco-routing for buses.-ds
enables ridesharing that combines trips with the same origin and destination zones.-r [your config file]
uses the user-specified configs.-v
turns on the verbose mode, displaying the messages between the SIM and HPC module.
Interactive mode
Modify the
run_interactive_NYC_win.json
by following the first four steps in configuring HPC with oeprational algorithms.Open interactive_example.ipynb in VSCode or other IPython notebook IDE.
Run each cell one by one.
Co-simulation mode (ongoing)
Modify the
run_consim_CARLAT5_win.json
by following the first four steps in configuring HPC with oeprational algorithms.Run
python cosim_example.py
More demand scenarios
More demand scenarios for the NYC network can be downloaded from
here.
You just need to copy this to data\
under the METS-R SIM folder.