Skip to content

[unopy] Apply the preset when it is set with set_option("preset", ...) - #1039

Merged
cvanaret merged 2 commits into
cvanaret:mainfrom
A-CGray:unopy-set-option-preset
Nov 3, 2026
Merged

cvanaret merged 2 commits into
cvanaret:mainfrom
A-CGray:unopy-set-option-preset

Conversation

@A-CGray

@A-CGray A-CGray commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #1040

This change adds one function, UnoSolverWrapper::set_preset.
Both set_preset and set_option("preset", ...) now use it

Tests

This change adds three tests to interfaces/Python/tests/test_solvers.py:

  • test_preset_as_option does a check of each preset: filtersqp, filterslp, funnelsqp, ipopt and auto.
    It solves hs015 two times: one time with set_option("preset", ...), and one time with set_preset.
    The test makes sure that the two solves use the same method and give the same result.
  • test_preset_option_overrides_previous_preset sets the preset two times: first with set_preset, then with set_option.
    The test makes sure that the solver uses the second preset.
  • test_unknown_preset_raises sets a preset name that does not exist.
    The test makes sure that both set_option and set_preset raise an error immediately.

🤖 Generated with Claude Code

The string set_option overload only stored "preset" in the user options and
never refreshed the preset options, so optimize() overlaid an empty preset and
failed on a missing ingredient option (e.g. inequality_handling_method).
set_preset and set_option("preset", ...) now go through a single
UnoSolverWrapper::set_preset, matching the C API's uno_set_solver_string_option.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@A-CGray
A-CGray marked this pull request as ready for review November 2, 2026 23:27
Comment thread interfaces/Python/tests/test_solvers.py Resolved
Co-authored-by: Charlie Vanaret <vanaret@zib.de>
@cvanaret

cvanaret commented Nov 3, 2026

Copy link
Copy Markdown
Owner

@A-CGray great catch, thanks a lot!

@cvanaret
cvanaret merged commit 0650f38 into cvanaret:main Nov 3, 2026
117 checks passed
@cvanaret

cvanaret commented Nov 3, 2026

Copy link
Copy Markdown
Owner

Patched in unopy 0.4.17.

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.

Setting preset through set_option results in error

2 participants