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]:
../_images/notebooks_24-MILP_highs_example_5_0.svg

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]:
../_images/notebooks_24-MILP_highs_example_9_0.svg
[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
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
2326 rows, 1722 cols, 8665 nonzeros  0s

MIP start solution is feasible, objective value is 113076.197044

Solving MIP model with:
   2326 rows
   1722 cols (842 binary, 880 integer, 0 implied int., 0 continuous, 0 domain fixed)
   8665 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%   18952.945815    113076.197044     83.24%        0      0      0         0     0.1s
         0       0         0   0.00%   103058.96252    113076.197044      8.86%        0      0      2      1242     0.2s
 L       0       0         0   0.00%   104703.625168   109307.825317      4.21%     3057     86    138      3358     3.0s
         0       0         0   0.00%   104703.653689   109307.825317      4.21%     3057     57    187     14528     8.6s

6.8% inactive integer columns, restarting
Model after restart has 2206 rows, 1602 cols (780 bin., 822 int., 0 impl., 0 cont., 0 dom.fix.), and 8178 nonzeros

         0       0         0   0.00%   104703.653689   109307.825317      4.21%       57      0      0     14528     8.7s
         0       0         0   0.00%   104703.653689   109307.825317      4.21%       57     55      5     15003     8.7s
        22      19         0   0.40%   104739.582671   109307.825317      4.18%       97     57    687     79329    16.5s
        60      32         4   0.42%   104739.582671   109307.825317      4.18%      656     64   1794    121487    21.8s
 L      64      27         5   1.28%   104739.582671   107975.453107      3.00%      770     73   1888    122055    23.6s
 L      93      32         9   3.94%   104739.582671   107387.202847      2.47%     1747     53   2804    131213    25.7s
       239     111        29   4.79%   104873.667389   107387.202847      2.34%     2329     93   5906    158874    31.0s
       324     156        38   4.95%   104913.716994   107387.202847      2.30%     1708    121   7813    181292    37.4s
       401     211        40   5.07%   104954.685446   107387.202847      2.27%     1403    111   9353    207327    46.6s
       546     304        47   5.19%   104975.197054   107387.202847      2.25%     1484     88   9480    234736    51.7s
 L     623     329        56   5.37%   104980.769957   107307.710638      2.17%      693    100   9944    251849    58.9s
       659     343        65   5.37%   104980.769957   107307.710638      2.17%      667    102   9669    260551    60.0s

Solving report
  Status            Time limit reached
  Primal bound      107307.710638
  Dual bound        104980.769957
  Gap               2.17% (tolerance: 0.5%)
  P-D integral      1.97954174207
  Solution status   feasible
                    107307.710638 (objective)
                    0 (bound viol.)
                    3.06354941415e-12 (int. viol.)
                    0 (row viol.)
  Timing            60.01 (total)
                    0.00 (presolve)
                    0.00 (solve)
                    0.00 (postsolve)
  Max sub-MIP depth 5
  Nodes             659
  Repair LPs        0 (0 feasible; 0 iterations)
  LP iterations     260551 (total)
                    138596 (strong br.)
                    16988 (separation)
                    35797 (heuristics)
[9]:
SolutionInfo(runtime=60.02319720000014, bound=104980.76995741787, objective=107307.71063789072, relgap=0.02168474815686916, termination='maxTimeLimit')
[10]:
S, G = solver.get_solution()
[11]:
svgplot(G)
[11]:
../_images/notebooks_24-MILP_highs_example_14_0.svg