Skip to content

Commit 34380f8

Browse files
David Erikssonfacebook-github-bot
David Eriksson
authored andcommitted
Keane bump function (#2802)
Summary: Pull Request resolved: #2802 Adding an additional very challenging constrained problem. Reviewed By: Balandat Differential Revision: D71779885 fbshipit-source-id: e6df5cb9c3e3bb6027d24742af1809e31c111ed7
1 parent e94a78a commit 34380f8

File tree

2 files changed

+91
-0
lines changed

2 files changed

+91
-0
lines changed

botorch/test_functions/synthetic.py

+79
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@
3838
Optimization with Noisy Experiments. Bayesian Analysis, Bayesian Anal.
3939
14(2), 495-519, 2019.
4040
41+
.. [Mishra2007]
42+
S. K. Mishra. Minimization of Keane's Bump Function by the Repulsive
43+
Particle Swarm and the Differential Evolution Methods (May 1, 2007).
44+
Available at SSRN: https://ssrn.com/abstract=983836.
45+
4146
.. [Gramacy2016]
4247
R. Gramacy, G. Gray, S. Le Digabel, H. Lee, P. Ranjan, G. Wells & S. Wild.
4348
Modeling an Augmented Lagrangian for Blackbox Constrained Optimization,
@@ -1203,3 +1208,77 @@ def evaluate_slack_true(self, X: Tensor) -> Tensor:
12031208
],
12041209
dim=-1,
12051210
)
1211+
1212+
1213+
class KeaneBumpFunction(ConstrainedSyntheticTestFunction):
1214+
r"""Keane Bump Function problem with constraints.
1215+
1216+
This is a challenging d-dimensional minimization problem with two
1217+
constraints that is evaluated on the domain [0, 10]^d.
1218+
1219+
There is no known global optimum for this problem, but the aproximate
1220+
global optimal value for a few different dimensionalities can be found in
1221+
[Mishra2007]_.
1222+
"""
1223+
1224+
num_constraints = 2
1225+
_optimal_value_lookup = {
1226+
2: -0.365,
1227+
10: -0.6737,
1228+
15: -0.781647601,
1229+
20: -0.803619104,
1230+
30: -0.818056222,
1231+
40: -0.826624404,
1232+
50: -0.83078783,
1233+
}
1234+
1235+
def __init__(
1236+
self,
1237+
dim: int,
1238+
noise_std: None | float = None,
1239+
constraint_noise_std: None | float | list[float] = None,
1240+
negate: bool = False,
1241+
bounds: list[tuple[float, float]] | None = None,
1242+
dtype: torch.dtype = torch.double,
1243+
) -> None:
1244+
r"""
1245+
Args:
1246+
dim: The (input) dimension.
1247+
noise_std: Standard deviation of the observation noise.
1248+
constraint_noise_std: Standard deviation of the constraint noise.
1249+
If a list is provided, specifies separate noise standard
1250+
deviations for each constraint.
1251+
negate: If True, negate the function.
1252+
bounds: Custom bounds for the function specified as (lower, upper) pairs.
1253+
dtype: The dtype that is used for the bounds of the function.
1254+
"""
1255+
self.dim = dim
1256+
if bounds is None:
1257+
bounds = [(0.0, 10.0) for _ in range(dim)]
1258+
if dim in self._optimal_value_lookup.keys():
1259+
self._optimal_value = self._optimal_value_lookup[dim]
1260+
super().__init__(
1261+
noise_std=noise_std,
1262+
constraint_noise_std=constraint_noise_std,
1263+
negate=negate,
1264+
bounds=bounds,
1265+
dtype=dtype,
1266+
)
1267+
1268+
def evaluate_true(self, X: Tensor) -> Tensor:
1269+
Xcos = X.cos()
1270+
num = Xcos.pow(4).sum(dim=-1) - 2 * Xcos.pow(2).prod(dim=-1)
1271+
den = torch.sqrt(
1272+
(torch.arange(1, self.dim + 1, device=X.device) * X.pow(2)).sum(dim=-1)
1273+
)
1274+
# clamp to avoid den=0, which happens when X=0.
1275+
return -(num / den.clamp(min=1e-3)).abs()
1276+
1277+
def evaluate_slack_true(self, X: Tensor) -> Tensor:
1278+
return torch.cat(
1279+
[
1280+
X.prod(dim=-1, keepdims=True) - 0.75,
1281+
7.5 * self.dim - X.sum(dim=-1, keepdims=True),
1282+
],
1283+
dim=-1,
1284+
)

test/test_functions/test_synthetic.py

+12
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
Griewank,
2323
Hartmann,
2424
HolderTable,
25+
KeaneBumpFunction,
2526
Levy,
2627
Michalewicz,
2728
Powell,
@@ -420,3 +421,14 @@ class TestWeldedBeamSO(
420421
WeldedBeamSO(),
421422
WeldedBeamSO(noise_std=0.1, constraint_noise_std=[0.2] * 6),
422423
]
424+
425+
426+
class TestKeaneBumpFunction(
427+
BotorchTestCase,
428+
BaseTestProblemTestCaseMixIn,
429+
ConstrainedTestProblemTestCaseMixin,
430+
):
431+
functions = [
432+
KeaneBumpFunction(dim=2),
433+
KeaneBumpFunction(dim=4, noise_std=0.1, constraint_noise_std=[0.1, 0.2]),
434+
]

0 commit comments

Comments
 (0)