-1

PuLPを使用してpython 3.7で設定された混合整数プログラミングの問題があります。デフォルトのソルバーである CBC を使用すると、私のコードは3.9 秒かかります。この時間を短縮したいので、スピードアップするために、Gurobi のアカデミック ライセンスを取得しました。ただし、代わりにこれをソルバーとして使用すると、実行時間が 1 秒近く長くなります: 4.7s

これらの行をセットアップに追加/更新することで、Gurobi ソルバーを使用するようにこれを更新します (同じ結果が得られるため、これは正しいと思います)。

solver = pl.GUROBI_CMD()

prob.solve(solver)

遅さの理由を知っている人はいますか?gurobi を使用したい場合、代わりにセットアップに使用すべき PuLP のより高速な代替手段はありますか?

編集:

ログファイルは次のとおりです。

  1. CBC
At line 2 NAME          MODEL
At line 3 ROWS
At line 2301 COLUMNS
At line 219058 RHS
At line 221355 BOUNDS
At line 222359 ENDATA
Problem MODEL has 2296 rows, 2051 columns and 212512 elements
Coin0008I MODEL read with 0 errors
Continuous objective value is 0 - 0.03 seconds
Cgl0004I processed model has 1765 rows, 1704 columns (852 integer (852 of which binary)) and 54646 elements
Cbc0038I Initial state - 0 integers unsatisfied sum - 0
Cbc0038I Solution found of 0
Cbc0038I Relaxing continuous gives 0
Cbc0038I Before mini branch and bound, 852 integers at bound fixed and 852 continuous
Cbc0038I Mini branch and bound did not improve solution (0.14 seconds)
Cbc0038I After 0.14 seconds - Feasibility pump exiting with objective of 0 - took 0.01 seconds
Cbc0012I Integer solution of 0 found by feasibility pump after 0 iterations and 0 nodes (0.15 seconds)
Cbc0001I Search completed - best objective 0, took 0 iterations and 0 nodes (0.15 seconds)
Cbc0035I Maximum depth 0, 0 variables fixed on reduced cost
Cuts at root node changed objective from 0 to 0
Probing was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Gomory was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Knapsack was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Clique was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
MixedIntegerRounding2 was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
FlowCover was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
TwoMirCuts was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)

Result - Optimal solution found

Objective value:                -0.00000000
Enumerated nodes:               0
Total iterations:               0
Time (CPU seconds):             0.21
Time (Wallclock seconds):       0.21

Option for printingOptions changed from normal to all
Total time (CPU seconds):       0.35   (Wallclock seconds):       0.35
  1. グロビ
Using license file C:\Users\NAME\gurobi.lic
Set parameter LogFile to value gurobi.log

Gurobi Optimizer version 9.1.2 build v9.1.2rc0 (win64)
Copyright (c) 2021, Gurobi Optimization, LLC

Read LP format model from file C:\Users\Cian\AppData\Local\Temp\ce8521ad48894665b17cd0db5c63d23b-pulp.lp
Reading time = 0.11 seconds
OBJ: 2264 rows, 2021 columns, 209244 nonzeros
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 2264 rows, 2021 columns and 209244 nonzeros
Model fingerprint: 0xfc10ac4d
Variable types: 1032 continuous, 989 integer (989 binary)
Coefficient statistics:
  Matrix range     [1e-03, 3e+04]
  Objective range  [9e-03, 1e+01]
  Bounds range     [1e+00, 1e+00]
  RHS range        [2e+01, 2e+01]
Found heuristic solution: objective -0.0000000
Presolve removed 616 rows and 434 columns
Presolve time: 0.31s
Presolved: 1648 rows, 1587 columns, 49216 nonzeros
Variable types: 800 continuous, 787 integer (787 binary)

Root relaxation: cutoff, 42 iterations, 0.01 seconds

    Nodes    |    Current Node    |     Objective Bounds      |     Work
 Expl Unexpl |  Obj  Depth IntInf | Incumbent    BestBd   Gap | It/Node Time

     0     0     cutoff    0        -0.00000   -0.00000  0.00%     -    0s

Explored 0 nodes (42 simplex iterations) in 0.34 seconds
Thread count was 8 (of 8 available processors)

Solution count 1: -0 
No other solutions better than -0

Optimal solution found (tolerance 1.00e-04)
Best objective -0.000000000000e+00, best bound -0.000000000000e+00, gap 0.0000%

この実行では、Gurobi は CBC よりも ~0.5 秒悪かった

4

1 に答える 1

0

GUROBI_CMD() を使用する代わりに、gurobi のネイティブ インターフェイスを使用する GUROBI() を使用します。

しかし、正直なところ、このサイズでの解決時間は非常に似ている可能性があり、解決時間の大きな違いは、分単位で測定した場合です。

于 2021-11-09T22:22:37.530 に答える