Multi-objective benchmarks¶
Test problems with a known Pareto front let you measure how well a multi-objective algorithm works (see Multiple objectives for the terms). ypea.benchmarks has the ZDT, DTLZ and WFG test suites with samples of their true fronts. ypea.indicators measures how close a set of objective vectors is to a front, and ypea.plot.front draws fronts. All objectives are minimized.
Each test function takes one point of shape (d,) or a batch of shape (..., d), where d is the number of variables, and returns objective values of shape (..., m), where m is the number of objectives. Here DTLZ2 with three objectives is evaluated at the center of its 12 variables:
import numpy as np
import ypea
print(ypea.benchmarks.dtlz2(np.full(12, 0.5), m=3))
[0.5 0.5 0.70710678]
disp(ypea.benchmarks.dtlz2(0.5 * ones(1, 12), 3))
0.5000 0.5000 0.7071
Problems¶
| Problems | Objectives | Variables | Bounds | Pareto front |
|---|---|---|---|---|
zdt1, zdt2, zdt3 |
2 | 30 | [0, 1] | convex, concave, five disconnected parts |
zdt4 |
2 | 10 | x1 in [0, 1], the rest in [-5, 5] | convex, 21^9 local fronts |
zdt5 |
2 | 80 bits | 0 or 1 | 31 discrete points |
zdt6 |
2 | 10 | [0, 1] | concave, nonuniform |
dtlz1 |
m | m - 1 + 5 | [0, 1] | linear, sum f = 0.5 |
dtlz2, dtlz3, dtlz4 |
m | m - 1 + 10 | [0, 1] | sphere, sum f^2 = 1 |
dtlz5, dtlz6 |
m | m - 1 + 10 | [0, 1] | degenerate curve on the sphere |
dtlz7 |
m | m - 1 + 20 | [0, 1] | 2^(m - 1) disconnected parts |
wfg1 |
m | k + 20 | x_i in [0, 2 i] | convex and mixed |
wfg2 |
m | k + 20 | x_i in [0, 2 i] | convex and disconnected |
wfg3 |
m | k + 20 | x_i in [0, 2 i] | linear and degenerate |
wfg4 to wfg9 |
m | k + 20 | x_i in [0, 2 i] | concave, sum (f_i / 2 i)^2 = 1 |
DTLZ and WFG take the number of objectives m (default 3). WFG also takes the number of position parameters k (default 2 (m - 1), a multiple of m - 1). The other variables are distance parameters, 20 by default, and WFG2 and WFG3 need an even number of them. ZDT5 takes bits: 30 for the first variable and 5 for each of the others. ypea.benchmarks.multi.REGISTRY holds the metadata of each problem. This example asks WFG4 for its default number of variables with three objectives, its bounds with four variables, and the shape of its front:
import ypea
b = ypea.benchmarks.multi.REGISTRY["wfg4"]
print(b.default_dim(3), b.bounds(4), b.front)
24 (array([0., 0., 0., 0.]), array([2., 4., 6., 8.])) concave
Differs from Python: multi_registry() returns a row of MultiBenchmark objects, where Python has a dict.
registry = ypea.benchmarks.multi_registry();
b = registry([registry.name] == "wfg4");
[lb, ub] = b.bounds(4);
disp(b.default_dim(3))
disp(lb)
disp(ub)
disp(b.front)
24
0 0 0 0
2 4 6 8
concave
The definitions follow Zitzler, Deb and Thiele (2000) for ZDT, Deb, Thiele, Laumanns and Zitzler (2001, ETH TIK report 112) for DTLZ, and Huband, Hingston, Barone and While (2006) for WFG.
As problems¶
multi_problem(name, m=None, dim=None, front_points=1000) gives a ready Problem with the usual bounds and size, and its sampled true front in info["pareto_front"]. The problem is vectorized: it evaluates a whole batch of solutions in one call. Its name holds the number of objectives and variables:
from ypea.benchmarks import multi_problem
problem = multi_problem("dtlz2", m=3)
print(problem.name, problem.n_obj, problem.info["pareto_front"].shape)
dtlz2_m3_d12 3 (990, 3)
problem = ypea.benchmarks.multi_problem("dtlz2", m=3);
fprintf("%s %d %s\n", problem.name, problem.n_obj, mat2str(size(problem.info.pareto_front)));
dtlz2_m3_d12 3 [990 3]
ZDT5 has one Binary variable, and the others one Real variable x. The experiment runner uses the true front for IGD and hypervolume.
True Pareto fronts¶
pareto_front(name, n_points, m) samples the true front. It returns an array with one row per point and one column per objective:
from ypea.benchmarks import pareto_front
front = pareto_front("dtlz2", 1000, m=3)
print(front.shape)
(990, 3)
front = ypea.benchmarks.pareto_front("dtlz2", 1000, 3);
disp(size(front))
990 3
DTLZ1 to DTLZ4 and WFG4 to WFG9 use the largest Das and Dennis lattice (ypea.benchmarks.das_dennis) with at most n_points points, so for three objectives you get 91, 990 or 5050. Most other fronts have exactly or at most n_points points, and ZDT5 always has its 31.
Degenerate fronts
The samples of DTLZ5 and DTLZ6 follow the usual curve, and WFG3 the usual line. Ishibuchi, Masuda and Nojima (2016) showed that the true fronts have more parts for DTLZ5 and DTLZ6 with four or more objectives, and for WFG3 with three or more. Solutions in those parts can count as far from the sample.
pareto_front: five ZDT problems with two objectives and three DTLZ problems with three.Indicators¶
A quality indicator turns a set of objective vectors into one number, so you can compare the fronts of different algorithms or runs. ypea.indicators compares a set points (shape (n, m)) with a sample front of the true front. The two most used are IGD (inverted generational distance), which is small when the points lie close to the front and cover all of it, and the hypervolume, the size of the region the points dominate up to a reference point ref, which grows as the points get better:
| Indicator | Meaning | Best |
|---|---|---|
gd(points, front) |
mean distance from each point to the nearest front point | 0 |
igd(points, front) |
mean distance from each front point to the nearest point | 0 |
gd_plus, igd_plus |
like GD and IGD, counting only where the points are worse than the front | 0 |
hypervolume(points, ref) |
volume dominated by the points and bounded by ref |
larger |
spacing(points) |
spread of the nearest neighbor distances in the set | 0 |
The example scales a sample of 28 points of the DTLZ2 front by 1.05, so the points lie a little behind the front:
from ypea import indicators as ind
from ypea.benchmarks import pareto_front
front = pareto_front("dtlz2", 1000, m=3)
points = 1.05 * pareto_front("dtlz2", 28, m=3)
igd = ind.igd(points, front)
gd = ind.gd(points, front)
hv = ind.hypervolume(points, [1.1, 1.1, 1.1])
spacing = ind.spacing(points)
print(round(igd, 4), round(gd, 4))
print(round(hv, 4), round(spacing, 4))
0.1217 0.0526
0.5872 0.1109
front = ypea.benchmarks.pareto_front("dtlz2", 1000, 3);
points = 1.05 * ypea.benchmarks.pareto_front("dtlz2", 28, 3);
igd = ypea.indicators.igd(points, front);
gd = ypea.indicators.gd(points, front);
hv = ypea.indicators.hypervolume(points, [1.1 1.1 1.1]);
spacing = ypea.indicators.spacing(points);
fprintf("%.4f %.4f\n", igd, gd);
fprintf("%.4f %.4f\n", hv, spacing);
0.1217 0.0526
0.5872 0.1109
IGD measures both convergence and spread, so it needs a dense, even front sample (hundreds to thousands of points). GD measures only convergence. GD+ and IGD+ (Ishibuchi et al. 2015) never reward a set for being worse than another, which plain GD and IGD can.
The hypervolume is exact for up to three objectives. Above that it is a Monte Carlo estimate from n_samples points (default one million), reproducible with seed. A common reference point is 1.1 times the nadir point of the true front, for example (1.1, 1.1, 1.1) for DTLZ2 with three objectives. An empty set gives inf for the distance indicators and 0 for the hypervolume.
The indicators assume minimization. For a maximized objective, multiply its column of the points, the front and the reference point by -1. The experiment runner does this for you.
Plots¶
ypea.plot.front draws two objectives as a scatter plot, three in 3D, and more as parallel coordinates. It needs matplotlib (pip install "ypea[plot]"). This example runs NSGA-II on ZDT1 and saves its front, with the true front in gray, to front.png:
import ypea
problem = ypea.benchmarks.multi_problem("zdt1")
result = ypea.NSGAII(max_nfe=20_000).solve(problem, seed=1)
ax = ypea.plot.front(result.front.obj_values, true_front=problem.info["pareto_front"])
ax.figure.savefig("front.png")
Differs from Python: figures are saved with exportgraphics, here to tempdir.
problem = ypea.benchmarks.multi_problem("zdt1");
result = ypea.NSGAII(max_nfe=20000).solve(problem, seed=1);
ax = ypea.plot.front(result.front.obj_values, true_front=problem.info.pareto_front);
exportgraphics(ax.Parent, fullfile(tempdir, "front.png"));

It draws several sets together, with labels= for the legend, objectives= for the axis names, and kind="parallel" for parallel coordinates with two or three objectives.