cplex 冲突中get 的return 值5 是什么意思?

What does it mean the value 5 as the return of get in conflict of cplex?

我正在使用 cplex.conflict 解决问题,当我使用 cplex.conflict.refine 然后请求 cplex.conflict.get 它为某些约束提供值 5 (一个不可行的例子)。有谁知道这是什么意思? 这是 python 中的示例:

> python
Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cplex
>>> c = cplex.Cplex()
>>> c.variables.add(names = ["x0"])
>>> c.linear_constraints.add(lin_expr = [[[0], [-1.0]], [[0], [1.0]]], senses = "LL", rhs = [-10,9]) 
>>> c.conflict.refine(c.conflict.linear_constraints())
>>> c.conflict.get()
[5, 5]
>>> 

api仅指返回值-1、0或3。

c.conflict.get() 也可能 return conflict.constraint_type。在你的例子中,这两个约束是冲突的成员和 cplex returns 类型的约束:

>>> c.conflict.group_status[5]
None
>>> c.conflict.constraint_type[5]
SOS

也就是说,你的约束是 SOS 类型的,这很奇怪,因为 SOS 约束是针对整数变量(二进制)的。如果添加冗余约束,例如

>>> c.linear_constraints.add(lin_expr = [[[0], [-1.0]], [[0], [1.0]], \
[[0], [1.0]]], senses = "LLL", rhs = [-10,9,10]) 
>>> c.conflict.refine(c.conflict.linear_constraints()) 
[5, 5, -1]

意味着最后一个被排除在外,因为它不是冲突的成员。我建议您使用 c.conflict.get_groups() 获取更多信息。

编辑:

如果您在定义所有内容时指定变量的类型,则一切正常:

>>> c.variables.add(names = ["x0"], obj=[1.0], types=[c.variables.type.continuous])
...etc...
>>> c.conflict.refine(c.conflict.linear_constraints()) 
Refine conflict on 3 members...

Iteration  Max Members  Min Members
     1            2            0
     2            2            1
     3            2            2

[3, 3, -1]