How to find is any truck share same edge in same time?
回答済みHello,
This is just a continuation of the question How to model all truck the same speed in a path?
ensure is any trucks share the same road segment will make platoon (at the same time, same edge, same segment)
the equation below
\[\begin{equation}
\sum_{e_{ij}\in E}^{k}{\ x_{i,j,t\ }^k==\ \sum_{e_{ij\ \in\ E}}^{w}{\ x_{i,j,t\ }^w\rightarrow\ \ \ q_{i,j}^{k,w}\ =1}}
\end{equation}\]
\(q_{i,j}^{k,w}\) Set a binary variable is true if tuck k and w on platoon on edge \(e_{ij}\)
My code has SyntaxError
set_time =[1000, 700, 802, 905, 770, 800, 850, 500]
tim_truck = {}
for k in trucks:
tim_truck[k] = mdl.addVars(location, set_time, vtype=GRB.BINARY, name="locate_"+str(k)+"_")
platoon = mdl.addVar(vtype= GRB.BINARY, name="platoon")
mdl.addConstrs( gp.quicksum( tim_truck[k][l[0],l[1],t] for t in set_time for k in trucks ) == gp.quicksum( tim_truck[w][l[0],l[1],t] for t in set_time for w in trucks ) if k != w for l in location >> platoon = 0)
Thank you
-
正式なコメント
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?. -
Hi John,
You are trying to use an indicator constraint. However, indicator constraints are used to state that
\[b=1 \rightarrow a^T x \leq b\]
meaning that if a binary variable \(b\) equals 1 then the linear constraint \(a^T x \leq b\) should hold, see the documentation of indicator constraints. In your case, the first statement reads \(y = z\) with \(y=\sum x_{i,j,t}^k, z=\sum_{i,j,t}^w}) which does not fit the indicator constraint syntax.
What you are looking for is described in the stackoverflow post Converting conditional constraints to linear constraints in Linear Programming.
Best regards,
Jaromił0
投稿コメントは受け付けていません。
コメント
2件のコメント