Солвер "CPLEX" не удалось. Предложение параметров - PullRequest
0 голосов
/ 14 апреля 2020

Я пытаюсь использовать 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 точки)

Любой предложения / материалы, которые могут мне помочь?

Большое спасибо!

1 Ответ

0 голосов
/ 14 апреля 2020

Вы можете использовать статус. Позвольте мне использовать пример шины .

# Import packages.
import cvxpy as cp


# Define and solve the CVXPY problem.
nbBus40 = cp.Variable(integer=True)
nbBus30 = cp.Variable( integer=True)
cost = 500*nbBus40+400*nbBus30
prob = cp.Problem(cp.Minimize(cost),[40*nbBus40+30*nbBus30>=300,
                                     nbBus40>=0,nbBus30>=0
                                     ])

prob.solve(solver=cp.CPLEX,verbose=True)

print("status = ",prob.status)

# Print result.
print("\nThe minimal cost is", prob.value)

print("number buses 40 seats = ",nbBus40.value)
print("number buses 30 seats = ",nbBus30.value)

дает

status =  optimal

The minimal cost is 3800.0
number buses 40 seats =  6.0
number buses 30 seats =  2.0

, тогда как если мы изменим ограничение на

prob = cp.Problem(cp.Minimize(cost),[40*nbBus40+30*nbBus30>=300,
                                     nbBus40>=0,nbBus30>=0,nbBus40<=2,nbBus30<=2
                                     ])

, тогда мы получить

status =  infeasible

The minimal cost is inf
number buses 40 seats =  None
number buses 30 seats =  None
...