pybop-team / PyBOP

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

Long term idea - use tools like SOBER to do model selection in PyBOP #228

Open davidhowey opened 7 months ago

davidhowey commented 7 months ago

Feature description

@ma921 has developed some great ideas e.g. as described in this paper and more recently SOBER for high speed Bayesian quadrature that we can use for model selection. It would be great, as a long term aim, to get this into PyBOP.

Motivation

No response

Possible implementation

No response

Additional context

No response

BradyPlanden commented 7 months ago

I have been thinking about this for a while now. I think there are a few technical decisions we need to sort out to make this work, here's a first list:

@ma921, I'd be interested to hear your thoughts on this. There's a follow-up discussion about how to handle SOBER's dependencies, and perhaps some of them wouldn't be needed after ingestion into PyBOP.

ma921 commented 7 months ago

Thank @davidhowey and @BradyPlanden! I have no preference—the PyPI matter is not as I had planned. As you mentioned, I think it's a great idea to integrate the SOBER codebase into one of the optimizers. Since BASQ is an inner loop function of SOBER, including SOBER means BASQ is automatically incorporated.

Several potential issues to consider:

How should we proceed to the next steps?

BradyPlanden commented 7 months ago

Excellent, thanks for the response @ma921. In which case, it seems ingesting SOBER (and by extension BASQ) into the PyBOP codebase makes the most sense. We haven't finalised the bayes architecture yet, so this would be a good time to align requirements. I'll take a further look at SOBER's API and let's have a chat early next week if that works.

In terms of dependancies, I think this is fine. We will probably want an optional installation and import like we do with plotly. Cross-posting to #229, as pytorch is a dependancy requirement there as well.

I'll create a branch for this issue, and if you want to start integrating that would be great. Opening a WIP PR would be a great way for us to review and collaborate as this progresses. For reference, here are the contributing guidelines . I'm happy to support development of this, so give me a shout if you want a hand!

ma921 commented 7 months ago

Excellent @BradyPlanden! I'm proceeding with merging my codebases into branch 228 and will inform you through a WIP PR once completed. After the deployment of my SOBER code base, it will establish a foundation that enables compatibility with other Bayesian methodologies, including MCMCs and Bayesian optimization. We might encounter minor differences, such as setting up priors via different libraries like torch.distributions, Pyro, or PyMC3. However, these issues primarily pertain to interfacing and should be manageable. Stay tuned for updates!

YannickNoelStephanKuhn commented 1 week ago

Hello everyone, I am commenting on this stale issue, since I experimented on how to use SOBER for battery-related optimization tasks. It's at a point now where I am confident that I figured out the intricacies of SOBER (and BASQ) and wrote some code that makes SOBER more accessible for non-ML people. I can not guarantee yet in which state that code will release; I just wanted to let you know that a) someone has figured out a way of using SOBER within PyBOP, and b) that someone will make it available soonish.

YannickNoelStephanKuhn commented 1 week ago

We figured out how we would like to commit our code: I would make a fork of the PyBOP repository, where we figure out if what I wrote aligns with the general design principle behind PyBOP. Is that okay with the main developers?

BradyPlanden commented 1 week ago

Hi @YannickNoelStephanKuhn, thanks for posting an update on this issue. Yes, forking and opening a PR for integration would be the recommended way to go. For reference, here is our Contributing Guide which should get you up to speed on running tests, pre-commit, etc. Looking forward to your updates!