-
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
Datatype restructure for optimisation objects #224
Datatype restructure for optimisation objects #224
Conversation
…y. Update tests, add base model classes to init, cleaner multi-signal interaction
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 @BradyPlanden, I've had a quick look through and all seems good, happy with the change to dictionaries naming the y
and dy
outputs. I wasn't sure what default_variables
was, but I don't really know how the design stuff works so that is probably why
|
||
np.testing.assert_allclose(x, 3.138, atol=1e-2) | ||
np.testing.assert_allclose(rmse_x, 3.05615, atol=1e-2) |
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 change was a bit worrisome, since the value should remain constant. I did a comparison with Pints' logic and it returned the updated value as well, pointing towards a bug in the previous RMSE calculation.
…er tests, dict output observer.evaluate()
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 177b-plotting-capabilities #224 +/- ##
==============================================================
+ Coverage 93.92% 94.08% +0.15%
==============================================================
Files 35 35
Lines 1762 1826 +64
==============================================================
+ Hits 1655 1718 +63
- Misses 107 108 +1 ☔ View full report in Codecov by Sentry. |
…version due to breaking change in 8.1.0
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 think this PR is heading in a very useful direction! Thanks @BradyPlanden. Here are some initial comments.
-
On the naming of
additional_variables
- can you make it clear what these variables are in addition to, in the description? Are they optional extras for plotting? Or perhapsrequired_variables
, i.e. the variables that are required for the specific optimisation problem? -
Do you think that
Discharge capacity [A.h]
will be required for all types of design problem? I would expect different requirements for different design costs. Could further variables be added as part of the Cost? -
I'm also not sure why the passing of
additional_variables
is limited to the Base and EChem models, why not the PyBaMM ECM models for example? If this logic is required, please add a warning for times when the input is not being used. -
In the cost functions, it is not clear to me why these two variables have been selected:
if key not in ["Time [s]", "Discharge capacity [A.h]"]:
and
if signal not in ["Time [s]", "Discharge capacity [A.h]"]
The original check was designed to cope with simulations that terminate early (which we expect in several situations such as reaching a voltage limit during the simulation). However, as written I think it is too general and could hide other, unexpected errors.
- Please can you increase the coverage and check why one of the tests appears to be failing?
These variables are in addition to the variables selected in the signal object. At the moment we lack this functionality, so this provides the user with the ability to capture additional variables from the forward model prediction. In the case of plotting, the better way to do this would be to save the pybamm solution object and reuse it in plotting. That's probably worth a separate PR in the near future.
At the moment this is an uncharted area, this PR provides the mechanisms to explore this further in future PRs. The decision on the
Probably because our tests don't pick this up. Another good place to improve. Although it's not specifically passed to EChem models, it's only within BaseModel at the moment. This was missed in the shuffle.
Added a few comments to make this more clear. Probably needs to be added to the docstring as well.
I need to do a double check on the failing windows examples, but I'm not confident it's isolated to this PR. I'm pretty sure we've been seeing it on the scheduled tests. |
… Discharge capacity as default additional_variable
…icode, add infeasible unit test
I believe the above issues have been addressed, I'm going to merge this into 177b and we can continue the discussion there. |
a9ea84c
into
177b-plotting-capabilities
I'm raising this commit to a PR as I believe there are enough changes to the backend to warrant a review at this stage. This started as an update to the plotting class to include alternative x-axis variables, but moved towards refactoring the pybop backend to make this possible.
This PR restructures PyBOP's datatypes for model output (
y
&dy
). As such, knock-on changes to the problem and cost classes were required. The main benefits of these changes are to move away from numpy array objects where possible and replace them with dictionaries. This PR achieves the following:problem.signal
becomes the only requirement.model.simulate
and the corresponding cost function classes.problem.additional_variables
object to capture variables needed within the design problem class, as well as plotting.x0
and not the groundtruth. They have been updated to sample from a random normal distribution to set the groundtruth, withx0
also randomly sampled too. This now represents the true optimiser performance.@NicolaCourtier @martinjrobins, there are quite a few changes in this one, and I would appreciate it if you both could take a good look at any potential bugs or improvements. I've spent a lot of time double-checking the cost function calculations, but it's very possible that I've missed something.
At the moment, the
UKF
tests are failing, I need to take a second look at them. @martinjrobins, if you can take a look as well that would be appreciated.