【发布时间】:2020-04-14 12:36:20
【问题描述】:
我正在尝试使用 cplex 来解决 LP 优化问题。 (在 python 中使用 cvxpy)
根据我对问题的约束,cplex 求解器有时无法找到解决方案。当提供verbose=True 时,我想要一些关于如何读取求解器输出的直觉。
例如,我得到这个:
Version identifier: 12.10.0.0 | 2019-11-26 | 843d4de
CPXPARAM_Read_DataCheck 1
CPXPARAM_Preprocessing_QCPDuals 2
Found incumbent of value 0.000000 after 0.00 sec. (0.08 ticks)
Tried aggregator 2 times.
MIP Presolve eliminated 4726 rows and 353 columns.
MIP Presolve modified 1008 coefficients.
Aggregator did 3 substitutions.
Reduced MIP has 1669 rows, 1670 columns, and 4505 nonzeros.
Reduced MIP has 1168 binaries, 0 generals, 0 SOSs, and 0 indicators.
Presolve time = 0.04 sec. (5.22 ticks)
Probing fixed 0 vars, tightened 2 bounds.
Probing time = 0.01 sec. (0.85 ticks)
Tried aggregator 1 time.
Detecting symmetries...
MIP Presolve modified 2 coefficients.
Reduced MIP has 1669 rows, 1670 columns, and 4505 nonzeros.
Reduced MIP has 1168 binaries, 0 generals, 0 SOSs, and 0 indicators.
Presolve time = 0.03 sec. (3.10 ticks)
Probing time = 0.01 sec. (0.90 ticks)
Clique table members: 2327.
MIP emphasis: balance optimality and feasibility.
MIP search method: dynamic search.
Parallel mode: deterministic, using up to 4 threads.
Root relaxation solution time = 0.01 sec. (5.82 ticks)
Nodes Cuts/
Node Left Objective IInf Best Integer Best Bound ItCnt Gap
* 0+ 0 0.0000 -325889.6000 ---
0 0 -23545.7611 333 0.0000 -23545.7611 723 ---
* 0+ 0 -15240.4400 -23545.7611 54.50%
0 0 -21360.6115 333 -15240.4400 Cuts: 333 1063 40.16%
* 0+ 0 -20698.8800 -21360.6115 3.20%
0 0 -21120.8531 333 -20698.8800 Cuts: 268 1232 2.04%
* 0+ 0 -20751.6200 -21120.8531 1.78%
0 0 -21057.6246 333 -20751.6200 Cuts: 92 1322 1.47%
* 0+ 0 -20843.7200 -21057.6246 1.03%
0 0 -21023.5211 333 -20843.7200 Cuts: 90 1397 0.86%
0 0 -20983.6905 333 -20843.7200 Cuts: 57 1440 0.67%
* 0+ 0 -20877.4400 -20983.6905 0.51%
Detecting symmetries...
0 0 -20972.8355 333 -20877.4400 Cuts: 13 1449 0.46%
* 0+ 0 -20878.2600 -20972.8355 0.45%
0 0 -20970.0341 333 -20878.2600 Cuts: 19 1460 0.44%
0 0 -20969.6020 333 -20878.2600 Cuts: 10 1471 0.44%
0 0 -20969.2988 333 -20878.2600 MIRcuts: 4 1476 0.44%
0 0 -20959.2311 333 -20878.2600 Cuts: 9 1483 0.39%
* 0+ 0 -20935.7200 -20959.2311 0.11%
0 0 -20958.0881 333 -20935.7200 Cuts: 15 1500 0.11%
* 0+ 0 -20935.7200 -20958.0881 0.11%
Detecting symmetries...
Repeating presolve.
Tried aggregator 2 times.
MIP Presolve eliminated 1039 rows and 925 columns.
MIP Presolve modified 62 coefficients.
Aggregator did 102 substitutions.
Reduced MIP has 528 rows, 639 columns, and 1468 nonzeros.
Reduced MIP has 526 binaries, 0 generals, 0 SOSs, and 0 indicators.
Presolve time = 0.04 sec. (2.78 ticks)
Probing fixed 0 vars, tightened 18 bounds.
Probing time = 0.00 sec. (0.36 ticks)
Tried aggregator 2 times.
MIP Presolve eliminated 241 rows and 308 columns.
MIP Presolve modified 23 coefficients.
Aggregator did 2 substitutions.
Reduced MIP has 285 rows, 329 columns, and 792 nonzeros.
Reduced MIP has 261 binaries, 0 generals, 0 SOSs, and 0 indicators.
Presolve time = 0.01 sec. (0.68 ticks)
Probing fixed 0 vars, tightened 1 bounds.
Probing time = 0.01 sec. (0.18 ticks)
Tried aggregator 1 time.
Detecting symmetries...
MIP Presolve modified 1 coefficients.
Reduced MIP has 285 rows, 329 columns, and 792 nonzeros.
Reduced MIP has 261 binaries, 0 generals, 0 SOSs, and 0 indicators.
Presolve time = 0.03 sec. (0.58 ticks)
Represolve time = 0.18 sec. (19.83 ticks)
Probing time = 0.00 sec. (0.18 ticks)
Clique table members: 547.
MIP emphasis: balance optimality and feasibility.
MIP search method: dynamic search.
Parallel mode: deterministic, using up to 4 threads.
Root relaxation solution time = 0.00 sec. (1.32 ticks)
Nodes Cuts/
Node Left Objective IInf Best Integer Best Bound ItCnt Gap
* 0+ 0 -20935.7200 -20949.2232 0.06%
0 0 -20950.6138 31 -20935.7200 -20949.2232 1635 0.06%
0 0 -20946.9943 31 -20935.7200 Cuts: 27 1650 0.05%
0 0 -20946.9195 31 -20935.7200 MIRcuts: 4 1653 0.05%
0 0 -20945.8979 31 -20935.7200 Cuts: 11 1658 0.05%
0 0 -20945.8979 31 -20935.7200 Flowcuts: 2 1659 0.05%
0 0 -20945.8979 31 -20935.7200 Flowcuts: 1 1663 0.05%
Detecting symmetries...
Clique cuts applied: 10
Implied bound cuts applied: 3
Flow cuts applied: 35
Mixed integer rounding cuts applied: 37
Lift and project cuts applied: 3
Gomory fractional cuts applied: 1
Root node processing (before b&c):
Real time = 1.34 sec. (232.86 ticks)
Parallel b&c, 4 threads:
Real time = 0.00 sec. (0.00 ticks)
Sync time (average) = 0.00 sec.
Wait time (average) = 0.00 sec.
------------
Total (root+branch&cut) = 1.34 sec. (232.86 ticks)
从给定的运行。我从this 知道如何将参数通过 cvxpy 传递到 cplex,但是读取求解器的输出并不能帮助我确定求解器是否由于内存问题而失败,或数字问题或任何类似的问题,并因此调整参数。 我还想指出,我使用的约束集很大(每个数据点可以达到 34 个),但求解器在非常小的数据帧(只有 24 个点)上仍然失败
有什么可以帮助我的建议/材料吗?
非常感谢!
【问题讨论】:
-
最简单的方法是将模型导出到文件(最好是 SAV),然后使用交互式 CPLEX 优化器进行调查。在那里您可以运行冲突优化器来查找冲突。
-
谢谢,我要试试 :)
-
你没有说求解器多久失败。它会很快失败,还是在(长时间)后失败?您从日志文件中得到什么 - 您在上面给出的摘录表明问题是可行的,并且求解器已经找到了解决方案。当求解器失败时,你没有得到任何日志吗?您能否发布更多关于求解器失败时会发生什么的信息。
-
它失败的速度相对较快(仅几秒钟),但从
~/.virtualenvs/tomorrow/lib/python3.7/site-packages/cvxpy/problems/problem.py in unpack_results(self, solution, chain, inverse_data) 716 raise error.SolverError( 717 "Solver '%s' failed. " % chain.solver.name() + --> 718 "Try another solver, or solve with verbose=True for more " 719 "information.") 720 self.unpack(solution)引发的异常由求解器返回状态solver_error触发