WIP: upgrade to rtc-tools 2.7.3, casadi 3.7.2, rtctools-highs 0.1.3#483
WIP: upgrade to rtc-tools 2.7.3, casadi 3.7.2, rtctools-highs 0.1.3#483jarsarasty wants to merge 4 commits into
Conversation
- Replace rtc-tools-gil-comp and casadi-gil-comp with rtc-tools 2.7.3 and rtctools-highs 0.1.3 (casadi 3.7.2 pinned transitively) - Register HiGHS 1.14.0 CasADi plugin via import in mesido/__init__.py - Widen python_requires to >=3.10,<3.15 - Update solver docstrings from cbc to HiGHS - Fix __state_vector_scaled duplication: delegate to BaseProblemMixin - Add BaseProblemMixin to FinancialMixin bases - Add presolve=off workaround for HiGHS 1.14.0 (ERGO-Code/HiGHS#2388) in HeatProblem and HeatProblemSetPoints; HeatProblemPlacingOverTime explicitly removes it as it needs presolve on for correct solution - Fix test_multicommodity: use asset IDs and correct .__disabled key - Fix test_electricity_storage: use asset IDs, relax tolerance - Fix test_gas_pipe_topology_optimization: relax atol 1e-10 -> 1e-6 - Add test_highs_solver.py: verify HiGHS 1.14.0 and GIL release - Raise tox.ini end_scenario_sizing timeout 120s -> 300s - Remove CBC solver override from test_multicommodity price_profile test - Tighten python_requires to <3.13 (pandas<2.0 has no wheels for 3.13+) - Add comment on CBC removal in test_multicommodity explaining why HiGHS 1.14.0 via rtctools-highs 0.1.3 now passes correctly Known failing (WIP): - test_head_loss::test_heat_network_pipe_split_head_loss: HiGHS 1.14.0 finds different valid flow split; test assumption too strict - test_end_scenario_sizing_staged: IndexError on _priorities_output[1], suggests a priority solve is failing with HiGHS 1.14.0
|
Hi @KobusVanRooyen, With the changes in this PR, we can finally run the latest Highs version (1.14) in mesido. However, two tests are failing due to numerical issues or testing assumptions, and some adjustments should be implemented in a separate PR before we merge this PR:
The piecewise-linear DW approximation introduces near-zero constraint coefficients that can cause numerical ill-conditioning in HiGHS 1.14.0, potentially leading to a suboptimal solution. The assertion could be relaxed to a lower-bound check pending investigation
|
Hi @jarsarasty. Some feedback:
And by the way the only test that I see currently failing is tests/test_head_loss.py::TestHeadLoss::test_heat_network_pipe_split_head_loss (with all the presolve turned in the branch dated 2026/06/10) |
| "pyesdl == 26.3", | ||
| "pandas >= 1.3.1, < 2.0", | ||
| "casadi-gil-comp == 3.6.7", | ||
| "rtctools-highs == 0.1.3", |
There was a problem hiding this comment.
Currently the specific HIGHS and CASADI version cannot be specified in MESIDO. Would it be possible to change the rtc-tools-casadi-plugins such that the HIGHS and CASADI version numbers are inputs?
There was a problem hiding this comment.
In rtc-tools-casadi-plugins now I tag releases with the the supported HiGHS/casadi versions (e.g. highs-1.15.1-casadi-3.7.2 ), which are configurable as inputs in the corresponding GitHub workflow.
There was a problem hiding this comment.
Regarding the idea of defining arbitrary casadi highs-casadi versions in mesido, the implementation would not be very practical in the short term, since it would require building and shipping multiple plugins for different highs-casadi versions. The practical approach for now is to publish the rtctools-highs package for the required highs-casadi versions, and with the new setup where the versions can be defined via input fields in the GitHub workflow, no code changes would be needed for version updates.
In this PR, I have pinned rtctools-highs==0.1.4 and added an explicit casadi==3.7.2 pin in setup.py to match.
In a follow-up in rtc-tools-casadi-plugins, I will expose the bundled HiGHS version as a runtime constant ( rtctools_highs.highs_version ) so tests can check against a package-provided value
| Operating System :: MacOS | ||
| """ | ||
|
|
||
| if sys.version_info < (3, 10): |
There was a problem hiding this comment.
I would not remove this but rather update the version numbers
There was a problem hiding this comment.
Restored the sys.version_info check (updated the supported range to 3.10–3.12). Good catch, thanks
| achieved by having an upper limit on the investment per time-step. | ||
| """ | ||
|
|
||
| def solver_options(self): |
There was a problem hiding this comment.
I am aware that you will still investigate potential solutions such that we do not have to turn of presolve. But this part is not needed, since presolve is already turned off in the inherited problem class (HeatProblem)
There was a problem hiding this comment.
You're right, it was already disabled via the HeatProblem class. Removed.
| Operating System :: MacOS | ||
| """ | ||
|
|
||
| if sys.version_info < (3, 10): |
There was a problem hiding this comment.
Please update with main before continuing, since there has been some fixes regarding network settings which might have an impact on the head loss testing
There was a problem hiding this comment.
Updated. Thanks!
| highs_options["mip_rel_gap"] = 0.02 | ||
| highs_options["presolve"] = "on" | ||
|
|
||
| # workaround for HiGHS 1.14.0 presolve bug (ERGO-Code/HiGHS#2388) |
There was a problem hiding this comment.
Not ideal. Any other insights in this one to potential get rid of this?
So this one is here for test_setpoint_constraints.py (test_run_small_ates_timed_setpoints_2_changes, test_run_small_ates_timed_setpoints_0_changes, test_run_small_ates_timed_setpoints_multiple_constraint --> presolve_infeasible_or_unbounded_priority_1)
There was a problem hiding this comment.
Re-tested with rtctools-highs 0.1.4 (HiGHS 1.15.1) — still required. Comment updated with the currently-open upstream presolve issues.
| options["casadi_solver"] = self._qpsol | ||
| highs_options = options.setdefault("highs", {}) | ||
| # workaround for HiGHS 1.14.0 presolve bug (ERGO-Code/HiGHS#2388) | ||
| highs_options["presolve"] = "off" |
There was a problem hiding this comment.
HiGHS#2388 -> I assume this refers to a specific issue number, but I cannot find it in https://github.com/ERGO-Code/HiGHS/issues?q=is%3Aissue%20state%3Aopen
Can you please clarify?
There was a problem hiding this comment.
The reference was to a presolve issue that I had reported ERGO-Code/HiGHS#2388.
The comment has been updated with the current open presolve issues.
| """ | ||
| options = super().solver_options() | ||
| options["casadi_solver"] = self._qpsol | ||
| highs_options = options.setdefault("highs", {}) |
There was a problem hiding this comment.
Not ideal. Any other insights to potentially not turn off presolve?
This one is needed for tests/test_ates.py::TestAtes::test_ates
There was a problem hiding this comment.
Same as above. I re-tested with HiGHS 1.15.1 and it is still required. Comment updated accordingly.
Regarding the root cause fix:
I have investigated the open pre-solve issues in HiGHS and will propose fixes to the developers. However, there is a chance that the pre-solve infeasibility in this test is a new regression. In that case, I will try to perform a Git bisect to identify the version where the bug was introduced.
| @@ -0,0 +1,77 @@ | |||
| """Tests for HiGHS 1.14.0 integration via rtctools-highs. | |||
There was a problem hiding this comment.
I am a bit uncertain about this test. Since the idea originally was to be able to specify the version number of casadi and highs in mesido (de-linked via mesido). I will think about this topic a bit futher and get back to you
But here is some feedback:
In this test all version numbers are hard-coded and specific version numbers are also mentioned in the comments/doc strings. I think this needs to be made a bit more generic with no version numbers mentioned in the text and all version numbers in the test itself should ideally be a variable where one sets the version number.
There was a problem hiding this comment.
Updated: docstring and comments no longer mention specific version numbers; the only place a version appears is the EXPECTED_HIGHS_VERSION variable, which is the single point to update when the rtctools-highs pin changes.
…rtctools-highs, fix scaling bug, de-hardcode test versions - setup.py: restore explicit sys.version_info runtime check (updated to 3.10-3.12 range) instead of relying solely on python_requires; add explicit casadi==3.7.2 pin; bump rtctools-highs to 0.1.4 (HiGHS 1.15.1) - run_ates.py (HeatProblemPlacingOverTime): fix unscaled bound in t=0 investment cap constraint (200000.0 -> 200000.0 / nominal) - run_ates.py: clarify HiGHS presolve workaround comments with accurate issue references (ERGO-Code/HiGHS#3090, #3074) instead of the unverifiable #2388 reference; re-verified workaround still required with HiGHS 1.15.1 - test_highs_solver.py: replace hard-coded version numbers with a single EXPECTED_HIGHS_VERSION constant (now 1.15.1) and a comment instructing maintainers to update it from the rtctools-highs release tag
45bdd7e to
82a1606
Compare
…c-tools-2.7.3-casadi-3.7.2
82a1606 to
6a26f9a
Compare
Known failing (WIP):