Conditional Constraint issue
x is a binary variable defined over time slots k
y is a binary variable defined over time slots k
if the value of x change from time slot k to time slot k+1, the value of y in timeslot k will be 1, otherwise it will be 0
I added the following code where K is the set of timeslots and k is an individual timeslot
for k in K:
model.addConstr((y[k]==1) >> (x[k]+x[K[K.index(k)+1]]==1))
model.addConstr((y[k]==0) >> (x[k]-x[K[K.index(k)+1]]==0))
There are separate constraints for variable x and even though i am optimizing the model to minimize on a certain function x, Gurobi is setting all the values of y = 0 and thereby not minimizing that function of x. If i take out these constraints, I am getting the expected result. Am I doing something wrong?
-
正式なコメント
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?.
投稿コメントは受け付けていません。
コメント
1件のコメント