Continuous inter-point constraints
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:
- Most importantly, the way of sampling points from a polytope. The reason is that
get_polytope_samplesis not made for including inter-point constraints, and hence a workaround was implemented. The workaround basically transforms the space in a one-dimensional space withbatches * featuresmany 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. - 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$.
- 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 :)
Note: This PR is currently on hold for two reasons:
- There was a misunderstanding between @AdrianSosic and me what "inter-point" constraint actually means, and incorporating the necessary changes might require some more redesign.
- There is another open PR which currently changes the behavior of
get_polytope_samples, and that PR should be merged first.
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
@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, wie man in den Wald schreit 😄: anything happening here?
This PR is outdated and a new version will probably be worked on.