this simulator simulates the operation of the ride-sourcing markets, including the generation of orders, the matching process, the driver behaviors(including cruising, pick-up, delivery, and so on), and the passenger behaviors(including raising the orders, quitting and so on).
Install
python version 3.8
- Download the code
git clone https://github.com/HKU-Smart-Mobility-Lab/simulator-matching-function-validation
- Install the requirements
cd simulator-matching-function-validation
pip install -r requirements.txt
- set your local path in the path.py
Config
The data is generated by the code. Thus there is no need to prepare the raw data. You can set the parameters of the simulator in config.py and main.py.
(If you want to keep it as default, you can go to the next step directly)
config.py
env_params = {
't_initial' :0, # simulation initial time (s)
't_end' : 21600, # simulation end time (s)
'delta_t' : 2, # time interval (s)
'vehicle_speed' : 11.11, # vehicle speed (m/s)
'driver_sample_ratio' : 1, # just as default
'order_sample_ratio' : 1, # just as default
'maximum_wait_time_mean' : 300, # passengers' max waiting time (s)
'maximum_wait_time_std' : 0, # the std of passengers' max waiting time (s)
'request_interval' : 2, # request generation inteval (s)
'max_idle_time': 60, # drivers' maximum idle time (s)
'pickup_dis_threshold': 1000, # drivers' maximum pick-up distance or matching distance (m)
# 'cruising_prob_file_name' : 'cruising_prob_matrix_equally_dist',
'method' : 'pickup_distance', # the matching is based on the minimum pick-up distance
'simulator_mode' : 'simulator_mode', # just as default
'request_file_name' : 'requests', # just as default
'driver_file_name' : 'drivers', # just as default
'experiment_date': 'test_day', # just as default
'grid_system_side_length' : 10000, # unit: m
'grid_system_grid_length': 1000, # unit: m
'ave_order' : 0.02, # order number per delta_t
'num_drivers': 1000, # driver number
}
In our paper, we need this model to simulate different ride-sourcing markets with different supply and demand, so we change the supply and demand in the main.py.
Run
After setting, you can run the main.py to get the results.
Results
The results will be stored in the Results folder.
For each simulated market, the final record includes:
Fleet size, total simulation time, total requests, speed, the number of matched requests, the matching rate, the passengers' average matching time, the average trip time, the average pick-up time, the total waiting time, the average waiting orders in each time interval, the maximum waiting orders, the average vacant drivers in each time interval
If you want to record more indicators, you can modify the save_data function in utilities.py
Draw picture
run Draw_diagram.py, and you can get the analysis diagrams in our paper. The diagrams will be saved in the Figure folder.
the flowchart of the simulator
The above picture shows the flowchart of the simulator. Next, we will introduce the role of each python file following the process.
main.py is our main console.
Config.py and path.py are used to set some basic settings
Utlities.py implements some functions.
Initialization for drivers, orders, and simulator:
Create_Drivers.py initializes the drivers' location and direction according to the config setting.
Create_Records.py initialize the location, destination, price, time, and so on for each record.
Simulator_env.py contains the code for simulator construction and operation.
Matching process:
Dispatch_alg.py implement the matching process
Information update:
the step() function in simulator_env.py
Results analysis:
Evaluate.py calculate some metrics for the subsequent evaluation.
Draw_diagram.py is used to generate pictures in our paper.
If you feel this code is useful for you and/or relevant to your research, please cite the following paper:
"Wei, S., Feng, S., Ke, J., & Yang, H. (2022). Calibration and validation of matching functions for ride-sourcing markets. Communications in Transportation Research, 2, 100058."
The simulator is mainly conducted by Siyuan Feng, the driver cruising, evaluation and drawing part is mainly implemented by Shuqing Wei, and the analysis, checking and verification is conducted by Jintao Ke.
This simulator is supported by the Smart Mobility Lab at The Univerisity of Hong Kong.
For help or issues using this simulator, please submit a GitHub issue.
For personal communication related to this simulator, please contact Shuqing Wei (sweiad@connect.ust.hk
), Siyuan Feng(sfengag@connect.ust.hk
), or Jintao Ke (kejintao@hku.hk
).