Gurobi LP文件语法

时间:2017-03-01 16:48:42

标签: gurobi

我尝试使用GurobiTM Optimizer。请在下面找到我的QP模型:

Gurobi Parallel Mixed Integer Programming求解器最常解决的问题是: 目标:最小化cT x 约束:A x = b(线性约束) l≤x≤u(约束约束) 部分或全部xj必须采用整数值(完整性约束)

Maximize
  - x1 + .5 x2 + .5 x3 + x4 - x5 + .5 x6 + .5 x7 - x8
  - .17 x1 * x2 + .66 * x1 * x3  + .66  x1 * x4
  + .56 x2 * x3 + .49 x2 * x4
  - .17 x5 * x6 + .82 x5 * x7 + .66 x5 * x8
  + .16  x6 * x7 + .49 x6 * x8
Subject To
  c1: x1 + x5 <=1
  c2: x2 + x6 <=1,
  c3: x3 + x7 <=1
  c4: x4 + x8 <=1,
  c5: x1 + x2 + x3 + x4 <= 2
  c6: x5 + x6 + x7 + x8 <= 2
Bounds
 0 <= x1 <= 1
 0 <= x2 <= 1
 0 <= x3 <= 1
 0 <= x4 <= 1
 0 <= x5 <= 1
 0 <= x6 <= 1
 0 <= x7 <= 1
 0 <= x8 <= 1
Integers
  PS PD JS JD AS AD MS MD
End


It seems that according to Gurobi Interactive Shell the syntax is not correct :

Error reading LP format file /.../toyproblem.lp at line 2
Malformed term in expression
Neighboring tokens: " - .17 x1 * x2 + .66 * x1 * "

有什么想法吗?

先谢谢你的帮助,

MM。

2 个答案:

答案 0 :(得分:0)

这不是一个线性程序(LP) - 它是一个不是以标准形式编写的二次程序(QP)。另外,编写二进制变量的产品是非常糟糕的形式;你应该引入新的二进制变量来表示逻辑条件。例如,将w1 * w2替换为新变量z,约束为z <= w1,z&lt; = w2,z&gt; = w1 + w2 - 1.

答案 1 :(得分:0)

错误发生在第三行:      - .17 x1 * x2 + .66 * x1 * x3 + .66 x1 * x4 它应该是:      - .17 x1 * x2 + .66 x1 * x3 + .66 x1 * x4而不是

记录。 Gurobi确实处理QP,它称之为单纯形......虽然我们知道它并不是真正意义上的单纯形。他们使用了一些名为&#34; active-set methods&#34;

的东西

您可能想在Google群组中发帖提问。他们在一天之内回答:)