Skip to content

Instantly share code, notes, and snippets.

@abduakhatov
Created October 22, 2018 13:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abduakhatov/b07721590de3d5c76c6d9de82ce1bbb6 to your computer and use it in GitHub Desktop.
Save abduakhatov/b07721590de3d5c76c6d9de82ce1bbb6 to your computer and use it in GitHub Desktop.
check_vehicle_updates
# Alternative to existing logic of
# chech_vehicle_updates
def check_vehicle_updates(dict_simulation_result, current_time):
print('>>> check_vehicle_updates')
cars_free = 0
try:
keys = list(dict_simulation_result)
keys.reverse()
for key in keys:
tmp_arr = np.array(dict_simulation_result[key]['dispatch_finish_time'])
dict_simulation_result[key]['dispatch_finish_time'] = tmp_arr[tmp_arr > current_time].tolist()
count = len(tmp_arr[tmp_arr <= current_time])
cars_free += count
except IndxeError:
return cars_free
except ValueError:
return cars_free
return cars_free
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment