Created
October 22, 2018 13:02
-
-
Save abduakhatov/b07721590de3d5c76c6d9de82ce1bbb6 to your computer and use it in GitHub Desktop.
check_vehicle_updates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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