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

Update to allow no bounds #213

Merged
merged 15 commits into from
Feb 29, 2024
Merged

Update to allow no bounds #213

merged 15 commits into from
Feb 29, 2024

Conversation

NicolaCourtier
Copy link
Member

  • Use the spm_adam example to test optimisation without bounds, since Adam does not use them
  • Allow bounds=None in place of lower and upper bounds
  • Add checks to test_parameters
  • Raise an error in plot_cost2d if bounds not available

@NicolaCourtier NicolaCourtier linked an issue Feb 22, 2024 that may be closed by this pull request
Copy link

codecov bot commented Feb 22, 2024

Codecov Report

Attention: Patch coverage is 94.52055% with 4 lines in your changes are missing coverage. Please review.

Project coverage is 94.34%. Comparing base (29c6ff2) to head (55b6bcf).
Report is 10 commits behind head on develop.

Files Patch % Lines
pybop/_problem.py 89.47% 2 Missing ⚠️
pybop/optimisers/pints_optimisers.py 80.00% 1 Missing ⚠️
pybop/optimisers/scipy_optimisers.py 90.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #213      +/-   ##
===========================================
+ Coverage    94.29%   94.34%   +0.04%     
===========================================
  Files           32       32              
  Lines         1614     1661      +47     
===========================================
+ Hits          1522     1567      +45     
- Misses          92       94       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@BradyPlanden BradyPlanden 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, thanks for the addition @NicolaCourtier!

Just to confirm, have you checked the performance of the non-gradient based optimisers without bounds added? Bounds are optional from the Pints side, but it would be good to check that they don't affect our solutions.

It would also be good to remove the bounds from the IRPropMin and GradientDescent examples.

@NicolaCourtier
Copy link
Member Author

Thanks for the comment @BradyPlanden - I've updated the two other examples as suggested.

What kind of performance tests are you thinking of for the non-gradient-based optimisers? If there are parameter values for which there is no solution, the optimiser can fail at the initial point but the likelihood of this is strongly dependent on the choice of prior.

@BradyPlanden
Copy link
Member

BradyPlanden commented Feb 23, 2024

Thanks - looks great!

I would consider updating the test_parameterisation/test_spm_optimisers test with one parameter that doesn't have bounds. That would give us continual check to ensure the lack of bounds on a parameter doesn't effect any current or future optimiser performance.

@NicolaCourtier
Copy link
Member Author

Hi @BradyPlanden, this might be worth a second review. I've made the following changes in order to implement your suggestion to have one parameter without bounds in the parameterisation tests:

  • add mean and sigma as properties to the non-Gaussian priors
  • pass sigma from the prior through the base problem, cost and optimisation classes to become sigma0 for PINTS
  • implement any missing bounds (if some bounds are given) as +/- np.inf
  • move the setting of bounds to __init__ for the SciPy optimisers to match PINTS
  • update the bounds check for PINTS PSO and SciPy Differential Evolution which require bounds which are all finite or None
  • add set_bounds to Parameter to allow for consistent updating of bounds, upper and lower (in future, it may be good to pass bounds, sigma and x0 all as part of the parameters object - I think this is related to Add likelihood classes #210)
  • add a default cost value to the min() in plot_convergence in case of unsuccessful iterations
  • update test_optimisation and test_parameterisations to include tests without bounds
  • add property checks to test_priors
  • update the Changelog

@BradyPlanden BradyPlanden mentioned this pull request Feb 26, 2024
5 tasks
Copy link
Member

@BradyPlanden BradyPlanden 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 adding in the additional code for unbounded optimisation @NicolaCourtier! I have a few comments in areas that I think we can improve code comprehension. All in all it's looking very good!

pybop/_problem.py Show resolved Hide resolved
pybop/_problem.py Outdated Show resolved Hide resolved
pybop/_problem.py Outdated Show resolved Hide resolved
pybop/_problem.py Show resolved Hide resolved
pybop/_problem.py Outdated Show resolved Hide resolved
pybop/optimisers/scipy_optimisers.py Outdated Show resolved Hide resolved
pybop/parameters/parameter.py Show resolved Hide resolved
pybop/parameters/parameter.py Outdated Show resolved Hide resolved
pybop/plotting/plot_convergence.py Show resolved Hide resolved
tests/integration/test_parameterisations.py Show resolved Hide resolved
NicolaCourtier and others added 3 commits February 29, 2024 10:30
Co-authored-by: Brady Planden <55357039+BradyPlanden@users.noreply.github.com>
Co-authored-by: Brady Planden <55357039+BradyPlanden@users.noreply.github.com>
@NicolaCourtier NicolaCourtier merged commit a168149 into develop Feb 29, 2024
31 checks passed
@NicolaCourtier NicolaCourtier deleted the 211-bounds-none branch February 29, 2024 13:22
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.

[Bug]: Allow parameters without bounds
2 participants