CPLEX不能正确替代等式吗?

时间:2016-07-10 06:56:28

标签: mathematical-optimization linear-programming cplex integer-programming

我是CPLEX的新手,我正在编写一个CPLEX不想满足的非常简单的模型。我知道我的模型是"详细"因为我的变量简单地等于其他变量,但这是我迈向更复杂模型的第一步,所以我想这样做。我不明白为什么会让CPLEX感到不安。

我的模特是:

Minimize
obj: v1
Subject To

l1: i_AB1 + i_AC1 - i_AB2 - i_AC3 = 1
l2: - i_AB1 + I_BB = 0
l3: I_CA + I_CC = 0


e5:   i_AB2 + i_BD2 - I_BB = 0

e8:   - i_AC1 - I_CA = 0
e9:   i_AC3 + i_CD3 - I_CC = 0


\Indicator constraints

\For each connection XY

c1:  bAB = 1-> i_AB1 - 1 v1 = 0
c2:  bAB = 1-> i_AB2 - 1 v2 = 0

c5:  bAC = 1-> i_AC1 - 1 v1 = 0
c6:  bAC = 1-> i_AC3 - 1 v3 = 0

c9:  bBD = 1-> i_BD2 - 1 v2 = 0

c13: bCD = 1-> i_CD3 - 1 v3 = 0

c15: bAB = 1
c16: bAC = 1
c17: bBD = 1
c18: bCD = 1


Bounds
    0 <= v1 <= 1000
-1000 <= v2 <= 1000
-1000 <= v3 <= 1000


General

Binaries
bAB bAC bBD bCD
End

这显然没有解决方案(确实如此,或者至少是我的意图,但CPLEX说没有!)。

然后我将等式e8替换为l3,我得到了我想要的解决方案! 这是代码:

Minimize
obj: v1
Subject To


\budget: 

l1: i_AB1 + i_AC1 - i_AB2 - i_AC3 = 1
l2: - i_AB1 + I_BB = 0
l3: - i_AC1  + I_CC = 0

e5:   i_AB2 + i_BD2 - I_BB = 0

\Row C
\e8:   - i_AC1 - I_CA = 0
e9:   i_AC3 + i_CD3 - I_CC = 0


\Indicator constraints

\For each connection XY

c1:  bAB = 1-> i_AB1 - 1 v1 = 0
c2:  bAB = 1-> i_AB2 - 1 v2 = 0

c5:  bAC = 1-> i_AC1 - 1 v1 = 0
c6:  bAC = 1-> i_AC3 - 1 v3 = 0

c9:  bBD = 1-> i_BD2 - 1 v2 = 0

c13: bCD = 1-> i_CD3 - 1 v3 = 0

c15: bAB = 1
c16: bAC = 1
c17: bBD = 1
c18: bCD = 1


Bounds
    0 <= v1 <= 1000
-1000 <= v2 <= 1000
-1000 <= v3 <= 1000


General

Binaries
bAB bAC bBD bCD
End

对我而言,两者都是完全相同的模型。我做错了什么,以便第一个模型没有解决方案,即使它看起来相当于第二个确实有解决方案?

顺便说一句,解决方案是:

Populate: phase I 
Tried aggregator 2 times.
MIP Presolve eliminated 4 rows and 4 columns.
Aggregator did 11 substitutions.
All rows and columns eliminated.
Presolve time =    0.00 sec.

Populate: phase II 
Solution status: 129.
Objective value of the incumbent: 1
Incumbent: Column v1:  Value =                 1
Incumbent: Column i_AB1:  Value =                 1
Incumbent: Column i_AC1:  Value =                 1
Incumbent: Column i_AB2:  Value =               0.5
Incumbent: Column i_AC3:  Value =               0.5
Incumbent: Column I_BB:  Value =                 1
Incumbent: Column I_CC:  Value =                 1
Incumbent: Column i_BD2:  Value =               0.5
Incumbent: Column i_CD3:  Value =               0.5
Incumbent: Column bAB:  Value =                 1
Incumbent: Column v2:  Value =               0.5
Incumbent: Column bAC:  Value =                 1
Incumbent: Column v3:  Value =               0.5
Incumbent: Column bBD:  Value =                 1
Incumbent: Column bCD:  Value =                 1

The solution pool contains 1 solutions.
0 solutions were removed due to the solution pool relative gap parameter.
In total, 1 solutions were generated.
The average objective value of the solutions is 1.

Solution        Objective   Number of variables
                value       that differ compared to
                            the incumbent
p1              1         0 / 15

问题本身甚至不是MIP(因为我在这个初始版本中修复了我的布尔值,但它将是一个合适的MIP)。这会改变什么吗? 我真的不知道这是什么问题。

谢谢

1 个答案:

答案 0 :(得分:1)

我认为问题是由于默认情况下I_CA的下限为0.在documentation for the LP format的Bounds部分中,它说

  

也可以单独输入上限和下限...默认下限为0(零),默认上限+∞保持有效,直到明确更改边界。

如果将I_CA free添加到第一个LP文件的bounds部分,则可行。