experimental-design / bofire

Experimental design and (multi-objective) bayesian optimization.
https://experimental-design.github.io/bofire/
BSD 3-Clause "New" or "Revised" License
232 stars 23 forks source link

Add Trust Regions #457

Open CompRhys opened 2 weeks ago

CompRhys commented 2 weeks ago

This is a WIP Draft PR to add trust regions.

This introduces a breaking change renaming LSRBO to LSRBOConfig.

TODO:

CompRhys commented 2 weeks ago

@jduerholt This is now in a "working" state but it has many rough edges, would appreciate a review and thoughts of how some things may be cleaned up

jduerholt commented 1 week ago

@CompRhys: I let some comments, when we have decided on how to handle these things, I would then have a look at the tests in the next iteration.

jduerholt commented 1 week ago

@CompRhys: short info: I try to get over it, today or tomorrow. Best, Johannes

CompRhys commented 6 days ago

Not sure why it's trying to test the base class and then giving validation errors

strategy_spec = SoboStrategy: {'domain': {'type': 'Domain', 'inputs': {'type': 'Inputs', 'features': [{'type': 'ContinuousInput', 'key... 'failure_counter': 0, 'experiment_batch_sizes': [[]], 'use_independent_tr': False, 'length': 0.8, 'X_center_idx': -1}}

    def test_strategy_should_be_serializable(strategy_spec: Spec):
        spec = strategy_spec.typed_spec()
>       obj = strategy_spec.cls(**spec)
E       TypeError: Can't instantiate abstract class TrustRegionConfig without an implementation for abstract methods 'init_trust_region', 'update_trust_region', 'validate_domain', 'validate_surrogates'

tests/bofire/data_models/serialization/test_serialization.py:60: TypeError

--- this error was caused by adding the base class to the AnyLocalSearchConfig typing Union.

jduerholt commented 3 days ago

Hi @CompRhys, I saw that you made some commits but also that you transferred it into a draft PR. Just ping me here, when I should review again! Best, Johannes

CompRhys commented 2 days ago

I want to actually have a chance to check that it works rather than just doesn't fail before moving to have it merged, thought it best to make as draft whilst not actively working on it

jduerholt commented 2 days ago

Ok, thanks for the info! I saw some nice stuff from you regarding SEBO in botorch/Ax. Nice! At some point, I also have to make it available here ;)

jduerholt commented 2 days ago

It appears to me that there are also quite a few changes needed in botorch itself to make SEBO really usable. Can you give me a "ping" when you have the feeling that it is now really usable? So that I can try to port it also to BoFire. And ofc it would be nice to also get this TR PR here at some point ready, as I really like it!

CompRhys commented 1 day ago

The majority of those changes do not impact how SEBO might be implemented here because the homotopy stuff is in botorch and then it's just using qnehvi so would require a similar amount of wrapper code here to implement.

I would say that it would be a great thing to add given that sparsity in high-dimensional formulation/mixtures problems is common in material science.

A missing part is a a sum-to-one constraint an equality constraints aren't yet in Ax. Not sure if that's an API design or bandwidth issue - potentially also just that equality constraints are harder to optimize so maybe ties to your cyipopt stuff relevant. And then you're into the rabbit whole of it being a pain to package cyipopt as you can't install via pip.

jduerholt commented 22 hours ago

I agree, so far we do not had so many high-dim optimizations, but I think it would be a great benefit. And I think it should be relatively easy to implement in BoFire. I have an idea ;) We will have a hackathon next Thursday (on-site, in Germany), and I will try to come up with a solution then. So I hope, that we have Sebo in BoFire at the end of next week together with all the other constraints ;)

CompRhys commented 20 hours ago

Looking forward to it, this PR https://github.com/pytorch/botorch/pull/2588 to botorch should have exposed everything needed to allow all the constraints allowed by botorch.

jduerholt commented 13 hours ago

Yeah, I saw this, optimization over mixed domains is still missing there to have it fully compabible with BoFire. But I created already a PR for it: https://github.com/pytorch/botorch/pull/2639