I have the following constraint set in the mathematical notation of Gurobi. x
variables are binary. sigmaplus
and sigmaminus
variables are positive and continuous.
Subject To
858 x[1,_2] + 1092 x[1,_3] - sigmaplus[1] + sigmaminus[1] = -200 # Constraint 1
858 x[1,_2] + 1092 x[1,_3] >= -1800 # Constraint 2
858 x[1,_2] + 1092 x[1,_3] <= 0 # Constraint 3
x[1,_2] + x[1,_3] = 1 # Constraint 4
720 x[2,_1] + 990 x[2,_2] - sigmaplus[2] + sigmaminus[2] = 2000 # Constraint 5
720 x[2,_1] + 990 x[2,_2] >= -500 # Constraint 6
720 x[2,_1] + 990 x[2,_2] <= 3000 # Constraint 7
x[2,_1] + x[2,_2] = 1 # Constraint 8
...
...
As you can notice, constraint 2
and constraint 3
make the solution infeasible. When, such a situation occurs with my x
variables, I want Gurobi to do the optimization by setting those conflicting x
values equal to 0. So, for this example, I want x[1,2]
and x[1,3]
to be equal to 0 in order to find a feasible solution without those variables. Is there any way to code this for Gurobi 7.0.2
.
Also, I am using 2.7.12 Anaconda 4.2.0(64-bit)
. Following is the code that I use for relaxing the problem to find a solution.
if m.status == GRB.INFEASIBLE:
m.feasRelaxS(1, False, False, True)
This works fine in some situation. I mean, it sets those infeasibility creating variables to 0. However, in some other cases where constraints 1,2,
and 3
do not create any infeasibility, constraint 4
creates an infeasibility, the solver increases the right-hand side of Constraint 4
. So, I need to find a way to set them 0 in such cases. Any suggestion appreciated.