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 the new interface for objective functions and derivatives #512

Merged
merged 32 commits into from
Aug 9, 2024

Conversation

janosg
Copy link
Member

@janosg janosg commented Aug 1, 2024

The changes for the objective function are described here

The changes for derivatives are described here

The jax integration is postponed to a later PR as it does not entail any breaking changes or deprecations.

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@janosg janosg changed the base branch from main to 0.5.0 August 1, 2024 16:30
Copy link
Member

@timmens timmens left a comment

Choose a reason for hiding this comment

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

Very nice PR, this is a big leap towards the new release 🎉

I only have a few clarifying questions. Once these are discussed, I will approve.

src/estimagic/estimate_msm.py Show resolved Hide resolved
src/optimagic/deprecations.py Show resolved Hide resolved
src/optimagic/mark.py Outdated Show resolved Hide resolved
src/optimagic/optimization/create_optimization_problem.py Outdated Show resolved Hide resolved
src/optimagic/shared/process_user_function.py Outdated Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

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

Why can we not use the .internal_value(solver_type) strategy here?

Copy link
Member Author

Choose a reason for hiding this comment

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

We are not simply evaluating a decorated version of the user provided fun but internal_criterion_and_derivative with the task criterion. So we don't get a SpecificFunctionValue object here. But I could get rid of the manual aggregation in a different way, by pretending we are using internal_criterion_and_derivative for a scalar optimizer.

Copy link
Member Author

Choose a reason for hiding this comment

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

Still couldn't delete _aggregate_func_output_to_value but should be possible when we have the new internal algorithm interface (which will have better result objects).

tests/estimagic/test_estimate_ml.py Outdated Show resolved Hide resolved
tests/optimagic/shared/test_process_user_functions.py Outdated Show resolved Hide resolved
tests/optimagic/test_mark.py Outdated Show resolved Hide resolved
docs/source/how_to/how_to_derivatives.ipynb Show resolved Hide resolved
@@ -0,0 +1,276 @@
{
Copy link
Member

@timmens timmens Aug 9, 2024

Choose a reason for hiding this comment

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

Line #6.        fun=sphere,

Do we need to pass fun if we pass fun_and_jac?


Reply via ReviewNB

Copy link
Member Author

Choose a reason for hiding this comment

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

Currently yes but I created an issue to remove this limitation.

docs/source/how_to/how_to_derivatives.ipynb Show resolved Hide resolved
Copy link
Member

@timmens timmens left a comment

Choose a reason for hiding this comment

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

Looks good, only one comment about a comment.

src/optimagic/shared/process_user_function.py Outdated Show resolved Hide resolved
@janosg janosg merged commit 735dfe1 into 0.5.0 Aug 9, 2024
16 checks passed
@janosg janosg deleted the criterion-interface branch August 9, 2024 13:43
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