-
Notifications
You must be signed in to change notification settings - Fork 24
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
Restructure optimisers to enable passing of kwargs #255
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #255 +/- ##
===========================================
+ Coverage 95.81% 96.93% +1.12%
===========================================
Files 39 41 +2
Lines 2101 2222 +121
===========================================
+ Hits 2013 2154 +141
+ Misses 88 68 -20 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done @NicolaCourtier - thanks for the addition!
I've added a few comments for you to look at. One addition is to update optimiser.needs_sensitivities
depending on self.options["method"]
. If not added in this PR, we should open an issue to add gradient support for the scipy optimisers.
Also, we should probably align the name of the bounds variable between the pints and the scipy optimisers. This can also be done in a separate PR.
This PR now includes changes to the PINTS interface as well as SciPy and introduces a true
Note that this update nests the PINTS optimiser within the optimiser property of an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought I would add a review on this even though it's not marked ready. It's a great step for the optimisers. There are a few areas I think we can improve, but thanks for the addition @NicolaCourtier!
Co-authored-by: Brady Planden <55357039+BradyPlanden@users.noreply.github.com>
Co-authored-by: Brady Planden <55357039+BradyPlanden@users.noreply.github.com>
Co-authored-by: Brady Planden <55357039+BradyPlanden@users.noreply.github.com>
Co-authored-by: Brady Planden <55357039+BradyPlanden@users.noreply.github.com>
Co-authored-by: Brady Planden <55357039+BradyPlanden@users.noreply.github.com>
Co-authored-by: Brady Planden <55357039+BradyPlanden@users.noreply.github.com>
This reverts commit aa73bff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for the additions @NicolaCourtier!
* Splits Optimisation -> BaseOptimiser/Optimisation, enables two optimisation APIs, updts where required, moves _optimisation to optimisers/ * increase coverage * Pass optimiser_kwargs though run() * updt examples * Converts DefaultOptimiser -> Optimisation * split Optimisation and BaseOptimsier classes, loosen standalone cost unit test * add incorrect attr test * fix: updt changelog entry, optimsation_interface notebook, review suggestions * fix: updt notebook state * Updt assertions, optimisation object name --------- Co-authored-by: NicolaCourtier <45851982+NicolaCourtier@users.noreply.github.com>
* Enable passing of kwargs to SciPy * Update checks on bounds * Add update_options and error for Pints * Rename opt to optim * Remove stray comments * Add BaseSciPyOptimiser and BasePintsOptimiser * Align optimiser option setting * Update notebooks with kwargs * Update scripts with kwargs * Update notebooks * Align optimisers with Optimisation as base class * Update stopping criteria in spm_NelderMead.py Co-authored-by: Brady Planden <55357039+BradyPlanden@users.noreply.github.com> * Update stopping criteria in spm_adam.py Co-authored-by: Brady Planden <55357039+BradyPlanden@users.noreply.github.com> * Update sigma0 in spm_descent.py Co-authored-by: Brady Planden <55357039+BradyPlanden@users.noreply.github.com> * Update GradientDescent * Change update to set and check pints_method * Update test_optimisation_options * Update notebooks * Update set learning rate * Pop threshold * Fix bug in model.simulate * Update notebooks * Update test_models.py * Store SciPy result * Update x0 input and add tests * Update bounds to avoid x0 outside * Re-initialise pints_method on certain options * Update x0_new test * Update test_optimisation.py * Create initialise_method for PINTS optimisers * Align optimisation result * Update checks on bounds * Apply suggestions Co-authored-by: Brady Planden <55357039+BradyPlanden@users.noreply.github.com> * Add standalone optimiser * Simplify optimiser set-up and align _minimising * Update option setting in notebooks * Take abs of cost0 * Implement suggestions from Brady * Update tests and base option setting * Update test_invalid_cost * Increase coverage * Sort out notebook changes * Reset scale parameter * Move settings into arguments * Update comments * Update optimiser call * Move check on jac * Add assertions * Add maxiter to test * Add assertion * Update to lambda functions Co-authored-by: Brady Planden <55357039+BradyPlanden@users.noreply.github.com> * Update comment Co-authored-by: Brady Planden <55357039+BradyPlanden@users.noreply.github.com> * Update to list comprehension Co-authored-by: Brady Planden <55357039+BradyPlanden@users.noreply.github.com> * Formatting * Revert "Update to lambda functions" This reverts commit aa73bff. * Move minimising out of costs * Update description * Updates to #236 to avoid breaking change to `pybop.Optimisation` (#309) * Splits Optimisation -> BaseOptimiser/Optimisation, enables two optimisation APIs, updts where required, moves _optimisation to optimisers/ * increase coverage * Pass optimiser_kwargs though run() * updt examples * Converts DefaultOptimiser -> Optimisation * split Optimisation and BaseOptimsier classes, loosen standalone cost unit test * add incorrect attr test * fix: updt changelog entry, optimsation_interface notebook, review suggestions * fix: updt notebook state * Updt assertions, optimisation object name --------- Co-authored-by: NicolaCourtier <45851982+NicolaCourtier@users.noreply.github.com> * Rename method to pints_optimiser * Rename base_optimiser to pints_base_optimiser * Rename _optimisation to base_optimiser --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Brady Planden <55357039+BradyPlanden@users.noreply.github.com>
Description
Enable valid keyword arguments to be passed through the set-up of an
Optimisation
class and restructure the optimiser classes so that all PINTS and SciPy optimisers are subclasses of the same BaseOptimiser.Issue reference
Fixes #236.
Review
Before you mark your PR as ready for review, please ensure that you've considered the following:
Type of change
Key checklist:
$ pre-commit run
(or$ nox -s pre-commit
) (see CONTRIBUTING.md for how to set this up to run automatically when committing locally, in just two lines of code)$ nox -s tests
$ nox -s docs
You can run integration tests, unit tests, and doctests together at once, using
$ nox -s quick
.Further checks:
Thank you for contributing to our project! Your efforts help us to deliver great software.