baybe icon indicating copy to clipboard operation
baybe copied to clipboard

Continuous inter-point constraints

Open AVHopp opened this issue 1 year ago • 3 comments

This PR introduces a first variant of inter-point constraints by using the botorch-provided interface.

Here, an inter-point constraint is a constraint that acts on a full batch instead of a single recommendation. If we think of a batch recommendation of a matrix with shape batches x features, then our previous constraints would be row-wise, while these constraints allow mixed constraints across both dimensions.

This PR introduces new classes, and these classes were modeled similar to the already existing classes for continuous constraints. Some things had to be changed though resp. we need to aware:

  1. Most importantly, the way of sampling points from a polytope. The reason is that get_polytope_samples is not made for including inter-point constraints, and hence a workaround was implemented. The workaround basically transforms the space in a one-dimensional space with batches * features many features, and then defines both normal and inter-point constraints over this space (see https://github.com/pytorch/botorch/issues/2468). Note that this might interfere with #301 and that some alignment might be necessary.
  2. The constraints in this PR always combines full columns. That is, the constraints $x_1 <=1$ would be interpreted as "the sum of $x_1$ across the whole batch needs to be smaller than 1". This can e.g. be used to limit the usage of resources, like only having 100ml of a substance available for the full batch. Also, different columns can be combined, so having $x_2 + 2*x_3 <=100$ would mean "sum of $x_1$ plus two times the sum of $x_3$ across the batch has to be smaller than 100$.
  3. For now, the constraints have only been applied for continuous search spaces. The reason for this is that I want to keep this PR rather short and use it to discuss in general about the design, and to avoid any potential conflicts with #301 . However, including them in hybrid search spaces should be possible already in this PR. For discrete spaces, this still needs some investigation. So interpret this as just a first step in the direction of more :)

AVHopp avatar Aug 20 '24 06:08 AVHopp

Note: This PR is currently on hold for two reasons:

  1. There was a misunderstanding between @AdrianSosic and me what "inter-point" constraint actually means, and incorporating the necessary changes might require some more redesign.
  2. There is another open PR which currently changes the behavior of get_polytope_samples, and that PR should be merged first.

AVHopp avatar Aug 21 '24 06:08 AVHopp

as mentioned in our call but posting here for documentation / reference: I think its worth exploring whether a design not via deriving from ContinuousLinearConstraint but by adding a simple switching flag to it might be better

Scienfitz avatar Oct 31 '24 16:10 Scienfitz

@AdrianSosic @Scienfitz this PR is now (once again) ready for review. As agreed, I added a validation preventing the use of interpoint and cardinality constraints together. Also, I cleaned the gir history a little bit and rebase onto main, so this should be as clean as possible for you to review :)

AVHopp avatar Dec 16 '24 10:12 AVHopp

@AVHopp, wie man in den Wald schreit 😄: anything happening here?

AdrianSosic avatar Aug 05 '25 08:08 AdrianSosic

This PR is outdated and a new version will probably be worked on.

AVHopp avatar Aug 11 '25 09:08 AVHopp