[英]Cplex giving wrong result
I created a sample test.lp
file as follows:我创建了一个示例
test.lp
文件,如下所示:
Maximize
y
Subject To
+x1+100M+3M2+x4-y+A=0
x1-M-M2-10x4>=-20
x1 - 3 M + M2 <= 100
M - 3.5 x4 + M2= 0
A+x1<=140
Bounds
x1<= 40
2 <= x4 <= 3
0<=x1
Binary
M
Integer
A
End
Used all default settings, and the following commands: read test.lp
-> opt
-> d sol v -
使用所有默认设置和以下命令:
read test.lp
-> opt
-> d sol v -
Result is:结果是:
Variable Name Solution Value
y 172.500000
x1 40.000000
M 1.000000
M2 9.500000
x4 3.000000
A 1.000000
However, the result should be y=271.5
and A=100
, the value of other variables seems okay.但是,结果应该是
y=271.5
和A=100
,其他变量的值似乎还可以。
This is also tested with google OR-Tools ( SCIP solver), which gives proper results.这也使用google OR-Tools ( SCIP求解器) 进行了测试,它给出了正确的结果。
What did I miss?我错过了什么?
If you change如果你改变
Integer
A
End
into进入
Generals
A
End
you ll get the right solution你会得到正确的解决方案
Integer
(or Integers
, or Int
, or Ints
) is a keyword in LP file that's been deprecated since a very long time (probably after CPLEX V4.0, in 1995). Integer
(或Integers
或Int
或Ints
)是 LP 文件中的一个关键字,该关键字已被弃用了很长时间(可能在 1995 年的 CPLEX V4.0 之后)。 It was kept in the code only for compatibility with old LP files, and will not be used by CPLEX when writing an LP file.它保留在代码中只是为了与旧 LP 文件兼容,CPLEX 在编写 LP 文件时不会使用它。
It used to work as follows.它曾经按如下方式工作。 If the bound of the variable was specified, then the variable is a general integer.
如果指定了变量的界限,则该变量是一般的 integer。 If the bound was not specified, then the variable is binary.
如果未指定边界,则变量是二进制的。
In your case, as A
doesn't appear in the Bounds
section, it is considered a binary variable.在您的情况下,由于
A
未出现在Bounds
部分中,因此它被视为二进制变量。 And indeed the value it has in the solution computed by CPLEX is coherent with this.事实上,它在 CPLEX 计算的解中的值与此一致。
Using display problem all
in the CPLEX Interactive will show the whole problem as it's known to CPLEX.在 CPLEX Interactive 中使用
display problem all
将显示 CPLEX 已知的整个问题。 In your case, this ends with在您的情况下,这以
[...]
Bounds
0 <= x1 <= 40
0 <= M <= 1
2 <= x4 <= 3
0 <= A <= 1
All other variables are >= 0.
Binaries
M A
You can see how CPLEX considers A
to be a binary variable.您可以看到 CPLEX 如何将
A
视为二元变量。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.