Regroup typical EC benchmarks functions to import easily and benchmark examples.
Single Objective Continuous | Multi Objective Continuous | Binary |
---|---|---|
cigar() | fonseca() | chuang_f1() |
plane() | kursawe() | chuang_f2() |
sphere() | schaffer_mo() | chuang_f3() |
ackley() | dtlz1() | royal_road1() |
bohachevsky() | dtlz2() | royal_road2() |
griewank() | dtlz3() | |
h1() | dtlz4() | |
himmelblau() | zdt1() | |
rastrigin() | zdt2() | |
rastrigin_scaled() | zdt3() | |
rastrigin_skew() | zdt4() | |
rosenbrock() | zdt6() | |
schaffer() | ||
schwefel() | ||
shekel() |
Cigar test objective function.
Plane test objective function.
Sphere test objective function.
Ackley test objective function.
(Source code, png, hires.png, pdf)
Bohachevsky test objective function
(Source code, png, hires.png, pdf)
Griewank test objective function
(Source code, png, hires.png, pdf)
Simple two-dimensional function containing several local maxima, H1 has a unique maximum value of 2.0 at the point (8.6998, 6.7665). From: The Merits of a Parallel Genetic Algorithm in Solving Hard Optimization Problems, A. J. Knoek van Soest and L. J. R. Richard Casius, J. Biomech. Eng. 125, 141 (2003)
(Source code, png, hires.png, pdf)
The Himmelblau’s function is multimodal with 4 defined minimums in .
(Source code, png, hires.png, pdf)
Rastrigin test objective function.
(Source code, png, hires.png, pdf)
Scaled Rastrigin test objective function,
Skewed Rastrigin test objective function
Rosenbrock test objective function.
(Source code, png, hires.png, pdf)
Schaffer test objective function.
(Source code, png, hires.png, pdf)
Schwefel test objective function.
(Source code, png, hires.png, pdf)
The Shekel multimodal function can have any number of maxima. The number of maxima is given by the length of any of the arguments a or c, a is a matrix of size , where M is the number of maxima and N the number of dimensions and c is a vector. The matrix can be seen as the position of the maxima and the vector , the width of the maxima.
The following figure uses
and , thus defining 5 maximums in .
(Source code, png, hires.png, pdf)
Fonseca and Fleming’s multiobjective function. From: C. M. Fonseca and P. J. Fleming, “Multiobjective optimization and multiple constraint handling with evolutionary algorithms – Part II: Application example”, IEEE Transactions on Systems, Man and Cybernetics, 1998.
Kursawe multiobjective function.
(Source code, png, hires.png, pdf)
Schaffer’s multiobjective function on a one attribute individual. From: J. D. Schaffer, “Multiple objective optimization with vector evaluated genetic algorithms”, in Proceedings of the First International Conference on Genetic Algorithms, 1987.
DTLZ1 mutliobjective function. It returns a tuple of obj values. The individual must have at least obj elements. From: K. Deb, L. Thiele, M. Laumanns and E. Zitzler. Scalable Multi-Objective Optimization Test Problems. CEC 2002, p. 825 - 830, IEEE Press, 2002.
Where is the number of objectives and is a vector of the remaining attributes of the individual in dimensions.
DTLZ2 mutliobjective function. It returns a tuple of obj values. The individual must have at least obj elements. From: K. Deb, L. Thiele, M. Laumanns and E. Zitzler. Scalable Multi-Objective Optimization Test Problems. CEC 2002, p. 825 - 830, IEEE Press, 2002.
Where is the number of objectives and is a vector of the remaining attributes of the individual in dimensions.
DTLZ3 mutliobjective function. It returns a tuple of obj values. The individual must have at least obj elements. From: K. Deb, L. Thiele, M. Laumanns and E. Zitzler. Scalable Multi-Objective Optimization Test Problems. CEC 2002, p. 825 - 830, IEEE Press, 2002.
Where is the number of objectives and is a vector of the remaining attributes of the individual in dimensions.
DTLZ4 mutliobjective function. It returns a tuple of obj values. The individual must have at least obj elements. The alpha parameter allows for a meta-variable mapping in dtlz2() , the authors suggest . From: K. Deb, L. Thiele, M. Laumanns and E. Zitzler. Scalable Multi-Objective Optimization Test Problems. CEC 2002, p. 825 - 830, IEEE Press, 2002.
Where is the number of objectives and is a vector of the remaining attributes of the individual in dimensions.
ZDT1 multiobjective function
ZDT2 multiobjective function
ZDT3 multiobjective function
ZDT4 multiobjective function
ZDT6 multiobjective function
Binary deceptive function from : Multivariate Multi-Model Approach for Globally Multimodal Problems by Chung-Yao Chuang and Wen-Lian Hsu.
The function takes individual of 40+1 dimensions and has two global optima in [1,1,...,1] and [0,0,...,0].
Binary deceptive function from : Multivariate Multi-Model Approach for Globally Multimodal Problems by Chung-Yao Chuang and Wen-Lian Hsu.
The function takes individual of 40+1 dimensions and has four global optima in [1,1,...,0,0], [0,0,...,1,1], [1,1,...,1] and [0,0,...,0].
Binary deceptive function from : Multivariate Multi-Model Approach for Globally Multimodal Problems by Chung-Yao Chuang and Wen-Lian Hsu.
The function takes individual of 40+1 dimensions and has two global optima in [1,1,...,1] and [0,0,...,0].
Royal Road Function R1 as presented by Melanie Mitchell in : “An introduction to Genetic Algorithms”.
Royal Road Function R2 as presented by Melanie Mitchell in : “An introduction to Genetic Algorithms”.
Convert a binary array into an array of float where each float is composed of nbits and is between min_ and max_ and return the result of the decorated function.
Note
This decorator requires the first argument of the evaluation function to be named individual.
Re-implementation of the Moving Peaks Benchmark by Jurgen Branke.
The Moving Peaks Benchmark is a fitness function changing over time. It consists of a number of peaks, changing in height, width and location. The peaks function is given by pfunc, wich is either a function object or a list of function objects (the default is function1()). The number of peaks is determined by npeaks (which defaults to 5), while the dimensionality of the search domain is dim. A basis function bfunc can also be given to act as static landscape (the default is no basis function). The argument random serves to grant an independent random number generator to the moving peaks so that the evolution is not influenced by number drawn by this object (the default uses random functions from the Python module random). Various other keyword parameters listed in the table below are required to setup the benchmark, default parameters are based on scenario 1 of this benchmark.
Parameter | SCENARIO_1 (Default) | SCENARIO_2 | SCENARIO_3 | Details |
---|---|---|---|---|
pfunc | function1() | cone() | cone() | The peak function or a list of peak function. |
npeaks | 5 | 10 | 50 | Number of peaks. |
bfunc | None | None | lambda x: 10 | Basis static function. |
min_coord | 0.0 | 0.0 | 0.0 | Minimum coordinate for the centre of the peaks. |
max_coord | 100.0 | 100.0 | 100.0 | Maximum coordinate for the centre of the peaks. |
min_height | 30.0 | 30.0 | 30.0 | Minimum height of the peaks. |
max_height | 70.0 | 70.0 | 70.0 | Maximum height of the peaks. |
uniform_height | 50.0 | 50.0 | 0 | Starting height for all peaks, if uniform_height <= 0 the initial height is set randomly for each peak. |
min_width | 0.0001 | 1.0 | 1.0 | Minimum width of the peaks. |
max_width | 0.2 | 12.0 | 12.0 | Maximum width of the peaks |
uniform_width | 0.1 | 0 | 0 | Starting width for all peaks, if uniform_width <= 0 the initial width is set randomly for each peak. |
lambda_ | 0.0 | 0.5 | 0.5 | Correlation between changes. |
move_severity | 1.0 | 1.5 | 1.0 | The distance a single peak moves when peaks change. |
height_severity | 7.0 | 7.0 | 1.0 | The standard deviation of the change made to the height of a peak when peaks change. |
width_severity | 0.01 | 1.0 | 0.5 | The standard deviation of the change made to the width of a peak when peaks change. |
Dictionnaries SCENARIO_1, SCENARIO_2 and SCENARIO_3 of this module define the defaults for these parameters. The scenario 3 requires a constant basis function which can be given as a lambda function lambda x: constant.
The following shows an example of scenario 1 with non uniform heights and widths.
(Source code, png, hires.png, pdf)
Order the peaks to change position, height and width.
Returns the global maximum value and position.
Returns all visible maximums value and position sorted with the global maximum first.
The cone peak function to be used with scenario 2 and 3.
The function1 peak function to be used with scenario 1.
Module containing tools that are useful when benchmarking algorithms
Given a Pareto front first_front and the optimal Pareto front, this function returns a metric of convergence of the front as explained in the original NSGA-II article by K. Deb. The smaller the value is, the closer the front is to the optimal one.
Given a Pareto front first_front and the two extreme points of the optimal Pareto front, this function returns a metric of the diversity of the front as explained in the original NSGA-II article by K. Deb. The smaller the value is, the better the front is.
Decorator for evaluation functions, it evaluates the objective function and adds noise by calling the function(s) provided in the noise argument. The noise functions are called without any argument, consider using the Toolbox or Python’s functools.partial() to provide any required argument. If a single function is provided it is applied to all objectives of the evaluation function. If a list of noise functions is provided, it must be of length equal to the number of objectives. The noise argument also accept None, which will leave the objective without noise.
This decorator adds a noise() function to the decorated function.
Set the current noise to noise. After decorating the evaluation function, this function will be available directly from the function object.
prand = functools.partial(random.gauss, mu=0.0, sigma=1.0)
@noise(prand)
def evaluate(individual):
return sum(individual),
# This will remove noise from the evaluation function
evaluate.noise(None)
Decorator for evaluation functions, it rotates the objective function by matrix which should be a valid orthogonal NxN rotation matrix, with N the length of an individual. When called the decorated function should take as first argument the individual to be evaluated. The inverse rotation matrix is actually applied to the individual and the resulting list is given to the evaluation function. Thus, the evaluation function shall not be expecting an individual as it will receive a plain list (numpy.array). The multiplication is done using numpy.
This decorator adds a rotate() function to the decorated function.
Note
A random orthogonal matrix Q can be created via QR decomposition.
A = numpy.random.random((n,n))
Q, _ = numpy.linalg.qr(A)
Set the current rotation to matrix. After decorating the evaluation function, this function will be available directly from the function object.
# Create a random orthogonal matrix
A = numpy.random.random((n,n))
Q, _ = numpy.linalg.qr(A)
@rotate(Q)
def evaluate(individual):
return sum(individual),
# This will reset rotation to identity
evaluate.rotate(numpy.identity(n))
Decorator for evaluation functions, it scales the objective function by factor which should be the same length as the individual size. When called the decorated function should take as first argument the individual to be evaluated. The inverse factor vector is actually applied to the individual and the resulting list is given to the evaluation function. Thus, the evaluation function shall not be expecting an individual as it will receive a plain list.
This decorator adds a scale() function to the decorated function.
Set the current scale to factor. After decorating the evaluation function, this function will be available directly from the function object.
@scale([0.25, 2.0, ..., 0.1])
def evaluate(individual):
return sum(individual),
# This will cancel the scaling
evaluate.scale([1.0, 1.0, ..., 1.0])
Decorator for evaluation functions, it translates the objective function by vector which should be the same length as the individual size. When called the decorated function should take as first argument the individual to be evaluated. The inverse translation vector is actually applied to the individual and the resulting list is given to the evaluation function. Thus, the evaluation function shall not be expecting an individual as it will receive a plain list.
This decorator adds a translate() function to the decorated function.
Set the current translation to vector. After decorating the evaluation function, this function will be available directly from the function object.
@translate([0.25, 0.5, ..., 0.1])
def evaluate(individual):
return sum(individual),
# This will cancel the translation
evaluate.translate([0.0, 0.0, ..., 0.0])