Repository navigation
HiGHS: build the model with one addCols and one addRows call - #957
Merged
Merged
Conversation
buildSolverModel added every column and every row with its own highspy call, and read the objective coefficient per column through lp.objective, which clones the expression on each access. On a model with 3000 columns, 3500 rows and 8000 nonzeros that build took 29 ms against a 1.4 s solve, and on the short re-solves of a multi-stage optimisation it was 7% of the median request and 16% at the 90th percentile. Collect costs, bounds, integrality and the row-major matrix into numpy arrays and hand them to HiGHS in one addCols, one changeColsIntegrality and one addRows. The arrays HiGHS ends up holding are identical; the build takes 3 to 6 ms on the same model. numpy is already a dependency. The warm start block is unchanged. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
andig
added a commit
to evcc-io/optimizer
that referenced
this pull request
Oct 11, 2026
…GHS model build (#199) * perf: build the HiGHS model in bulk pulp 4.0.0 feeds HiGHS one addCol and one addRow call per column and row and re-reads the objective for every column, 0.028 s per solve on this model natively, 6.5 % of a HiGHS request at the median and 15 % at p90 in the amd64 benchmark, paid again on every stage. One addCols and one addRows call bring it to 0.004-0.006 s: paired on 170 captured requests the request time drops 5.5 % at the median and 8 % on the 1 to 5 s band, with identical model arrays. This is coin-or/pulp#957 as a subclass, to be dropped once a pulp release carries it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * perf: hybrid solver, CBC for the joint probe and HiGHS for the split stages Production on HiGHS alone (2026-10-11 12:10 to 13:10Z) lifted p99 from 6.4 to 8.5 s and replicas from 4.4 to 7, and was rolled back: of 54 captured requests CBC proves joint in 1 to 5 s, HiGHS needs 2.5 to 5 times longer on 8, overruns the 2 s probe and pays a 6 to 8 s split for each. On the split stages HiGHS is the better solver, 11 CBC Not Solved on the slow captures become 9 Optimal and 2 Feasible. OPTIMIZER_SOLVER=hybrid gives each stage the solver that wins it: the probe runs on CBC, cost, tie break and continuity on HiGHS. Measured paired on 170 captured requests it matches CBC on the mid band (p90 2.05 against 2.01 s, no splits) and keeps HiGHS's statuses, at the price of the 19 slow requests HiGHS proves joint in about 1.3 s, which the hybrid splits; total time is CBC's. The default stays cbc. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
pchtsp
reviewed
Oct 12, 2026
pchtsp
left a comment
Collaborator
There was a problem hiding this comment.
thanks, this makes sense to me. I left a very minor comment. Let me know if it makes sense, if does, make it and I merge
Review suggestion from pchtsp. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This was referenced Oct 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
HiGHS.buildSolverModeladds every column and every row with its own highspy call, and reads the objective coefficient per column throughlp.objective, which clones the expression on each access.On a model with 3000 columns, 3500 rows and 8000 nonzeros that build takes 29 ms against a 1.4 s solve. On a multi-stage optimisation that re-solves the same problem several times per request (evcc-io/optimizer, where this came up), the build is 7% of the median request time and 16% at the 90th percentile.
This collects costs, bounds, integrality and the row-major matrix into numpy arrays and hands them to HiGHS in one
addCols, onechangeColsIntegralityand oneaddRows. The arrays HiGHS holds afterwards are identical to the per-call build (verified withgetLp()on three models, and asserted on a small one in the new test); the build drops to 3–6 ms on the same model. numpy is already a dependency. The warm start block is unchanged.Independent of #956 (that one touches
actualSolve/buildStats).Tests:
pulp.tests.test_highs34 tests OK (5 skipped), ruff and ty clean.🤖 Generated with Claude Code