This guide provides step-by-step instructions to set up the SUMO RL environment, create a Conda environment, install the required Python modules, and run experiments. It also includes details on generating and analyzing plots from experiment outputs.
Before starting, ensure you have the following installed on your system:
- Python (version 3.8 or later recommended)
- Anaconda/Miniconda
- SUMO (Simulation of Urban MObility) installed and added to your system's PATH
First, clone the repository to your local machine:
git clone https://github.com/Transyltooniaa/RL-Project.git
cd RL-Project-
Create a new Conda environment for the project:
conda create -n sumo_rl_env python=3.8 -y
-
Activate the environment:
conda activate sumo_rl_env
Install the required Python modules listed in the requirements.txt file:
pip install -r requirements.txtFor PettingZoo, install a specific version:
pip uninstall pettingzoo -y
pip install pettingzoo==1.23.1To ensure all dependencies are installed, you can also run:
pip install argparse pandas numpy tqdm gymnasium traci supersuit pyvirtualdisplay sumo_rl stable-baselines3 ray[rllib] tensorflow-probability torchEnsure that SUMO is correctly installed and accessible from your terminal. You can verify this by running the following command:
sumo --versionIf SUMO is not installed or not in your PATH, refer to the SUMO documentation for installation guidance.
- Locate the installation directory for SUMO, typically:
C:\Program Files (x86)\Eclipse\Sumo - Set the environment variables:
- SUMO_HOME: Point to the main directory, e.g.,
C:\Program Files (x86)\Eclipse\Sumo - SUMO_PATH: Add the
binsub-directory to your system's PATH, e.g.,C:\Program Files (x86)\Eclipse\Sumo\bin
- SUMO_HOME: Point to the main directory, e.g.,
- Steps to configure:
- Open System Properties > Advanced > Environment Variables.
- Under System Variables, select New.
- Add:
- Variable name:
SUMO_HOME - Variable value:
C:\Program Files (x86)\Eclipse\Sumo
- Variable name:
- Find the
Pathvariable, click Edit, and add:C:\Program Files (x86)\Eclipse\Sumo\bin.
To run an experiment, navigate to the experiment directory and use the following command:
python experiment/<file_name>Replace <file_name> with the name of the Python script you want to execute.
Example:
python experiment/train_agent.pyThe experiment outputs are saved as CSV files in the specified outputs directory within the repository.
After running experiments, you can visualize and analyze the results using the plot.py script.
- This script generates plots based on the CSV outputs generated by experiments.
- It looks for CSV files stored in the
outputsfolder, which is created automatically after you run experiments. - The script allows you to compare one column of a CSV file with another, providing a clear visualization of the data.
To generate a plot, run the following command:
python outputs/plot.py- Use this script to analyze and compare metrics such as rewards, waiting times, or other key performance indicators stored in the CSV files.
- Visualizations can be saved for later use.
In addition to the dependencies listed in requirements.txt, the following modules are used across the project:
argparseos,sys,shutil,subprocesspandasnumpytqdmgymnasiumtracisupersuitpyvirtualdisplay.smartdisplaysumo_rlstable_baselines3ray[rllib]tensorflow-probabilitytorch
Ensure all these dependencies are installed for the project to run smoothly.
- If you encounter any issues, ensure that all required modules are installed and that SUMO is properly set up.