gpt4 book ai didi

CPLEX 无法求解 Gurobi 可以求解的 .lp 文件

转载 作者:行者123 更新时间:2023-12-01 19:34:33 46 4
gpt4 key购买 nike

我正在 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 output

Gurobi 输出:

Gurobi output

最佳答案

我认为您的 LP 文件规范有误。例如,你有

-2.98563348744947 <= ti0k0 <= 1.33632173341833

但同时ti0k0被标记为“半连续”。那是什么意思? “半连续”表示“必须为 0 或在指定范围内”。如果指定的边界包括 0,则变量可能只是半连续的。它有助于解决这个问题吗?

我不确定 Gurobi 对这样的变量做了什么。如果您使用 Gurobi 读取 LP,然后将其写出并将新创建的 LP 文件提供给 CPLEX,会发生什么情况?您是否检查过 Gurobi 提供的解决方案实际上是否满足您的所有约束条件?

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

46 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com