Skip to content

Add needs_bounds and supports_infinite_bounds fields in algo info #610

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jul 16, 2025

Conversation

gauravmanmode
Copy link
Collaborator

@gauravmanmode gauravmanmode commented Jul 8, 2025

PR Description

This PR references issue #597.
Currently, there is no easy way to find out if an algorithm requires bounds. Not all algorithms that support supports bounds also requires them.

Proposed Solution:

  • Add a needs_bounds and supports_infinite_bounds field analogus to suuports_bounds in the mark.minimizer decorator.

  • Optional: Strict checking of needs_bounds and supports_infinite_bounds fields in optimize.py.

  • This requires a new exception for error handling, namely:

    • IncompleteBoundsError if bounds are required but not provided or if infinite value is encountered in parameter bounds.

This table lists values for each optimizer that supports bounds.

Show Table
type name needs_bounds supports_infinite_bounds reason
LOCAL fides False True algo works on unconstrained problems, set to -np.inf and np.inf for unbounded
LOCAL iminuit_migrad False True "setting bounds makes a transfom of internal parameters like optimagic, set to None if inf values"
LOCAL ipopt False True it will set to -np.inf and np.inf itself
LOCAL nag_dfols False True algo works with unconstrained var; bounds not compulsory
LOCAL nag_pybobyqa False True "
GLOBAL nevergrad_bo False False samples from N(0,1)
GLOBAL nevergrad_cga False False "
GLOBAL nevergrad_cmaes False False "
GLOBAL nevergrad_de False False "
GLOBAL nevergrad_eda False False "
GLOBAL nevergrad_emna False False "
GLOBAL nevergrad_meta False False "
GLOBAL nevergrad_NGOpt False False "
GLOBAL nevergrad_oneplusone False False "
GLOBAL nevergrad_pso False False "
GLOBAL nevergrad_randomsearch False False "
GLOBAL nevergrad_samplingsearch False False "
GLOBAL nevergrad_tbpsa False False "
LOCAL nlopt_bobyqa False True If a lower/upper bound is not set, the default is no bound (unconstrained, i.e. a bound of infinity)
LOCAL nlopt_ccsaq False True "
LOCAL nlopt_cobyla False True "
GLOBAL nlopt_crs2_lm True False Only bound-constrained problems are supported by this algorithm.
GLOBAL nlopt_direct True False "
GLOBAL nlopt_esch True False "
GLOBAL nlopt_isres True False "
LOCAL nlopt_lbfgsb False True If a lower/upper bound is not set, the default is no bound (unconstrained, i.e. a bound of infinity)
LOCAL nlopt_mma False True "
LOCAL nlopt_newuoa False True "
LOCAL nlopt_neldermead False True "
LOCAL nlopt_slsqp False True "
LOCAL nlopt_sbplx False True "
LOCAL nlopt_tnewton False True "
LOCAL nlopt_var False True "
LOCAL pounders False True uses normalized bounds. If none provided, uses unit cube [-1, 1]
GLOBAL pygmo_bee_colony True False need finite bounds for sampling
GLOBAL pygmo_cmaes True False "
GLOBAL pygmo_compass_search True False "
GLOBAL pygmo_de True False "
GLOBAL pygmo_de1220 True False "
GLOBAL pygmo_gaco True False "
GLOBAL pygmo_gwo True False "
GLOBAL pygmo_ihs True False "
GLOBAL pygmo_mbh True False "
GLOBAL pygmo_pso True False "
GLOBAL pygmo_pso_gen True False "
GLOBAL pygmo_sade True False "
GLOBAL pygmo_sea True False "
GLOBAL pygmo_sga True False "
GLOBAL pygmo_simulated_annealing True False "
GLOBAL pygmo_xnes True False "
GLOBAL scipy_basinhopping False True local optimizers used by algo work on unconstrained/bounded vars
GLOBAL scipy_brute True False need finite bounds
GLOBAL scipy_differential_evolution True False "
GLOBAL scipy_direct True False "
GLOBAL scipy_dual_annealing True False "
LOCAL scipy_lbfgsb False True algo works with unconstrained prob
LOCAL scipy_ls_dogbox False True "
LOCAL scipy_ls_trf False True "
LOCAL scipy_neldermead False True "
LOCAL scipy_powell False True "
GLOBAL scipy_shgo False True bounds is not a requirement for shgo, mentioned in impl paper
LOCAL scipy_slsqp False True "
LOCAL scipy_truncated_newton False True "
LOCAL scipy_trust_constr False True "
LOCAL tao_pounders False True set to -np.inf , np.inf
LOCAL tranquilo False True set to -np.inf , np.inf
LOCAL tranquilo_ls False True "

For optimizers that do not support bounds, these additional fields will be set to False.

Todo

  • Add corresponding fields in the mark.minimizer decorator for every algorithm.
  • Explain usage in the How-to-Guide on how to choose algorithms.
  • Add additional tests if required

Closes #597

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@gauravmanmode gauravmanmode changed the title Add new fields in algo info Add needs_bounds and supports_infinite_bounds fields in algo info Jul 8, 2025
Copy link

codecov bot commented Jul 8, 2025

Codecov Report

Attention: Patch coverage is 86.66667% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/optimagic/optimization/optimize.py 75.00% 2 Missing ⚠️
Files with missing lines Coverage Δ
src/optimagic/exceptions.py 88.23% <100.00%> (+0.35%) ⬆️
src/optimagic/mark.py 90.00% <ø> (ø)
src/optimagic/optimization/algorithm.py 94.94% <100.00%> (+0.15%) ⬆️
src/optimagic/optimizers/bhhh.py 90.38% <ø> (ø)
src/optimagic/optimizers/fides.py 95.77% <ø> (ø)
src/optimagic/optimizers/iminuit_migrad.py 97.29% <ø> (ø)
src/optimagic/optimizers/ipopt.py 96.92% <ø> (ø)
src/optimagic/optimizers/nag_optimizers.py 93.30% <ø> (ø)
src/optimagic/optimizers/neldermead.py 92.24% <ø> (ø)
src/optimagic/optimizers/nevergrad_optimizers.py 97.67% <ø> (ø)
... and 7 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gauravmanmode gauravmanmode requested a review from janosg July 8, 2025 12:08
@janosg
Copy link
Member

janosg commented Jul 9, 2025

About iminuit_migrad you wrote:

setting bounds makes a transfom of internal parameters like optimagic, set to None if inf values"

For optimagic users we only want inf to express missing bounds for some parameters, not None. Were you only referring to the original optimizer or is this about the optimagic wrapper?

Copy link
Member

@janosg janosg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. Looks really good. I have a few questions we can discuss during our next call.

@gauravmanmode
Copy link
Collaborator Author

Hi @janosg , I have made the suggested changes. Can you tell me if I'm missing anything?

Copy link
Member

@janosg janosg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is ready to go. Thanks a lot for this great PR!

@janosg janosg merged commit c430ee6 into main Jul 16, 2025
23 checks passed
@janosg janosg deleted the add_new_fields_in_algo_info branch July 16, 2025 09:12
@janosg janosg mentioned this pull request Jul 16, 2025
13 tasks
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.

Should AlgoInfo have a needs_bounds field?
2 participants