0

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.

4

1 回答 1

2
feasRelaxS ( relaxobjtype, minrelax, vrelax, crelax )

论据:

Relaxobjtype:找到最小成本松弛时使用的成本函数。

minrelax:要执行的可行性放松类型。

vrelax:表示是否可以放宽变量界限。

crelax:指示是否可以放松约束。

此函数修改模型对象以创建可行性松弛。此方法提供了许多用于指定松弛的选项。minrelax参数是一个布尔值,用于控制所创建的可行性松弛类型如果minrelax = False,则优化返回的模型会给出一个使违规成本最小化的解决方案。如果minrelax = True,则优化返回的模型会找到一个使原始目标最小化的解决方案,但只能从那些使违规成本最小化的解决方案中找到。如果您希望模型放松约束不可行的变量值,请将 vrelax从 False 更改为 True。您可以阅读以下内容的完整说明:https://www.gurobi.com/documentation/7.5/refman/py_model_feasrelaxs.html

于 2018-05-11T23:24:37.347 回答