Skip to content

Commit

Permalink
Add constrained hartmann problem (#2022)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #2022

This comes from Letham et al 2019.

Reviewed By: esantorella

Differential Revision: D49599156

fbshipit-source-id: 42dbf2c5fc685e0ab90e3e33bfadc9668935e4ac
  • Loading branch information
sdaulton authored and facebook-github-bot committed Sep 25, 2023
1 parent e53a160 commit d50c9a5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
17 changes: 17 additions & 0 deletions botorch/test_functions/synthetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
13 changes: 13 additions & 0 deletions test/test_functions/test_synthetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
Beale,
Branin,
Bukin,
ConstrainedHartmann,
Cosine8,
DixonPrice,
DropWave,
Expand Down Expand Up @@ -67,6 +68,7 @@ class TestCustomBounds(BotorchTestCase):
(EggHolder, 2),
(Griewank, 2),
(Hartmann, 6),
(ConstrainedHartmann, 6),
(HolderTable, 2),
(Levy, 2),
(Michalewicz, 2),
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit d50c9a5

Please sign in to comment.