Created
September 14, 2020 17:39
-
-
Save AnishN/1e6c9042ecbafd47e546ffeddf24e2eb to your computer and use it in GitHub Desktop.
This file contains hidden or 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
cpdef float _cost(int[:] path, int length, float[:, :] time, float[:, :] cost): | |
cdef: | |
float final_cost = 0 | |
float time_sum = 0 | |
int count = 0 | |
int i = 0 | |
int p1, p2 | |
int p0 | |
p0 = path[0] | |
for i in range(length): | |
p1 = path[i] | |
p2 = path[i+1] | |
if time_sum < 8: | |
time_sum += time[p1][p2] | |
final_cost += cost[p1][p2] | |
else: | |
time_sum = time[p1][p0] + time[p0][p2] | |
final_cost += cost[p1][p0] + cost[p0][p2] | |
count +=1 | |
final_cost += cost[p0][path[length]] | |
return final_cost + count * 9.25 * 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment