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:

  1. Use git clone https://github.com/umnilab/METS-R_HPC.git to clone the repository;

  2. Use cd METS-R_HPC to navigate to the repository directory;

Then, you need to:

  1. 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
    
  2. Update the carla_dir variable in configs/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.

  3. Go to the subfolder named docker and run:

    docker build -t postgres postgres
    
  4. 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

  1. Download and install Eclipse IDE with Repast Simphony 2.7 from here.

  2. Clone the METS-R repository using git to a target folder.

    git clone https://github.com/umnilab/METS-R_SIM.git
    
  3. Open Eclipse and go to File -> Open Projects from File System…

  4. In the Import Projects from File System or Archive window click on Directory and open the METS_R directory you cloned in Step 2.

  5. 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

    Load the METS_R SIM project in Eclipse

  6. 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.

  7. 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).

  8. Click on the Start Run button in the pop-up window to begin the simulation.

  9. The simulation outputs can be found in the agg_output folder, and the vehicle trajectories is in the trajectory_output folder.

  10. You can check the configuration file (METS_R/data/Data.properties) for options available in the simulation.

Asynchronized mode

  1. Configure METS-R SIM by following the steps in setting up the standalone mode.

  2. Download the METSR_HPC code to use the HPC module.

    git clone git@github.com:umnilab/METSR_HPC.git
    cd METSR_HPC
    
  3. Set up a Python (version = 3.8) environment and install the packages in &requirements.txt&.

  4. View the HPC configuration JSON file in configs/. Currently, you need to modify the run_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.

  5. 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

  1. Following the instructure in configuring asynchronized mode until Step 4.

  2. Modify the run_hpc_NYC_[ubuntu/win].json file to set synchronized to be true.

  3. Install docker for hosting Kafka brokers and databases.

  4. Go to the METS-R HPC/docker directory, run

    docker build -t postgres postgres
    
  5. Go back to METS-R HPC/, run python 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

  1. Modify the run_interactive_NYC_win.json by following the first four steps in configuring HPC with oeprational algorithms.

  2. Open interactive_example.ipynb in VSCode or other IPython notebook IDE.

  3. Run each cell one by one.

Co-simulation mode (ongoing)

  1. Modify the run_consim_CARLAT5_win.json by following the first four steps in configuring HPC with oeprational algorithms.

  2. 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.