Benchmarks¶
Regroup typical EC benchmarks functions to import easily and benchmark examples.
Single Objective Continuous | Multi Objective Continuous | Binary | Symbolic Regression |
---|---|---|---|
cigar() |
fonseca() |
chuang_f1() |
kotanchek() |
plane() |
kursawe() |
chuang_f2() |
salustowicz_1d() |
sphere() |
schaffer_mo() |
chuang_f3() |
salustowicz_2d() |
rand() |
dtlz1() |
royal_road1() |
unwrapped_ball() |
ackley() |
dtlz2() |
royal_road2() |
rational_polynomial() |
bohachevsky() |
dtlz3() |
rational_polynomial2() |
|
griewank() |
dtlz4() |
sin_cos() |
|
h1() |
zdt1() |
ripple() |
|
himmelblau() |
zdt2() |
||
rastrigin() |
zdt3() |
||
rastrigin_scaled() |
zdt4() |
||
rastrigin_skew() |
zdt6() |
||
rosenbrock() |
|||
schaffer() |
|||
schwefel() |
|||
shekel() |
Continuous Optimization¶
-
deap.benchmarks.
cigar
(individual)¶ Cigar test objective function.
Type minimization Range none Global optima ,
Function
-
deap.benchmarks.
plane
(individual)¶ Plane test objective function.
Type minimization Range none Global optima ,
Function
-
deap.benchmarks.
sphere
(individual)¶ Sphere test objective function.
Type minimization Range none Global optima ,
Function
-
deap.benchmarks.
rand
(individual)¶ Random test objective function.
Type minimization or maximization Range none Global optima none Function
-
deap.benchmarks.
ackley
(individual)¶ Ackley test objective function.
Type minimization Range Global optima ,
Function
-
deap.benchmarks.
bohachevsky
(individual)¶ Bohachevsky test objective function.
Type minimization Range Global optima ,
Function
-
deap.benchmarks.
griewank
(individual)¶ Griewank test objective function.
Type minimization Range Global optima ,
Function
-
deap.benchmarks.
h1
(individual)¶ Simple two-dimensional function containing several local maxima. 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)
Type maximization Range Global optima ,
Function
-
deap.benchmarks.
himmelblau
(individual)¶ The Himmelblau’s function is multimodal with 4 defined minimums in
.
Type minimization Range Global optima ,
,
,
,
Function
-
deap.benchmarks.
rastrigin
(individual)¶ Rastrigin test objective function.
Type minimization Range Global optima ,
Function
-
deap.benchmarks.
rastrigin_scaled
(individual)¶ Scaled Rastrigin test objective function.
-
deap.benchmarks.
rastrigin_skew
(individual)¶ Skewed Rastrigin test objective function.
-
deap.benchmarks.
rosenbrock
(individual)¶ Rosenbrock test objective function.
Type minimization Range none Global optima ,
Function
-
deap.benchmarks.
schaffer
(individual)¶ Schaffer test objective function.
Type minimization Range Global optima ,
Function
-
deap.benchmarks.
schwefel
(individual)¶ Schwefel test objective function.
Type minimization Range Global optima ,
Function
-
deap.benchmarks.
shekel
(individual, a, c)¶ 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
.
Multi-objective¶
-
deap.benchmarks.
fonseca
(individual)¶ 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.
-
deap.benchmarks.
kursawe
(individual)¶ Kursawe multiobjective function.
-
deap.benchmarks.
schaffer_mo
(individual)¶ 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.
-
deap.benchmarks.
dtlz1
(individual, obj)¶ 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.
-
deap.benchmarks.
dtlz2
(individual, obj)¶ 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.
-
deap.benchmarks.
dtlz3
(individual, obj)¶ 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.
-
deap.benchmarks.
dtlz4
(individual, obj, alpha)¶ 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.
-
deap.benchmarks.
zdt1
(individual)¶ ZDT1 multiobjective function.
-
deap.benchmarks.
zdt2
(individual)¶ ZDT2 multiobjective function.
-
deap.benchmarks.
zdt3
(individual)¶ ZDT3 multiobjective function.
-
deap.benchmarks.
zdt4
(individual)¶ ZDT4 multiobjective function.
-
deap.benchmarks.
zdt6
(individual)¶ ZDT6 multiobjective function.
Binary Optimization¶
-
deap.benchmarks.binary.
chuang_f1
(individual)¶ 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].
-
deap.benchmarks.binary.
chuang_f2
(individual)¶ 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].
-
deap.benchmarks.binary.
chuang_f3
(individual)¶ 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].
-
deap.benchmarks.binary.
royal_road1
(individual, order)¶ Royal Road Function R1 as presented by Melanie Mitchell in : “An introduction to Genetic Algorithms”.
-
deap.benchmarks.binary.
royal_road2
(individual, order)¶ Royal Road Function R2 as presented by Melanie Mitchell in : “An introduction to Genetic Algorithms”.
-
deap.benchmarks.binary.
bin2float
(min_, max_, nbits)¶ 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.
Symbolic Regression¶
-
deap.benchmarks.gp.
kotanchek
(data)¶ Kotanchek benchmark function.
Range Function
-
deap.benchmarks.gp.
salustowicz_1d
(data)¶ Salustowicz benchmark function.
Range Function
-
deap.benchmarks.gp.
salustowicz_2d
(data)¶ Salustowicz benchmark function.
Range Function
-
deap.benchmarks.gp.
unwrapped_ball
(data)¶ Unwrapped ball benchmark function.
Range Function
-
deap.benchmarks.gp.
rational_polynomial
(data)¶ Rational polynomial ball benchmark function.
Range Function
-
deap.benchmarks.gp.
rational_polynomial2
(data)¶ Rational polynomial benchmark function.
Range Function
-
deap.benchmarks.gp.
sin_cos
(data)¶ Sine cosine benchmark function.
Range Function
-
deap.benchmarks.gp.
ripple
(data)¶ Ripple benchmark function.
Range Function
Moving Peaks Benchmark¶
Benchmarks tools¶
Module containing tools that are useful when benchmarking algorithms
-
deap.benchmarks.tools.
convergence
(first_front, optimal_front)¶ 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.
-
deap.benchmarks.tools.
diversity
(first_front, first, last)¶ 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.
-
deap.benchmarks.tools.
noise
(noise)¶ 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’sfunctools.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 acceptNone
, which will leave the objective without noise.This decorator adds a
noise()
method to the decorated function.-
noise.
noise
(noise)¶ 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)
-
-
deap.benchmarks.tools.
rotate
(matrix)¶ 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()
method 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)
-
rotate.
rotate
(matrix)¶ 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))
-
-
deap.benchmarks.tools.
scale
(factor)¶ 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()
method to the decorated function.-
scale.
scale
(factor)¶ 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])
-
-
deap.benchmarks.tools.
translate
(vector)¶ 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()
method to the decorated function.-
translate.
translate
(vector)¶ 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])
-