Add public Solver.from_file API for existing LP/MPS files - #996
danielelerede-oet wants to merge 2 commits into
Conversation
Merging this PR will not alter performance
Comparing Footnotes
|
|
We tested head The small HiGHS LP/MPS cases cover file-byte preservation, native solver access, options, status, comparison with the legacy path and external variable names. This API looks useful for replaying exported BirdFlow MPS files when diagnosing solver options or versions. We have not yet replayed a full BirdFlow MPS through it; other backends and repeated-run behavior remain untested. For that workflow, the empty model-indexed primal/dual results without a linopy model are worth documenting prominently. Consumers need native values and labels before closing the solver, plus explicit mapping back to PyPSA components. One possible follow-up: check the native Our assessment and reproduction details are published.
168-hour BirdFlow MPS replayAdditional large-model replay check, using head A sealed 168-hour BirdFlow production float64 LP contained approximately 2.58 million rows, 1.66 million columns and 4.99 million nonzeros. Production linearized unit commitment was applied explicitly; native variable types were preserved and verified continuous. HiGHS 1.15.1 used HiPO, 3 threads and crossover on. Native direct and Native vectors were not identical: maximum generator dispatch difference was 3634 MW and storage state-of-charge difference 11.3 GWh. Raw nodal-balance dual differences stayed below 1.05e-7; other dual vectors differed. This does not establish identical operational outputs or exported prices. No API defect appeared; no speed or annual-validation claim is made. |
Related to open-energy-transition/solver-benchmark#604 (cc @eantonini).
Note
The following technical summary and validation report were generated with AI assistance.
Changes proposed in this Pull Request
Adds
Solver.from_file(name, problem_fn, options=...)as a public, non-deprecated entry point for solving existing LP/MPS files without constructing a linopyModel.The constructor validates the solver's file-reading capability and input path, copies solver options, and prepares the existing file-based solve path. The backend reads the input during
solve().This PR also:
Existing backend restrictions and result semantics remain unchanged. Without a linopy Model, label-indexed primal and dual arrays may be empty; this limitation is documented.
Validation
Solver.from_file: LP and MPS passed, including objective, native variable values and input preservation.--forked: 212 passed, 20 skipped, 4 failed. The remaining failures occur in existing tests that open a second Gurobi environment while the first remains active, which the single-use license rejects.mypy linopy/solvers.py: passed.Checklist
AGENTS.md).doc.doc/release_notes.rstof the upcoming release is included.