Benchmarks¶
Guide: Benchmarks.
Classic suite¶
problem ¶
problem(name, dim, shift=False, rotate=False, seed=0, bounds=None)
A classic benchmark as a vectorized Problem with one variable x.
Parameters
name(str): One ofnames().dim(int): Number of dimensions.shift(bool): Move the optimum to a random point in the central 80 percent of the bounds.rotate(bool): Rotate the function around its optimum with a random orthogonal matrix.seed(int): Seed of the shift and the rotation. The shift does not depend onrotateand the rotation does not depend onshift.bounds((lb, ub), optional): Search bounds instead of the standard ones.
info holds x_opt (the optimum location), bounds, source, shift
(the vector o such that z = R (x - o) is the base function argument, or None),
rotate (the matrix or None) and seed.
classic ¶
classic(dim, names=None, shift=False, rotate=False, seed=0)
A list of classic benchmark problems (all of them by default).
With shift or rotate and no names, functions that cannot be transformed
(Michalewicz) are left out.
CEC 2017¶
cec2017 ¶
cec2017(dim, functions=None, include_f2=False)
CEC 2017 problems at dimension dim.
Parameters
dim(int): One of 2, 10, 20, 30, 50 and 100.functions(list of int, optional): Function numbers. By default, every function the C code defines atdimexcept F2. Named functions must exist atdim.include_f2(bool): Add F2 to the default list. F2 was removed from the competition because it is numerically unstable.
Returns
list of Problem
Each with optimum = 100 * f and info with suite, function,
dim, x_opt and source.
cec2017_problem ¶
cec2017_problem(f, dim)
CEC 2017 function f at dimension dim as a vectorized Problem.
cec2017_function ¶
cec2017_function(f, dim)
The array function of CEC 2017 function f at dimension dim.
It takes x with shape (..., dim) and returns values with shape (...).
CEC 2022¶
cec2022 ¶
cec2022(dim, functions=None)
CEC 2022 problems at dimension dim (2, 10 or 20).
functions is a list of function numbers. By default, every function the C code
defines at dim. Each problem has optimum set to the function's optimal value
and info with suite, function, dim, x_opt and source.
cec2022_problem ¶
cec2022_problem(f, dim)
CEC 2022 function f at dimension dim as a vectorized Problem.
cec2022_function ¶
cec2022_function(f, dim)
The array function of CEC 2022 function f at dimension dim.
It takes x with shape (..., dim) and returns values with shape (...).
Multi-objective benchmarks¶
Guide: Multi-objective benchmarks.
multi_problem ¶
multi_problem(name, *, m=None, dim=None, front_points=1000)
A ZDT, DTLZ or WFG benchmark as a vectorized Problem with one variable x.
Parameters
name(str): One ofmulti.REGISTRY("zdt1" to "zdt6", "dtlz1" to "dtlz7", "wfg1" to "wfg9").m(int, optional): Number of objectives of DTLZ and WFG (default 3). ZDT always has 2.dim(int, optional): Number of variables (bits for ZDT5). The default is the usual size, for example 30 for ZDT1 and m - 1 + 10 for DTLZ2.front_points(int): Size of the sample of the true Pareto front,pareto_front(name, front_points, m).
The name is <name>_m<m>_d<dim>, for example dtlz2_m3_d12. info holds
pareto_front (the sampled true front, shape (n, m)), suite and front (the
shape of the front). The experiment runner uses info["pareto_front"] for IGD and
hypervolume. ZDT5 has one Binary variable with dim bits, the others one
Real variable with the bounds of multi.REGISTRY.
pareto_front ¶
pareto_front(name, n_points=1000, m=None)
Points on the true Pareto front of a benchmark, shape (n, m).
DTLZ1 to DTLZ4 and WFG4 to WFG9 use the Das and Dennis lattice (the largest with at most n_points points), projected on the front. ZDT and the degenerate fronts (DTLZ5, DTLZ6, WFG3) have exactly n_points points, evenly spaced in the first parameter. ZDT5 has its 31 discrete points. DTLZ7 uses a grid in the front objectives with at most n_points points. WFG1 and WFG2 take, for each Das and Dennis direction, the point of a dense sample of the front closest to it, so they have at most n_points points (fewer on the disconnected WFG2 front, where several directions share a point at the edge of a gap).
das_dennis ¶
das_dennis(n_points, m)
Uniform points on the unit simplex (sum 1): the largest lattice with at most n_points.
The lattice with H divisions has comb(H + m - 1, m - 1) points with coordinates j / H. Das and Dennis (1998).
nondominated ¶
nondominated(F)
Boolean mask of the rows of F (minimized) that no other row dominates. Duplicates are kept.
MultiBenchmark
dataclass
¶
MultiBenchmark(fn, suite, default_dim, lower, upper, front, n_obj=None, default_m=2, binary=False, sense='min')
Metadata of a multi-objective benchmark.
n_obj is 2 for ZDT and None for the scalable suites. default_dim(m) gives the
usual dimension for m objectives, and bounds(d) the lower and upper bounds.
front describes the shape of the true Pareto front. All objectives are minimized.
Multi-objective benchmark functions: ZDT, DTLZ and WFG.
Each function takes one point (shape (d,)) or a batch (shape (..., d)) and returns the
objective values with shape (..., m). All objectives are minimized. The scalable suites
take the number of objectives m. DTLZ infers k = d - m + 1 from the dimension. WFG
takes the number of position parameters k (default 2 (m - 1)) and uses the rest of
the variables as distance parameters.
REGISTRY holds the bounds, the default dimension and number of objectives, and the
shape of the Pareto front of each problem. pareto_front(name, n_points, m) samples the
true front. das_dennis(n_points, m) gives uniform reference points on the simplex.
Sources:
- Zitzler, Deb and Thiele (2000), "Comparison of multiobjective evolutionary algorithms: Empirical results", Evolutionary Computation 8(2). ZDT1 to ZDT6.
- Deb, Thiele, Laumanns and Zitzler (2001), "Scalable test problems for evolutionary multi-objective optimization", TIK Technical Report 112, ETH Zurich. DTLZ1 to DTLZ7. Two typing errors of the report are read as in later implementations: the DTLZ1 optimum is x_M = 0.5 (as its g function gives), and the DTLZ5 angles theta_i are used directly, not multiplied by pi / 2 again.
- Huband, Hingston, Barone and While (2006), "A review of multiobjective test problems and
a scalable test problem toolkit", IEEE Transactions on Evolutionary Computation 10(5).
WFG1 to WFG9. The values agree with the pymoo and PlatEMO implementations, except for
the rounding step noted in
wfg1. - Das and Dennis (1998), "Normal-boundary intersection", SIAM Journal on Optimization 8(3). Reference points on the simplex.
zdt3 ¶
zdt3(x)
ZDT3: front of five disconnected parts, f2 = 1 - sqrt(f1) - f1 sin(10 pi f1). d = 30.
zdt4 ¶
zdt4(x)
ZDT4: Rastrigin type g with 21^9 local fronts. x1 in [0, 1], the rest in [-5, 5], d = 10.
zdt5 ¶
zdt5(x)
ZDT5: deceptive binary problem. x holds 0 and 1 bits, d = 30 + 5 j (default 80).
u_1 counts the ones in the first 30 bits and u_i the ones in each next group of 5. f1 = 1 + u_1, g = sum v(u_i) with v(u) = 2 + u for u < 5 and v(5) = 1, f2 = g / f1.
zdt6 ¶
zdt6(x)
ZDT6: nonuniform concave front f2 = 1 - f1^2 with f1 >= 0.2808. x in [0, 1]^d, d = 10.
dtlz4 ¶
dtlz4(x, m=3, alpha=100.0)
DTLZ4: DTLZ2 with the biased mapping x_i^alpha (alpha = 100). Default k = 10.
dtlz7 ¶
dtlz7(x, m=3)
DTLZ7: 2^(m - 1) disconnected front regions. Default k = 20.
f_i = x_i for i < m, g = 1 + 9 / k sum x_M, f_m = (1 + g) (m - sum f_i / (1 + g) (1 + sin(3 pi f_i))).
wfg1 ¶
wfg1(x, m=3, k=None)
WFG1: convex and mixed front, flat and polynomial bias. Default k = 2 (m - 1), l = 20.
The shift step sets values below 1e-12 to 0, so the optimal distance parameters
x_i = 0.7 i reach the front despite rounding (see the note in _s_linear).
wfg2 ¶
wfg2(x, m=3, k=None)
WFG2: convex and disconnected front, nonseparable distance. l must be even.
wfg7 ¶
wfg7(x, m=3, k=None)
WFG7: concave front, position parameters biased by the distance parameters.
wfg8 ¶
wfg8(x, m=3, k=None)
WFG8: concave front, distance parameters biased by the earlier parameters.
wfg9 ¶
wfg9(x, m=3, k=None)
WFG9: concave front, parameter dependent bias, deceptive and multimodal, nonseparable.
Classic functions¶
Classic benchmark functions.
Each function takes one point (shape (d,)) or a batch (shape (..., d)) and returns values
with shape (...), so it can be used directly in vectorized problems. REGISTRY holds the
standard search bounds, the optimum value and the optimum location of each function.
Sources:
- Jamil and Yang (2013), "A literature survey of benchmark functions for global optimization problems", Int. J. Math. Model. Numer. Optim. 4(2).
- Yao, Liu and Lin (1999), "Evolutionary programming made faster", IEEE TEVC 3(2).
- Awad et al. (2016), the CEC 2017 technical report "Problem definitions and evaluation criteria for the CEC 2017 special session on single-objective real parameter numerical optimization".
- Suganthan et al. (2005), the CEC 2005 technical report.
ellipsoid ¶
ellipsoid(x)
High conditioned elliptic: sum 10^(6 (i-1)/(d-1)) x_i^2. CEC 2017 technical report.
schwefel_1_2 ¶
schwefel_1_2(x)
Schwefel 1.2 (double sum): sum_i (sum_{j<=i} x_j)^2. Jamil and Yang (2013).
schwefel_2_26 ¶
schwefel_2_26(x)
Schwefel 2.26: sum (c - x_i sin(sqrt|x_i|)) with c = 418.9829..., so the minimum is 0.
Yao et al. (1999) f8, shifted up by c per coordinate. Inside [-500, 500] it is the standard function. Outside, it uses the boundary treatment of the modified Schwefel function in the CEC 2017 technical report, so the minimum stays 0 when the function is shifted or rotated.
rosenbrock ¶
rosenbrock(x)
Rosenbrock: sum 100 (x_{i+1} - x_i^2)^2 + (x_i - 1)^2. Jamil and Yang (2013).
griewank ¶
griewank(x)
Griewank: sum x_i^2 / 4000 - prod cos(x_i / sqrt(i)) + 1. Jamil and Yang (2013).
zakharov ¶
zakharov(x)
Zakharov: sum x_i^2 + s^2 + s^4 with s = sum 0.5 i x_i. Jamil and Yang (2013).
step ¶
step(x)
Step: sum floor(x_i + 0.5)^2. Yao et al. (1999) f6, "Step 2" in Jamil and Yang (2013).
The minimum 0 is reached on the whole cube [-0.5, 0.5)^d.
quartic_noisy ¶
quartic_noisy(x, rng)
Quartic with noise: sum i x_i^4 + U[0, 1). Yao et al. (1999) f7.
rng is a NumPy Generator. One uniform number is drawn per point.
styblinski_tang ¶
styblinski_tang(x)
Styblinski Tang: 0.5 sum (x_i^4 - 16 x_i^2 + 5 x_i). Jamil and Yang (2013).
The minimum is about -39.166166 d at x_i = -2.903534.
dixon_price ¶
dixon_price(x)
Dixon Price: (x_1 - 1)^2 + sum_{i>=2} i (2 x_i^2 - x_{i-1})^2. Jamil and Yang (2013).
The minimum 0 is at x_i = 2^(-(2^i - 2) / 2^i) (and at the sign variants for i >= 2).
michalewicz ¶
michalewicz(x, m=10)
Michalewicz: -sum sin(x_i) sin(i x_i^2 / pi)^(2m), with m = 10. Jamil and Yang (2013).
The literature gives the minimum only for some dimensions (about -1.8013 for d = 2,
-4.687658 for d = 5 and -9.66015 for d = 10). The function is a sum of one variable
terms, so michalewicz_optimum(d) computes the minimizer for any d numerically.
weierstrass ¶
weierstrass(x)
Weierstrass with a = 0.5, b = 3 and k_max = 20. CEC 2017 technical report.
happy_cat ¶
happy_cat(x)
HappyCat: |S - d|^(1/4) + (0.5 S + sum x_i) / d + 0.5 with S = sum x_i^2.
CEC 2017 technical report (Beyer and Finck 2012). The minimum 0 is at x_i = -1.
hgbat ¶
hgbat(x)
HGBat: |S^2 - T^2|^(1/2) + (0.5 S + T) / d + 0.5 with S = sum x_i^2, T = sum x_i.
CEC 2017 technical report. The minimum 0 is at x_i = -1.
expanded_schaffer_f6 ¶
expanded_schaffer_f6(x)
Expanded Schaffer F6: sum g(x_i, x_{i+1}) over the ring of coordinates, with g(x, y) = 0.5 + (sin^2(sqrt(x^2 + y^2)) - 0.5) / (1 + 0.001 (x^2 + y^2))^2.
CEC 2017 technical report.