diff --git a/botorch/test_functions/synthetic.py b/botorch/test_functions/synthetic.py index f8aceb4eeb..f62b65870a 100644 --- a/botorch/test_functions/synthetic.py +++ b/botorch/test_functions/synthetic.py @@ -32,6 +32,11 @@ Silva. Constrained optimization problems in mechanical engineering design using a real-coded steady-state genetic algorithm. Mecánica Computacional, XXIX:9287–9303, 2010. + +.. [Letham2019] + B. Letham, B. Karrer, G. Ottoni, and E. Bakshy. Constrained Bayesian + Optimization with Noisy Experiments. Bayesian Analysis, Bayesian Anal. + 14(2), 495-519, 2019. """ from __future__ import annotations @@ -792,6 +797,18 @@ def evaluate_true(self, X: Tensor) -> Tensor: # ------------ Constrained synthetic test functions ----------- # +class ConstrainedHartmann(Hartmann, ConstrainedBaseTestProblem): + r"""Constrained Hartmann test function. + + This is a constrained version of the standard Hartmann test function that + uses `||x||_2 <= 1` as the constraint. This problem comes from [Letham2019]_. + """ + num_constraints = 1 + + def evaluate_slack_true(self, X: Tensor) -> Tensor: + return -X.norm(dim=-1, keepdim=True) + 1 + + class PressureVessel(SyntheticTestFunction, ConstrainedBaseTestProblem): r"""Pressure vessel design problem with constraints. diff --git a/test/test_functions/test_synthetic.py b/test/test_functions/test_synthetic.py index ccc00b32a6..9a6a30e7f8 100644 --- a/test/test_functions/test_synthetic.py +++ b/test/test_functions/test_synthetic.py @@ -11,6 +11,7 @@ Beale, Branin, Bukin, + ConstrainedHartmann, Cosine8, DixonPrice, DropWave, @@ -67,6 +68,7 @@ class TestCustomBounds(BotorchTestCase): (EggHolder, 2), (Griewank, 2), (Hartmann, 6), + (ConstrainedHartmann, 6), (HolderTable, 2), (Levy, 2), (Michalewicz, 2), @@ -316,6 +318,17 @@ class TestThreeHumpCamel( # ------------------ Constrained synthetic test problems ------------------ # +class TestConstrainedHartmann( + BotorchTestCase, + BaseTestProblemTestCaseMixIn, + ConstrainedTestProblemTestCaseMixin, +): + + functions = [ + ConstrainedHartmann(dim=6, negate=True), + ] + + class TestPressureVessel( BotorchTestCase, BaseTestProblemTestCaseMixIn,