HiGHS 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 Triton¶
[2]:
locations = load_repository()
[3]:
L = locations.triton
capacity = 8
[4]:
svgplot(L)
[4]:
Optimize Triton¶
[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]:
[7]:
solver = solver_factory('highs')
[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.005,
time_limit=60,
verbose=True,
)
Running HiGHS 1.11.0 (git hash: n/a): Copyright (c) 2025 HiGHS under MIT licence terms
RUN!
MIP has 2618 rows; 1764 cols; 9660 nonzeros; 1764 integer variables (882 binary)
Coefficient ranges:
Matrix [1e+00, 8e+00]
Cost [8e+02, 1e+04]
Bound [1e+00, 8e+00]
RHS [1e+00, 9e+01]
Assessing feasibility of MIP using primal feasibility and integrality tolerance of 1e-06
Solution has num max sum
Col infeasibilities 0 0 0
Integer infeasibilities 0 0 0
Row infeasibilities 0 0 0
Row residuals 0 0 0
Presolving model
2618 rows, 1764 cols, 9660 nonzeros 0s
2320 rows, 1722 cols, 8634 nonzeros 0s
MIP start solution is feasible, objective value is 113076.197044
Solving MIP model with:
2320 rows
1722 cols (842 binary, 880 integer, 0 implied int., 0 continuous, 0 domain fixed)
8634 nonzeros
Src: B => Branching; C => Central rounding; F => Feasibility pump; J => Feasibility jump;
H => Heuristic; L => Sub-MIP; P => Empty MIP; R => Randomized rounding; Z => ZI Round;
I => Shifting; S => Solve LP; T => Evaluate node; U => Unbounded; X => User solution;
z => Trivial zero; l => Trivial lower; u => Trivial upper; p => Trivial point
Nodes | B&B Tree | Objective Bounds | Dynamic Constraints | Work
Src Proc. InQueue | Leaves Expl. | BestBound BestSol Gap | Cuts InLp Confl. | LpIters Time
0 0 0 0.00% -21710.457804 113076.197044 119.20% 0 0 0 0 0.1s
0 0 0 0.00% 103058.96252 113076.197044 8.86% 0 0 3 1337 0.2s
L 0 0 0 0.00% 104464.184489 108377.625532 3.61% 1159 68 110 3028 2.5s
7.5% inactive integer columns, restarting
Model after restart has 2189 rows, 1591 cols (775 bin., 816 int., 0 impl., 0 cont., 0 dom.fix.), and 8087 nonzeros
0 0 0 0.00% 104464.185655 108377.625532 3.61% 45 0 0 11293 7.0s
0 0 0 0.00% 104464.185655 108377.625532 3.61% 45 44 1 11755 7.0s
0 0 0 0.00% 104464.185655 108377.625532 3.61% 45 44 82 22212 12.8s
16 13 0 1.17% 104581.335462 108377.625532 3.50% 63 46 239 81564 21.2s
39 32 0 1.19% 104581.335462 108377.625532 3.50% 220 51 851 120401 26.5s
145 80 19 1.54% 104581.335462 108377.625532 3.50% 2308 83 4160 149709 33.7s
L 161 93 19 1.58% 104627.611389 108301.102486 3.39% 2240 88 4334 152193 35.7s
L 275 115 35 3.75% 104636.344814 107622.069286 2.77% 918 81 6037 169707 39.8s
428 199 53 4.90% 104651.947562 107622.069286 2.76% 860 85 10070 196590 44.8s
605 297 75 6.59% 104733.8315 107622.069286 2.68% 945 80 9565 222478 50.0s
774 403 87 8.40% 104812.054462 107622.069286 2.61% 544 68 9898 248602 55.1s
956 479 124 8.51% 104848.88925 107622.069286 2.58% 792 90 9879 274146 60.0s
Solving report
Status Time limit reached
Primal bound 107622.069286
Dual bound 104848.88925
Gap 2.58% (tolerance: 0.5%)
P-D integral 2.09509593034
Solution status feasible
107622.069286 (objective)
0 (bound viol.)
0 (int. viol.)
0 (row viol.)
Timing 60.00 (total)
0.00 (presolve)
0.00 (solve)
0.00 (postsolve)
Max sub-MIP depth 5
Nodes 956
Repair LPs 0 (0 feasible; 0 iterations)
LP iterations 274146 (total)
144307 (strong br.)
11085 (separation)
28964 (heuristics)
WARNING: Loading a feasible but suboptimal solution. Please set
load_solution=False and check results.termination_condition and
results.found_feasible_solution() before loading a solution.
[9]:
SolutionInfo(runtime=<pyomo.opt.results.container.UndefinedData object at 0x000001CA1B986ED0>, bound=104848.88924958107, objective=107622.0692857606, relgap=0.02576776356916277, termination='maxTimeLimit')
[10]:
S, G = solver.get_solution()
[11]:
svgplot(G)
[11]: