pybop-team / PyBOP

A parameterisation and optimisation package for battery models.
https://pybop-docs.readthedocs.io
BSD 3-Clause "New" or "Revised" License
63 stars 20 forks source link

Allow multiple datasets & models at once #238

Open brosaplanella opened 6 months ago

brosaplanella commented 6 months ago

Feature description

Allow the FittingProblem class to take lists of datasets and of models, which would streamline certain processes. The key idea is that when multiple models are present, they all use the same parameters (otherwise one can just write a for loop with N FittingProblems).

Cases:

Motivation

Provided for each of the cases above.

Possible implementation

Loop over and concatenate the error arrays before passing to cost function.

Additional context

Here is the equivalent issue in pybamm-param (https://github.com/paramm-team/pybamm-param/issues/38), for reference (we didn't do any progress on it). This issue arises from discussion in the meeting at Imperial on 13/03/24.

BradyPlanden commented 6 months ago

Excellent thanks @brosaplanella, it looks like we were thinking along the same lines (#232). Happy to leave this one open as it has more background info.

To note, adding a weighting function to enable cost scaling across the datasets should be added at the same time as this functionality.

BradyPlanden commented 5 months ago

Hi @MarkBlyth, just checking in to see how you are getting on with issue. If you are running into issues, or don't have the time to continue please let me know so that I can support or reassign.

MarkBlyth commented 5 months ago

Hi Brady, I've been out the office for most of the past month so haven't had the chance to look at this yet. Still keen to work on it, and aiming to get started by the end of next week.

MarkBlyth commented 5 months ago

Hi all, I've made a first pass, with code here. Currently it will break the observer methods, hasn't been tested with multiple models, and has no unit tests, so it's very much work in progress.

The approach I've gone for is to make a DatasetCollection class, representing multiple datasets, and have the fitting_problem evaluate multiple models over multiple datasets, with the plotting and cost functions updated to accept multiple results at once. Given that this means making a large number of breaking changes to the code base, I was keen to get some feedback before I keep going with tests etc.

NicolaCourtier commented 5 months ago

Sounds good, thanks @MarkBlyth! It would helpful at this stage to make a (draft) pull request so we can more easily see where you have made changes.

NicolaCourtier commented 3 months ago

Hi @brosaplanella and @MarkBlyth,

I've made an example MultiFittingProblem class to tackle this open issue. It would be great if you could take a look at the draft PR #364. It's not a robust method yet, but I wanted to demonstrate the direction I think we should go in (similar to #329).