Simulator code for our paper: Fleet Rebalancing for Expanding Shared e-Mobility Systems: A Multi-agent Deep Reinforcement Learning Approach
Man Luo, Bowen Du, Wenzhe Zhang, Tianyou Song, Kun Li, Hongming Zhu, Mark Birkin and Hongkai Wen
- Python 3.7
- utm 0.5.0
- pandas 0.25.0
- kdtree 0.16
- numpy 1.16.4
- prettytable 0.7.2
pip install -r requirements.txt
conda env create -f environment.yaml
conda activate vehicle3.7
ev-reb-simulator/
├── data
│ ├── hex_pos_info.csv # Hexagon partition of the space
│ ├── orders_one_week.pkl # Sample user orders (demand) within one week
│ ├── station_seq_info.csv # EV station properties
│ └── daily_online_offline.pkl # Station dynamics within one week
├── environment.yaml # Configuration file for conda
├── logs
│ └── log.txt # Log output by the simulator
├── README.md
├── requirements.txt # Configuration file for pip
├── run.py # Main entry of the simulator
└── src
├── env.py # Main environment of the simulator
└── utils
├── car.py # EV
├── order.py # Order
└── station.py # Station
python run.py
The simulator operates on a 2D space with hexagonal partition with discrete time. There are three key elements:
- Shared EVs with certain range and charging time
- EV Stations with different numbers of charging docks (parking spaces)
- User orders with describes their demand at different timestamps
We also provide a set of sample data for the simulator to run. In practice, such data can be generated by learning from the real operation logs of the EV sharing system. More concretely, we provide the following data:
- Geometric details of the hexagon partition (
hex_pos_info.csv
) - Properties of EV stations (
station_seq_info.csv
) - User demand in one week (
orders_one_week.pkl
) - Station network dynamics in one week (
daily_online_offline.pkl
)
At the beginning of each timestamp, the simulator performs the following:
- Implement the station dynamics: i.e. making certain stations online or offline
- Process rent demand: assign the orders within this timestamp to different EVs at the stations specified by the users
- EV status update: keep tracking the status of each EV, if it is parked or running, its battery status, if its order has been completed, etc.
- Process return demand: charge the EV at the destination stations, and handle cases such as if there isn't enough parking space for an arriving EV.
One could plug in their own rebalancing strategies in the following function:
def rebalance_cars_across_hexagon(self, car, action, order_money=-1, average_dis=-1)
It is also possible to directly implement rebalancing strategies in the simulator. We leave the readers to explore further.
At each timestamp (currently set to 10 mins), a snapshot should be generated to show current status (including various statistics) of the simulation. The log will also be stored in logs/log.txt
. Here is a sample output:
[Snapshot] 2020-04-02 00:00:00 -- No rebalancing
+--------------------------------------------------+----------+-----------------------------------------------+------------+
| item | amount | item | amount |
+--------------------------------------------------+----------+-----------------------------------------------+------------+
| Number of stations in operation | 3014 | Number of available charging docks | 15161 |
| Number of EVs in operation | 8041 | Number of EVs in charging | 6966 |
| Number of newly deployed EVs | 15 | Number of EVs on the road | 1075 |
| Number of EVs returned with no available parking | 764 | Number of EVs returned to an offline station | 8 |
| Number of running orders | 1075 | Number of rebalancing operations | 0 |
| Number of finished orders | 12093 | Total number of unfulfilled orders | 7392 |
| Number of unfulfilled orders(EV battery low) | 1958 | Number of unfulfilled orders(no available EV) | 5434 |
| Total income (10k) | 27.09 | Total cost on user incentives (10k) | 0.0 |
+--------------------------------------------------+----------+-----------------------------------------------+------------+