cTORS
a C++ implementation of TORS, a Train Unit Shunting and Servicing Simulator
|
This implementation of TORS consists of a backend written in C++ (cTORS), and a front-end written in python (TORS).
The basic project setup uses the structure provided by cmake. The subfolders are subprojects:
The following section explains how to compile this source code. Alternatively one can run the code in a docker container. The Dockerfile also shows how this project can be compiled and run step-by-step.
To compile cTORS, cmake 3.11 (or higher) is required and the python development libraries:
For windows:
This project uses Google Protocol Buffers to read the data files. Installation is required to compile the C++ source:
You can build cTORS and the pyTORS library with the following command.
In the source directory execute the following commands:
This has been tested with gcc 9.3. Older versions may not support the c++17 standard.
You can also run TORS in a docker container. To build and run the container, run:
To run challenge environment, run the following code
Optionally you can change the episode or agent data by changing the parameters
The --agent
option sets the file that configures the agent. The --episode
option sets the file that configures the episode.
You can also run the file with the --train
flag to train the agent instead of eveluating its performance.
To use cTORS in python, you need to import they pyTORS
library. E.g.
The visualizer runs as a flask server. Install the dependencies in TORS/requirements-visualizer
first.
Now flask can be run by running the commands:
The repository also includes example code that wraps cTORS in a gym-environment and uses an RL implementation from stable-baselines3 to learn a policy. To run this example, first install the requirements:
Then run:
You can check the learning progress using tensorboard:
TORS can be configured through configuration files. Seperate configuration exists for
A location is described by the location.json
file in the data folder. It describes the shunting yard: how all tracks are connected, what kind of tracks they are, and distances among tracks.
In order to use the visualizer for that location, you need to provided another file vis_config.json
. See the folder data/Demo
and data/KleineBinckhorstVisualizer
for examples.
A scenario is described by the scenario.json
file in the data folder. It describes the scenario: which employees are available, shunting units' arrivals and departures, and possible disturbances.
The simulator can be configured by the config.json
file in the data folder. It describes which business rules need to be checked and the parameters for the actions
You can provide an episode configuration and pass it to TORS/run.py
with the --episode
parameter. This file describes the evaluation/training episode. It contains the path to the data folder, the number of runs, RL parameters and parameters for scenario generation.
You can provide an agent configuration and pass it to TORS/run.py
with the --agent
parameter. This file prescribes which agent to use, and passes parameters to the agent.
To run the cTORS tests, execute the commands