-
Notifications
You must be signed in to change notification settings - Fork 28
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
Include PyBaMM solution in OptimizationResult #573
base: develop
Are you sure you want to change the base?
Include PyBaMM solution in OptimizationResult #573
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #573 +/- ##
===========================================
+ Coverage 99.08% 99.15% +0.07%
===========================================
Files 52 56 +4
Lines 3605 3913 +308
===========================================
+ Hits 3572 3880 +308
Misses 33 33 ☔ View full report in Codecov by Sentry. |
This is looking great - thanks @pipliggins! To ensure the pybamm solution matches the optimal parameter values, I would consider updating the code to run the forward model with the |
Hey @BradyPlanden I'm just coming back to this - can you point me at which part you're talking about? |
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.
Hi @pipliggins - hopefully this helps!
@@ -359,6 +359,7 @@ def fun(x): | |||
n_iterations=self._iterations, | |||
optim=self, | |||
time=total_time, | |||
pybamm_solution=self.cost.problem.solution, |
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.
This returns the solution of the last parameter values ran by the optimiser, whereas the user would want the solution from the best parameter combination. This will be the value stored in x
parameter above. One method would be add to call the forward model with the x_best
values a final time before accessing self.cost.problem.solution
. This only needs to be done for the Pints' based methods since the SciPy optimisers return the optimal value from their self._run_optimiser()
i.e. we don't have the same granular access.
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.
Ahhh okay makes sense, thanks!
Description
Saves the latest pybamm solution object into a Problem class, to add into an OptimisationResult.
Issue reference
Fixes #548
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 doctest
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.