How do I handle the following logic?
Dear Gurobi Teams,
I am working on a project in Python, But I have a problem with logic.
Where m is the known number, a[I], x1, x2, x3 are integer variables, and y[I] is binary variable. So far my approach is as follows.
a5 = model.addVars(numb, vtype=GRB.INTEGER) #auxiliary variable
a6 = model.addVars(numb, vtype=GRB.INTEGER) #auxiliary variable
a51 = model.addVars(numb, vtype=GRB.INTEGER) #auxiliary variable
a61 = model.addVars(numb, vtype=GRB.INTEGER) #auxiliary variable
a81 = model.addVars(numb, vtype=GRB.INTEGER) #auxiliary variable
a82 = model.addVars(numb, vtype=GRB.INTEGER) #auxiliary variable
obj = gb.quicksum(x3[i] + (a5[i] + a6[i]) for i in numb )
model.addConstrs((a5[i] == 0)>>(m <= a[i]) for i in numb )
model.addConstrs((a6[i]== 0)>>(a[i] <= m+1 for i in numb))
model.addConstrs(a51[i] == 1-a5[i] for i in numb )
model.addConstrs(a61[i] == 1-a6[i] for i in numb )
model.addConstrs(y[i] == gp.and_(a51[i],a61[i]) for i in numb)
model.addConstrs((y[0]) >> (x1[0]==x2[0] )
model.addConstrs(a81[i] == gp.and_(y[i],y[i-1]) for i in numb if i>0)
model.addConstrs(a82[i] == gp.or_(y[i],y[i-1]) for i in numb if i>0)
model.addConstrs(x1[i]==(1-a81[i])*x2[i]+x3[i]+(a82[i]-1)*(x3[i]+x2[i]-x1[i])for i in numb if i>0)
In this way there are parts of a[i] and x1 [i] that are constrained, but the other parts are both 0.
HELP ME PLEASE
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?.
Post is closed for comments.
Comments
1 comment