Can integer programming problem with non-continuous feasible region be solved with Gurobi?
AnsweredHello, I'm looking for a suitable and easy-to-use solver for the specific problem below.
Can the problem be formulated with gurobi solver?
Minimize (int) x
s.t. x - a >= 0 (where a is a scalar given in the problem)
where feasible region for x is a bounded and non-continuous("jump") integer space such as [1,2,3,4,8,9,10,11,18,19,20].
-
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 try Gurobot, our chatbot interface offering instant, expert-level support. -
Hi Hyewook,
yes, this is possible, with the help of a few indicator constraints and variables. Perhaps this post will give you an idea.
Best regards,
Jonasz0 -
Thank you for a help, and sorry for a late reply.
I certainly got an idea from the post above that adding extra binary variables(z) can implement 'Or constraints', such as 'less than n1 Or greater than n2'.
Now, I'm struggling with how to utilize this idea to present choose-one-of-numerous-'And constraints' problem like my original question.
As written above, x should be between either one of (1<=x<=4) or (8<=x<=11) or (18<=x<=20) ranges.
And adding binary variable might help the solver to choose one of these 3 between-ranges.
But I'm still middle of figuring out how to implement 'And constraints' (e.g. greater than 1 and less than 4).
Best regards,
HW
0 -
Hi Hyewook,
the "And" part is governed by adding two indicator constraints for each indicator variable. For example:
z[i, 1] = m.addVar(vtype="B",name=f"indicator_{i}_1")
z[i, 2] = m.addVar(vtype="B",name=f"indicator_{i}_2")
z[i, 3] = m.addVar(vtype="B",name=f"indicator_{i}_3")
m.addLConstr(z[i, 1] + z[i, 2] + z[i, 3] == 1)
m.addGenConstrIndicator(z[i, 1], True, x, gp.GRB.GREATER_EQUAL, 1.0)
m.addGenConstrIndicator(z[i, 1], True, x, gp.GRB.LESS_EQUAL, 4.0)
m.addGenConstrIndicator(z[i, 2], True, x, gp.GRB.GREATER_EQUAL, 8.0)
m.addGenConstrIndicator(z[i, 2], True, x, gp.GRB.LESS_EQUAL, 11.0)
m.addGenConstrIndicator(z[i, 3], True, x, gp.GRB.GREATER_EQUAL, 18.0)
m.addGenConstrIndicator(z[i, 3], True, x, gp.GRB.LESS_EQUAL, 20.0)Hope this helps.
Best regards
Jonasz0
Post is closed for comments.
Comments
4 comments