Add FLEXMEASURES_LP_SOLVER_OPTIONS to configure solver options#2283
Open
Flix6x wants to merge 2 commits into
Open
Add FLEXMEASURES_LP_SOLVER_OPTIONS to configure solver options#2283Flix6x wants to merge 2 commits into
Flix6x wants to merge 2 commits into
Conversation
Solver options for the scheduling solver could previously only be set in
code (a hardcoded HiGHS profile in device_scheduler). This adds a
FLEXMEASURES_LP_SOLVER_OPTIONS config dict, merged over that profile so
operators can tune the solver (e.g. {"mip_rel_gap": "1e-4"}) without
patching FlexMeasures.
When the solver is HiGHS, the options are validated against the installed
HiGHS build: an unknown option name, an invalid value, or a feature the
build lacks raises a clear ValueError. This matters because Pyomo's
appsi_highs interface applies options without checking HiGHS' return
status, so a mistake would otherwise be silently ignored (e.g.
solver="hipo" is unavailable in the pip-installed highspy, yet appsi_highs
solves on as if nothing were wrong). Setting threads/parallel logs a
warning about HiGHS' process-global thread scheduler.
Found while investigating SeitaBV/ems#172.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LeqGFrHfGrBHAJyjdAyr3y
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LeqGFrHfGrBHAJyjdAyr3y
Documentation build overview
5 files changed ·
|
Flix6x
commented
Jul 12, 2026
| # Apply operator-configured options last, so they override the defaults above. | ||
| configured_options = current_app.config.get("FLEXMEASURES_LP_SOLVER_OPTIONS") or {} | ||
| if configured_options and "highs" in solver_name.lower(): | ||
| validate_highs_options(configured_options) |
Member
Author
There was a problem hiding this comment.
It would be better to do this once on startup rather than for each scheduling job.
Comment on lines
+20
to
+25
| "mip_rel_gap": "0", | ||
| "mip_abs_gap": "0", | ||
| "primal_feasibility_tolerance": "1e-9", | ||
| "dual_feasibility_tolerance": "1e-9", | ||
| "mip_feasibility_tolerance": "1e-9", | ||
| "output_flag": "false", |
Member
Author
There was a problem hiding this comment.
The settings tested here should be gotten from the operational codebase. Maybe via a shared import.
This was referenced Jul 17, 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.
What
Solver options for the scheduling solver could previously only be set in code (a hardcoded HiGHS profile inside
device_scheduler). This adds aFLEXMEASURES_LP_SOLVER_OPTIONSconfig dict, merged over that profile so operators can tune the solver without patching FlexMeasures:Validation (the important part)
When the solver is HiGHS, the options are validated against the installed HiGHS build before use. An unknown option name, an invalid value, or a feature the build lacks raises a clear
ValueError.This matters because Pyomo's
appsi_highsinterface applies options without checking HiGHS' return status — so a mistake is otherwise silently ignored. Concretely,solver="hipo"is unavailable in the pip-installedhighspy(it needs a HiGHS built against BLAS + METIS), yetappsi_highssolves on as if nothing were wrong. Anyone benchmarking such an option would get a false negative. Validation turns that silent no-op into an explicit error.Setting
threads/parallellogs a warning: HiGHS initializes its thread scheduler once per process, so in a long-lived worker only the first solve honours them and later solves fail withglobal scheduler has already been initialized.Tests
test_solver_options.pycovers: the shipped default profile stays acceptable, unknown names / invalid values / unavailable solvers raise, all rejected options are reported, andthreadswarns.Context
Found while investigating SeitaBV/ems#172 (benchmarking whether the HiGHS
hiposolver helps the HEMS scheduler — it can't even be selected from the pip wheel, andappsi_highswas hiding that).🤖 Generated with Claude Code
https://claude.ai/code/session_01LeqGFrHfGrBHAJyjdAyr3y