HKU-Smart-Mobility-Lab / Transportation_Simulator

MIT License
29 stars 9 forks source link

Could you please provide a description about all the packages and versions? #26

Closed KL4805 closed 11 months ago

KL4805 commented 1 year ago

Hi authors,

I tried to run the simulator, but it seems that I am in a wrong version of python/tensorflow/azureml-core combination.

I am using python3.11.5, tensorflow 2.12.0 and azureml-core 1.53.0. These versions create a conflict that, tensorflow 2.12.0 requires urllib3 2.0.5, but azureml-core 1.53.0 requires urllib<2.

Maybe you can help me by telling me what your versions are to ensure smooth running.

Thanks.

Caffretro commented 1 year ago

Hi there, I have uploaded a conda environment config file that we are using. You can check the versions of these modules or import the environment from this yaml file. Although we do not have azureml installed in this module, you can still import and install the missing modules that are required for the specific part of the simulations you are trying to run.

If there are some errors in importing the yaml file to your conda, you can try to build a new environment with python 3.8 from scratch, installing the libraries that are missing and let conda resolve conflicts.

If you need more help, feel free to leave a message below.

KL4805 commented 1 year ago

Hi there, thanks for your help!

I have built the environments as per your .yaml file. I downloaded the Manhattan data, put it under input, and did proper re-naming. However, when I run python3 simulator/main.py, an error popped out. I copy the full error trace below.



  File "simulator/main.py", line 314, in <module>

    grid_array, time_array, idle_drivers_by_grid, waiting_orders_by_grid = simulator.step1()

  File "/Users/yilunjin/Desktop/Transportation_Simulator/simulator/simulator_env.py", line 1324, in step1

    self.step_bootstrap_new_orders()

  File "/Users/yilunjin/Desktop/Transportation_Simulator/simulator/simulator_env.py", line 547, in step_bootstrap_new_orders
    if time in self.request_databases.keys():

AttributeError: 'list' object has no attribute 'keys'

Could you please run the code from your side and take a look at the error? Thanks. 
Caffretro commented 1 year ago

Hi there, could you please show me the config that you are using so I can copy your experiment settings and check what went wrong? I guess you are running the test mode for reposition now. You can simply copy your config.py content here, or just the contents of env_params.

I have double-checked the request file's structure, basically, it is a dictionary of dictionaries. Each date links to a dictionary of dictionary containing time (in seconds) - orders pair, and since the table initialization code is the same, the code in line 547 should work fine.

Sorry that I am not able to run the code at first. I will try to run the code later today, if there are any updates, I will reply to you ASAP. Thanks!

KL4805 commented 1 year ago

Hi,

What I basically did was:

  1. Download and install all dependencies as per the simulator.yaml.
  2. Download the Manhattan data from the link provided (and did some renaming)
  3. Run python3 main.py just to make sure everything runs smoothly. When I do so, an error was popped out just like above.

I did not modify config. Basically it was just what is given in the repo.

env_params = {
't_initial' :36000,
't_end' : 36100,
'delta_t' : 5,  # s
'vehicle_speed' : 22.788,   # km / h
'repo_speed' : 1, #目前的设定需要与vehicl speed保持一致
'order_sample_ratio' : 1,
'order_generation_mode' : 'sample_from_base',
'driver_sample_ratio' : 1,
'maximum_wait_time_mean' : 300,
'maximum_wait_time_std' : 0,
"maximum_pickup_time_passenger_can_tolerate_mean":float('inf'),  # s
"maximum_pickup_time_passenger_can_tolerate_std":0, # s
"maximum_price_passenger_can_tolerate_mean":float('inf'), # ¥
"maximum_price_passenger_can_tolerate_std":0,  # ¥
'maximal_pickup_distance' : 1,  # km
'request_interval': 5,  #
'cruise_flag' :False,
'delivery_mode':'rg',
'pickup_mode':'rg',
'max_idle_time' : 1,
'cruise_mode': 'random',
'reposition_flag': False,
'eligible_time_for_reposition' : 10, # s
'reposition_mode': '',
'track_recording_flag' : True,
'driver_far_matching_cancel_prob_file' : 'driver_far_matching_cancel_prob',
'input_file_path':'input/dataset.csv',
'request_file_name' : 'input/order', #'toy_requests',
'driver_file_name' : 'input/driver_info',
'road_network_file_name' : 'road_network_information.pickle',
'dispatch_method': 'LD', #LD: lagarange decomposition method designed by Peibo Duan
# 'method': 'instant_reward_no_subway',
'simulator_mode' : 'toy_mode',
'experiment_mode' : 'train',
'driver_num':500,
'side':4,
'price_per_km':5,  # ¥ / km
'road_information_mode':'load',
'price_increasing_percentage': 0.2,
'north_lat': 40.8845,
'south_lat': 40.6968,
'east_lng': -74.0831,
'west_lng': -73.8414,
'rl_mode': 'reposition',  # reposition and matching
'method': 'sarsa_no_subway',  #  'sarsa_no_subway' / 'pickup_distance' / 'instant_reward_no_subway'   #  rl for matching
'reposition_method': 'A2C_global_aware',  # A2C, A2C_global_aware, random_cruise, stay  # rl for repositioning
'dayparting': True, # if true, simulator_env will compute information based on time periods in a day, e.g. 'morning', 'afternoon'
}
wait_time_params_dict = {'morning': [2.582, 2.491, 0.026, 1.808, 2.581],
                    'evening': [4.862, 2.485, 0, 1.379, 13.456],
                    'midnight_early': [0, 2.388, 2.972, 2.954, 3.14],
                    'other': [0, 2.017, 2.978, 2.764, 2.973]}

pick_time_params_dict = {'morning': [1.877, 2.018, 2.691, 1.865, 6.683],
                    'evening': [2.673,2.049,2.497,1.736,9.208],
                    'midnight_early': [3.589,2.319,2.185,1.664,9.6],
                    'other': [0,1.886,4.099,3.185,3.636]}

price_params_dict = {'short': [1.245,0.599,10.629,10.305,0.451],
                    'short_medium': [0.451,0.219,19.585,58.407,0.18],
                    'medium_long': [14.411,4.421,11.048,9.228,145],
                    'long': [15.821,3.409,0,16.221,838.587]}

# price_increase_params_dict = {'morning': [0.001,1.181,3.583,4.787,0.001],
#                     'evening': [0,1.21,2.914,5.023,0.013],
#                     'midnight_early': [1.16,0,0,6.366,0],
#                     'other': [0,2.053,0.857,4.666,1.961]}
#  rl for matching
# global variable and parameters for sarsa
START_TIMESTAMP = 36000  # the start timestamp
LEN_TIME_SLICE = 5  # the length of a time slice, 5 minute (300 seconds) in this experiment
LEN_TIME = 100 # 3 hours
# NUM_EPOCH = 4001  # 4001 / 3001
FLAG_LOAD = False
sarsa_params = dict(learning_rate=0.005, discount_rate=0.95)  # parameters in sarsa algorithm
#  rl for matching

# rl for repositioning
# hyperparameters for rl
NUM_EPOCH = 1301
STOP_EPOCH = 1300
DISCOUNT_FACTOR = 0.95
ACTOR_LR = 0.001
CRITIC_LR = 0.005
ACTOR_STRUCTURE = [64,128] #[16, 32] for A2C, and [64, 128] for A2C global aware
CRITIC_STRUCTURE = [64,128]
# rl for repositioning

#  rl for matching
# parameters for exploration
INIT_EPSILON = 0.9
FINAL_EPSILON = 0
DECAY = 0.997
PRE_STEP = 0
#  rl for matching

#  rl for matching
# TRAIN_DATE_LIST = ['2015-07-06', '2015-07-07', '2015-07-08', '2015-07-09', '2015-07-10',
#                    '2015-07-13', '2015-07-14', '2015-07-15', '2015-07-16', '2015-07-17'
#                    ]
TRAIN_DATE_LIST = [i for i in range(36000,36100)]

TEST_DATE_LIST = ['2015-07-27', '2015-07-28', '2015-07-29', '2015-07-30', '2015-07-31']
#  rl for matching
Caffretro commented 1 year ago

I have checked the keys of the order file. You need to modify the TRAIN_DATE_LIST in config.py to ['2015-05-04', '2015-05-05', '2015-05-06', '2015-05-07', '2015-05-08', '2015-05-11', '2015-05-12', '2015-05-13', '2015-05-14', '2015-05-15', '2015-05-18'].

You might encounter some runtime errors since this repo is a generalized version that records the basic structure of our simulation platform. If you would like to try a particular function or module within the scope of our simulator's abilities, feel free to leave a message about what mode you are interested in, and we will check if the latest runnable codes related to that version have been merged.

Happy mid-Autumn Festival!

KL4805 commented 1 year ago

Thanks for your very prompt help! After changing that, the error is resolved.

I am specifically interested in the order dispatching (or order-driver matching) part. We are planning to use it to test and benchmark some popular RL-based dispatching algorithms.

Happy mid-autumn and enjoy the holiday!

KL4805 commented 12 months ago

Hi,

Unfortunately, there is another issue regarding running the code. I resolved the TRAIN_DATE_LIST issue, and rerun python3 simulator/main.py. The following error popped out.

Traceback (most recent call last):
  File "simulator/main.py", line 314, in <module>
    grid_array, time_array, idle_drivers_by_grid, waiting_orders_by_grid = simulator.step1()
  File "/Users/yilunjin/Desktop/Transportation_Simulator/simulator/simulator_env.py", line 1311, in step1
    df_new_matched_requests, df_update_wait_requests = self.update_info_after_matching_multi_process(matched_pair_actual_indexes,matched_itinerary)
  File "/Users/yilunjin/Desktop/Transportation_Simulator/simulator/simulator_env.py", line 250, in update_info_after_matching_multi_process
    self.avg_revenue_by_grid[indices] = gsum['designed_reward'].values
ValueError: shape mismatch: value array of shape (4,) could not be broadcast to indexing result of shape (1,)

That seems like a shape mismatch problem (maybe a bug). Could you take a look?

Caffretro commented 12 months ago

This error is related to a setting in config.py. You can modify the value of "side" from 4 to 10 in env_params. Sorry for the delayed reply.

Caffretro commented 12 months ago

Solved. This issue thread is also too long to keep track of. If there are new issues related to runtime errors, feel free to start a new issue thread.

GuangwenSi commented 2 weeks ago

I completely replicated the error mentioned above and made the necessary adjustments. Thank you so much! This is a monumental project, and if possible, I encourage the authors to create a group for communication and exchange. This would allow us to learn more about related knowledge. Additionally, I am an engineer working in this field, and I hope to help build a bridge between academic and industrial scenarios.