Skip to content
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

Implement filtered autocomplete for algorithm selection #534

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

janosg
Copy link
Member

@janosg janosg commented Sep 24, 2024

Short description

After this PR, algorithms can for example be selected as follows:

import optimagic as om
import numpy as np 
 
om.minimize(
    fun=lambda x: x @ x,
    params=np.arange(3),
    algorithm=om.algos.Bounded.scipy_lbfgsb,
)

After typing om.algos.Bounded, the autocomplete in any modern editor will only suggest algorithms that support bound constraints.

Categories that can be used to filter algorithms are:

  • GradientBased
  • GradientFree
  • Global
  • Local
  • Bounded
  • LinearConstrained
  • NonlinearConstrained
  • LeastSquares
  • Likelihood
  • Parallel

Categories can be selected in any order. We make sure that mutually exclusive categories (e.g. Local and Global) cannot be selected at the same time.

Detailed description

The changes are described in EP-02: Static Typing

Deviations from the EP

  • The Unbounded and Unconstrained categories were removed because people rarely want to specifically choose an optimizer that does not support constraints or bounds.
  • om.algorithms was renamed to om.algos because it is still unambiguous and makes the code shorter, which hopefully improves adoption of using this instead of strings for algorithm selection.

Copy link

codecov bot commented Sep 24, 2024

Codecov Report

Attention: Patch coverage is 86.14458% with 207 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/optimagic/algo_selection.py 86.11% 207 Missing ⚠️
Files with missing lines Coverage Δ
src/optimagic/__init__.py 100.00% <100.00%> (ø)
src/optimagic/config.py 70.96% <100.00%> (+0.47%) ⬆️
src/optimagic/algo_selection.py 86.11% <86.11%> (ø)

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.

2 participants