CPLEX example¶

[1]:
from optiwindnet.importer import load_repository
from optiwindnet.svg import svgplot
from optiwindnet.mesh import make_planar_embedding
from optiwindnet.interarraylib import G_from_S
from optiwindnet.heuristics import EW_presolver
from optiwindnet.MILP import solver_factory, ModelOptions

Initialize Race Bank 2¶

[2]:
locations = load_repository()
[3]:
L = locations.race
capacity = 5
[4]:
svgplot(L)
[4]:
../_images/notebooks_23-MILP_cplex_example_5_0.svg

Optimize Race Bank 2¶

[5]:
P, A = make_planar_embedding(L)

Initial heuristic solution to warm-start the solver:

[6]:
Sʹ = EW_presolver(A, capacity=capacity)
Gʹ = G_from_S(Sʹ, A)
svgplot(Gʹ)
[6]:
../_images/notebooks_23-MILP_cplex_example_9_0.svg
[7]:
solver = solver_factory('cplex')
[8]:
solver.set_problem(
    P, A,
    capacity=Sʹ.graph['capacity'],
    model_options=ModelOptions(
        topology="branched",
        feeder_route="segmented",
        feeder_limit="unlimited",
    ),
    warmstart=Sʹ,
)
[9]:
solver.solve(
    mip_gap=0.002,
    time_limit=20,
    verbose=True,
)
Version identifier: 22.1.2.0 | 2024-11-25 | 0edbb82fd
CPXPARAM_Read_DataCheck                          1
CPXPARAM_Parallel                                -1
CPXPARAM_Emphasis_MIP                            4
CPXPARAM_TimeLimit                               20
CPXPARAM_MIP_Tolerances_MIPGap                   0.002
1 of 1 MIP starts provided solutions.
MIP start 'm1' defined initial solution with objective 93274.5215.
Tried aggregator 1 time.
MIP Presolve eliminated 368 rows and 0 columns.
MIP Presolve modified 1040 coefficients.
Reduced MIP has 2740 rows, 2080 columns, and 9890 nonzeros.
Reduced MIP has 1040 binaries, 1040 generals, 0 SOSs, and 0 indicators.
Presolve time = 0.00 sec. (7.87 ticks)
Probing time = 0.01 sec. (2.90 ticks)
Tried aggregator 1 time.
Detecting symmetries...
Reduced MIP has 2740 rows, 2080 columns, and 9890 nonzeros.
Reduced MIP has 1040 binaries, 1040 generals, 0 SOSs, and 0 indicators.
Presolve time = 0.00 sec. (6.22 ticks)
Probing time = 0.02 sec. (2.83 ticks)
Clique table members: 476.
MIP emphasis: hidden feasible solutions.
MIP search method: dynamic search.
Parallel mode: opportunistic, using up to 16 threads.
Root relaxation solution time = 0.03 sec. (36.66 ticks)

        Nodes                                         Cuts/
   Node  Left     Objective  IInf  Best Integer    Best Bound    ItCnt     Gap

*     0+    0                        93274.5215        0.0000           100.00%
      0     0    85779.2773   106    93274.5215    85779.2773     1392    8.04%
*     0+    0                        91529.1336    85779.2773             6.28%
      0     0    86296.5926   291    91529.1336     Cuts: 112     1615    5.72%
      0     0    86449.7008   233    91529.1336     Cuts: 113     1773    5.55%
*     0+    0                        90212.0836    86449.7008             4.17%
      0     0    86530.8140   310    90212.0836      Cuts: 44     1854    4.08%
      0     0    86591.5711   260    90212.0836      Cuts: 45     1935    4.01%
      0     0    86613.4710   293    90212.0836      Cuts: 25     2000    3.99%
Detecting symmetries...
      0     0    86630.5237   312    90212.0836      Cuts: 27     2054    3.97%
*     0+    0                        89811.3539    86630.5237             3.54%
      0     0    86656.5904   314    89811.3539      Cuts: 26     2131    3.51%
      0     0    86668.0809   308    89811.3539      Cuts: 23     2187    3.50%
*     0+    0                        88489.5866    86668.0809             2.06%
      0     0  -1.00000e+75     0    88489.5866    86668.0809     2187    2.06%
      0     0    86688.9715   323    88489.5866      Cuts: 29     2250    2.03%
      0     0    86728.0362   292    88489.5866      Cuts: 13     2310    1.99%
      0     0    86743.6061   316    88489.5866      Cuts: 25     2380    1.97%
      0     0    86755.7227   324    88489.5866      Cuts: 31     2446    1.96%
      0     0    86758.6886   318    88489.5866      Cuts: 21     2468    1.96%
      0     0    86761.2511   312    88489.5866      Cuts: 19     2495    1.95%
*     0+    0                        88420.3525    86761.2511             1.88%
*     0+    0                        88331.6140    86761.2511             1.78%
      0     0  -1.00000e+75     0    88331.6140    86761.2511     2495    1.78%
Detecting symmetries...
      0     2    86761.2511   312    88331.6140    86761.2511     2495    1.78%
Elapsed time = 2.92 sec. (1626.09 ticks, tree = 0.02 MB, solutions = 7)
    219   169    86992.6114   291    88331.6140    86797.0783    28596    1.74%
    552   393    87304.9614   263    88331.6140    86797.0783    62224    1.74%
    952   567    87938.1457   193    88331.6140    86895.1664    83205    1.63%
*  1398+  807                        88167.0731    86946.6821             1.38%
   1453   935    87450.9176   219    88167.0731    86946.6821   123491    1.38%
*  1792+ 1113                        87993.7803    86958.9363             1.18%
   1853  1135        cutoff          87993.7803    86958.9363   155644    1.18%
   2219  1129    87094.4152   312    87993.7803    87006.4361   182773    1.12%
   2709  1512    87584.8536   287    87993.7803    87067.9193   238180    1.05%
   3129  1670    87323.2703   249    87993.7803    87082.0990   255155    1.04%
   3508  1970    87973.1209   233    87993.7803    87082.0990   288727    1.04%
*  4582+ 2467                        87938.3833    87144.1873             0.90%

Performing restart 1

Repeating presolve.
Tried aggregator 2 times.
MIP Presolve eliminated 381 rows and 350 columns.
MIP Presolve modified 135 coefficients.
Aggregator did 2 substitutions.
Reduced MIP has 2357 rows, 1728 columns, and 8268 nonzeros.
Reduced MIP has 868 binaries, 860 generals, 0 SOSs, and 0 indicators.
Presolve time = 0.01 sec. (6.21 ticks)
Tried aggregator 1 time.
Reduced MIP has 2357 rows, 1728 columns, and 8268 nonzeros.
Reduced MIP has 868 binaries, 860 generals, 0 SOSs, and 0 indicators.
Presolve time = 0.00 sec. (5.54 ticks)
Represolve time = 0.05 sec. (28.48 ticks)
   4589     0    86847.0677   351    87938.3833     Cuts: 116   394059    0.88%
   4589     0    86872.8665   342    87938.3833      Cuts: 65   394171    0.88%
*  4589+    0                        87802.9883    87162.8768             0.73%
   4589     0    86892.1240   363    87802.9883     Cuts: 100   394292    0.73%
   4589     0    86908.8440   365    87802.9883      Cuts: 81   394425    0.73%
   4589     0    86925.2403   374    87802.9883     Cuts: 105   394559    0.73%
   4589     0    86935.4419   375    87802.9883      Cuts: 68   394680    0.73%
   4589    16        cutoff          87802.9883    87222.3496   399510    0.66%
Elapsed time = 11.91 sec. (6659.73 ticks, tree = 0.02 MB, solutions = 12)
   4940    13    87517.9866   370    87802.9883    87233.7246   397451    0.65%
   5074    28        cutoff          87802.9883    87233.7246   402592    0.65%

GUB cover cuts applied:  6
Cover cuts applied:  1
Flow cuts applied:  44
Mixed integer rounding cuts applied:  105
Zero-half cuts applied:  47
Lift and project cuts applied:  62
Gomory fractional cuts applied:  5

Root node processing (before b&c):
  Real time             =    2.80 sec. (1624.64 ticks)
Parallel b&c, 16 threads:
  Real time             =   10.25 sec. (7660.06 ticks)
  Sync time (average)   =    1.63 sec.
  Wait time (average)   =    0.01 sec.
                          ------------
Total (root+branch&cut) =   13.05 sec. (9284.70 ticks)
[9]:
SolutionInfo(runtime=13.05971646308899, bound=87628.45738695332, objective=87802.98827587758, relgap=0.001987755682937409, termination='optimal')
[10]:
S, G = solver.get_solution()
[11]:
svgplot(G)
[11]:
../_images/notebooks_23-MILP_cplex_example_14_0.svg