Open Dong-Jie-Chen opened 9 months ago
Hi, thank you for sharing your codes! Could you please share how to get or generate od_distinct_route.json files? They are used in train_gan.py and train_region_gan.py
Hello, I believe some files are missing from this code, which is causing the failure to generate the od_distinct_route.json file. I tried to reconstruct the file generation code based on other parts of the code and achieved similar results in the model reproduction. I guess it might be correct.
Try this
import json
# read csv
df = pd.read_csv('./data/BJ-Taxi/BJ_Taxi_201511_trajectory.csv')
# load dict from JSON file
with open('./data/BJ-Taxi/rid_gps.json', 'r') as f:
rid_gps = json.load(f)
# init dict
od_route = {}
for index, row in df.iterrows():
rid_list = [x for x in row['rid_list'].split(',') if x != '000']
origin = rid_list[0] # get origin
des = rid_list[-1] # get des
GPS_list=[rid_gps[x] for x in rid_list]
od_key = '{}-{}'.format(origin, des)
if od_key not in od_route:
od_route[od_key] = [GPS_list]
else:
od_route[od_key].append(GPS_list)
json_file_path = './data/BJ-Taxi/od_distinct_route.json'
# output json
with open(json_file_path, 'w') as json_file:
json.dump(od_route, json_file) ```
Hi, thank you for sharing your codes! Could you please share how to get or generate od_distinct_route.json files? They are used in train_gan.py and train_region_gan.py