我正在使用CPLEX 12.8.0,Python API上的混合整数二次编程(MIQP)。我为.lp文件生成了一个模型。原来,该模型是整数不可行的。这很奇怪,因为我之前用Gurobi产生了完全相同的问题,并且可以解决。

我在这里附加了指向.lp文件的链接,以及使用CPLEX和Gurobi求解的结果。我声明了一些半连续变量。我的目标函数是二次函数,但是我不认为这是导致整数不可行的原因,不是吗?最后,由于CPLEX可以执行某些功能,但我真的想在我的工作中使用CPLEX,但是Gurobi不能。

.lp文件:

Minimize
 obj: - wi0k0 - wi1k0 - wi2k0 - wi3k0 - wi0k1 - wi1k1 - wi2k1 - wi3k1 + [ m0 ^2
      + m1 ^2 + 1.54315034142201 loss0 ^2 + 1.54315034142201 loss1 ^2
      + 1.54315034142201 loss2 ^2 + 1.54315034142201 loss3 ^2 ] / 2
Subject To
 c1i0k0:  - 2.98563348744947 zi0k0 - ti0k0 <= 0
 c2i0k0:  - 1.33632173341833 zi0k0 + ti0k0 <= 0
 c3i0k0:  m0 + 1.33632173341833 zi0k0 - ti0k0 <= 1.33632173341833
 c4i0k0:  - m0 + 2.98563348744947 zi0k0 + ti0k0 <= 2.98563348744947
 c5i0k0:  - 2.30258509299405 zi0k0 - wi0k0 <= 0
 c6i0k0:  0.22314355131421 zi0k0 + wi0k0 <= 0
 c7i0k0:  v0 - 0.22314355131421 zi0k0 - wi0k0 <= -0.22314355131421
 c8i0k0:  - v0 + 2.30258509299405 zi0k0 + wi0k0 <= 2.30258509299405
 c1i1k0:  - 2.98563348744947 zi1k0 - ti1k0 <= 0
 c2i1k0:  - 1.33632173341833 zi1k0 + ti1k0 <= 0
 c3i1k0:  m0 + 1.33632173341833 zi1k0 - ti1k0 <= 1.33632173341833
 c4i1k0:  - m0 + 2.98563348744947 zi1k0 + ti1k0 <= 2.98563348744947
 c5i1k0:  - 2.30258509299405 zi1k0 - wi1k0 <= 0
 c6i1k0:  0.22314355131421 zi1k0 + wi1k0 <= 0
 c7i1k0:  v0 - 0.22314355131421 zi1k0 - wi1k0 <= -0.22314355131421
 c8i1k0:  - v0 + 2.30258509299405 zi1k0 + wi1k0 <= 2.30258509299405
 c1i2k0:  - 2.98563348744947 zi2k0 - ti2k0 <= 0
 c2i2k0:  - 1.33632173341833 zi2k0 + ti2k0 <= 0
 c3i2k0:  m0 + 1.33632173341833 zi2k0 - ti2k0 <= 1.33632173341833
 c4i2k0:  - m0 + 2.98563348744947 zi2k0 + ti2k0 <= 2.98563348744947
 c5i2k0:  - 2.30258509299405 zi2k0 - wi2k0 <= 0
 c6i2k0:  0.22314355131421 zi2k0 + wi2k0 <= 0
 c7i2k0:  v0 - 0.22314355131421 zi2k0 - wi2k0 <= -0.22314355131421
 c8i2k0:  - v0 + 2.30258509299405 zi2k0 + wi2k0 <= 2.30258509299405
 c1i3k0:  - 2.98563348744947 zi3k0 - ti3k0 <= 0
 c2i3k0:  - 1.33632173341833 zi3k0 + ti3k0 <= 0
 c3i3k0:  m0 + 1.33632173341833 zi3k0 - ti3k0 <= 1.33632173341833
 c4i3k0:  - m0 + 2.98563348744947 zi3k0 + ti3k0 <= 2.98563348744947
 c5i3k0:  - 2.30258509299405 zi3k0 - wi3k0 <= 0
 c6i3k0:  0.22314355131421 zi3k0 + wi3k0 <= 0
 c7i3k0:  v0 - 0.22314355131421 zi3k0 - wi3k0 <= -0.22314355131421
 c8i3k0:  - v0 + 2.30258509299405 zi3k0 + wi3k0 <= 2.30258509299405
 c9k0:    - pi0 + omk0j1 + omk0j2 + omk0j3 + omk0j4  = 0
 c10k0:   - v0 + 5.78057663816274 omk0j1 - 2.88064275681032 gk0j1
          + 2.81415134341597 omk0j2 - 2.06487580075496 gk0j2
          + 1.87716609698306 omk0j3 - 1.64323243986015 gk0j3
          + 1.41062901675158 omk0j4 - 1.35164676471547 gk0j4  = 0
 c11k0:   gk0j1 + gk0j2 + gk0j3 + gk0j4  = 1
 c12k0j1: - omk0j1 + 0.1 gk0j1 <= 0
 c13k0j1: omk0j1 - 0.275 gk0j1 <= 0
 c12k0j2: - omk0j2 + 0.275 gk0j2 <= 0
 c13k0j2: omk0j2 - 0.45 gk0j2 <= 0
 c12k0j3: - omk0j3 + 0.45 gk0j3 <= 0
 c13k0j3: omk0j3 - 0.625 gk0j3 <= 0
 c12k0j4: - omk0j4 + 0.625 gk0j4 <= 0
 c13k0j4: omk0j4 - 0.8 gk0j4 <= 0
 c14k0:   - 4 pi0 + zi0k0 + zi1k0 + zi2k0 + zi3k0  = 0
 c15k0:   1.33632173341833 zi0k0 - ti0k0 - 1.17708699624777 zi1k0 - ti1k0
          - 2.28656128473847 zi2k0 - ti2k0 - 2.98563348744947 zi3k0 - ti3k0
           = 0
 c1i0k1:  - 2.98563348744947 zi0k1 - ti0k1 <= 0
 c2i0k1:  - 1.33632173341833 zi0k1 + ti0k1 <= 0
 c3i0k1:  m1 + 1.33632173341833 zi0k1 - ti0k1 <= 1.33632173341833
 c4i0k1:  - m1 + 2.98563348744947 zi0k1 + ti0k1 <= 2.98563348744947
 c5i0k1:  - 2.30258509299405 zi0k1 - wi0k1 <= 0
 c6i0k1:  0.22314355131421 zi0k1 + wi0k1 <= 0
 c7i0k1:  v1 - 0.22314355131421 zi0k1 - wi0k1 <= -0.22314355131421
 c8i0k1:  - v1 + 2.30258509299405 zi0k1 + wi0k1 <= 2.30258509299405
 c1i1k1:  - 2.98563348744947 zi1k1 - ti1k1 <= 0
 c2i1k1:  - 1.33632173341833 zi1k1 + ti1k1 <= 0
 c3i1k1:  m1 + 1.33632173341833 zi1k1 - ti1k1 <= 1.33632173341833
 c4i1k1:  - m1 + 2.98563348744947 zi1k1 + ti1k1 <= 2.98563348744947
 c5i1k1:  - 2.30258509299405 zi1k1 - wi1k1 <= 0
 c6i1k1:  0.22314355131421 zi1k1 + wi1k1 <= 0
 c7i1k1:  v1 - 0.22314355131421 zi1k1 - wi1k1 <= -0.22314355131421
 c8i1k1:  - v1 + 2.30258509299405 zi1k1 + wi1k1 <= 2.30258509299405
 c1i2k1:  - 2.98563348744947 zi2k1 - ti2k1 <= 0
 c2i2k1:  - 1.33632173341833 zi2k1 + ti2k1 <= 0
 c3i2k1:  m1 + 1.33632173341833 zi2k1 - ti2k1 <= 1.33632173341833
 c4i2k1:  - m1 + 2.98563348744947 zi2k1 + ti2k1 <= 2.98563348744947
 c5i2k1:  - 2.30258509299405 zi2k1 - wi2k1 <= 0
 c6i2k1:  0.22314355131421 zi2k1 + wi2k1 <= 0
 c7i2k1:  v1 - 0.22314355131421 zi2k1 - wi2k1 <= -0.22314355131421
 c8i2k1:  - v1 + 2.30258509299405 zi2k1 + wi2k1 <= 2.30258509299405
 c1i3k1:  - 2.98563348744947 zi3k1 - ti3k1 <= 0
 c2i3k1:  - 1.33632173341833 zi3k1 + ti3k1 <= 0
 c3i3k1:  m1 + 1.33632173341833 zi3k1 - ti3k1 <= 1.33632173341833
 c4i3k1:  - m1 + 2.98563348744947 zi3k1 + ti3k1 <= 2.98563348744947
 c5i3k1:  - 2.30258509299405 zi3k1 - wi3k1 <= 0
 c6i3k1:  0.22314355131421 zi3k1 + wi3k1 <= 0
 c7i3k1:  v1 - 0.22314355131421 zi3k1 - wi3k1 <= -0.22314355131421
 c8i3k1:  - v1 + 2.30258509299405 zi3k1 + wi3k1 <= 2.30258509299405
 c9k1:    - pi1 + omk1j1 + omk1j2 + omk1j3 + omk1j4  = 0
 c10k1:   - v1 + 5.78057663816274 omk1j1 - 2.88064275681032 gk1j1
          + 2.81415134341597 omk1j2 - 2.06487580075496 gk1j2
          + 1.87716609698306 omk1j3 - 1.64323243986015 gk1j3
          + 1.41062901675158 omk1j4 - 1.35164676471547 gk1j4  = 0
 c11k1:   gk1j1 + gk1j2 + gk1j3 + gk1j4  = 1
 c12k1j1: - omk1j1 + 0.1 gk1j1 <= 0
 c13k1j1: omk1j1 - 0.275 gk1j1 <= 0
 c12k1j2: - omk1j2 + 0.275 gk1j2 <= 0
 c13k1j2: omk1j2 - 0.45 gk1j2 <= 0
 c12k1j3: - omk1j3 + 0.45 gk1j3 <= 0
 c13k1j3: omk1j3 - 0.625 gk1j3 <= 0
 c12k1j4: - omk1j4 + 0.625 gk1j4 <= 0
 c13k1j4: omk1j4 - 0.8 gk1j4 <= 0
 c14k1:   - 4 pi1 + zi0k1 + zi1k1 + zi2k1 + zi3k1  = 0
 c15k1:   1.33632173341833 zi0k1 - ti0k1 - 1.17708699624777 zi1k1 - ti1k1
          - 2.28656128473847 zi2k1 - ti2k1 - 2.98563348744947 zi3k1 - ti3k1
           = 0
 c16i0:   zi0k0 + zi0k1  = 1
 c16i1:   zi1k0 + zi1k1  = 1
 c16i2:   zi2k0 + zi2k1  = 1
 c16i3:   zi3k0 + zi3k1  = 1
 c17k0:   zi0k0 + zi1k0 + zi2k0 + zi3k0 >= 0.4
 c18k0:   zi0k0 + zi1k0 + zi2k0 + zi3k0 <= 3.2
 c17k1:   zi0k1 + zi1k1 + zi2k1 + zi3k1 >= 0.4
 c18k1:   zi0k1 + zi1k1 + zi2k1 + zi3k1 <= 3.2
 c21k0:   m0 - m1 <= 0
 c22:     pi0 + pi1  = 1
 c23i0:   ti0k0 + ti0k1 + loss0  = 1.33632173341833
 c23i1:   ti1k0 + ti1k1 + loss1  = -1.17708699624777
 c23i2:   ti2k0 + ti2k1 + loss2  = -2.28656128473847
 c23i3:   ti3k0 + ti3k1 + loss3  = -2.98563348744947
Bounds
 0.1 <= pi0 <= 0.8
-2.98563348744947 <= m0 <= 1.33632173341833
-2.30258509299405 <= v0 <= -0.22314355131421
 0 <= zi0k0 <= 1
-2.98563348744947 <= ti0k0 <= 1.33632173341833
-2.30258509299405 <= wi0k0 <= -0.22314355131421
 0 <= zi1k0 <= 1
-2.98563348744947 <= ti1k0 <= 1.33632173341833
-2.30258509299405 <= wi1k0 <= -0.22314355131421
 0 <= zi2k0 <= 1
-2.98563348744947 <= ti2k0 <= 1.33632173341833
-2.30258509299405 <= wi2k0 <= -0.22314355131421
 0 <= zi3k0 <= 1
-2.98563348744947 <= ti3k0 <= 1.33632173341833
-2.30258509299405 <= wi3k0 <= -0.22314355131421
 0.1 <= omk0j1 <= 0.8
 0 <= gk0j1 <= 1
 0.1 <= omk0j2 <= 0.8
 0 <= gk0j2 <= 1
 0.1 <= omk0j3 <= 0.8
 0 <= gk0j3 <= 1
 0.1 <= omk0j4 <= 0.8
 0 <= gk0j4 <= 1
 0.1 <= pi1 <= 0.8
-2.98563348744947 <= m1 <= 1.33632173341833
-2.30258509299405 <= v1 <= -0.22314355131421
 0 <= zi0k1 <= 1
-2.98563348744947 <= ti0k1 <= 1.33632173341833
-2.30258509299405 <= wi0k1 <= -0.22314355131421
 0 <= zi1k1 <= 1
-2.98563348744947 <= ti1k1 <= 1.33632173341833
-2.30258509299405 <= wi1k1 <= -0.22314355131421
 0 <= zi2k1 <= 1
-2.98563348744947 <= ti2k1 <= 1.33632173341833
-2.30258509299405 <= wi2k1 <= -0.22314355131421
 0 <= zi3k1 <= 1
-2.98563348744947 <= ti3k1 <= 1.33632173341833
-2.30258509299405 <= wi3k1 <= -0.22314355131421
 0.1 <= omk1j1 <= 0.8
 0 <= gk1j1 <= 1
 0.1 <= omk1j2 <= 0.8
 0 <= gk1j2 <= 1
 0.1 <= omk1j3 <= 0.8
 0 <= gk1j3 <= 1
 0.1 <= omk1j4 <= 0.8
 0 <= gk1j4 <= 1
 0 <= loss0 <= 4.3219552208678
-2.5134087296661 <= loss1 <= 1.80854649120169
-3.6228830181568 <= loss2 <= 0.699072202710996
-4.3219552208678 <= loss3 <= 0
Binaries
 zi0k0  zi1k0  zi2k0  zi3k0  gk0j1  gk0j2  gk0j3  gk0j4  zi0k1  zi1k1  zi2k1
 zi3k1  gk1j1  gk1j2  gk1j3  gk1j4
Semi-Continuous
 ti0k0  wi0k0  ti1k0  wi1k0  ti2k0  wi2k0  ti3k0  wi3k0  omk0j1  omk0j2
 omk0j3  omk0j4  ti0k1  wi0k1  ti1k1  wi1k1  ti2k1  wi2k1  ti3k1  wi3k1
 omk1j1  omk1j2  omk1j3  omk1j4
End

Gurobi在这里可以求解模型,但CPLEX不能求解。

CPLEX输出:

cplex - CPLEX无法解决Gurobi可以解决的.lp文件-LMLPHP

Gurobi输出:

cplex - CPLEX无法解决Gurobi可以解决的.lp文件-LMLPHP

最佳答案

除了我在其他答案中提到的怪异(无法编辑我的答案,因为我未在此处注册)之外,CPLEX的LP文件实际上是错误的。如果您查看https://www.ibm.com/support/knowledgecenter/SSSA5P_12.8.0/ilog.odms.cplex.help/CPLEX/UsrMan/topics/discr_optim/semi_cont_var/02_SemiCont_defn.html,则可以阅读

半连续下限(sclb)必须大于或等于
到0(零)。尝试将负值用于
半连续下限(sclb)将导致该界限为
视为0(零)。

因此,“0或负数”的半连续变量可能会导致模型不可行,因为它们的下限设置为0,从而导致变量的界线矛盾。

您必须将这些变量乘以-1,以便它们变为“0或在正范围内”。

关于cplex - CPLEX无法解决Gurobi可以解决的.lp文件,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/54819352/

10-11 22:53