Skip to content

[Do not merge] a script to benchmark impact of lazy PTDF#114

Open
odow wants to merge 7 commits into
od/fix-nameoffrom
od/lazy-test
Open

[Do not merge] a script to benchmark impact of lazy PTDF#114
odow wants to merge 7 commits into
od/fix-nameoffrom
od/lazy-test

Conversation

@odow
Copy link
Copy Markdown
Collaborator

@odow odow commented May 8, 2026

So this actually super interesting.

The win depends on the MIPGap. Previously I had been running with MIPGap=0.01 and I couldn't get the lazy constraints to make a difference in solve time. It's because it matters only for a much smaller MIPGap.

Nevertheless, I think this is a reasonable enough evidence to pursue. It probably makes an even bigger difference as we get larger systems.

Next I think we ned to show than an iterative HiGHS solve is a performance win. Which is less obvious.

Without

Gurobi Optimizer version 13.0.2 build v13.0.2rc1 (mac64[arm] - Darwin 24.6.0 24G419)

CPU model: Apple M4
Thread count: 10 physical cores, 10 logical processors, using up to 10 threads

WLS license 722777 - registered to JuMP Development
Optimize a model with 291312 rows, 302472 columns and 33168331 nonzeros (Min)
Model fingerprint: 0x8667202d
Model has 196440 linear objective coefficients
Variable types: 238176 continuous, 64296 integer (64296 binary)
Coefficient statistics:
  Matrix range     [3e-04, 1e+01]
  Objective range  [2e+01, 2e+06]
  Bounds range     [1e-03, 1e+01]
  RHS range        [2e-04, 3e+02]

User MIP start did not produce a new incumbent solution
User MIP start violates constraint R21456 by 0.000013500
Processed MIP start in 2.77 seconds (5.05 work units)

Presolve removed 183420 rows and 145371 columns (presolve time = 5s)...
Presolve removed 181239 rows and 137094 columns
Presolve time: 9.18s
Presolved: 110073 rows, 165393 columns, 1731163 nonzeros
Variable types: 102883 continuous, 62510 integer (62510 binary)
Deterministic concurrent LP optimizer: primal simplex, dual simplex, and barrier
Showing barrier log only...

Root barrier log...

Ordering time: 1.55s

Barrier statistics:
 AA' NZ     : 1.702e+06
 Factor NZ  : 1.700e+07 (roughly 200 MB of memory)
 Factor Ops : 2.360e+10 (less than 1 second per iteration)
 Threads    : 7

Barrier performed 0 iterations in 16.29 seconds (41.35 work units)
Barrier solve interrupted - model solved by another algorithm

Concurrent spin time: 0.22s (can be avoided by choosing Method=3)

Solved with dual simplex

Root simplex log...

Iteration    Objective       Primal Inf.    Dual Inf.      Time
   37148    6.5717951e+06   0.000000e+00   0.000000e+00     16s

Use crossover to convert LP symmetric solution to basic solution...

Root crossover log...

    5003 DPushes remaining with DInf 0.0000000e+00                16s
       0 DPushes remaining with DInf 0.0000000e+00                16s

     404 PPushes remaining with PInf 0.0000000e+00                16s
       0 PPushes remaining with PInf 0.0000000e+00                17s

  Push phase complete: Pinf 0.0000000e+00, Dinf 6.0210069e-09     17s


Root simplex log...

Iteration    Objective       Primal Inf.    Dual Inf.      Time
   40438    6.5717951e+06   0.000000e+00   0.000000e+00     17s
Crossover time: 0.19 seconds (0.43 work units)
   40438    6.5717951e+06   0.000000e+00   0.000000e+00     17s

Root relaxation: objective 6.571795e+06, 40438 iterations, 2.91 seconds (5.56 work units)

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

     0     0 6571795.07    0  324          - 6571795.07      -     -   17s
Another try with MIP start
H    0     0                    1.348303e+07 6571795.07  51.3%     -   19s
H    0     0                    9275149.0718 6571795.07  29.1%     -   19s
H    0     0                    6798378.9315 6571795.07  3.33%     -   20s
H    0     0                    6798322.1558 6571795.07  3.33%     -   20s
     0     0 6575229.97    0  240 6798322.16 6575229.97  3.28%     -   21s
H    0     0                    6723688.9946 6575229.97  2.21%     -   21s
H    0     0                    6677214.5265 6575229.97  1.53%     -   22s
     0     0 6575234.26    0  245 6677214.53 6575234.26  1.53%     -   22s
     0     0 6575234.26    0  248 6677214.53 6575234.26  1.53%     -   22s
     0     0 6575250.46    0  275 6677214.53 6575250.46  1.53%     -   23s
     0     0 6575250.46    0  260 6677214.53 6575250.46  1.53%     -   24s
     0     0 6575258.19    0  317 6677214.53 6575258.19  1.53%     -   25s
     0     0 6575273.12    0  304 6677214.53 6575273.12  1.53%     -   26s
     0     0 6575277.72    0  293 6677214.53 6575277.72  1.53%     -   26s
     0     0 6575277.72    0  295 6677214.53 6575277.72  1.53%     -   26s
     0     0 6575292.03    0  294 6677214.53 6575292.03  1.53%     -   27s
H    0     0                    6629226.0141 6575292.03  0.81%     -   28s
     0     0 6575313.90    0  308 6629226.01 6575313.90  0.81%     -   28s
     0     0 6575314.01    0  325 6629226.01 6575314.01  0.81%     -   28s
     0     0 6575326.03    0  345 6629226.01 6575326.03  0.81%     -   29s
     0     0 6575329.89    0  350 6629226.01 6575329.89  0.81%     -   29s
     0     0 6575330.64    0  350 6629226.01 6575330.64  0.81%     -   29s
     0     0 6575334.20    0  371 6629226.01 6575334.20  0.81%     -   30s
H    0     0                    6579983.5515 6575334.20  0.07%     -   31s
H    0     0                    6576790.2077 6575334.20  0.02%     -   31s
H    0     0                    6576595.0267 6575334.20  0.02%     -   32s
H    0     0                    6576595.0255 6575334.20  0.02%     -   33s
H    0     0                    6576548.0191 6575334.20  0.02%     -   33s
H    0     0                    6576518.1685 6575334.20  0.02%     -   33s
H    0     0                    6576480.7882 6575334.20  0.02%     -   33s
H    0     0                    6576396.9593 6575334.20  0.02%     -   33s
     0     0 6575336.42    0  373 6576396.96 6575336.42  0.02%     -   33s
     0     0 6575336.54    0  382 6576396.96 6575336.54  0.02%     -   33s
     0     0 6575353.01    0  369 6576396.96 6575353.01  0.02%     -   34s
     0     0 6575353.70    0  378 6576396.96 6575353.70  0.02%     -   35s
     0     0 6575364.70    0  395 6576396.96 6575364.70  0.02%     -   35s
     0     0 6575366.35    0  396 6576396.96 6575366.35  0.02%     -   36s
     0     0 6575372.69    0  403 6576396.96 6575372.69  0.02%     -   36s
     0     0 6575372.86    0  395 6576396.96 6575372.86  0.02%     -   36s
     0     0 6575375.76    0  399 6576396.96 6575375.76  0.02%     -   37s
     0     0 6575379.60    0  405 6576396.96 6575379.60  0.02%     -   38s
     0     0 6575379.60    0  403 6576396.96 6575379.60  0.02%     -   38s
     0     0 6575382.54    0  429 6576396.96 6575382.54  0.02%     -   38s
     0     0 6575382.56    0  429 6576396.96 6575382.56  0.02%     -   39s
     0     0 6575382.56    0  429 6576396.96 6575382.56  0.02%     -   39s
     0     0 6575382.56    0  323 6576396.96 6575382.56  0.02%     -   40s
H    0     0                    6576364.9063 6575382.56  0.01%     -   42s
     0     2 6575382.56    0  321 6576364.91 6575382.56  0.01%     -   44s
     7    16 6575392.46    3  336 6576364.91 6575392.46  0.01%   114   45s
   105   234 6575403.25   10  337 6576364.91 6575398.35  0.01%  19.2   52s
H  233   350                    6576364.6837 6575398.35  0.01%  12.7   58s
   349  1391 6575409.40   21  306 6576364.68 6575398.35  0.01%  10.5   71s
H 1393  2254                    6576364.6797 6575398.35  0.01%   7.8   77s
H 1559  2254                    6576361.4115 6575398.35  0.01%   8.5   77s
H 2260  2348                    6576338.0255 6575398.35  0.01%   9.4   84s
H 2296  2348                    6576250.6127 6575398.35  0.01%   9.3   84s
  2354  3486 6575515.04  179  202 6576250.61 6575398.35  0.01%   9.2   89s
  3494  4579 6575596.44  292  185 6576250.61 6575398.35  0.01%   8.5   93s
H 3608  4579                    6576250.6093 6575398.35  0.01%   8.4   93s
  4587  5356 6575634.84  397  161 6576250.61 6575398.35  0.01%   7.5   97s
  5364  6007 6575652.03  484  143 6576250.61 6575398.35  0.01%   7.2  100s
  6477  7283 6575673.93  535  140 6576250.61 6575398.35  0.01%   6.8  107s
  7291  7944 6575728.03  607  141 6576250.61 6575398.35  0.01%   6.5  111s
  8739  8728 6575803.19  719  323 6576250.61 6575398.35  0.01%   6.6  124s
  8741  8729 6575700.18  565  293 6576250.61 6575398.35  0.01%   6.6  129s
  8742  8730 6575807.31  761  194 6576250.61 6575398.35  0.01%   6.6  133s
  8746  8733 6575579.52  230  229 6576250.61 6575398.35  0.01%   6.5  135s
  8749  8735 6575499.09  163  282 6576250.61 6575398.35  0.01%   6.5  140s
  8751  8736 6575534.52  147  274 6576250.61 6575398.35  0.01%   6.5  145s
  8753  8737 6575618.42  247  292 6576250.61 6575398.35  0.01%   6.5  150s
  8757  8740 6575684.55  440  264 6576250.61 6575398.35  0.01%   6.5  155s
  8760  8742 6575577.42  221  270 6576250.61 6575398.35  0.01%   6.5  163s
  8761  8743 6575844.13  757  307 6576250.61 6575398.35  0.01%   6.5  165s
  8764  8745 6575700.40  549  324 6576250.61 6575399.83  0.01%   6.5  172s
  8766  8746 6575670.76  486  338 6576250.61 6575400.22  0.01%   6.5  177s
  8768  8747 6575421.18   55  296 6576250.61 6575403.48  0.01%   6.5  182s
  8769  8748 6575446.43   72  262 6576250.61 6575403.48  0.01%   6.5  185s
H 8769  8310                    6576223.5243 6575403.48  0.01%   6.5  192s
H 8770  7897                    6576206.1198 6575403.48  0.01%  13.3  194s
  8773  7902 6575668.54   12  273 6576206.12 6575403.48  0.01%  13.3  195s
  8856  8044 6575706.48   18  328 6576206.12 6575434.86  0.01%  13.4  201s
  8947  8203 6575697.70   23  324 6576206.12 6575434.86  0.01%  13.4  207s
  9139  8377 6575730.70   32  296 6576206.12 6575434.86  0.01%  13.3  216s
H 9356  7908                    6576182.6394 6575434.86  0.01%  13.3  216s
  9377  8654 6575741.01   41  281 6576182.64 6575434.86  0.01%  13.3  238s
 10144  9127 6575770.14   77  248 6576182.64 6575434.86  0.01%  12.8  256s
 10893  9583 6575774.49  113  239 6576182.64 6575434.86  0.01%  12.6  275s
 11626 10021 6575780.19  149  199 6576182.64 6575434.86  0.01%  12.3  292s
H12315  9426                    6576182.6353 6575434.86  0.01%  12.0  306s
H12320  9067                    6576181.1010 6575434.86  0.01%  12.0  306s
H12322  8726                    6576173.8179 6575434.86  0.01%  12.0  306s
 12325  9506 6575795.81  186  191 6576173.82 6575434.86  0.01%  12.0  325s
 13138  9874 6575892.45  226  177 6576173.82 6575434.86  0.01%  11.8  343s
 13814 10303 6575834.60  261  170 6576173.82 6575434.86  0.01%  12.0  361s
H14146  9871                    6576173.8159 6575434.86  0.01%  12.3  361s
 14485 10400 6575852.87  299  158 6576173.82 6575434.86  0.01%  12.3  381s
 15155 10819 6575908.50  334  154 6576173.82 6575434.86  0.01%  12.3  401s
H15641 10351                    6576173.8151 6575434.86  0.01%  12.8  401s
 15853 10907 6575916.21  368  149 6576173.82 6575434.86  0.01%  12.7  421s
 16518 11316 6575922.43  401  141 6576173.82 6575434.86  0.01%  12.9  439s
H17177 10851                    6576167.6845 6575434.86  0.01%  13.0  457s
H17182 10566                    6576160.4634 6575434.86  0.01%  13.0  457s
H17239 10237                    6576142.9041 6575434.86  0.01%  13.0  457s
 17240 11529 6575984.12  439  137 6576142.90 6575434.86  0.01%  13.0  499s
H18670 11242                    6576131.0239 6575434.86  0.01%  13.6  515s
H18764 10960                    6576127.5667 6575434.86  0.01%  13.6  515s
H19197 10613                    6576127.2787 6575434.86  0.01%  13.8  528s
H19204 10187                    6576089.4261 6575434.86  0.01%  13.8  528s
H19208  9835                    6576067.0494 6575434.86  0.01%  13.8  528s
H19240  9548                    6576053.8836 6575434.86  0.01%  13.8  528s

Cutting planes:
  Gomory: 21
  Implied bound: 106
  Clique: 148
  MIR: 130
  Flow cover: 50
  GUB cover: 2
  Zero half: 16
  RLT: 27
  Relax-and-lift: 33

Explored 19266 nodes (309615 simplex iterations) in 528.44 seconds (925.24 work units)
Thread count was 10 (of 10 available processors)

Solution count 10: 6.57605e+06 6.57607e+06 6.57609e+06 ... 6.57618e+06

Optimal solution found (tolerance 1.00e-04)
Best objective 6.576053883585e+06, best bound 6.575434862258e+06, gap 0.0094%

User-callback calls 77578, time in user-callback 0.12 sec
776.688322 seconds (587.07 M allocations: 225.477 GiB, 1.74% gc time, 1.31% compilation time: <1% of which was recompilation)

With Lazy=1

Gurobi Optimizer version 13.0.2 build v13.0.2rc1 (mac64[arm] - Darwin 24.6.0 24G419)

CPU model: Apple M4
Thread count: 10 physical cores, 10 logical processors, using up to 10 threads

WLS license 722777 - registered to JuMP Development
Optimize a model with 291312 rows, 302472 columns and 33168331 nonzeros (Min)
Model fingerprint: 0xe390beef
Model has 196440 linear objective coefficients
Variable types: 238176 continuous, 64296 integer (64296 binary)
Coefficient statistics:
  Matrix range     [3e-04, 1e+01]
  Objective range  [2e+01, 2e+06]
  Bounds range     [1e-03, 1e+01]
  RHS range        [2e-04, 3e+02]

User MIP start did not produce a new incumbent solution
User MIP start violates constraint R21456 by 0.000013500
Processed MIP start in 2.76 seconds (4.90 work units)

Presolve removed 184313 rows and 146264 columns (presolve time = 5s)...
Presolve removed 181239 rows and 137094 columns
Presolve time: 8.90s
Presolved: 110073 rows, 165393 columns, 1731163 nonzeros
Extracted 1781 lazy constraints
Variable types: 102883 continuous, 62510 integer (62510 binary)
Root relaxation presolved: 107633 rows, 164804 columns, 1426914 nonzeros

Deterministic concurrent LP optimizer: primal simplex, dual simplex, and barrier
Showing barrier log only...

Root barrier log...

Ordering time: 1.14s

Barrier performed 0 iterations in 15.10 seconds (39.84 work units)
Barrier solve interrupted - model solved by another algorithm

Concurrent spin time: 0.05s

Solved with dual simplex

Root simplex log...

Iteration    Objective       Primal Inf.    Dual Inf.      Time
   34130    6.5283770e+06   0.000000e+00   0.000000e+00     15s

Use crossover to convert LP symmetric solution to basic solution...

Root crossover log...

    4933 DPushes remaining with DInf 0.0000000e+00                15s
       0 DPushes remaining with DInf 0.0000000e+00                15s

     299 PPushes remaining with PInf 0.0000000e+00                15s
       0 PPushes remaining with PInf 0.0000000e+00                15s

  Push phase complete: Pinf 0.0000000e+00, Dinf 5.5983590e-09     15s


Root simplex log...

Iteration    Objective       Primal Inf.    Dual Inf.      Time
   37331    6.5283770e+06   0.000000e+00   0.000000e+00     15s
Crossover time: 0.12 seconds (0.30 work units)
   37331    6.5283770e+06   0.000000e+00   0.000000e+00     15s

Root relaxation: objective 6.528377e+06, 37331 iterations, 1.93 seconds (3.47 work units)
Another try with MIP start

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

     0     0 6528377.01    0  167          - 6528377.01      -     -   21s
     0     0 6528377.01    0  167          - 6528377.01      -     -   25s
     0     0 6528377.01    0  167          - 6528377.01      -     -   25s
     0     0 6538823.61    0  240          - 6538823.61      -     -   25s
Another try with MIP start
     0     0 6543716.66    0  267          - 6543716.66      -     -   30s
     0     0 6543716.66    0  267          - 6543716.66      -     -   36s
     0     0 6543716.66    0  267          - 6543716.66      -     -   38s
     0     0 6571278.15    0  413          - 6571278.15      -     -   38s
     0     0 6574876.82    0  241          - 6574876.82      -     -   39s
     0     0 6574876.82    0  241          - 6574876.82      -     -   40s
     0     0 6574954.13    0  243          - 6574954.13      -     -   40s
     0     0 6574954.13    0  246          - 6574954.13      -     -   40s
     0     0 6575089.90    0  254          - 6575089.90      -     -   41s
H    0     0                    1.177870e+07 6575089.90  44.2%     -   42s
H    0     0                    1.177368e+07 6575089.90  44.2%     -   42s
     0     0 6575178.73    0  265 1.1774e+07 6575178.73  44.2%     -   42s
     0     0 6575178.73    0  266 1.1774e+07 6575178.73  44.2%     -   42s
     0     0 6575238.64    0  298 1.1774e+07 6575238.64  44.2%     -   43s
H    0     0                    6816578.6311 6575238.64  3.54%     -   44s
     0     0 6575261.02    0  301 6816578.63 6575261.02  3.54%     -   44s
     0     0 6575263.20    0  303 6816578.63 6575263.20  3.54%     -   44s
     0     0 6575267.24    0  313 6816578.63 6575267.24  3.54%     -   44s
     0     0 6575268.63    0  304 6816578.63 6575268.63  3.54%     -   44s
     0     0 6575279.40    0  320 6816578.63 6575279.40  3.54%     -   45s
     0     0 6575287.05    0  323 6816578.63 6575287.05  3.54%     -   46s
     0     0 6575287.08    0  334 6816578.63 6575287.08  3.54%     -   46s
     0     0 6575308.19    0  331 6816578.63 6575308.19  3.54%     -   46s
     0     0 6575309.62    0  333 6816578.63 6575309.62  3.54%     -   47s
     0     0 6575309.62    0  336 6816578.63 6575309.62  3.54%     -   47s
     0     0 6575353.78    0  338 6816578.63 6575353.78  3.54%     -   48s
     0     0 6575354.51    0  350 6816578.63 6575354.51  3.54%     -   48s
     0     0 6575354.67    0  357 6816578.63 6575354.67  3.54%     -   49s
     0     0 6575354.68    0  363 6816578.63 6575354.68  3.54%     -   50s
     0     0 6575356.11    0  358 6816578.63 6575356.11  3.54%     -   50s
H    0     0                    6675516.7747 6575357.04  1.50%     -   51s
     0     0 6575359.19    0  365 6675516.77 6575359.19  1.50%     -   51s
     0     0 6575359.19    0  362 6675516.77 6575359.19  1.50%     -   51s
     0     0 6575361.42    0  348 6675516.77 6575361.42  1.50%     -   51s
H    0     0                    6650298.4642 6575365.43  1.13%     -   52s
     0     0 6575365.43    0  364 6650298.46 6575365.43  1.13%     -   52s
     0     0 6575365.43    0  370 6650298.46 6575365.43  1.13%     -   53s
     0     0 6575365.43    0  370 6650298.46 6575365.43  1.13%     -   53s
     0     0 6575365.43    0  274 6650298.46 6575365.43  1.13%     -   54s
H    0     0                    6641697.3406 6575365.43  1.00%     -   55s
     0     2 6575365.43    0  256 6641697.34 6575365.43  1.00%     -   57s
    35   123 6575382.16    6  300 6641697.34 6575365.43  1.00%  40.7   60s
   255   616 6575396.27   23  274 6641697.34 6575365.43  1.00%  14.2   66s
   615  1478 6575429.70   49  268 6641697.34 6575365.43  1.00%   9.2   73s
  1477  2250 6575465.91  113  238 6641697.34 6575365.43  1.00%   7.2   80s
H 1553  2250                    6641598.6613 6575365.43  1.00%   7.2   80s
H 1626  2250                    6641578.3854 6575365.43  1.00%   7.1   80s
H 1778  2250                    6641489.8014 6575365.43  1.00%   7.1   80s
H 1857  2250                    6623196.9303 6575365.43  0.72%   7.0   80s
H 2249  2444                    6576009.6776 6575365.43  0.01%   6.9   86s
H 2249  2444                    6575962.0697 6575365.43  0.01%   6.9   86s

Cutting planes:
  Gomory: 32
  Implied bound: 126
  Clique: 99
  MIR: 141
  Flow cover: 43
  Zero half: 99
  RLT: 28
  Relax-and-lift: 12
  Lazy constraints: 59

Explored 2443 nodes (58738 simplex iterations) in 86.61 seconds (196.95 work units)
Thread count was 10 (of 10 available processors)

Solution count 10: 6.57596e+06 6.57601e+06 6.6232e+06 ... 6.81658e+06

Optimal solution found (tolerance 1.00e-04)
Best objective 6.575962069677e+06, best bound 6.575365433716e+06, gap 0.0091%

User-callback calls 14558, time in user-callback 0.01 sec
332.983966 seconds (586.65 M allocations: 225.464 GiB, 3.52% gc time, 3.03% compilation time: <1% of which was recompilation)

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 8, 2026

Performance Results

Version Precompile Time
Main 2.936839575
This Branch 2.932913148
Version Build Time
Main-Build Time Precompile 98.857084349
Main-Build Time Postcompile 13.337176858
This Branch-Build Time Precompile 98.44508351
This Branch-Build Time Postcompile 13.549939781
Version Solve Time
Main-Solve Time Precompile 408.776272014
Main-Solve Time Postcompile 375.898593618
This Branch-Solve Time Precompile 169.345811244
This Branch-Solve Time Postcompile 135.826377071

@odow
Copy link
Copy Markdown
Collaborator Author

odow commented May 11, 2026

The iterative approach converges very fast, even faster than Lazy=1:

julia> function solve_with_loop(model)
           jmp = POM.IOM.get_optimization_container(model).JuMPmodel
           constraints_lb, constraints_ub = Dict{Any,Any}(), Dict{Any,Any}()
           for (k, v) in model.internal.container.constraints
               if k == POM.ConstraintKey{POM.FlowRateConstraint,PSY.Line}("lb")
                   for vi in v
                       constraints_lb[vi] = JuMP.constraint_object(vi)
                   end
               elseif k == POM.ConstraintKey{POM.FlowRateConstraint,PSY.Line}("ub")
                   for vi in v
                       constraints_ub[vi] = JuMP.constraint_object(vi)
                   end
               end
           end
           JuMP.delete(jmp, [k for k in keys(constraints_lb)])
           JuMP.delete(jmp, [k for k in keys(constraints_ub)])
           JuMP.set_silent(jmp)
           total_solve_time = 0.0
           while true
               start_time = time()
               JuMP.optimize!(jmp)
               total_solve_time += time() - start_time
               n_constraints_added = 0
               for (k, c) in constraints_lb
                   if JuMP.value(c.func) < c.set.lower
                       JuMP.@constraint(jmp, c.func in c.set)
                       n_constraints_added += 1
                       delete!(constraints_lb, k)
                   end
               end
               for (k, c) in constraints_ub
                   if JuMP.value(c.func) > c.set.upper
                       JuMP.@constraint(jmp, c.func in c.set)
                       n_constraints_added += 1
                       delete!(constraints_ub, k)
                   end
               end
               if n_constraints_added == 0
                   break
               else
                   @show n_constraints_added
               end
           end
           @show total_solve_time
           return jmp
       end
solve_with_loop (generic function with 1 method)

julia> solve_with_loop(model)
n_constraints_added = 129
n_constraints_added = 14
total_solve_time = 33.15950894355774
A JuMP Model
├ mode: DIRECT
├ solver: Gurobi
├ objective_sense: MIN_SENSE
│ └ objective_function_type: JuMP.AffExpr
├ num_variables: 302472
├ num_constraints: 618311
│ ├ JuMP.VariableRef in MOI.GreaterThan{Float64}: 238176
│ ├ JuMP.AffExpr in MOI.GreaterThan{Float64}: 36235
│ ├ JuMP.VariableRef in MOI.ZeroOne: 64296
│ ├ JuMP.AffExpr in MOI.LessThan{Float64}: 86212
│ ├ JuMP.VariableRef in MOI.LessThan{Float64}: 131280
│ └ JuMP.AffExpr in MOI.EqualTo{Float64}: 62112
└ Names registered in the model: none

@odow
Copy link
Copy Markdown
Collaborator Author

odow commented May 14, 2026

Here is runtime in seconds for various cases:

Solver Lazy? tol=1e-2 tol=1e-3
Gurobi false 55 57
Gurobi true 12 17
HiGHS false 175 201
HiGHS true 173 670
HiGHS true* 94 589

The last line with true* includes jump-dev/MathOptLazy.jl#4

The log for 201s includes

Solving MIP model with:
   116783 rows
   187392 cols (62508 binary, 0 integer, 0 implied int., 124884 continuous, 0 domain fixed)
   8164919 nonzeros

Src: B => Branching; C => Central rounding; F => Feasibility pump; H => Heuristic;
     I => Shifting; J => Feasibility jump; L => Sub-MIP; P => Empty MIP; R => Randomized rounding;
     S => Solve LP; T => Evaluate node; U => Unbounded; X => User solution; Y => HiGHS solution;
     Z => ZI Round; l => Trivial lower; p => Trivial point; u => Trivial upper; z => Trivial zero

        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%   0               13487200.2811    100.00%        0      0      0         0    21.5s
         0       0         0   0.00%   6573053.229569  13487200.2811     51.26%        0      0      1     47026    57.0s
 C       0       0         0   0.00%   6576702.167353  6811313.095706     3.44%     3378    173      1     47789    78.3s
         0       0         0   0.00%   6577399.191767  6811313.095706     3.43%     6441    443      1     56355    83.9s
         0       0         0   0.00%   6577455.752973  6811313.095706     3.43%     9917    484      1     59031    89.3s
         0       0         0   0.00%   6577476.356697  6811313.095706     3.43%    10980    490      1     63574    94.5s
 L       0       0         0   0.00%   6577486.143518  6606023.202195     0.43%    10560    598      1     66720   128.4s

Symmetry detection completed in 54.0s
Found 390 generator(s)

 L       0       0         0   0.00%   6577486.143518  6579094.995904     0.02%     9676    276      1     69981   160.5s
         1       0         0 100.00%   6577486.143518  6579094.995904     0.02%     9676    276      1     74230   160.6s

whereas the loop approach has an intermediate solve

Solving MIP model with:
   83256 rows
   154394 cols (62508 binary, 0 integer, 0 implied int., 91886 continuous, 0 domain fixed)
   564593 nonzeros

Src: B => Branching; C => Central rounding; F => Feasibility pump; H => Heuristic;
     I => Shifting; J => Feasibility jump; L => Sub-MIP; P => Empty MIP; R => Randomized rounding;
     S => Solve LP; T => Evaluate node; U => Unbounded; X => User solution; Y => HiGHS solution;
     Z => ZI Round; l => Trivial lower; p => Trivial point; u => Trivial upper; z => Trivial zero

        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%   0               13482730.8989    100.00%        0      0      0         0     2.0s
         0       0         0   0.00%   6572705.242175  13482730.8989     51.25%        0      0      1      5455     3.7s
 C       0       0         0   0.00%   6573747.830725  6809077.093305     3.46%     3641    192      1      7104     9.3s
         0       0         0   0.00%   6574680.041911  6809077.093305     3.44%    10310    448      1     11801    14.5s
         0       0         0   0.00%   6575547.532877  6809077.093305     3.43%    10017    673      1     16361    19.8s
         0       0         0   0.00%   6575770.448638  6809077.093305     3.43%     9339    488      1     17107    25.3s
         0       0         0   0.00%   6575992.443474  6809077.093305     3.42%    11082    695      1     30687    31.0s
         0       0         0   0.00%   6576087.488504  6809077.093305     3.42%    10791    868      1     39255    36.4s
         0       0         0   0.00%   6576357.67513   6809077.093305     3.42%    11056    849      1     43482    41.8s
         0       0         0   0.00%   6576420.080284  6809077.093305     3.42%    10843    923      1     45576    47.2s
         0       0         0   0.00%   6576452.91673   6809077.093305     3.42%    10800    745      1     46591    52.6s
 L       0       0         0   0.00%   6576454.349451  6730506.501134     2.29%    10423    792      1     47012    63.2s
 L       0       0         0   0.00%   6576454.349451  6609693.398911     0.50%    10423    792      1     50998    73.0s

Symmetry detection completed in 5.6s
Found 390 generator(s)

 L       0       0         0   0.00%   6576454.349451  6591642.093022     0.23%    10423    453      1     54583    85.5s
         8       7         0   0.78%   6576457.835103  6591642.093022     0.23%    10429    453      1     84591   127.2s
 L       8       1         0  37.50%   6576457.835103  6584444.996995     0.12%    10983    484      1     84753   140.9s
        27      17         0  50.00%   6576922.356932  6584444.996995     0.11%    10322    681      1    131097   200.3s
        39      27         0  50.01%   6576922.356932  6584444.996995     0.11%    10855    701      1    164673   237.5s
        51      37         0  50.01%   6576922.356932  6584444.996995     0.11%    10262    717      1    179767   259.2s
        63      47         0  50.01%   6576922.356932  6584444.996995     0.11%    10777    739      1    186592   268.3s

        Nodes      |    B&B Tree     |            Objective Bounds              |  Dynamic Constraints |       Work
Src  Proc. InQueue |  Leaves   Expl. | BestBound       BestSol              Gap |   Cuts   InLp Confl. | LpIters     Time

        68      50         0  50.01%   6576922.356932  6584444.996995     0.11%    10860    459      1    190785   275.8s
        73      51         0  50.01%   6576922.356932  6584444.996995     0.11%    10683    516      1    195564   283.4s
        86      60         0  50.01%   6576922.356932  6584444.996995     0.11%    10221    566      1    199018   289.8s
       102      72         0  50.06%   6576939.559263  6584444.996995     0.11%    10376    426      1    202456   299.4s
       149     115         0  50.06%   6576939.559263  6584444.996995     0.11%     9857    471      1    207324   308.6s
       200     160         0  50.06%   6576939.559263  6584444.996995     0.11%     9503    411      1    209824   314.5s
       265     221         0  50.06%   6576939.559263  6584444.996995     0.11%     9430    410      1    212451   322.5s
       326     276         0  50.06%   6576944.981067  6584444.996995     0.11%    10698    478      1    214882   328.9s
       380     326         0  50.06%   6576944.981067  6584444.996995     0.11%    10303    414      1    217929   337.1s
       433     373         0  50.06%   6576944.981067  6584444.996995     0.11%    10425    371      1    219874   342.9s
       474     406         0  50.06%   6576944.981067  6584444.996995     0.11%    10343    473      1    222904   349.6s
       533     459         0  50.06%   6576955.084396  6584444.996995     0.11%    10634    445      1    225876   358.3s
       591     511         0  50.06%   6576955.084396  6584444.996995     0.11%     9285    393      1    229806   366.6s
       670     586         0  50.06%   6576955.084396  6584444.996995     0.11%    10224    474      1    232867   376.5s
       693     607         0  50.06%   6576955.084396  6584444.996995     0.11%     9869    437      1    234713   381.5s
       742     652         0  50.06%   6576962.329769  6584444.996995     0.11%    10571    520      1    237522   388.3s
       787     693         0  50.06%   6576962.329769  6584444.996995     0.11%     9979    587      1    240369   395.3s
       830     734         0  50.06%   6576962.329769  6584444.996995     0.11%    10390    394      1    243033   400.8s
       876     776         0  50.06%   6576962.329769  6584444.996995     0.11%     9547    474      1    245691   407.8s
       946     842         0  50.06%   6576962.329769  6584444.996995     0.11%    10425    557      1    248609   416.9s

        Nodes      |    B&B Tree     |            Objective Bounds              |  Dynamic Constraints |       Work
Src  Proc. InQueue |  Leaves   Expl. | BestBound       BestSol              Gap |   Cuts   InLp Confl. | LpIters     Time

      1005     897         0  50.06%   6576962.329769  6584444.996995     0.11%     9519    428      1    251041   424.5s
      1079     967         0  50.06%   6576969.483228  6584444.996995     0.11%    10341    512      1    254177   432.2s

Restarting search from the root node
Model after restart has 83205 rows, 154336 cols (62457 bin., 0 int., 0 impl., 91879 cont., 0 dom.fix.), and 564446 nonzeros

      1079       0         0   0.00%   6576969.483228  6584444.996995     0.11%      512      0      0    254177   433.5s
      1079       0         0   0.00%   6576969.483228  6584444.996995     0.11%      512    212      0    272843   436.6s
      1079       0         0   0.00%   6576969.483228  6584444.996995     0.11%     4385    387      0    274781   441.9s
      1079       0         0   0.00%   6576969.483228  6584444.996995     0.11%     7497    459      0    275328   447.0s
      1079       0         0   0.00%   6576969.483228  6584444.996995     0.11%    10240    441      0    275928   452.8s
      1079       0         0   0.00%   6576969.483228  6584444.996995     0.11%    10635    537      0    277735   458.5s
      1079       0         0   0.00%   6576969.483228  6584444.996995     0.11%    10286    684      0    283462   464.2s
      1079       0         0   0.00%   6576969.483228  6584444.996995     0.11%    10441    812      0    287053   469.5s
      1079       0         0   0.00%   6576969.483228  6584444.996995     0.11%     8303    856      0    289771   475.6s
 L    1079       0         0   0.00%   6576969.483228  6581359.125091     0.07%     9656    760      0    290838   491.4s
      1080       0         1 100.00%   6576969.483228  6581359.125091     0.07%     9656    760      0    296603   491.4s

So it the lazy constraint approach is solving a smaller problem. It just takes longer. Is this just a special case? An outlier? Or something more fundamental in HiGHS? I don't know at the moment.

@odow
Copy link
Copy Markdown
Collaborator Author

odow commented May 15, 2026

The answer is that the solve times are highly variable for different random seeds. I get anywhere between 180 seconds and 650 seconds. It depends whether we manage to solve the second problem almost at the root node, or if we start branching. I'll get some instances for @Opt-Mucca since the ones where we branch are ideal candidates for his parallel MIP solver.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant