How to program correctly a list with list comprehension including if-statement ?
AnsweredI have n=4 and P = [1,2,3,4] , plus the next dictionnaries
d1= {m+10: 0 for m in range(12)}
d = {0:0, 1:15,2:30,3:15,4:30,5:15,6:30,7:15,8:30,9:0,**d1}
c = {(i,j): np.round(np.hypot(xc[i]-xc[j], yc[i]-yc[j])) for i in N for j in N }
t = {a : np.round (c[a] / v) for a in c } # distance over velocity 60km/h
L = { i: t[i,n+i]*2 for i in P}
infeasible-path1 = [(i, n+j) for i in P for j in P if d[j] + t[j,i] + d[i] + t[i,(n+j)] + d[n+j] + t[n+j, n+i] + d[n+i] > L[i]]
'''
When I try to print(len(infeasible-path1)), it gives me SyntaxError: can't assign to the operator.?????!!!!!!
An additional issue is how can I write in the coding mode? .......can not see any icon or a sign for that.
0
-
Official comment
This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum. Or why not try our AI Gurobot?. -
I caught my mistake, infeasible-path1 should be infeasible_path1
Thanks a lot.
0
Post is closed for comments.
Comments
2 comments