0

我已经模拟了 MILP 问题。

执行代码时

m.Optimize()

输出如下所示:

Optimize a model with 798001 rows, 312006 columns and 2117780 nonzeros
Variable types: 1920 continuous, 310086 integer (310080 binary)
Coefficient statistics:
 Matrix range [3e-01, 2e+04]
 Objective range [1e-01, 9e+02]
 Bounds range [1e+00, 3e+04]
 RHS range [3e-01, 3e+04]
Presolve removed 725090 rows and 191031 columns
Presolve time: 3.22s

Explored 0 nodes (0 simplex iterations) in 3.59 seconds
Thread count was 1 (of 8 available processors)

Solution count 0

Model is infeasible
Best objective -, best bound -, gap -

但是当执行下面的代码时:

copy1 = m.copy()

if m.status == GRB.INFEASIBLE:
 copy1.feasRelaxS(1, True, False, True)
 copy1.optimize()

输出如下所示:

Solve phase I feasrelax model to determine minimal relaxation

Optimize a model with 798001 rows, 1114022 columns and 2919796 nonzeros
Model has 802016 quadratic objective terms
Variable types: 803936 continuous, 310086 integer (310080 binary)
Coefficient statistics:
  Matrix range     [3e-01, 2e+04]
  Objective range  [0e+00, 0e+00]
  QObjective range [2e+00, 2e+00]
  Bounds range     [1e+00, 3e+04]
  RHS range        [3e-01, 3e+04]
Found heuristic solution: objective 3.175944e+24
Presolve removed 1620 rows and 64056 columns (presolve time = 6s) ...
Presolve removed 1620 rows and 64056 columns
Presolve time: 5.59s
Presolved: 796381 rows, 1049966 columns, 2909656 nonzeros
Presolved model has 800396 quadratic objective terms
Found heuristic solution: objective 3.169464e+24
Variable types: 802316 continuous, 247650 integer (247650 binary)

在这里它指定模型具有二次目标项。

有人可以指导我这两者之间到底有什么区别吗?为什么它给模型有二次项?

4

1 回答 1

1

feasRelaxS用参数调用(1, True, False, True)文档说:

feasRelaxS (relaxobjtype, minrelax, vrelax, crelax)

如果您指定relaxobjtype=1,则可行性松弛的目标是最小化边界和约束违规的平方和。

所以平方和不是线性的,Gurobi 需要使用一些非线性求解方法。如果是 QP 或 SOCP 或其他什么,那是 Gurobi 的决定。

这是引入这些二次项的地方:边界和约束违规的平方和

输出:

Found heuristic solution: objective 3.169464e+24

看起来你的模型离可行还很远,我会说。

编辑:也许不是。作为非 Gurobi 用户,我印象深刻,这就是最终结果。但是你削减了你的输出,这只是一个早期的启发式结果,我们现在不能对未知的最终结果说太多!

doc-sentence 回答了关于它在做什么的一般问题:

可行性松弛是一个模型,当求解时,最小化解决方案违反原始模型的边界和线性约束的数量

含义:你不再关心你原来的目标,而是关心一个新的目标,它表达了一些解决方案在违反约束和变量界限方面有多糟糕。

(旁注:所有这些都在文档中进行了解释,老实说:在我看来,与某些竞争对手相比,Gurobi 的文档非常好!所以使用它,不要在不知道函数在做什么的情况下调用函数)

于 2018-10-13T10:11:15.377 回答