Benchmarks¶
Guide: Benchmarks.
Classic suite¶
ypea.benchmarks.problem¶
A classic benchmark as a vectorized ypea.Problem with one variable x.
p = ypea.benchmarks.problem(name, dim, shift=false, rotate=false, seed=0)
name One of ypea.benchmarks.names().
dim Number of dimensions.
shift Move the optimum to a random point in the central 80 percent
of the bounds.
rotate Rotate the function around its optimum with a random
orthogonal matrix.
seed Seed of the shift and the rotation. The shift does not depend
on rotate, and the rotation does not depend on shift.
bounds {lb, ub} instead of the standard bounds.
x_opt A given optimum location (1 x dim) instead of a random shift.
rotation A given orthogonal matrix (dim x dim) instead of a random one.
The objective is f(z) with z = z_opt + (x - x_opt) R', where z_opt is
the optimum of the base function, so f(x_opt) is exactly the optimum
value. MATLAB draws its own shift and rotation, so the same seed gives a
different instance than the Python version. Pass x_opt and rotation to
build a given instance.
info holds x_opt (the optimum location), bounds, source, shift (the
vector o such that z = (x - o) R' is the base function argument, or []),
rotate (the matrix or []) and seed.
ypea.benchmarks.classic¶
A list of classic benchmark problems (all of them by default).
problems = ypea.benchmarks.classic(dim, names=[], shift=false, rotate=false, seed=0)
Returns a cell array of ypea.Problem. With shift or rotate and no
names, functions that cannot be transformed (Michalewicz) are left out.
ypea.benchmarks.names¶
Names of the classic benchmark functions, as a string array.
CEC 2017¶
ypea.benchmarks.cec2017¶
CEC 2017 single-objective bound-constrained benchmark problems.
problems = ypea.benchmarks.cec2017(dim, functions=[], include_f2=false)
dim One of 2, 10, 20, 30, 50 and 100.
functions Function numbers. By default, every function the C code
defines at dim except F2. Named functions must exist at dim.
include_f2 Add F2 to the default list. F2 was removed from the
competition because it is numerically unstable.
Returns a cell array of ypea.Problem, each with optimum = 100 * f and
info with suite, func (the function number), dim, x_opt and source.
A port of the official C code cec17_test_func.cpp (Awad, Ali, Suganthan,
Liang and Qu, 2016), with the official shift vectors, rotation matrices
and shuffle data (see NOTICE.md in the private folder of this package).
The search range is [-100, 100] in every dimension.
Functions at each dimension, as in the C code:
2 F1 to F10 and F23 to F28
10, 30, 50, 100 F1 to F30
20 F1 to F10 and F20 to F28
The C code differs from the technical report in a few places, and the
port follows the C code:
- F6 (Schaffer F7) uses the shifted point without the rotation.
- F8 (non continuous Rastrigin) is the plain shifted and rotated
Rastrigin function.
- F9 (Levy) has its minimum where the rotated point is all ones, at
o + inv(M) * ones instead of at the shift vector o.
- In F14 and F20, the Schaffer F7 part reads the first variables of the
whole shuffled vector instead of its own segment.
Location of the optimum (info x_opt): the shift vector for F1 to F20
except F9, and the first shift vector of the compositions F21 to F30.
ypea.benchmarks.cec2017_problem¶
CEC 2017 function fnum at dimension dim as a vectorized ypea.Problem.
Differs from Python: A CEC problem stores its function number as info.func (Python: info["function"]), because function is a reserved word.
p = ypea.benchmarks.cec2017_problem(fnum, dim)
One Real variable x of size dim in [-100, 100], optimum = 100 * fnum, and
info with suite, func (the function number), dim, x_opt (the location of the optimum) and
source. F2 also has info excluded = true. See ypea.benchmarks.cec2017.
ypea.benchmarks.cec2017_function¶
The function of CEC 2017 function fnum at dimension dim.
Differs from Python: Returns a function of one point per row. The data Python keeps on its function object comes back as a second output.
[f, data] = ypea.benchmarks.cec2017_function(fnum, dim)
f is a function handle: f(x) takes points x, one per row (n x dim), and
returns their values as a column. data holds the official data the
function uses: shift (one row, or one row per part of a composition), M
(the rotation, dim x dim, or dim x dim x parts), S (the 1-based shuffle,
or []), bias (the optimal value) and spec.
See ypea.benchmarks.cec2017 for the functions defined at each dimension.
CEC 2022¶
ypea.benchmarks.cec2022¶
CEC 2022 single-objective bound-constrained benchmark problems.
problems = ypea.benchmarks.cec2022(dim, functions=[])
dim One of 2, 10 and 20.
functions Function numbers. By default, every function the C code
defines at dim.
Returns a cell array of ypea.Problem, each with optimum set to the
function's optimal value and info with suite, func (the function number), dim, x_opt and
source.
A port of the official C code cec22_test_func.cpp (Kumar, Price, Mohamed,
Hadi and Suganthan, 2021), with the official shift vectors, rotation
matrices and shuffle data (see NOTICE.md in the private folder of this
package). The search range is [-100, 100] in every dimension. F1 to F12
are defined at dimensions 10 and 20, and all but F6, F7 and F8 also at
dimension 2.
Optimal values: 300, 400, 600, 800, 900, 1800, 2000, 2200, 2300, 2400,
2600 and 2700.
The C code differs from the technical report in a few places, and the
port follows the C code:
- F3 (Schaffer F7, named expanded Schaffer f6 in the report) uses the
shifted point without the rotation.
- F4 (non continuous Rastrigin) is the plain shifted and rotated
Rastrigin function.
- In F7, the Schaffer F7 part reads the first variables of the whole
shuffled vector instead of its own segment.
- F10 has three components, not four.
Location of the optimum (info x_opt): the shift vector for F1 to F8, and
the first shift vector of the compositions F9 to F12.
ypea.benchmarks.cec2022_problem¶
CEC 2022 function fnum at dimension dim as a vectorized ypea.Problem.
p = ypea.benchmarks.cec2022_problem(fnum, dim)
One Real variable x of size dim in [-100, 100], optimum set to the
function's optimal value, and info with suite, func (the function number), dim, x_opt (the
location of the optimum) and source. See ypea.benchmarks.cec2022.
ypea.benchmarks.cec2022_function¶
The function of CEC 2022 function fnum at dimension dim.
[f, data] = ypea.benchmarks.cec2022_function(fnum, dim)
f is a function handle: f(x) takes points x, one per row (n x dim), and
returns their values as a column. data holds the official data the
function uses: shift (one row, or one row per part of a composition), M
(the rotation, dim x dim, or dim x dim x parts), S (the 1-based shuffle,
or []), bias (the optimal value) and spec.
See ypea.benchmarks.cec2022 for the functions defined at each dimension.
Multi-objective benchmarks¶
Guide: Multi-objective benchmarks.
ypea.benchmarks.multi_problem¶
A ZDT, DTLZ or WFG benchmark as a vectorized ypea.Problem with one variable x.
p = ypea.benchmarks.multi_problem(name, m=[], dim=[], front_points=1000)
name One of "zdt1" to "zdt6", "dtlz1" to "dtlz7", "wfg1" to "wfg9".
m Number of objectives of DTLZ and WFG (default 3). ZDT always has 2.
dim 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 Size of the sample of the true Pareto front,
ypea.benchmarks.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, n x m), suite and front (the shape
of the front). ZDT5 has one Binary variable with dim bits, the others one
Real variable with the bounds of ypea.benchmarks.multi_registry.
ypea.benchmarks.pareto_front¶
Points on the true Pareto front of a benchmark, one per row (n x m).
F = ypea.benchmarks.pareto_front(name, n_points, m), n_points default 1000,
m default 2 for ZDT and 3 for DTLZ and WFG.
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). When two candidates are exactly as
close to a direction, rounding decides, so a few WFG1 and WFG2 points for
3 or more objectives can differ from Python's (equally close) choice.
ypea.benchmarks.das_dennis¶
Uniform points on the unit simplex (sum 1): the largest lattice with at most n_points.
w = ypea.benchmarks.das_dennis(n_points, m) is k x m. The lattice with H
divisions has nchoosek(H + m - 1, m - 1) points with coordinates j / H.
Das and Dennis (1998), "Normal-boundary intersection", SIAM Journal on
Optimization 8(3).
ypea.benchmarks.nondominated¶
Logical column of the rows of F (minimized) that no other row dominates.
keep = ypea.benchmarks.nondominated(F), F with one point per row.
Repeated rows are kept.
ypea.benchmarks.MultiBenchmark¶
Metadata of a multi-objective benchmark (see ypea.benchmarks.multi_registry).
Differs from Python: ypea.benchmarks.multi_registry() returns these objects as a row, where Python has a dict.
fn the function: f = fn(x) for ZDT, fn(x, m) for DTLZ, fn(x, m, k) for WFG
suite "ZDT", "DTLZ" or "WFG"
default_dim the usual dimension for m objectives: default_dim(m)
front the shape of the true Pareto front, for example "concave"
n_obj 2 for ZDT, [] for the scalable suites
default_m the default number of objectives (2 for ZDT, 3 otherwise)
binary true for ZDT5, whose variables are bits
sense "min": all objectives are minimized
[lb, ub] = b.bounds(d) gives the lower and upper bounds (1 x d).
ypea.benchmarks.zdt1¶
Convex front f2 = 1 - sqrt(f1). x in [0, 1]^d, d = 30.
x has one point per row (n x d). f is n x 2. Zitzler, Deb and Thiele (2000).
ypea.benchmarks.zdt2¶
Concave front f2 = 1 - f1^2. x in [0, 1]^d, d = 30.
x has one point per row (n x d). f is n x 2. Zitzler, Deb and Thiele (2000).
ypea.benchmarks.zdt3¶
Front of five disconnected parts, f2 = 1 - sqrt(f1) - f1 sin(10 pi f1). d = 30.
x has one point per row (n x d). f is n x 2. Zitzler, Deb and Thiele (2000).
ypea.benchmarks.zdt4¶
Rastrigin type g with 21^9 local fronts. x1 in [0, 1], the rest in [-5, 5], d = 10.
x has one point per row (n x d). f is n x 2. Zitzler, Deb and Thiele (2000).
ypea.benchmarks.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. x has one point per row (n x d). f is n x 2.
Zitzler, Deb and Thiele (2000).
ypea.benchmarks.zdt6¶
Nonuniform concave front f2 = 1 - f1^2 with f1 >= 0.2808. x in [0, 1]^d, d = 10.
x has one point per row (n x d). f is n x 2. Zitzler, Deb and Thiele (2000).
ypea.benchmarks.dtlz1¶
Linear front sum f = 0.5 with a multimodal g. Default k = 5.
f = ypea.benchmarks.dtlz1(x, m), m objectives (default 3), x in [0, 1]^d
with d = m - 1 + k, one point per row. f is n x m. Deb, Thiele, Laumanns and Zitzler (2001).
ypea.benchmarks.dtlz2¶
Spherical front sum f^2 = 1. Default k = 10.
f = ypea.benchmarks.dtlz2(x, m), m objectives (default 3), x in [0, 1]^d
with d = m - 1 + k, one point per row. f is n x m. Deb, Thiele, Laumanns and Zitzler (2001).
ypea.benchmarks.dtlz3¶
Spherical front with the multimodal g of DTLZ1. Default k = 10.
f = ypea.benchmarks.dtlz3(x, m), m objectives (default 3), x in [0, 1]^d
with d = m - 1 + k, one point per row. f is n x m. Deb, Thiele, Laumanns and Zitzler (2001).
ypea.benchmarks.dtlz4¶
DTLZ2 with the biased mapping x_i^alpha (alpha = 100). Default k = 10.
f = ypea.benchmarks.dtlz4(x, m, alpha), m objectives (default 3), x in
[0, 1]^d with d = m - 1 + k, one point per row. f is n x m. Deb, Thiele, Laumanns and Zitzler (2001).
ypea.benchmarks.dtlz5¶
Degenerate front, a curve on the unit sphere. Default k = 10.
f = ypea.benchmarks.dtlz5(x, m), m objectives (default 3), x in [0, 1]^d
with d = m - 1 + k, one point per row. f is n x m. The angles theta_i are
used directly, not multiplied by pi / 2 again (a typing error of the
report). Deb, Thiele, Laumanns and Zitzler (2001).
ypea.benchmarks.dtlz6¶
DTLZ5 with g = sum x_i^0.1, harder to converge. Default k = 10.
f = ypea.benchmarks.dtlz6(x, m), m objectives (default 3), x in [0, 1]^d
with d = m - 1 + k, one point per row. f is n x m. Deb, Thiele, Laumanns and Zitzler (2001).
ypea.benchmarks.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))).
f = ypea.benchmarks.dtlz7(x, m), m objectives (default 3), x in [0, 1]^d
with d = m - 1 + k, one point per row. f is n x m. Deb, Thiele, Laumanns and Zitzler (2001).
ypea.benchmarks.wfg1¶
Convex and mixed front, flat and polynomial bias. Default l = 20.
f = ypea.benchmarks.wfg1(x, m, k), m objectives (default 3), k position
parameters (default 2 (m - 1)), the other variables are distance
parameters. x_i in [0, 2 i], one point per row. f is n x m.
Huband, Hingston, Barone and While (2006).
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.
ypea.benchmarks.wfg2¶
Convex and disconnected front, nonseparable distance. l must be even.
f = ypea.benchmarks.wfg2(x, m, k), m objectives (default 3), k position
parameters (default 2 (m - 1)), the other variables are distance
parameters. x_i in [0, 2 i], one point per row. f is n x m.
Huband, Hingston, Barone and While (2006).
ypea.benchmarks.wfg3¶
Linear degenerate front, nonseparable distance. l must be even.
f = ypea.benchmarks.wfg3(x, m, k), m objectives (default 3), k position
parameters (default 2 (m - 1)), the other variables are distance
parameters. x_i in [0, 2 i], one point per row. f is n x m.
Huband, Hingston, Barone and While (2006).
ypea.benchmarks.wfg4¶
Concave front, multimodal shift on all variables.
f = ypea.benchmarks.wfg4(x, m, k), m objectives (default 3), k position
parameters (default 2 (m - 1)), the other variables are distance
parameters. x_i in [0, 2 i], one point per row. f is n x m.
Huband, Hingston, Barone and While (2006).
ypea.benchmarks.wfg5¶
Concave front, deceptive shift on all variables.
f = ypea.benchmarks.wfg5(x, m, k), m objectives (default 3), k position
parameters (default 2 (m - 1)), the other variables are distance
parameters. x_i in [0, 2 i], one point per row. f is n x m.
Huband, Hingston, Barone and While (2006).
ypea.benchmarks.wfg6¶
Concave front, nonseparable reductions.
f = ypea.benchmarks.wfg6(x, m, k), m objectives (default 3), k position
parameters (default 2 (m - 1)), the other variables are distance
parameters. x_i in [0, 2 i], one point per row. f is n x m.
Huband, Hingston, Barone and While (2006).
ypea.benchmarks.wfg7¶
Concave front, position parameters biased by the distance parameters.
f = ypea.benchmarks.wfg7(x, m, k), m objectives (default 3), k position
parameters (default 2 (m - 1)), the other variables are distance
parameters. x_i in [0, 2 i], one point per row. f is n x m.
Huband, Hingston, Barone and While (2006).
ypea.benchmarks.wfg8¶
Concave front, distance parameters biased by the earlier parameters.
f = ypea.benchmarks.wfg8(x, m, k), m objectives (default 3), k position
parameters (default 2 (m - 1)), the other variables are distance
parameters. x_i in [0, 2 i], one point per row. f is n x m.
Huband, Hingston, Barone and While (2006).
ypea.benchmarks.wfg9¶
Concave front, parameter dependent bias, deceptive and multimodal, nonseparable.
f = ypea.benchmarks.wfg9(x, m, k), m objectives (default 3), k position
parameters (default 2 (m - 1)), the other variables are distance
parameters. x_i in [0, 2 i], one point per row. f is n x m.
Huband, Hingston, Barone and While (2006).
Classic functions¶
ypea.benchmarks.sphere¶
sum x_i^2. Yao et al. (1999) f1.
x has one point per row (n x d). f is n x 1.
ypea.benchmarks.ellipsoid¶
High conditioned elliptic: sum 10^(6 (i-1)/(d-1)) x_i^2. CEC 2017 technical report.
x has one point per row (n x d). f is n x 1.
ypea.benchmarks.sum_squares¶
sum i x_i^2. Jamil and Yang (2013).
x has one point per row (n x d). f is n x 1.
ypea.benchmarks.schwefel_1_2¶
Double sum: sum_i (sum_{j<=i} x_j)^2. Jamil and Yang (2013).
x has one point per row (n x d). f is n x 1.
ypea.benchmarks.schwefel_2_21¶
max |x_i|. Jamil and Yang (2013).
x has one point per row (n x d). f is n x 1.
ypea.benchmarks.schwefel_2_22¶
sum |x_i| + prod |x_i|. Jamil and Yang (2013).
x has one point per row (n x d). f is n x 1.
ypea.benchmarks.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.
ypea.benchmarks.rosenbrock¶
sum 100 (x_{i+1} - x_i^2)^2 + (x_i - 1)^2. Jamil and Yang (2013).
x has one point per row (n x d). f is n x 1.
ypea.benchmarks.rastrigin¶
sum x_i^2 + 10 (1 - cos(2 pi x_i)). Yao et al. (1999) f9.
x has one point per row (n x d). f is n x 1.
ypea.benchmarks.ackley¶
20 + e - 20 exp(-0.2 sqrt(mean x_i^2)) - exp(mean cos(2 pi x_i)). Yao et al. (1999) f10.
x has one point per row (n x d). f is n x 1.
ypea.benchmarks.griewank¶
sum x_i^2 / 4000 - prod cos(x_i / sqrt(i)) + 1. Jamil and Yang (2013).
x has one point per row (n x d). f is n x 1.
ypea.benchmarks.levy¶
Levy, with w_i = 1 + (x_i - 1) / 4. CEC 2017 technical report.
x has one point per row (n x d). f is n x 1.
ypea.benchmarks.zakharov¶
sum x_i^2 + s^2 + s^4 with s = sum 0.5 i x_i. Jamil and Yang (2013).
x has one point per row (n x d). f is n x 1.
ypea.benchmarks.step¶
sum floor(x_i + 0.5)^2. Yao et al. (1999) f6.
The minimum 0 is reached on the whole cube [-0.5, 0.5)^d.
ypea.benchmarks.quartic¶
Quartic without noise: sum i x_i^4. Yao et al. (1999) f7.
x has one point per row (n x d). f is n x 1.
ypea.benchmarks.quartic_noisy¶
Quartic with noise: sum i x_i^4 + U[0, 1). Yao et al. (1999) f7.
rng is a ypea.Rng. One uniform number is drawn per point.
ypea.benchmarks.alpine1¶
sum |x_i sin(x_i) + 0.1 x_i|. Jamil and Yang (2013).
x has one point per row (n x d). f is n x 1.
ypea.benchmarks.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.
ypea.benchmarks.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).
ypea.benchmarks.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).
ypea.benchmarks.michalewicz_optimum(d) computes the minimizer for any d.
ypea.benchmarks.salomon¶
1 - cos(2 pi r) + 0.1 r with r = ||x||. Jamil and Yang (2013).
x has one point per row (n x d). f is n x 1.
ypea.benchmarks.weierstrass¶
Weierstrass with a = 0.5, b = 3 and k_max = 20. CEC 2017 technical report.
x has one point per row (n x d). f is n x 1.
ypea.benchmarks.happy_cat¶
|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.
ypea.benchmarks.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.
ypea.benchmarks.expanded_schaffer_f6¶
sum g(x_i, x_{i+1}) over the ring of coordinates. CEC 2017 technical report.
g(x, y) = 0.5 + (sin^2(sqrt(x^2 + y^2)) - 0.5) / (1 + 0.001 (x^2 + y^2))^2.
ypea.benchmarks.bent_cigar¶
x_1^2 + 10^6 sum_{i>=2} x_i^2. CEC 2017 technical report.
x has one point per row (n x d). f is n x 1.
ypea.benchmarks.discus¶
10^6 x_1^2 + sum_{i>=2} x_i^2. CEC 2017 technical report.
x has one point per row (n x d). f is n x 1.