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 constructor
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]:
Optimize Race Bank 2¶
[5]:
P, A = make_planar_embedding(L)
Initial heuristic solution to warm-start the solver:
[6]:
Sʹ = constructor(A, capacity=capacity)
Gʹ = G_from_S(Sʹ, A)
svgplot(Gʹ)
[6]:
[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-26 | 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 93901.0670.
Tried aggregator 1 time.
MIP Presolve eliminated 366 rows and 0 columns.
MIP Presolve modified 1038 coefficients.
Reduced MIP has 2736 rows, 2076 columns, and 9870 nonzeros.
Reduced MIP has 1038 binaries, 1038 generals, 0 SOSs, and 0 indicators.
Presolve time = 0.01 sec. (7.85 ticks)
Probing time = 0.00 sec. (2.89 ticks)
Tried aggregator 1 time.
Detecting symmetries...
Reduced MIP has 2736 rows, 2076 columns, and 9870 nonzeros.
Reduced MIP has 1038 binaries, 1038 generals, 0 SOSs, and 0 indicators.
Presolve time = 0.01 sec. (6.20 ticks)
Probing time = 0.00 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. (32.69 ticks)
Nodes Cuts/
Node Left Objective IInf Best Integer Best Bound ItCnt Gap
* 0+ 0 93901.0670 0.0000 100.00%
0 0 85779.2773 106 93901.0670 85779.2773 1375 8.65%
* 0+ 0 91566.2815 85779.2773 6.32%
0 0 86250.4617 268 91566.2815 Cuts: 119 1577 5.81%
0 0 86422.4029 276 91566.2815 Cuts: 102 1724 5.62%
* 0+ 0 90436.7369 86422.4029 4.44%
0 0 86503.3039 278 90436.7369 Cuts: 47 1819 4.35%
0 0 86544.1957 271 90436.7369 Cuts: 39 1881 4.30%
0 0 86579.1952 288 90436.7369 Cuts: 27 1951 4.27%
Detecting symmetries...
0 0 86592.7377 278 90436.7369 Cuts: 21 1998 4.25%
0 0 86619.5861 301 90436.7369 Cuts: 18 2046 4.22%
0 0 86633.8326 254 90436.7369 Cuts: 20 2088 4.21%
0 0 86639.0729 247 90436.7369 Cuts: 14 2130 4.20%
0 0 86643.9394 238 90436.7369 Cuts: 17 2146 4.19%
* 0+ 0 90184.6613 86643.9394 3.93%
* 0+ 0 89689.8969 86643.9394 3.40%
* 0+ 0 89335.9763 86643.9394 3.01%
0 0 -1.00000e+75 0 89335.9763 86643.9394 2146 3.01%
Detecting symmetries...
0 2 86643.9394 238 89335.9763 86643.9394 2146 3.01%
Elapsed time = 1.02 sec. (685.32 ticks, tree = 0.02 MB, solutions = 6)
* 79+ 13 89249.0347 86647.6587 2.91%
536 388 86734.1351 293 89249.0347 86698.2007 28641 2.86%
1399 856 88464.1348 128 88763.3852 86760.4828 68500 2.26%
* 1413+ 951 88618.2794 86760.4828 2.10%
2242 949 87417.8676 269 88261.6166 86783.2962 92793 1.67%
3204 1663 87263.8740 208 88261.6166 86878.9561 129116 1.57%
4187 2606 cutoff 88261.6166 86884.4290 174750 1.56%
* 4553+ 2617 88157.0288 86884.4290 1.44%
4606 2718 87140.7204 224 88157.0288 86884.4290 179231 1.44%
Performing restart 1
Repeating presolve.
Tried aggregator 2 times.
MIP Presolve eliminated 229 rows and 221 columns.
MIP Presolve modified 25 coefficients.
Aggregator did 1 substitutions.
Reduced MIP has 2506 rows, 1854 columns, and 8944 nonzeros.
Reduced MIP has 928 binaries, 926 generals, 0 SOSs, and 0 indicators.
Presolve time = 0.01 sec. (6.08 ticks)
Tried aggregator 1 time.
Reduced MIP has 2506 rows, 1854 columns, and 8944 nonzeros.
Reduced MIP has 928 binaries, 926 generals, 0 SOSs, and 0 indicators.
Presolve time = 0.01 sec. (5.94 ticks)
Represolve time = 0.03 sec. (28.09 ticks)
* 4609+ 0 87938.3833 86913.5818 1.17%
4609 0 86769.4075 318 87938.3833 Cuts: 107 201604 1.17%
4609 0 86825.0546 362 87938.3833 Cuts: 104 201776 1.17%
4609 0 86846.1193 341 87938.3833 Cuts: 87 201889 1.17%
4609 0 86873.0659 342 87938.3833 Cuts: 79 202026 1.17%
4609 0 86956.4591 348 87938.3833 Cuts: 109 202243 0.90%
4609 0 86992.1332 372 87938.3833 Cuts: 114 202416 0.90%
4609 0 87007.2847 373 87938.3833 Cuts: 113 202578 0.78%
4609 0 87025.0635 392 87938.3833 Cuts: 100 202668 0.78%
4609 0 87049.3410 373 87938.3833 Cuts: 67 202790 0.69%
4609 0 87054.9770 373 87938.3833 Cuts: 64 202883 0.69%
4609 0 87060.2946 376 87938.3833 Cuts: 42 202983 0.69%
* 4609+ 0 87835.9279 87398.6964 0.50%
* 4609+ 0 87819.1346 87398.6964 0.48%
4609 0 -1.00000e+75 0 87819.1346 87398.6964 202983 0.48%
4609 2 87060.2946 376 87819.1346 87464.1843 202983 0.40%
4721 22 cutoff 87802.9883 87464.1843 208580 0.39%
4924 281 87544.7773 300 87802.9883 87464.1843 274674 0.39%
5467 278 cutoff 87802.9883 87464.1843 274797 0.39%
Elapsed time = 10.03 sec. (7112.22 ticks, tree = 0.68 MB, solutions = 21)
GUB cover cuts applied: 3
Cover cuts applied: 1
Flow cuts applied: 40
Mixed integer rounding cuts applied: 141
Zero-half cuts applied: 42
Lift and project cuts applied: 44
Gomory fractional cuts applied: 8
Root node processing (before b&c):
Real time = 0.97 sec. (684.15 ticks)
Parallel b&c, 16 threads:
Real time = 9.07 sec. (6523.03 ticks)
Sync time (average) = 1.01 sec.
Wait time (average) = 0.01 sec.
------------
Total (root+branch&cut) = 10.03 sec. (7207.18 ticks)
[9]:
SolutionInfo(runtime=10.041604042053223, bound=87627.39352862877, objective=87802.98827587762, relgap=0.0019998721079643733, termination='optimal')
[10]:
S, G = solver.get_solution()
[11]:
svgplot(G)
[11]: