import go_benchmark_functions
from scipy
This commit is contained in:
parent
ea1ad4e722
commit
3fccc2f937
29 changed files with 9839 additions and 0 deletions
72
go_benchmark_functions/__init__.py
Normal file
72
go_benchmark_functions/__init__.py
Normal file
|
@ -0,0 +1,72 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
==============================================================================
|
||||
`go_benchmark_functions` -- Problems for testing global optimization routines
|
||||
==============================================================================
|
||||
|
||||
This module provides a comprehensive set of problems for benchmarking global
|
||||
optimization routines, such as scipy.optimize.basinhopping, or
|
||||
scipy.optimize.differential_evolution. The purpose is to see whether a given
|
||||
optimization routine can find the global minimum, and how many function
|
||||
evaluations it requires to do so.
|
||||
The range of problems is extensive, with a range of difficulty. The problems are
|
||||
multivariate, with N=2 to N=17 provided.
|
||||
|
||||
References
|
||||
----------
|
||||
.. [1] Momin Jamil and Xin-She Yang, A literature survey of benchmark
|
||||
functions for global optimization problems, Int. Journal of Mathematical
|
||||
Modelling and Numerical Optimisation, Vol. 4, No. 2, pp. 150--194 (2013).
|
||||
https://arxiv.org/abs/1308.4008v1
|
||||
(and references contained within)
|
||||
.. [2] http://infinity77.net/global_optimization/
|
||||
.. [3] S. K. Mishra, Global Optimization By Differential Evolution and
|
||||
Particle Swarm Methods: Evaluation On Some Benchmark Functions, Munich
|
||||
Research Papers in Economics
|
||||
.. [4] E. P. Adorio, U. P. Dilman, MVF - Multivariate Test Function Library
|
||||
in C for Unconstrained Global Optimization Methods, [Available Online]:
|
||||
https://www.geocities.ws/eadorio/mvf.pdf
|
||||
.. [5] S. K. Mishra, Some New Test Functions For Global Optimization And
|
||||
Performance of Repulsive Particle Swarm Method, [Available Online]:
|
||||
https://mpra.ub.uni-muenchen.de/2718/
|
||||
.. [6] NIST StRD Nonlinear Regression Problems, retrieved on 1 Oct, 2014
|
||||
https://www.itl.nist.gov/div898/strd/nls/nls_main.shtml
|
||||
|
||||
"""
|
||||
|
||||
"""
|
||||
Copyright 2013 Andrea Gavana
|
||||
Author: <andrea.gavana@gmail.com>
|
||||
|
||||
Modifications 2014 Andrew Nelson
|
||||
<andyfaff@gmail.com>
|
||||
"""
|
||||
|
||||
from .go_funcs_A import *
|
||||
from .go_funcs_B import *
|
||||
from .go_funcs_C import *
|
||||
from .go_funcs_D import *
|
||||
from .go_funcs_E import *
|
||||
from .go_funcs_F import *
|
||||
from .go_funcs_G import *
|
||||
from .go_funcs_H import *
|
||||
from .go_funcs_I import *
|
||||
from .go_funcs_J import *
|
||||
from .go_funcs_K import *
|
||||
from .go_funcs_L import *
|
||||
from .go_funcs_M import *
|
||||
from .go_funcs_N import *
|
||||
from .go_funcs_O import *
|
||||
from .go_funcs_P import *
|
||||
from .go_funcs_Q import *
|
||||
from .go_funcs_R import *
|
||||
from .go_funcs_S import *
|
||||
from .go_funcs_T import *
|
||||
from .go_funcs_U import *
|
||||
from .go_funcs_V import *
|
||||
from .go_funcs_W import *
|
||||
from .go_funcs_X import *
|
||||
from .go_funcs_Y import *
|
||||
from .go_funcs_Z import *
|
||||
|
||||
__all__ = [s for s in dir() if not s.startswith('_')]
|
207
go_benchmark_functions/go_benchmark.py
Normal file
207
go_benchmark_functions/go_benchmark.py
Normal file
|
@ -0,0 +1,207 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import numpy as np
|
||||
from numpy import abs, asarray
|
||||
|
||||
from ..common import safe_import
|
||||
|
||||
with safe_import():
|
||||
from scipy.special import factorial
|
||||
|
||||
|
||||
class Benchmark:
|
||||
|
||||
"""
|
||||
Defines a global optimization benchmark problem.
|
||||
|
||||
This abstract class defines the basic structure of a global
|
||||
optimization problem. Subclasses should implement the ``fun`` method
|
||||
for a particular optimization problem.
|
||||
|
||||
Attributes
|
||||
----------
|
||||
N : int
|
||||
The dimensionality of the problem.
|
||||
bounds : sequence
|
||||
The lower/upper bounds to be used for minimizing the problem.
|
||||
This a list of (lower, upper) tuples that contain the lower and upper
|
||||
bounds for the problem. The problem should not be asked for evaluation
|
||||
outside these bounds. ``len(bounds) == N``.
|
||||
xmin : sequence
|
||||
The lower bounds for the problem
|
||||
xmax : sequence
|
||||
The upper bounds for the problem
|
||||
fglob : float
|
||||
The global minimum of the evaluated function.
|
||||
global_optimum : sequence
|
||||
A list of vectors that provide the locations of the global minimum.
|
||||
Note that some problems have multiple global minima, not all of which
|
||||
may be listed.
|
||||
nfev : int
|
||||
the number of function evaluations that the object has been asked to
|
||||
calculate.
|
||||
change_dimensionality : bool
|
||||
Whether we can change the benchmark function `x` variable length (i.e.,
|
||||
the dimensionality of the problem)
|
||||
custom_bounds : sequence
|
||||
a list of tuples that contain lower/upper bounds for use in plotting.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions):
|
||||
"""
|
||||
Initialises the problem
|
||||
|
||||
Parameters
|
||||
----------
|
||||
|
||||
dimensions : int
|
||||
The dimensionality of the problem
|
||||
"""
|
||||
|
||||
self._dimensions = dimensions
|
||||
self.nfev = 0
|
||||
self.fglob = np.nan
|
||||
self.global_optimum = None
|
||||
self.change_dimensionality = False
|
||||
self.custom_bounds = None
|
||||
|
||||
def __str__(self):
|
||||
return '{0} ({1} dimensions)'.format(self.__class__.__name__, self.N)
|
||||
|
||||
def __repr__(self):
|
||||
return self.__class__.__name__
|
||||
|
||||
def initial_vector(self):
|
||||
"""
|
||||
Random initialisation for the benchmark problem.
|
||||
|
||||
Returns
|
||||
-------
|
||||
x : sequence
|
||||
a vector of length ``N`` that contains random floating point
|
||||
numbers that lie between the lower and upper bounds for a given
|
||||
parameter.
|
||||
"""
|
||||
|
||||
return asarray([np.random.uniform(l, u) for l, u in self.bounds])
|
||||
|
||||
def success(self, x, tol=1.e-5):
|
||||
"""
|
||||
Tests if a candidate solution at the global minimum.
|
||||
The default test is
|
||||
|
||||
Parameters
|
||||
----------
|
||||
x : sequence
|
||||
The candidate vector for testing if the global minimum has been
|
||||
reached. Must have ``len(x) == self.N``
|
||||
tol : float
|
||||
The evaluated function and known global minimum must differ by less
|
||||
than this amount to be at a global minimum.
|
||||
|
||||
Returns
|
||||
-------
|
||||
bool : is the candidate vector at the global minimum?
|
||||
"""
|
||||
val = self.fun(asarray(x))
|
||||
if abs(val - self.fglob) < tol:
|
||||
return True
|
||||
|
||||
# the solution should still be in bounds, otherwise immediate fail.
|
||||
if np.any(x > np.asfarray(self.bounds)[:, 1]):
|
||||
return False
|
||||
if np.any(x < np.asfarray(self.bounds)[:, 0]):
|
||||
return False
|
||||
|
||||
# you found a lower global minimum. This shouldn't happen.
|
||||
if val < self.fglob:
|
||||
raise ValueError("Found a lower global minimum",
|
||||
x,
|
||||
val,
|
||||
self.fglob)
|
||||
|
||||
return False
|
||||
|
||||
def fun(self, x):
|
||||
"""
|
||||
Evaluation of the benchmark function.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
x : sequence
|
||||
The candidate vector for evaluating the benchmark problem. Must
|
||||
have ``len(x) == self.N``.
|
||||
|
||||
Returns
|
||||
-------
|
||||
val : float
|
||||
the evaluated benchmark function
|
||||
"""
|
||||
|
||||
raise NotImplementedError
|
||||
|
||||
def change_dimensions(self, ndim):
|
||||
"""
|
||||
Changes the dimensionality of the benchmark problem
|
||||
|
||||
The dimensionality will only be changed if the problem is suitable
|
||||
|
||||
Parameters
|
||||
----------
|
||||
ndim : int
|
||||
The new dimensionality for the problem.
|
||||
"""
|
||||
|
||||
if self.change_dimensionality:
|
||||
self._dimensions = ndim
|
||||
else:
|
||||
raise ValueError('dimensionality cannot be changed for this'
|
||||
'problem')
|
||||
|
||||
@property
|
||||
def bounds(self):
|
||||
"""
|
||||
The lower/upper bounds to be used for minimizing the problem.
|
||||
This a list of (lower, upper) tuples that contain the lower and upper
|
||||
bounds for the problem. The problem should not be asked for evaluation
|
||||
outside these bounds. ``len(bounds) == N``.
|
||||
"""
|
||||
if self.change_dimensionality:
|
||||
return [self._bounds[0]] * self.N
|
||||
else:
|
||||
return self._bounds
|
||||
|
||||
@property
|
||||
def N(self):
|
||||
"""
|
||||
The dimensionality of the problem.
|
||||
|
||||
Returns
|
||||
-------
|
||||
N : int
|
||||
The dimensionality of the problem
|
||||
"""
|
||||
return self._dimensions
|
||||
|
||||
@property
|
||||
def xmin(self):
|
||||
"""
|
||||
The lower bounds for the problem
|
||||
|
||||
Returns
|
||||
-------
|
||||
xmin : sequence
|
||||
The lower bounds for the problem
|
||||
"""
|
||||
return asarray([b[0] for b in self.bounds])
|
||||
|
||||
@property
|
||||
def xmax(self):
|
||||
"""
|
||||
The upper bounds for the problem
|
||||
|
||||
Returns
|
||||
-------
|
||||
xmax : sequence
|
||||
The upper bounds for the problem
|
||||
"""
|
||||
return asarray([b[1] for b in self.bounds])
|
279
go_benchmark_functions/go_funcs_A.py
Normal file
279
go_benchmark_functions/go_funcs_A.py
Normal file
|
@ -0,0 +1,279 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from numpy import abs, cos, exp, pi, prod, sin, sqrt, sum
|
||||
from .go_benchmark import Benchmark
|
||||
|
||||
|
||||
class Ackley01(Benchmark):
|
||||
|
||||
r"""
|
||||
Ackley01 objective function.
|
||||
|
||||
The Ackley01 [1]_ global optimization problem is a multimodal minimization
|
||||
problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Ackley01}}(x) = -20 e^{-0.2 \sqrt{\frac{1}{n} \sum_{i=1}^n
|
||||
x_i^2}} - e^{\frac{1}{n} \sum_{i=1}^n \cos(2 \pi x_i)} + 20 + e
|
||||
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and :math:`x_i \in
|
||||
[-35, 35]` for :math:`i = 1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x_i = 0` for
|
||||
:math:`i = 1, ..., n`
|
||||
|
||||
.. [1] Adorio, E. MVF - "Multivariate Test Functions Library in C for
|
||||
Unconstrained Global Optimization", 2005
|
||||
|
||||
TODO: the -0.2 factor in the exponent of the first term is given as
|
||||
-0.02 in Jamil et al.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-35.0] * self.N, [35.0] * self.N))
|
||||
self.global_optimum = [[0 for _ in range(self.N)]]
|
||||
self.fglob = 0.0
|
||||
self.change_dimensionality = True
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
u = sum(x ** 2)
|
||||
v = sum(cos(2 * pi * x))
|
||||
return (-20. * exp(-0.2 * sqrt(u / self.N))
|
||||
- exp(v / self.N) + 20. + exp(1.))
|
||||
|
||||
|
||||
class Ackley02(Benchmark):
|
||||
|
||||
r"""
|
||||
Ackley02 objective function.
|
||||
|
||||
The Ackley02 [1]_ global optimization problem is a multimodal minimization
|
||||
problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Ackley02}(x) = -200 e^{-0.02 \sqrt{x_1^2 + x_2^2}}
|
||||
|
||||
|
||||
with :math:`x_i \in [-32, 32]` for :math:`i=1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = -200` for :math:`x = [0, 0]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
|
||||
"""
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-32.0] * self.N, [32.0] * self.N))
|
||||
self.global_optimum = [[0 for _ in range(self.N)]]
|
||||
self.fglob = -200.
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
return -200 * exp(-0.02 * sqrt(x[0] ** 2 + x[1] ** 2))
|
||||
|
||||
|
||||
class Ackley03(Benchmark):
|
||||
|
||||
r"""
|
||||
Ackley03 [1]_ objective function.
|
||||
|
||||
The Ackley03 global optimization problem is a multimodal minimization
|
||||
problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Ackley03}}(x) = -200 e^{-0.02 \sqrt{x_1^2 + x_2^2}} +
|
||||
5e^{\cos(3x_1) + \sin(3x_2)}
|
||||
|
||||
|
||||
with :math:`x_i \in [-32, 32]` for :math:`i=1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = -195.62902825923879` for :math:`x
|
||||
= [-0.68255758, -0.36070859]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
|
||||
TODO: I think the minus sign is missing in front of the first term in eqn3
|
||||
in [1]_. This changes the global minimum
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-32.0] * self.N, [32.0] * self.N))
|
||||
self.global_optimum = [[-0.68255758, -0.36070859]]
|
||||
self.fglob = -195.62902825923879
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
a = -200 * exp(-0.02 * sqrt(x[0] ** 2 + x[1] ** 2))
|
||||
a += 5 * exp(cos(3 * x[0]) + sin(3 * x[1]))
|
||||
return a
|
||||
|
||||
|
||||
class Adjiman(Benchmark):
|
||||
|
||||
r"""
|
||||
Adjiman objective function.
|
||||
|
||||
The Adjiman [1]_ global optimization problem is a multimodal minimization
|
||||
problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Adjiman}}(x) = \cos(x_1)\sin(x_2) - \frac{x_1}{(x_2^2 + 1)}
|
||||
|
||||
|
||||
with, :math:`x_1 \in [-1, 2]` and :math:`x_2 \in [-1, 1]`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = -2.02181` for :math:`x = [2.0, 0.10578]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = ([-1.0, 2.0], [-1.0, 1.0])
|
||||
self.global_optimum = [[2.0, 0.10578]]
|
||||
self.fglob = -2.02180678
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
return cos(x[0]) * sin(x[1]) - x[0] / (x[1] ** 2 + 1)
|
||||
|
||||
|
||||
class Alpine01(Benchmark):
|
||||
|
||||
r"""
|
||||
Alpine01 objective function.
|
||||
|
||||
The Alpine01 [1]_ global optimization problem is a multimodal minimization
|
||||
problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Alpine01}}(x) = \sum_{i=1}^{n} \lvert {x_i \sin \left( x_i
|
||||
\right) + 0.1 x_i} \rvert
|
||||
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and :math:`x_i \in
|
||||
[-10, 10]` for :math:`i = 1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x_i = 0` for
|
||||
:math:`i = 1, ..., n`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-10.0] * self.N, [10.0] * self.N))
|
||||
self.global_optimum = [[0 for _ in range(self.N)]]
|
||||
self.fglob = 0.0
|
||||
self.change_dimensionality = True
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return sum(abs(x * sin(x) + 0.1 * x))
|
||||
|
||||
|
||||
class Alpine02(Benchmark):
|
||||
|
||||
r"""
|
||||
Alpine02 objective function.
|
||||
|
||||
The Alpine02 [1]_ global optimization problem is a multimodal minimization
|
||||
problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Alpine02}(x) = \prod_{i=1}^{n} \sqrt{x_i} \sin(x_i)
|
||||
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and :math:`x_i \in [0,
|
||||
10]` for :math:`i = 1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = -6.1295` for :math:`x =
|
||||
[7.91705268, 4.81584232]` for :math:`i = 1, 2`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
|
||||
TODO: eqn 7 in [1]_ has the wrong global minimum value.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([0.0] * self.N, [10.0] * self.N))
|
||||
self.global_optimum = [[7.91705268, 4.81584232]]
|
||||
self.fglob = -6.12950
|
||||
self.change_dimensionality = True
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return prod(sqrt(x) * sin(x))
|
||||
|
||||
|
||||
class AMGM(Benchmark):
|
||||
|
||||
r"""
|
||||
AMGM objective function.
|
||||
|
||||
The AMGM (Arithmetic Mean - Geometric Mean Equality) global optimization
|
||||
problem is a multimodal minimization problem defined as follows
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{AMGM}}(x) = \left ( \frac{1}{n} \sum_{i=1}^{n} x_i -
|
||||
\sqrt[n]{ \prod_{i=1}^{n} x_i} \right )^2
|
||||
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and :math:`x_i \in
|
||||
[0, 10]` for :math:`i = 1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x_1 = x_2 = ... = x_n` for
|
||||
:math:`i = 1, ..., n`
|
||||
|
||||
.. [1] Gavana, A. Global Optimization Benchmarks and AMPGO, retrieved 2015
|
||||
|
||||
TODO: eqn 7 in [1]_ has the wrong global minimum value.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([0.0] * self.N, [10.0] * self.N))
|
||||
self.global_optimum = [[1, 1]]
|
||||
self.fglob = 0.0
|
||||
self.change_dimensionality = True
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
f1 = sum(x)
|
||||
f2 = prod(x)
|
||||
f1 = f1 / self.N
|
||||
f2 = f2 ** (1.0 / self.N)
|
||||
f = (f1 - f2) ** 2
|
||||
|
||||
return f
|
759
go_benchmark_functions/go_funcs_B.py
Normal file
759
go_benchmark_functions/go_funcs_B.py
Normal file
|
@ -0,0 +1,759 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from numpy import abs, cos, exp, log, arange, pi, sin, sqrt, sum
|
||||
from .go_benchmark import Benchmark
|
||||
|
||||
|
||||
class BartelsConn(Benchmark):
|
||||
|
||||
r"""
|
||||
Bartels-Conn objective function.
|
||||
|
||||
The BartelsConn [1]_ global optimization problem is a multimodal
|
||||
minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{BartelsConn}}(x) = \lvert {x_1^2 + x_2^2 + x_1x_2} \rvert +
|
||||
\lvert {\sin(x_1)} \rvert + \lvert {\cos(x_2)} \rvert
|
||||
|
||||
|
||||
with :math:`x_i \in [-500, 500]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 1` for :math:`x = [0, 0]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-500.] * self.N, [500.] * self.N))
|
||||
self.global_optimum = [[0 for _ in range(self.N)]]
|
||||
self.fglob = 1.0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return (abs(x[0] ** 2.0 + x[1] ** 2.0 + x[0] * x[1]) + abs(sin(x[0]))
|
||||
+ abs(cos(x[1])))
|
||||
|
||||
|
||||
class Beale(Benchmark):
|
||||
|
||||
r"""
|
||||
Beale objective function.
|
||||
|
||||
The Beale [1]_ global optimization problem is a multimodal
|
||||
minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Beale}}(x) = \left(x_1 x_2 - x_1 + 1.5\right)^{2} +
|
||||
\left(x_1 x_2^{2} - x_1 + 2.25\right)^{2} + \left(x_1 x_2^{3} - x_1 +
|
||||
2.625\right)^{2}
|
||||
|
||||
|
||||
with :math:`x_i \in [-4.5, 4.5]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x=[3, 0.5]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-4.5] * self.N, [4.5] * self.N))
|
||||
self.global_optimum = [[3.0, 0.5]]
|
||||
self.fglob = 0.0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return ((1.5 - x[0] + x[0] * x[1]) ** 2
|
||||
+ (2.25 - x[0] + x[0] * x[1] ** 2) ** 2
|
||||
+ (2.625 - x[0] + x[0] * x[1] ** 3) ** 2)
|
||||
|
||||
|
||||
class BiggsExp02(Benchmark):
|
||||
|
||||
r"""
|
||||
BiggsExp02 objective function.
|
||||
|
||||
The BiggsExp02 [1]_ global optimization problem is a multimodal minimization
|
||||
problem defined as follows
|
||||
|
||||
.. math::
|
||||
|
||||
\begin{matrix}
|
||||
f_{\text{BiggsExp02}}(x) = \sum_{i=1}^{10} (e^{-t_i x_1}
|
||||
- 5 e^{-t_i x_2} - y_i)^2 \\
|
||||
t_i = 0.1 i\\
|
||||
y_i = e^{-t_i} - 5 e^{-10t_i}\\
|
||||
\end{matrix}
|
||||
|
||||
|
||||
with :math:`x_i \in [0, 20]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x = [1, 10]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([0] * 2,
|
||||
[20] * 2))
|
||||
self.global_optimum = [[1., 10.]]
|
||||
self.fglob = 0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
t = arange(1, 11.) * 0.1
|
||||
y = exp(-t) - 5 * exp(-10 * t)
|
||||
vec = (exp(-t * x[0]) - 5 * exp(-t * x[1]) - y) ** 2
|
||||
|
||||
return sum(vec)
|
||||
|
||||
|
||||
class BiggsExp03(Benchmark):
|
||||
|
||||
r"""
|
||||
BiggsExp03 objective function.
|
||||
|
||||
The BiggsExp03 [1]_ global optimization problem is a multimodal minimization
|
||||
problem defined as follows
|
||||
|
||||
.. math::
|
||||
|
||||
\begin{matrix}\ f_{\text{BiggsExp03}}(x) = \sum_{i=1}^{10}
|
||||
(e^{-t_i x_1} - x_3e^{-t_i x_2} - y_i)^2\\
|
||||
t_i = 0.1i\\
|
||||
y_i = e^{-t_i} - 5e^{-10 t_i}\\
|
||||
\end{matrix}
|
||||
|
||||
|
||||
with :math:`x_i \in [0, 20]` for :math:`i = 1, 2, 3`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x = [1, 10, 5]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=3):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([0] * 3,
|
||||
[20] * 3))
|
||||
self.global_optimum = [[1., 10., 5.]]
|
||||
self.fglob = 0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
t = arange(1., 11.) * 0.1
|
||||
y = exp(-t) - 5 * exp(-10 * t)
|
||||
vec = (exp(-t * x[0]) - x[2] * exp(-t * x[1]) - y) ** 2
|
||||
|
||||
return sum(vec)
|
||||
|
||||
|
||||
class BiggsExp04(Benchmark):
|
||||
|
||||
r"""
|
||||
BiggsExp04 objective function.
|
||||
|
||||
The BiggsExp04 [1]_ global optimization problem is a multimodal
|
||||
minimization problem defined as follows
|
||||
|
||||
.. math::
|
||||
|
||||
\begin{matrix}\ f_{\text{BiggsExp04}}(x) = \sum_{i=1}^{10}
|
||||
(x_3 e^{-t_i x_1} - x_4 e^{-t_i x_2} - y_i)^2\\
|
||||
t_i = 0.1i\\
|
||||
y_i = e^{-t_i} - 5 e^{-10 t_i}\\
|
||||
\end{matrix}
|
||||
|
||||
|
||||
with :math:`x_i \in [0, 20]` for :math:`i = 1, ..., 4`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x = [1, 10, 1, 5]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=4):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([0.] * 4,
|
||||
[20.] * 4))
|
||||
self.global_optimum = [[1., 10., 1., 5.]]
|
||||
self.fglob = 0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
t = arange(1, 11.) * 0.1
|
||||
y = exp(-t) - 5 * exp(-10 * t)
|
||||
vec = (x[2] * exp(-t * x[0]) - x[3] * exp(-t * x[1]) - y) ** 2
|
||||
|
||||
return sum(vec)
|
||||
|
||||
|
||||
class BiggsExp05(Benchmark):
|
||||
|
||||
r"""
|
||||
BiggsExp05 objective function.
|
||||
|
||||
The BiggsExp05 [1]_ global optimization problem is a multimodal minimization
|
||||
problem defined as follows
|
||||
|
||||
.. math::
|
||||
|
||||
\begin{matrix}\ f_{\text{BiggsExp05}}(x) = \sum_{i=1}^{11}
|
||||
(x_3 e^{-t_i x_1} - x_4 e^{-t_i x_2} + 3 e^{-t_i x_5} - y_i)^2\\
|
||||
t_i = 0.1i\\
|
||||
y_i = e^{-t_i} - 5e^{-10 t_i} + 3e^{-4 t_i}\\
|
||||
\end{matrix}
|
||||
|
||||
|
||||
with :math:`x_i \in [0, 20]` for :math:`i=1, ..., 5`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x = [1, 10, 1, 5, 4]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=5):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([0.] * 5,
|
||||
[20.] * 5))
|
||||
self.global_optimum = [[1., 10., 1., 5., 4.]]
|
||||
self.fglob = 0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
t = arange(1, 12.) * 0.1
|
||||
y = exp(-t) - 5 * exp(-10 * t) + 3 * exp(-4 * t)
|
||||
vec = (x[2] * exp(-t * x[0]) - x[3] * exp(-t * x[1])
|
||||
+ 3 * exp(-t * x[4]) - y) ** 2
|
||||
|
||||
return sum(vec)
|
||||
|
||||
|
||||
class Bird(Benchmark):
|
||||
|
||||
r"""
|
||||
Bird objective function.
|
||||
|
||||
The Bird global optimization problem is a multimodal minimization
|
||||
problem defined as follows
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Bird}}(x) = \left(x_1 - x_2\right)^{2} + e^{\left[1 -
|
||||
\sin\left(x_1\right) \right]^{2}} \cos\left(x_2\right) + e^{\left[1 -
|
||||
\cos\left(x_2\right)\right]^{2}} \sin\left(x_1\right)
|
||||
|
||||
|
||||
with :math:`x_i \in [-2\pi, 2\pi]`
|
||||
|
||||
*Global optimum*: :math:`f(x) = -106.7645367198034` for :math:`x
|
||||
= [4.701055751981055, 3.152946019601391]` or :math:`x =
|
||||
[-1.582142172055011, -3.130246799635430]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-2.0 * pi] * self.N,
|
||||
[2.0 * pi] * self.N))
|
||||
self.global_optimum = [[4.701055751981055, 3.152946019601391],
|
||||
[-1.582142172055011, -3.130246799635430]]
|
||||
self.fglob = -106.7645367198034
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return (sin(x[0]) * exp((1 - cos(x[1])) ** 2)
|
||||
+ cos(x[1]) * exp((1 - sin(x[0])) ** 2) + (x[0] - x[1]) ** 2)
|
||||
|
||||
|
||||
class Bohachevsky1(Benchmark):
|
||||
|
||||
r"""
|
||||
Bohachevsky 1 objective function.
|
||||
|
||||
The Bohachevsky 1 [1]_ global optimization problem is a multimodal
|
||||
minimization problem defined as follows
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Bohachevsky}}(x) = \sum_{i=1}^{n-1}\left[x_i^2 + 2 x_{i+1}^2 -
|
||||
0.3 \cos(3 \pi x_i) - 0.4 \cos(4 \pi x_{i + 1}) + 0.7 \right]
|
||||
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and :math:`x_i \in
|
||||
[-15, 15]` for :math:`i = 1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x_i = 0` for :math:`i = 1,
|
||||
..., n`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
|
||||
TODO: equation needs to be fixed up in the docstring. see Jamil#17
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-100.0] * self.N, [100.0] * self.N))
|
||||
self.global_optimum = [[0 for _ in range(self.N)]]
|
||||
self.fglob = 0.0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return (x[0] ** 2 + 2 * x[1] ** 2 - 0.3 * cos(3 * pi * x[0])
|
||||
- 0.4 * cos(4 * pi * x[1]) + 0.7)
|
||||
|
||||
|
||||
class Bohachevsky2(Benchmark):
|
||||
|
||||
r"""
|
||||
Bohachevsky 2 objective function.
|
||||
|
||||
The Bohachevsky 2 [1]_ global optimization problem is a multimodal
|
||||
minimization problem defined as follows
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Bohachevsky}}(x) = \sum_{i=1}^{n-1}\left[x_i^2 + 2 x_{i+1}^2 -
|
||||
0.3 \cos(3 \pi x_i) - 0.4 \cos(4 \pi x_{i + 1}) + 0.7 \right]
|
||||
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and :math:`x_i \in
|
||||
[-15, 15]` for :math:`i = 1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x_i = 0` for :math:`i = 1,
|
||||
..., n`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
|
||||
TODO: equation needs to be fixed up in the docstring. Jamil is also wrong.
|
||||
There should be no 0.4 factor in front of the cos term
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-100.0] * self.N, [100.0] * self.N))
|
||||
self.global_optimum = [[0 for _ in range(self.N)]]
|
||||
self.fglob = 0.0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return (x[0] ** 2 + 2 * x[1] ** 2 - 0.3 * cos(3 * pi * x[0])
|
||||
* cos(4 * pi * x[1]) + 0.3)
|
||||
|
||||
|
||||
class Bohachevsky3(Benchmark):
|
||||
|
||||
r"""
|
||||
Bohachevsky 3 objective function.
|
||||
|
||||
The Bohachevsky 3 [1]_ global optimization problem is a multimodal
|
||||
minimization problem defined as follows
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Bohachevsky}}(x) = \sum_{i=1}^{n-1}\left[x_i^2 + 2 x_{i+1}^2 -
|
||||
0.3 \cos(3 \pi x_i) - 0.4 \cos(4 \pi x_{i + 1}) + 0.7 \right]
|
||||
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and :math:`x_i \in
|
||||
[-15, 15]` for :math:`i = 1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x_i = 0` for :math:`i = 1,
|
||||
..., n`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
|
||||
TODO: equation needs to be fixed up in the docstring. Jamil#19
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-100.0] * self.N, [100.0] * self.N))
|
||||
self.global_optimum = [[0 for _ in range(self.N)]]
|
||||
self.fglob = 0.0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return (x[0] ** 2 + 2 * x[1] ** 2
|
||||
- 0.3 * cos(3 * pi * x[0] + 4 * pi * x[1]) + 0.3)
|
||||
|
||||
|
||||
class BoxBetts(Benchmark):
|
||||
|
||||
r"""
|
||||
BoxBetts objective function.
|
||||
|
||||
The BoxBetts global optimization problem is a multimodal
|
||||
minimization problem defined as follows
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{BoxBetts}}(x) = \sum_{i=1}^k g(x_i)^2
|
||||
|
||||
|
||||
Where, in this exercise:
|
||||
|
||||
.. math::
|
||||
|
||||
g(x) = e^{-0.1i x_1} - e^{-0.1i x_2} - x_3\left[e^{-0.1i}
|
||||
- e^{-i}\right]
|
||||
|
||||
|
||||
And :math:`k = 10`.
|
||||
|
||||
Here, :math:`x_1 \in [0.9, 1.2], x_2 \in [9, 11.2], x_3 \in [0.9, 1.2]`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x = [1, 10, 1]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=3):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = ([0.9, 1.2], [9.0, 11.2], [0.9, 1.2])
|
||||
self.global_optimum = [[1.0, 10.0, 1.0]]
|
||||
self.fglob = 0.0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
i = arange(1, 11)
|
||||
g = (exp(-0.1 * i * x[0]) - exp(-0.1 * i * x[1])
|
||||
- (exp(-0.1 * i) - exp(-i)) * x[2])
|
||||
return sum(g**2)
|
||||
|
||||
|
||||
class Branin01(Benchmark):
|
||||
|
||||
r"""
|
||||
Branin01 objective function.
|
||||
|
||||
The Branin01 global optimization problem is a multimodal minimization
|
||||
problem defined as follows
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Branin01}}(x) = \left(- 1.275 \frac{x_1^{2}}{\pi^{2}} + 5
|
||||
\frac{x_1}{\pi} + x_2 -6\right)^{2} + \left(10 -\frac{5}{4 \pi} \right)
|
||||
\cos\left(x_1\right) + 10
|
||||
|
||||
|
||||
with :math:`x_1 \in [-5, 10], x_2 \in [0, 15]`
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0.39788735772973816` for :math:`x =
|
||||
[-\pi, 12.275]` or :math:`x = [\pi, 2.275]` or :math:`x = [3\pi, 2.475]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
|
||||
TODO: Jamil#22, one of the solutions is different
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = [(-5., 10.), (0., 15.)]
|
||||
|
||||
self.global_optimum = [[-pi, 12.275], [pi, 2.275], [3 * pi, 2.475]]
|
||||
self.fglob = 0.39788735772973816
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return ((x[1] - (5.1 / (4 * pi ** 2)) * x[0] ** 2
|
||||
+ 5 * x[0] / pi - 6) ** 2
|
||||
+ 10 * (1 - 1 / (8 * pi)) * cos(x[0]) + 10)
|
||||
|
||||
|
||||
class Branin02(Benchmark):
|
||||
|
||||
r"""
|
||||
Branin02 objective function.
|
||||
|
||||
The Branin02 global optimization problem is a multimodal minimization
|
||||
problem defined as follows
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Branin02}}(x) = \left(- 1.275 \frac{x_1^{2}}{\pi^{2}}
|
||||
+ 5 \frac{x_1}{\pi} + x_2 - 6 \right)^{2} + \left(10 - \frac{5}{4 \pi}
|
||||
\right) \cos\left(x_1\right) \cos\left(x_2\right)
|
||||
+ \log(x_1^2+x_2^2 + 1) + 10
|
||||
|
||||
|
||||
with :math:`x_i \in [-5, 15]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 5.559037` for :math:`x = [-3.2, 12.53]`
|
||||
|
||||
.. [1] Gavana, A. Global Optimization Benchmarks and AMPGO retrieved 2015
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = [(-5.0, 15.0), (-5.0, 15.0)]
|
||||
|
||||
self.global_optimum = [[-3.1969884, 12.52625787]]
|
||||
self.fglob = 5.5589144038938247
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return ((x[1] - (5.1 / (4 * pi ** 2)) * x[0] ** 2
|
||||
+ 5 * x[0] / pi - 6) ** 2
|
||||
+ 10 * (1 - 1 / (8 * pi)) * cos(x[0]) * cos(x[1])
|
||||
+ log(x[0] ** 2.0 + x[1] ** 2.0 + 1.0) + 10)
|
||||
|
||||
|
||||
class Brent(Benchmark):
|
||||
|
||||
r"""
|
||||
Brent objective function.
|
||||
|
||||
The Brent [1]_ global optimization problem is a multimodal minimization
|
||||
problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Brent}}(x) = (x_1 + 10)^2 + (x_2 + 10)^2 + e^{(-x_1^2 -x_2^2)}
|
||||
|
||||
|
||||
with :math:`x_i \in [-10, 10]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x = [-10, -10]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
|
||||
TODO solution is different to Jamil#24
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-10.0] * self.N, [10.0] * self.N))
|
||||
self.custom_bounds = ([-10, 2], [-10, 2])
|
||||
|
||||
self.global_optimum = [[-10.0, -10.0]]
|
||||
self.fglob = 0.0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
return ((x[0] + 10.0) ** 2.0 + (x[1] + 10.0) ** 2.0
|
||||
+ exp(-x[0] ** 2.0 - x[1] ** 2.0))
|
||||
|
||||
|
||||
class Brown(Benchmark):
|
||||
|
||||
r"""
|
||||
Brown objective function.
|
||||
|
||||
The Brown [1]_ global optimization problem is a multimodal minimization
|
||||
problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Brown}}(x) = \sum_{i=1}^{n-1}\left[
|
||||
\left(x_i^2\right)^{x_{i + 1}^2 + 1}
|
||||
+ \left(x_{i + 1}^2\right)^{x_i^2 + 1}\right]
|
||||
|
||||
|
||||
with :math:`x_i \in [-1, 4]` for :math:`i=1,...,n`.
|
||||
|
||||
*Global optimum*: :math:`f(x_i) = 0` for :math:`x_i = 0` for
|
||||
:math:`i=1,...,n`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-1.0] * self.N, [4.0] * self.N))
|
||||
self.custom_bounds = ([-1.0, 1.0], [-1.0, 1.0])
|
||||
|
||||
self.global_optimum = [[0 for _ in range(self.N)]]
|
||||
self.fglob = 0.0
|
||||
self.change_dimensionality = True
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
x0 = x[:-1]
|
||||
x1 = x[1:]
|
||||
return sum((x0 ** 2.0) ** (x1 ** 2.0 + 1.0)
|
||||
+ (x1 ** 2.0) ** (x0 ** 2.0 + 1.0))
|
||||
|
||||
|
||||
class Bukin02(Benchmark):
|
||||
|
||||
r"""
|
||||
Bukin02 objective function.
|
||||
|
||||
The Bukin02 [1]_ global optimization problem is a multimodal minimization
|
||||
problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Bukin02}}(x) = 100 (x_2^2 - 0.01x_1^2 + 1)
|
||||
+ 0.01(x_1 + 10)^2
|
||||
|
||||
|
||||
with :math:`x_1 \in [-15, -5], x_2 \in [-3, 3]`
|
||||
|
||||
*Global optimum*: :math:`f(x) = -124.75` for :math:`x = [-15, 0]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
|
||||
TODO: I think that Gavana and Jamil are wrong on this function. In both
|
||||
sources the x[1] term is not squared. As such there will be a minimum at
|
||||
the smallest value of x[1].
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = [(-15.0, -5.0), (-3.0, 3.0)]
|
||||
|
||||
self.global_optimum = [[-15.0, 0.0]]
|
||||
self.fglob = -124.75
|
||||
|
||||
def fun(self, x, *args):
|
||||
|
||||
self.nfev += 1
|
||||
return (100 * (x[1] ** 2 - 0.01 * x[0] ** 2 + 1.0)
|
||||
+ 0.01 * (x[0] + 10.0) ** 2.0)
|
||||
|
||||
|
||||
class Bukin04(Benchmark):
|
||||
|
||||
r"""
|
||||
Bukin04 objective function.
|
||||
|
||||
The Bukin04 [1]_ global optimization problem is a multimodal minimization
|
||||
problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Bukin04}}(x) = 100 x_2^{2} + 0.01 \lvert{x_1 + 10}
|
||||
\rvert
|
||||
|
||||
|
||||
with :math:`x_1 \in [-15, -5], x_2 \in [-3, 3]`
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x = [-10, 0]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = [(-15.0, -5.0), (-3.0, 3.0)]
|
||||
|
||||
self.global_optimum = [[-10.0, 0.0]]
|
||||
self.fglob = 0.0
|
||||
|
||||
def fun(self, x, *args):
|
||||
|
||||
self.nfev += 1
|
||||
return 100 * x[1] ** 2 + 0.01 * abs(x[0] + 10)
|
||||
|
||||
|
||||
class Bukin06(Benchmark):
|
||||
|
||||
r"""
|
||||
Bukin06 objective function.
|
||||
|
||||
The Bukin06 [1]_ global optimization problem is a multimodal minimization
|
||||
problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Bukin06}}(x) = 100 \sqrt{ \lvert{x_2 - 0.01 x_1^{2}}
|
||||
\rvert} + 0.01 \lvert{x_1 + 10} \rvert
|
||||
|
||||
|
||||
with :math:`x_1 \in [-15, -5], x_2 \in [-3, 3]`
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x = [-10, 1]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = [(-15.0, -5.0), (-3.0, 3.0)]
|
||||
self.global_optimum = [[-10.0, 1.0]]
|
||||
self.fglob = 0.0
|
||||
|
||||
def fun(self, x, *args):
|
||||
|
||||
self.nfev += 1
|
||||
return 100 * sqrt(abs(x[1] - 0.01 * x[0] ** 2)) + 0.01 * abs(x[0] + 10)
|
578
go_benchmark_functions/go_funcs_C.py
Normal file
578
go_benchmark_functions/go_funcs_C.py
Normal file
|
@ -0,0 +1,578 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import numpy as np
|
||||
from numpy import (abs, asarray, cos, exp, floor, pi, sign, sin, sqrt, sum,
|
||||
size, tril, isnan, atleast_2d, repeat)
|
||||
from numpy.testing import assert_almost_equal
|
||||
|
||||
from .go_benchmark import Benchmark
|
||||
|
||||
|
||||
class CarromTable(Benchmark):
|
||||
r"""
|
||||
CarromTable objective function.
|
||||
|
||||
The CarromTable [1]_ global optimization problem is a multimodal
|
||||
minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{CarromTable}}(x) = - \frac{1}{30}\left(\cos(x_1)
|
||||
cos(x_2) e^{\left|1 - \frac{\sqrt{x_1^2 + x_2^2}}{\pi}\right|}\right)^2
|
||||
|
||||
|
||||
with :math:`x_i \in [-10, 10]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = -24.15681551650653` for :math:`x_i = \pm
|
||||
9.646157266348881` for :math:`i = 1, 2`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-10.0] * self.N, [10.0] * self.N))
|
||||
self.global_optimum = [(9.646157266348881, 9.646134286497169),
|
||||
(-9.646157266348881, 9.646134286497169),
|
||||
(9.646157266348881, -9.646134286497169),
|
||||
(-9.646157266348881, -9.646134286497169)]
|
||||
self.fglob = -24.15681551650653
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
u = cos(x[0]) * cos(x[1])
|
||||
v = sqrt(x[0] ** 2 + x[1] ** 2)
|
||||
return -((u * exp(abs(1 - v / pi))) ** 2) / 30.
|
||||
|
||||
|
||||
class Chichinadze(Benchmark):
|
||||
r"""
|
||||
Chichinadze objective function.
|
||||
|
||||
This class defines the Chichinadze [1]_ global optimization problem. This is a
|
||||
multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Chichinadze}}(x) = x_{1}^{2} - 12 x_{1}
|
||||
+ 8 \sin\left(\frac{5}{2} \pi x_{1}\right)
|
||||
+ 10 \cos\left(\frac{1}{2} \pi x_{1}\right) + 11
|
||||
- 0.2 \frac{\sqrt{5}}{e^{\frac{1}{2} \left(x_{2} -0.5 \right)^{2}}}
|
||||
|
||||
|
||||
with :math:`x_i \in [-30, 30]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = -42.94438701899098` for :math:`x =
|
||||
[6.189866586965680, 0.5]`
|
||||
|
||||
.. [1] Gavana, A. Global Optimization Benchmarks and AMPGO retrieved 2015
|
||||
|
||||
TODO: Jamil#33 has a dividing factor of 2 in the sin term. However, f(x)
|
||||
for the given solution does not give the global minimum. i.e. the equation
|
||||
is at odds with the solution.
|
||||
Only by removing the dividing factor of 2, i.e. `8 * sin(5 * pi * x[0])`
|
||||
does the given solution result in the given global minimum.
|
||||
Do we keep the result or equation?
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-30.0] * self.N, [30.0] * self.N))
|
||||
self.custom_bounds = [(-10, 10), (-10, 10)]
|
||||
|
||||
self.global_optimum = [[6.189866586965680, 0.5]]
|
||||
self.fglob = -42.94438701899098
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return (x[0] ** 2 - 12 * x[0] + 11 + 10 * cos(pi * x[0] / 2)
|
||||
+ 8 * sin(5 * pi * x[0] / 2)
|
||||
- 1.0 / sqrt(5) * exp(-((x[1] - 0.5) ** 2) / 2))
|
||||
|
||||
|
||||
class Cigar(Benchmark):
|
||||
r"""
|
||||
Cigar objective function.
|
||||
|
||||
This class defines the Cigar [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Cigar}}(x) = x_1^2 + 10^6\sum_{i=2}^{n} x_i^2
|
||||
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and :math:`x_i \in
|
||||
[-100, 100]` for :math:`i = 1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x_i = 0` for
|
||||
:math:`i = 1, ..., n`
|
||||
|
||||
.. [1] Gavana, A. Global Optimization Benchmarks and AMPGO retrieved 2015
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-100.0] * self.N,
|
||||
[100.0] * self.N))
|
||||
self.custom_bounds = [(-5, 5), (-5, 5)]
|
||||
|
||||
self.global_optimum = [[0 for _ in range(self.N)]]
|
||||
self.fglob = 0.0
|
||||
self.change_dimensionality = True
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return x[0] ** 2 + 1e6 * sum(x[1:] ** 2)
|
||||
|
||||
|
||||
class Cola(Benchmark):
|
||||
r"""
|
||||
Cola objective function.
|
||||
|
||||
This class defines the Cola global optimization problem. The 17-dimensional
|
||||
function computes indirectly the formula :math:`f(n, u)` by setting
|
||||
:math:`x_0 = y_0, x_1 = u_0, x_i = u_{2(i2)}, y_i = u_{2(i2)+1}` :
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Cola}}(x) = \sum_{i<j}^{n} \left (r_{i,j} - d_{i,j} \right )^2
|
||||
|
||||
|
||||
Where :math:`r_{i, j}` is given by:
|
||||
|
||||
.. math::
|
||||
|
||||
r_{i, j} = \sqrt{(x_i - x_j)^2 + (y_i - y_j)^2}
|
||||
|
||||
And :math:`d` is a symmetric matrix given by:
|
||||
|
||||
.. math::
|
||||
|
||||
\{d} = \left [ d_{ij} \right ] = \begin{pmatrix}
|
||||
1.27 & & & & & & & & \\
|
||||
1.69 & 1.43 & & & & & & & \\
|
||||
2.04 & 2.35 & 2.43 & & & & & & \\
|
||||
3.09 & 3.18 & 3.26 & 2.85 & & & & & \\
|
||||
3.20 & 3.22 & 3.27 & 2.88 & 1.55 & & & & \\
|
||||
2.86 & 2.56 & 2.58 & 2.59 & 3.12 & 3.06 & & & \\
|
||||
3.17 & 3.18 & 3.18 & 3.12 & 1.31 & 1.64 & 3.00 & \\
|
||||
3.21 & 3.18 & 3.18 & 3.17 & 1.70 & 1.36 & 2.95 & 1.32 & \\
|
||||
2.38 & 2.31 & 2.42 & 1.94 & 2.85 & 2.81 & 2.56 & 2.91 & 2.97
|
||||
\end{pmatrix}
|
||||
|
||||
|
||||
This function has bounds :math:`x_0 \in [0, 4]` and :math:`x_i \in [-4, 4]`
|
||||
for :math:`i = 1, ..., n-1`.
|
||||
*Global optimum* 11.7464.
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=17):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = [[0.0, 4.0]] + list(zip([-4.0] * (self.N - 1),
|
||||
[4.0] * (self.N - 1)))
|
||||
|
||||
self.global_optimum = [[0.651906, 1.30194, 0.099242, -0.883791,
|
||||
-0.8796, 0.204651, -3.28414, 0.851188,
|
||||
-3.46245, 2.53245, -0.895246, 1.40992,
|
||||
-3.07367, 1.96257, -2.97872, -0.807849,
|
||||
-1.68978]]
|
||||
self.fglob = 11.7464
|
||||
|
||||
self.d = asarray([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[1.27, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[1.69, 1.43, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[2.04, 2.35, 2.43, 0, 0, 0, 0, 0, 0, 0],
|
||||
[3.09, 3.18, 3.26, 2.85, 0, 0, 0, 0, 0, 0],
|
||||
[3.20, 3.22, 3.27, 2.88, 1.55, 0, 0, 0, 0, 0],
|
||||
[2.86, 2.56, 2.58, 2.59, 3.12, 3.06, 0, 0, 0, 0],
|
||||
[3.17, 3.18, 3.18, 3.12, 1.31, 1.64, 3.00, 0, 0, 0],
|
||||
[3.21, 3.18, 3.18, 3.17, 1.70, 1.36, 2.95, 1.32, 0, 0],
|
||||
[2.38, 2.31, 2.42, 1.94, 2.85, 2.81, 2.56, 2.91, 2.97, 0.]])
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
xi = atleast_2d(asarray([0.0, x[0]] + list(x[1::2])))
|
||||
xj = repeat(xi, size(xi, 1), axis=0)
|
||||
xi = xi.T
|
||||
|
||||
yi = atleast_2d(asarray([0.0, 0.0] + list(x[2::2])))
|
||||
yj = repeat(yi, size(yi, 1), axis=0)
|
||||
yi = yi.T
|
||||
|
||||
inner = (sqrt(((xi - xj) ** 2 + (yi - yj) ** 2)) - self.d) ** 2
|
||||
inner = tril(inner, -1)
|
||||
return sum(sum(inner, axis=1))
|
||||
|
||||
|
||||
class Colville(Benchmark):
|
||||
r"""
|
||||
Colville objective function.
|
||||
|
||||
This class defines the Colville global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Colville}}(x) = \left(x_{1} -1\right)^{2}
|
||||
+ 100 \left(x_{1}^{2} - x_{2}\right)^{2}
|
||||
+ 10.1 \left(x_{2} -1\right)^{2} + \left(x_{3} -1\right)^{2}
|
||||
+ 90 \left(x_{3}^{2} - x_{4}\right)^{2}
|
||||
+ 10.1 \left(x_{4} -1\right)^{2} + 19.8 \frac{x_{4} -1}{x_{2}}
|
||||
|
||||
|
||||
with :math:`x_i \in [-10, 10]` for :math:`i = 1, ..., 4`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x_i = 1` for
|
||||
:math:`i = 1, ..., 4`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
|
||||
TODO docstring equation is wrong use Jamil#36
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=4):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-10.0] * self.N, [10.0] * self.N))
|
||||
|
||||
self.global_optimum = [[1 for _ in range(self.N)]]
|
||||
self.fglob = 0.0
|
||||
|
||||
def fun(self, x, *args):
|
||||
|
||||
self.nfev += 1
|
||||
return (100 * (x[0] - x[1] ** 2) ** 2
|
||||
+ (1 - x[0]) ** 2 + (1 - x[2]) ** 2
|
||||
+ 90 * (x[3] - x[2] ** 2) ** 2
|
||||
+ 10.1 * ((x[1] - 1) ** 2 + (x[3] - 1) ** 2)
|
||||
+ 19.8 * (x[1] - 1) * (x[3] - 1))
|
||||
|
||||
|
||||
class Corana(Benchmark):
|
||||
r"""
|
||||
Corana objective function.
|
||||
|
||||
This class defines the Corana [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Corana}}(x) = \begin{cases} \sum_{i=1}^n 0.15 d_i
|
||||
[z_i - 0.05\textrm{sgn}(z_i)]^2 & \textrm{if }|x_i-z_i| < 0.05 \\
|
||||
d_ix_i^2 & \textrm{otherwise}\end{cases}
|
||||
|
||||
|
||||
Where, in this exercise:
|
||||
|
||||
.. math::
|
||||
|
||||
z_i = 0.2 \lfloor |x_i/s_i|+0.49999\rfloor\textrm{sgn}(x_i),
|
||||
d_i=(1,1000,10,100, ...)
|
||||
|
||||
|
||||
with :math:`x_i \in [-5, 5]` for :math:`i = 1, ..., 4`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x_i = 0` for
|
||||
:math:`i = 1, ..., 4`
|
||||
|
||||
..[1] Gavana, A. Global Optimization Benchmarks and AMPGO retrieved 2015
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=4):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-5.0] * self.N, [5.0] * self.N))
|
||||
|
||||
self.global_optimum = [[0 for _ in range(self.N)]]
|
||||
self.fglob = 0.0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
d = [1., 1000., 10., 100.]
|
||||
r = 0
|
||||
for j in range(4):
|
||||
zj = floor(abs(x[j] / 0.2) + 0.49999) * sign(x[j]) * 0.2
|
||||
if abs(x[j] - zj) < 0.05:
|
||||
r += 0.15 * ((zj - 0.05 * sign(zj)) ** 2) * d[j]
|
||||
else:
|
||||
r += d[j] * x[j] * x[j]
|
||||
return r
|
||||
|
||||
|
||||
class CosineMixture(Benchmark):
|
||||
r"""
|
||||
Cosine Mixture objective function.
|
||||
|
||||
This class defines the Cosine Mixture global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{CosineMixture}}(x) = -0.1 \sum_{i=1}^n \cos(5 \pi x_i)
|
||||
- \sum_{i=1}^n x_i^2
|
||||
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and :math:`x_i \in
|
||||
[-1, 1]` for :math:`i = 1, ..., N`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = -0.1N` for :math:`x_i = 0` for
|
||||
:math:`i = 1, ..., N`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
|
||||
TODO, Jamil #38 has wrong minimum and wrong fglob. I plotted it.
|
||||
-(x**2) term is always negative if x is negative.
|
||||
cos(5 * pi * x) is equal to -1 for x=-1.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self.change_dimensionality = True
|
||||
self._bounds = list(zip([-1.0] * self.N, [1.0] * self.N))
|
||||
|
||||
self.global_optimum = [[-1. for _ in range(self.N)]]
|
||||
self.fglob = -0.9 * self.N
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return -0.1 * sum(cos(5.0 * pi * x)) - sum(x ** 2.0)
|
||||
|
||||
|
||||
class CrossInTray(Benchmark):
|
||||
r"""
|
||||
Cross-in-Tray objective function.
|
||||
|
||||
This class defines the Cross-in-Tray [1]_ global optimization problem. This is a
|
||||
multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{CrossInTray}}(x) = - 0.0001 \left(\left|{e^{\left|{100
|
||||
- \frac{\sqrt{x_{1}^{2} + x_{2}^{2}}}{\pi}}\right|}
|
||||
\sin\left(x_{1}\right) \sin\left(x_{2}\right)}\right| + 1\right)^{0.1}
|
||||
|
||||
|
||||
with :math:`x_i \in [-15, 15]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = -2.062611870822739` for :math:`x_i =
|
||||
\pm 1.349406608602084` for :math:`i = 1, 2`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-10.0] * self.N, [10.0] * self.N))
|
||||
|
||||
self.global_optimum = [(1.349406685353340, 1.349406608602084),
|
||||
(-1.349406685353340, 1.349406608602084),
|
||||
(1.349406685353340, -1.349406608602084),
|
||||
(-1.349406685353340, -1.349406608602084)]
|
||||
self.fglob = -2.062611870822739
|
||||
|
||||
def fun(self, x, *args):
|
||||
|
||||
self.nfev += 1
|
||||
return (-0.0001 * (abs(sin(x[0]) * sin(x[1])
|
||||
* exp(abs(100 - sqrt(x[0] ** 2 + x[1] ** 2) / pi)))
|
||||
+ 1) ** (0.1))
|
||||
|
||||
|
||||
class CrossLegTable(Benchmark):
|
||||
r"""
|
||||
Cross-Leg-Table objective function.
|
||||
|
||||
This class defines the Cross-Leg-Table [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{CrossLegTable}}(x) = - \frac{1}{\left(\left|{e^{\left|{100
|
||||
- \frac{\sqrt{x_{1}^{2} + x_{2}^{2}}}{\pi}}\right|}
|
||||
\sin\left(x_{1}\right) \sin\left(x_{2}\right)}\right| + 1\right)^{0.1}}
|
||||
|
||||
|
||||
with :math:`x_i \in [-10, 10]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = -1`. The global minimum is found on the
|
||||
planes :math:`x_1 = 0` and :math:`x_2 = 0`
|
||||
|
||||
..[1] Mishra, S. Global Optimization by Differential Evolution and Particle
|
||||
Swarm Methods: Evaluation on Some Benchmark Functions Munich University,
|
||||
2006
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-10.0] * self.N, [10.0] * self.N))
|
||||
|
||||
self.global_optimum = [[0., 0.]]
|
||||
self.fglob = -1.0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
u = 100 - sqrt(x[0] ** 2 + x[1] ** 2) / pi
|
||||
v = sin(x[0]) * sin(x[1])
|
||||
return -(abs(v * exp(abs(u))) + 1) ** (-0.1)
|
||||
|
||||
|
||||
class CrownedCross(Benchmark):
|
||||
r"""
|
||||
Crowned Cross objective function.
|
||||
|
||||
This class defines the Crowned Cross [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{CrownedCross}}(x) = 0.0001 \left(\left|{e^{\left|{100
|
||||
- \frac{\sqrt{x_{1}^{2} + x_{2}^{2}}}{\pi}}\right|}
|
||||
\sin\left(x_{1}\right) \sin\left(x_{2}\right)}\right| + 1\right)^{0.1}
|
||||
|
||||
|
||||
with :math:`x_i \in [-10, 10]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x_i) = 0.0001`. The global minimum is found on
|
||||
the planes :math:`x_1 = 0` and :math:`x_2 = 0`
|
||||
|
||||
..[1] Mishra, S. Global Optimization by Differential Evolution and Particle
|
||||
Swarm Methods: Evaluation on Some Benchmark Functions Munich University,
|
||||
2006
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-10.0] * self.N, [10.0] * self.N))
|
||||
|
||||
self.global_optimum = [[0, 0]]
|
||||
self.fglob = 0.0001
|
||||
|
||||
def fun(self, x, *args):
|
||||
|
||||
self.nfev += 1
|
||||
u = 100 - sqrt(x[0] ** 2 + x[1] ** 2) / pi
|
||||
v = sin(x[0]) * sin(x[1])
|
||||
return 0.0001 * (abs(v * exp(abs(u))) + 1) ** (0.1)
|
||||
|
||||
|
||||
class Csendes(Benchmark):
|
||||
r"""
|
||||
Csendes objective function.
|
||||
|
||||
This class defines the Csendes [1]_ global optimization problem. This is a
|
||||
multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Csendes}}(x) = \sum_{i=1}^n x_i^6 \left[ 2 + \sin
|
||||
\left( \frac{1}{x_i} \right ) \right]
|
||||
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and :math:`x_i \in
|
||||
[-1, 1]` for :math:`i = 1, ..., N`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0.0` for :math:`x_i = 0` for
|
||||
:math:`i = 1, ..., N`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self.change_dimensionality = True
|
||||
self._bounds = list(zip([-1.0] * self.N, [1.0] * self.N))
|
||||
|
||||
self.global_optimum = [[0 for _ in range(self.N)]]
|
||||
self.fglob = np.nan
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
try:
|
||||
return sum((x ** 6.0) * (2.0 + sin(1.0 / x)))
|
||||
except ZeroDivisionError:
|
||||
return np.nan
|
||||
except FloatingPointError:
|
||||
return np.nan
|
||||
|
||||
def success(self, x):
|
||||
"""Is a candidate solution at the global minimum"""
|
||||
val = self.fun(asarray(x))
|
||||
if isnan(val):
|
||||
return True
|
||||
try:
|
||||
assert_almost_equal(val, 0., 4)
|
||||
return True
|
||||
except AssertionError:
|
||||
return False
|
||||
|
||||
return False
|
||||
|
||||
|
||||
class Cube(Benchmark):
|
||||
r"""
|
||||
Cube objective function.
|
||||
|
||||
This class defines the Cube global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Cube}}(x) = 100(x_2 - x_1^3)^2 + (1 - x1)^2
|
||||
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and :math:`x_i \in [-10, 10]` for :math:`i=1,...,N`.
|
||||
|
||||
*Global optimum*: :math:`f(x_i) = 0.0` for :math:`x = [1, 1]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
|
||||
TODO: jamil#41 has the wrong solution.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-10.0] * self.N, [10.0] * self.N))
|
||||
self.custom_bounds = ([0, 2], [0, 2])
|
||||
|
||||
self.global_optimum = [[1.0, 1.0]]
|
||||
self.fglob = 0.0
|
||||
|
||||
def fun(self, x, *args):
|
||||
|
||||
self.nfev += 1
|
||||
return 100.0 * (x[1] - x[0] ** 3.0) ** 2.0 + (1.0 - x[0]) ** 2.0
|
568
go_benchmark_functions/go_funcs_D.py
Normal file
568
go_benchmark_functions/go_funcs_D.py
Normal file
|
@ -0,0 +1,568 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import numpy as np
|
||||
from numpy import abs, cos, exp, arange, pi, sin, sqrt, sum, zeros, tanh
|
||||
from numpy.testing import assert_almost_equal
|
||||
from .go_benchmark import Benchmark
|
||||
|
||||
|
||||
class Damavandi(Benchmark):
|
||||
r"""
|
||||
Damavandi objective function.
|
||||
|
||||
This class defines the Damavandi [1]_ global optimization problem. This is a
|
||||
multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Damavandi}}(x) = \left[ 1 - \lvert{\frac{
|
||||
\sin[\pi (x_1 - 2)]\sin[\pi (x2 - 2)]}{\pi^2 (x_1 - 2)(x_2 - 2)}}
|
||||
\rvert^5 \right] \left[2 + (x_1 - 7)^2 + 2(x_2 - 7)^2 \right]
|
||||
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and :math:`x_i \in
|
||||
[0, 14]` for :math:`i = 1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0.0` for :math:`x_i = 2` for
|
||||
:math:`i = 1, ..., n`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, 2)
|
||||
|
||||
self._bounds = list(zip([0.0] * self.N, [14.0] * self.N))
|
||||
|
||||
self.global_optimum = [[2 for _ in range(self.N)]]
|
||||
self.fglob = np.nan
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
try:
|
||||
num = sin(pi * (x[0] - 2.0)) * sin(pi * (x[1] - 2.0))
|
||||
den = (pi ** 2) * (x[0] - 2.0) * (x[1] - 2.0)
|
||||
factor1 = 1.0 - (abs(num / den)) ** 5.0
|
||||
factor2 = 2 + (x[0] - 7.0) ** 2.0 + 2 * (x[1] - 7.0) ** 2.0
|
||||
return factor1 * factor2
|
||||
except ZeroDivisionError:
|
||||
return np.nan
|
||||
|
||||
def success(self, x):
|
||||
"""Is a candidate solution at the global minimum"""
|
||||
val = self.fun(x)
|
||||
if np.isnan(val):
|
||||
return True
|
||||
try:
|
||||
assert_almost_equal(val, 0., 4)
|
||||
return True
|
||||
except AssertionError:
|
||||
return False
|
||||
|
||||
return False
|
||||
|
||||
|
||||
class Deb01(Benchmark):
|
||||
r"""
|
||||
Deb 1 objective function.
|
||||
|
||||
This class defines the Deb 1 [1]_ global optimization problem. This is a
|
||||
multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Deb01}}(x) = - \frac{1}{N} \sum_{i=1}^n \sin^6(5 \pi x_i)
|
||||
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and
|
||||
:math:`x_i \in [-1, 1]` for :math:`i = 1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x_i) = 0.0`. The number of global minima is
|
||||
:math:`5^n` that are evenly spaced in the function landscape, where
|
||||
:math:`n` represents the dimension of the problem.
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self.change_dimensionality = True
|
||||
|
||||
self._bounds = list(zip([-1.0] * self.N, [1.0] * self.N))
|
||||
|
||||
self.global_optimum = [[0.3, -0.3]]
|
||||
self.fglob = -1.0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
return -(1.0 / self.N) * sum(sin(5 * pi * x) ** 6.0)
|
||||
|
||||
|
||||
class Deb03(Benchmark):
|
||||
r"""
|
||||
Deb 3 objective function.
|
||||
|
||||
This class defines the Deb 3 [1]_ global optimization problem. This is a
|
||||
multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Deb02}}(x) = - \frac{1}{N} \sum_{i=1}^n \sin^6 \left[ 5 \pi
|
||||
\left ( x_i^{3/4} - 0.05 \right) \right ]
|
||||
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and :math:`x_i \in
|
||||
[0, 1]` for :math:`i = 1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0.0`. The number of global minima is
|
||||
:math:`5^n` that are evenly spaced in the function landscape, where
|
||||
:math:`n` represents the dimension of the problem.
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self.change_dimensionality = True
|
||||
|
||||
self._bounds = list(zip([-1.0] * self.N, [1.0] * self.N))
|
||||
|
||||
self.global_optimum = [[0.93388314, 0.68141781]]
|
||||
self.fglob = -1.0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return -(1.0 / self.N) * sum(sin(5 * pi * (x ** 0.75 - 0.05)) ** 6.0)
|
||||
|
||||
|
||||
class Decanomial(Benchmark):
|
||||
r"""
|
||||
Decanomial objective function.
|
||||
|
||||
This class defines the Decanomial function global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Decanomial}}(x) = 0.001 \left(\lvert{x_{2}^{4} + 12 x_{2}^{3}
|
||||
+ 54 x_{2}^{2} + 108 x_{2} + 81.0}\rvert + \lvert{x_{1}^{10}
|
||||
- 20 x_{1}^{9} + 180 x_{1}^{8} - 960 x_{1}^{7} + 3360 x_{1}^{6}
|
||||
- 8064 x_{1}^{5} + 13340 x_{1}^{4} - 15360 x_{1}^{3} + 11520 x_{1}^{2}
|
||||
- 5120 x_{1} + 2624.0}\rvert\right)^{2}
|
||||
|
||||
|
||||
with :math:`x_i \in [-10, 10]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x = [2, -3]`
|
||||
|
||||
.. [1] Gavana, A. Global Optimization Benchmarks and AMPGO retrieved 2015
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-10.0] * self.N, [10.0] * self.N))
|
||||
self.custom_bounds = [(0, 2.5), (-2, -4)]
|
||||
|
||||
self.global_optimum = [[2.0, -3.0]]
|
||||
self.fglob = 0.0
|
||||
|
||||
def fun(self, x, *args):
|
||||
|
||||
self.nfev += 1
|
||||
|
||||
val = x[1] ** 4 + 12 * x[1] ** 3 + 54 * x[1] ** 2 + 108 * x[1] + 81.0
|
||||
val2 = x[0] ** 10. - 20 * x[0] ** 9 + 180 * x[0] ** 8 - 960 * x[0] ** 7
|
||||
val2 += 3360 * x[0] ** 6 - 8064 * x[0] ** 5 + 13340 * x[0] ** 4
|
||||
val2 += - 15360 * x[0] ** 3 + 11520 * x[0] ** 2 - 5120 * x[0] + 2624
|
||||
return 0.001 * (abs(val) + abs(val2)) ** 2.
|
||||
|
||||
|
||||
class Deceptive(Benchmark):
|
||||
r"""
|
||||
Deceptive objective function.
|
||||
|
||||
This class defines the Deceptive [1]_ global optimization problem. This is a
|
||||
multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Deceptive}}(x) = - \left [\frac{1}{n}
|
||||
\sum_{i=1}^{n} g_i(x_i) \right ]^{\beta}
|
||||
|
||||
|
||||
Where :math:`\beta` is a fixed non-linearity factor; in this exercise,
|
||||
:math:`\beta = 2`. The function :math:`g_i(x_i)` is given by:
|
||||
|
||||
.. math::
|
||||
|
||||
g_i(x_i) = \begin{cases}
|
||||
- \frac{x}{\alpha_i} + \frac{4}{5} &
|
||||
\textrm{if} \hspace{5pt} 0 \leq x_i \leq \frac{4}{5} \alpha_i \\
|
||||
\frac{5x}{\alpha_i} -4 &
|
||||
\textrm{if} \hspace{5pt} \frac{4}{5} \alpha_i \le x_i \leq \alpha_i \\
|
||||
\frac{5(x - \alpha_i)}{\alpha_i-1} &
|
||||
\textrm{if} \hspace{5pt} \alpha_i \le x_i \leq \frac{1 + 4\alpha_i}{5} \\
|
||||
\frac{x - 1}{1 - \alpha_i} &
|
||||
\textrm{if} \hspace{5pt} \frac{1 + 4\alpha_i}{5} \le x_i \leq 1
|
||||
\end{cases}
|
||||
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and :math:`x_i \in
|
||||
[0, 1]` for :math:`i = 1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = -1` for :math:`x_i = \alpha_i` for
|
||||
:math:`i = 1, ..., n`
|
||||
|
||||
.. [1] Gavana, A. Global Optimization Benchmarks and AMPGO retrieved 2015
|
||||
|
||||
TODO: this function was taken from the Gavana website. The following code
|
||||
is based on his code. His code and the website don't match, the equations
|
||||
are wrong.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([0.0] * self.N, [1.0] * self.N))
|
||||
|
||||
alpha = arange(1.0, self.N + 1.0) / (self.N + 1.0)
|
||||
|
||||
self.global_optimum = [alpha]
|
||||
self.fglob = -1.0
|
||||
self.change_dimensionality = True
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
alpha = arange(1.0, self.N + 1.0) / (self.N + 1.0)
|
||||
beta = 2.0
|
||||
|
||||
g = zeros((self.N, ))
|
||||
|
||||
for i in range(self.N):
|
||||
if x[i] <= 0.0:
|
||||
g[i] = x[i]
|
||||
elif x[i] < 0.8 * alpha[i]:
|
||||
g[i] = -x[i] / alpha[i] + 0.8
|
||||
elif x[i] < alpha[i]:
|
||||
g[i] = 5.0 * x[i] / alpha[i] - 4.0
|
||||
elif x[i] < (1.0 + 4 * alpha[i]) / 5.0:
|
||||
g[i] = 5.0 * (x[i] - alpha[i]) / (alpha[i] - 1.0) + 1.0
|
||||
elif x[i] <= 1.0:
|
||||
g[i] = (x[i] - 1.0) / (1.0 - alpha[i]) + 4.0 / 5.0
|
||||
else:
|
||||
g[i] = x[i] - 1.0
|
||||
|
||||
return -((1.0 / self.N) * sum(g)) ** beta
|
||||
|
||||
|
||||
class DeckkersAarts(Benchmark):
|
||||
r"""
|
||||
Deckkers-Aarts objective function.
|
||||
|
||||
This class defines the Deckkers-Aarts [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{DeckkersAarts}}(x) = 10^5x_1^2 + x_2^2 - (x_1^2 + x_2^2)^2
|
||||
+ 10^{-5}(x_1^2 + x_2^2)^4
|
||||
|
||||
|
||||
with :math:`x_i \in [-20, 20]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = -24776.518242168` for
|
||||
:math:`x = [0, \pm 14.9451209]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
|
||||
TODO: jamil solution and global minimum are slightly wrong.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-20.0] * self.N, [20.0] * self.N))
|
||||
self.custom_bounds = ([-1, 1], [14, 16])
|
||||
|
||||
self.global_optimum = [[0.0, 14.9451209]]
|
||||
self.fglob = -24776.518342168
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
return (1.e5 * x[0] ** 2 + x[1] ** 2 - (x[0] ** 2 + x[1] ** 2) ** 2
|
||||
+ 1.e-5 * (x[0] ** 2 + x[1] ** 2) ** 4)
|
||||
|
||||
|
||||
class DeflectedCorrugatedSpring(Benchmark):
|
||||
r"""
|
||||
DeflectedCorrugatedSpring objective function.
|
||||
|
||||
This class defines the Deflected Corrugated Spring [1]_ function global
|
||||
optimization problem. This is a multimodal minimization problem defined as
|
||||
follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{DeflectedCorrugatedSpring}}(x) = 0.1\sum_{i=1}^n \left[ (x_i -
|
||||
\alpha)^2 - \cos \left( K \sqrt {\sum_{i=1}^n (x_i - \alpha)^2}
|
||||
\right ) \right ]
|
||||
|
||||
|
||||
Where, in this exercise, :math:`K = 5` and :math:`\alpha = 5`.
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and :math:`x_i \in
|
||||
[0, 2\alpha]` for :math:`i = 1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = -1` for :math:`x_i = \alpha` for
|
||||
:math:`i = 1, ..., n`
|
||||
|
||||
.. [1] Gavana, A. Global Optimization Benchmarks and AMPGO retrieved 2015
|
||||
|
||||
TODO: website has a different equation to the gavana codebase. The function
|
||||
below is different to the equation above. Also, the global minimum is
|
||||
wrong.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
alpha = 5.0
|
||||
self._bounds = list(zip([0] * self.N, [2 * alpha] * self.N))
|
||||
|
||||
self.global_optimum = [[alpha for _ in range(self.N)]]
|
||||
self.fglob = -1.0
|
||||
self.change_dimensionality = True
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
K, alpha = 5.0, 5.0
|
||||
|
||||
return (-cos(K * sqrt(sum((x - alpha) ** 2)))
|
||||
+ 0.1 * sum((x - alpha) ** 2))
|
||||
|
||||
|
||||
class DeVilliersGlasser01(Benchmark):
|
||||
r"""
|
||||
DeVilliers-Glasser 1 objective function.
|
||||
|
||||
This class defines the DeVilliers-Glasser 1 [1]_ function global optimization
|
||||
problem. This is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{DeVilliersGlasser01}}(x) = \sum_{i=1}^{24} \left[ x_1x_2^{t_i}
|
||||
\sin(x_3t_i + x_4) - y_i \right ]^2
|
||||
|
||||
|
||||
Where, in this exercise, :math:`t_i = 0.1(i - 1)` and
|
||||
:math:`y_i = 60.137(1.371^{t_i}) \sin(3.112t_i + 1.761)`.
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and :math:`x_i \in
|
||||
[1, 100]` for :math:`i = 1, ..., 4`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x_i = 0` for
|
||||
:math:`x = [60.137, 1.371, 3.112, 1.761]`.
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=4):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([1.0] * self.N, [100.0] * self.N))
|
||||
|
||||
self.global_optimum = [[60.137, 1.371, 3.112, 1.761]]
|
||||
self.fglob = 0.0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
t = 0.1 * arange(24)
|
||||
y = 60.137 * (1.371 ** t) * sin(3.112 * t + 1.761)
|
||||
|
||||
return sum((x[0] * (x[1] ** t) * sin(x[2] * t + x[3]) - y) ** 2.0)
|
||||
|
||||
|
||||
class DeVilliersGlasser02(Benchmark):
|
||||
r"""
|
||||
DeVilliers-Glasser 2 objective function.
|
||||
|
||||
This class defines the DeVilliers-Glasser 2 [1]_ function global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{DeVilliersGlasser01}}(x) = \sum_{i=1}^{24} \left[ x_1x_2^{t_i}
|
||||
\tanh \left [x_3t_i + \sin(x_4t_i) \right] \cos(t_ie^{x_5}) -
|
||||
y_i \right ]^2
|
||||
|
||||
|
||||
Where, in this exercise, :math:`t_i = 0.1(i - 1)` and
|
||||
:math:`y_i = 53.81(1.27^{t_i}) \tanh (3.012t_i + \sin(2.13t_i))
|
||||
\cos(e^{0.507}t_i)`.
|
||||
|
||||
with :math:`x_i \in [1, 60]` for :math:`i = 1, ..., 5`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for
|
||||
:math:`x = [53.81, 1.27, 3.012, 2.13, 0.507]`.
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=5):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([1.0] * self.N, [60.0] * self.N))
|
||||
|
||||
self.global_optimum = [[53.81, 1.27, 3.012, 2.13, 0.507]]
|
||||
self.fglob = 0.0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
t = 0.1 * arange(16)
|
||||
y = (53.81 * 1.27 ** t * tanh(3.012 * t + sin(2.13 * t))
|
||||
* cos(exp(0.507) * t))
|
||||
|
||||
return sum((x[0] * (x[1] ** t) * tanh(x[2] * t + sin(x[3] * t))
|
||||
* cos(t * exp(x[4])) - y) ** 2.0)
|
||||
|
||||
|
||||
class DixonPrice(Benchmark):
|
||||
r"""
|
||||
Dixon and Price objective function.
|
||||
|
||||
This class defines the Dixon and Price global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{DixonPrice}}(x) = (x_i - 1)^2
|
||||
+ \sum_{i=2}^n i(2x_i^2 - x_{i-1})^2
|
||||
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and
|
||||
:math:`x_i \in [-10, 10]` for :math:`i = 1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x_i) = 0` for
|
||||
:math:`x_i = 2^{- \frac{(2^i - 2)}{2^i}}` for :math:`i = 1, ..., n`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
|
||||
TODO: Gavana code not correct. i array should start from 2.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-10.0] * self.N, [10.0] * self.N))
|
||||
self.custom_bounds = [(-2, 3), (-2, 3)]
|
||||
|
||||
self.global_optimum = [[2.0 ** (-(2.0 ** i - 2.0) / 2.0 ** i)
|
||||
for i in range(1, self.N + 1)]]
|
||||
self.fglob = 0.0
|
||||
self.change_dimensionality = True
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
i = arange(2, self.N + 1)
|
||||
s = i * (2.0 * x[1:] ** 2.0 - x[:-1]) ** 2.0
|
||||
return sum(s) + (x[0] - 1.0) ** 2.0
|
||||
|
||||
|
||||
class Dolan(Benchmark):
|
||||
r"""
|
||||
Dolan objective function.
|
||||
|
||||
This class defines the Dolan [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Dolan}}(x) = \lvert (x_1 + 1.7 x_2)\sin(x_1) - 1.5 x_3
|
||||
- 0.1 x_4\cos(x_5 + x_5 - x_1) + 0.2 x_5^2 - x_2 - 1 \rvert
|
||||
|
||||
|
||||
with :math:`x_i \in [-100, 100]` for :math:`i = 1, ..., 5`.
|
||||
|
||||
*Global optimum*: :math:`f(x_i) = 10^{-5}` for
|
||||
:math:`x = [8.39045925, 4.81424707, 7.34574133, 68.88246895, 3.85470806]`
|
||||
|
||||
.. [1] Gavana, A. Global Optimization Benchmarks and AMPGO retrieved 2015
|
||||
|
||||
TODO Jamil equation is missing the absolute brackets around the entire
|
||||
expression.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=5):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-100.0] * self.N,
|
||||
[100.0] * self.N))
|
||||
|
||||
self.global_optimum = [[-74.10522498, 44.33511286, 6.21069214,
|
||||
18.42772233, -16.5839403]]
|
||||
self.fglob = 0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return (abs((x[0] + 1.7 * x[1]) * sin(x[0]) - 1.5 * x[2]
|
||||
- 0.1 * x[3] * cos(x[3] + x[4] - x[0]) + 0.2 * x[4] ** 2
|
||||
- x[1] - 1))
|
||||
|
||||
|
||||
class DropWave(Benchmark):
|
||||
r"""
|
||||
DropWave objective function.
|
||||
|
||||
This class defines the DropWave [1]_ global optimization problem. This is a
|
||||
multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{DropWave}}(x) = - \frac{1 + \cos\left(12 \sqrt{\sum_{i=1}^{n}
|
||||
x_i^{2}}\right)}{2 + 0.5 \sum_{i=1}^{n} x_i^{2}}
|
||||
|
||||
|
||||
with :math:`x_i \in [-5.12, 5.12]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = -1` for :math:`x = [0, 0]`
|
||||
|
||||
.. [1] Gavana, A. Global Optimization Benchmarks and AMPGO retrieved 2015
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-5.12] * self.N, [5.12] * self.N))
|
||||
|
||||
self.global_optimum = [[0 for _ in range(self.N)]]
|
||||
self.fglob = -1.0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
norm_x = sum(x ** 2)
|
||||
return -(1 + cos(12 * sqrt(norm_x))) / (0.5 * norm_x + 2)
|
304
go_benchmark_functions/go_funcs_E.py
Normal file
304
go_benchmark_functions/go_funcs_E.py
Normal file
|
@ -0,0 +1,304 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from numpy import abs, asarray, cos, exp, arange, pi, sin, sqrt, sum
|
||||
from .go_benchmark import Benchmark
|
||||
|
||||
|
||||
class Easom(Benchmark):
|
||||
|
||||
r"""
|
||||
Easom objective function.
|
||||
|
||||
This class defines the Easom [1]_ global optimization problem. This is a
|
||||
a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Easom}}({x}) = a - \frac{a}{e^{b \sqrt{\frac{\sum_{i=1}^{n}
|
||||
x_i^{2}}{n}}}} + e - e^{\frac{\sum_{i=1}^{n} \cos\left(c x_i\right)}
|
||||
{n}}
|
||||
|
||||
|
||||
Where, in this exercise, :math:`a = 20, b = 0.2` and :math:`c = 2 \pi`.
|
||||
|
||||
Here, :math:`x_i \in [-100, 100]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x = [0, 0]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
|
||||
TODO Gavana website disagrees with Jamil, etc. Gavana equation in docstring is totally wrong.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-100.0] * self.N,
|
||||
[100.0] * self.N))
|
||||
|
||||
self.global_optimum = [[pi for _ in range(self.N)]]
|
||||
self.fglob = -1.0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
a = (x[0] - pi)**2 + (x[1] - pi)**2
|
||||
return -cos(x[0]) * cos(x[1]) * exp(-a)
|
||||
|
||||
|
||||
class Eckerle4(Benchmark):
|
||||
r"""
|
||||
Eckerle4 objective function.
|
||||
Eckerle, K., NIST (1979).
|
||||
Circular Interference Transmittance Study.
|
||||
|
||||
..[1] https://www.itl.nist.gov/div898/strd/nls/data/eckerle4.shtml
|
||||
|
||||
#TODO, this is a NIST regression standard dataset, docstring needs
|
||||
improving
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=3):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([0., 1., 10.],
|
||||
[20, 20., 600.]))
|
||||
self.global_optimum = [[1.5543827178, 4.0888321754, 4.5154121844e2]]
|
||||
self.fglob = 1.4635887487E-03
|
||||
|
||||
self.a = asarray([1.5750000E-04, 1.6990000E-04, 2.3500000E-04,
|
||||
3.1020000E-04, 4.9170000E-04, 8.7100000E-04,
|
||||
1.7418000E-03, 4.6400000E-03, 6.5895000E-03,
|
||||
9.7302000E-03, 1.4900200E-02, 2.3731000E-02,
|
||||
4.0168300E-02, 7.1255900E-02, 1.2644580E-01,
|
||||
2.0734130E-01, 2.9023660E-01, 3.4456230E-01,
|
||||
3.6980490E-01, 3.6685340E-01, 3.1067270E-01,
|
||||
2.0781540E-01, 1.1643540E-01, 6.1676400E-02,
|
||||
3.3720000E-02, 1.9402300E-02, 1.1783100E-02,
|
||||
7.4357000E-03, 2.2732000E-03, 8.8000000E-04,
|
||||
4.5790000E-04, 2.3450000E-04, 1.5860000E-04,
|
||||
1.1430000E-04, 7.1000000E-05])
|
||||
|
||||
self.b = asarray([4.0000000E+02, 4.0500000E+02, 4.1000000E+02,
|
||||
4.1500000E+02, 4.2000000E+02, 4.2500000E+02,
|
||||
4.3000000E+02, 4.3500000E+02, 4.3650000E+02,
|
||||
4.3800000E+02, 4.3950000E+02, 4.4100000E+02,
|
||||
4.4250000E+02, 4.4400000E+02, 4.4550000E+02,
|
||||
4.4700000E+02, 4.4850000E+02, 4.5000000E+02,
|
||||
4.5150000E+02, 4.5300000E+02, 4.5450000E+02,
|
||||
4.5600000E+02, 4.5750000E+02, 4.5900000E+02,
|
||||
4.6050000E+02, 4.6200000E+02, 4.6350000E+02,
|
||||
4.6500000E+02, 4.7000000E+02, 4.7500000E+02,
|
||||
4.8000000E+02, 4.8500000E+02, 4.9000000E+02,
|
||||
4.9500000E+02, 5.0000000E+02])
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
vec = x[0] / x[1] * exp(-(self.b - x[2]) ** 2 / (2 * x[1] ** 2))
|
||||
return sum((self.a - vec) ** 2)
|
||||
|
||||
|
||||
class EggCrate(Benchmark):
|
||||
|
||||
r"""
|
||||
Egg Crate objective function.
|
||||
|
||||
This class defines the Egg Crate [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{EggCrate}}(x) = x_1^2 + x_2^2 + 25 \left[ \sin^2(x_1)
|
||||
+ \sin^2(x_2) \right]
|
||||
|
||||
|
||||
with :math:`x_i \in [-5, 5]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x = [0, 0]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-5.0] * self.N, [5.0] * self.N))
|
||||
|
||||
self.global_optimum = [[0.0, 0.0]]
|
||||
self.fglob = 0.0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
return x[0] ** 2 + x[1] ** 2 + 25 * (sin(x[0]) ** 2 + sin(x[1]) ** 2)
|
||||
|
||||
|
||||
class EggHolder(Benchmark):
|
||||
|
||||
r"""
|
||||
Egg Holder [1]_ objective function.
|
||||
|
||||
This class defines the Egg Holder global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{EggHolder}}=\sum_{1}^{n - 1}\left[-\left(x_{i + 1}
|
||||
+ 47 \right ) \sin\sqrt{\lvert x_{i+1} + x_i/2 + 47 \rvert}
|
||||
- x_i \sin\sqrt{\lvert x_i - (x_{i + 1} + 47)\rvert}\right ]
|
||||
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and :math:`x_i \in
|
||||
[-512, 512]` for :math:`i = 1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = -959.640662711` for
|
||||
:math:`{x} = [512, 404.2319]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
|
||||
TODO: Jamil is missing a minus sign on the fglob value
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-512.1] * self.N,
|
||||
[512.0] * self.N))
|
||||
|
||||
self.global_optimum = [[512.0, 404.2319]]
|
||||
self.fglob = -959.640662711
|
||||
self.change_dimensionality = True
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
vec = (-(x[1:] + 47) * sin(sqrt(abs(x[1:] + x[:-1] / 2. + 47)))
|
||||
- x[:-1] * sin(sqrt(abs(x[:-1] - (x[1:] + 47)))))
|
||||
return sum(vec)
|
||||
|
||||
|
||||
class ElAttarVidyasagarDutta(Benchmark):
|
||||
|
||||
r"""
|
||||
El-Attar-Vidyasagar-Dutta [1]_ objective function.
|
||||
|
||||
This class defines the El-Attar-Vidyasagar-Dutta function global
|
||||
optimization problem. This is a multimodal minimization problem defined as
|
||||
follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{ElAttarVidyasagarDutta}}(x) = (x_1^2 + x_2 - 10)^2
|
||||
+ (x_1 + x_2^2 - 7)^2 + (x_1^2 + x_2^3 - 1)^2
|
||||
|
||||
|
||||
with :math:`x_i \in [-100, 100]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 1.712780354` for
|
||||
:math:`x= [3.40918683, -2.17143304]`
|
||||
|
||||
.. [1] Gavana, A. Global Optimization Benchmarks and AMPGO retrieved 2015
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-100.0] * self.N,
|
||||
[100.0] * self.N))
|
||||
self.custom_bounds = [(-4, 4), (-4, 4)]
|
||||
|
||||
self.global_optimum = [[3.40918683, -2.17143304]]
|
||||
self.fglob = 1.712780354
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return ((x[0] ** 2 + x[1] - 10) ** 2 + (x[0] + x[1] ** 2 - 7) ** 2
|
||||
+ (x[0] ** 2 + x[1] ** 3 - 1) ** 2)
|
||||
|
||||
|
||||
class Exp2(Benchmark):
|
||||
|
||||
r"""
|
||||
Exp2 objective function.
|
||||
|
||||
This class defines the Exp2 global optimization problem. This is a
|
||||
multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Exp2}}(x) = \sum_{i=0}^9 \left ( e^{-ix_1/10} - 5e^{-ix_2/10}
|
||||
- e^{-i/10} + 5e^{-i} \right )^2
|
||||
|
||||
|
||||
with :math:`x_i \in [0, 20]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x = [1, 10.]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([0.0] * self.N, [20.0] * self.N))
|
||||
self.custom_bounds = [(0, 2), (0, 20)]
|
||||
|
||||
self.global_optimum = [[1.0, 10.]]
|
||||
self.fglob = 0.
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
i = arange(10.)
|
||||
vec = (exp(-i * x[0] / 10.) - 5 * exp(-i * x[1] / 10.) - exp(-i / 10.)
|
||||
+ 5 * exp(-i)) ** 2
|
||||
|
||||
return sum(vec)
|
||||
|
||||
|
||||
class Exponential(Benchmark):
|
||||
|
||||
r"""
|
||||
Exponential [1] objective function.
|
||||
|
||||
This class defines the Exponential global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Exponential}}(x) = -e^{-0.5 \sum_{i=1}^n x_i^2}
|
||||
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and :math:`x_i \in
|
||||
[-1, 1]` for :math:`i = 1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x_i) = -1` for :math:`x_i = 0` for
|
||||
:math:`i = 1, ..., n`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
|
||||
TODO Jamil are missing a minus sign on fglob
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-1.0] * self.N, [1.0] * self.N))
|
||||
|
||||
self.global_optimum = [[0.0 for _ in range(self.N)]]
|
||||
self.fglob = -1.0
|
||||
self.change_dimensionality = True
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return -exp(-0.5 * sum(x ** 2.0))
|
44
go_benchmark_functions/go_funcs_F.py
Normal file
44
go_benchmark_functions/go_funcs_F.py
Normal file
|
@ -0,0 +1,44 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from .go_benchmark import Benchmark
|
||||
|
||||
|
||||
class FreudensteinRoth(Benchmark):
|
||||
|
||||
r"""
|
||||
FreudensteinRoth objective function.
|
||||
|
||||
This class defines the Freudenstein & Roth [1]_ global optimization problem.
|
||||
This is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{FreudensteinRoth}}(x) = \left\{x_1 - 13 + \left[(5 - x_2) x_2
|
||||
- 2 \right] x_2 \right\}^2 + \left \{x_1 - 29
|
||||
+ \left[(x_2 + 1) x_2 - 14 \right] x_2 \right\}^2
|
||||
|
||||
|
||||
with :math:`x_i \in [-10, 10]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x = [5, 4]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-10.0] * self.N, [10.0] * self.N))
|
||||
self.custom_bounds = [(-3, 3), (-5, 5)]
|
||||
|
||||
self.global_optimum = [[5.0, 4.0]]
|
||||
self.fglob = 0.0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
f1 = (-13.0 + x[0] + ((5.0 - x[1]) * x[1] - 2.0) * x[1]) ** 2
|
||||
f2 = (-29.0 + x[0] + ((x[1] + 1.0) * x[1] - 14.0) * x[1]) ** 2
|
||||
|
||||
return f1 + f2
|
222
go_benchmark_functions/go_funcs_G.py
Normal file
222
go_benchmark_functions/go_funcs_G.py
Normal file
|
@ -0,0 +1,222 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import numpy as np
|
||||
from numpy import abs, sin, cos, exp, floor, log, arange, prod, sqrt, sum
|
||||
|
||||
from .go_benchmark import Benchmark
|
||||
|
||||
|
||||
class Gear(Benchmark):
|
||||
|
||||
r"""
|
||||
Gear objective function.
|
||||
|
||||
This class defines the Gear [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Gear}}({x}) = \left \{ \frac{1.0}{6.931}
|
||||
- \frac{\lfloor x_1\rfloor \lfloor x_2 \rfloor }
|
||||
{\lfloor x_3 \rfloor \lfloor x_4 \rfloor } \right\}^2
|
||||
|
||||
|
||||
with :math:`x_i \in [12, 60]` for :math:`i = 1, ..., 4`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 2.7 \cdot 10^{-12}` for :math:`x =
|
||||
[16, 19, 43, 49]`, where the various :math:`x_i` may be permuted.
|
||||
|
||||
.. [1] Gavana, A. Global Optimization Benchmarks and AMPGO retrieved 2015
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=4):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([12.0] * self.N, [60.0] * self.N))
|
||||
self.global_optimum = [[16, 19, 43, 49]]
|
||||
self.fglob = 2.7e-12
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return (1. / 6.931
|
||||
- floor(x[0]) * floor(x[1]) / floor(x[2]) / floor(x[3])) ** 2
|
||||
|
||||
|
||||
class Giunta(Benchmark):
|
||||
|
||||
r"""
|
||||
Giunta objective function.
|
||||
|
||||
This class defines the Giunta [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Giunta}}({x}) = 0.6 + \sum_{i=1}^{n} \left[\sin^{2}\left(1
|
||||
- \frac{16}{15} x_i\right) - \frac{1}{50} \sin\left(4
|
||||
- \frac{64}{15} x_i\right) - \sin\left(1
|
||||
- \frac{16}{15} x_i\right)\right]
|
||||
|
||||
|
||||
with :math:`x_i \in [-1, 1]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0.06447042053690566` for
|
||||
:math:`x = [0.4673200277395354, 0.4673200169591304]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
|
||||
TODO Jamil has the wrong fglob. I think there is a lower value.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-1.0] * self.N, [1.0] * self.N))
|
||||
|
||||
self.global_optimum = [[0.4673200277395354, 0.4673200169591304]]
|
||||
self.fglob = 0.06447042053690566
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
arg = 16 * x / 15.0 - 1
|
||||
return 0.6 + sum(sin(arg) + sin(arg) ** 2 + sin(4 * arg) / 50.)
|
||||
|
||||
|
||||
class GoldsteinPrice(Benchmark):
|
||||
|
||||
r"""
|
||||
Goldstein-Price objective function.
|
||||
|
||||
This class defines the Goldstein-Price [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{GoldsteinPrice}}(x) = \left[ 1 + (x_1 + x_2 + 1)^2
|
||||
(19 - 14 x_1 + 3 x_1^2 - 14 x_2 + 6 x_1 x_2 + 3 x_2^2) \right]
|
||||
\left[ 30 + ( 2x_1 - 3 x_2)^2 (18 - 32 x_1 + 12 x_1^2
|
||||
+ 48 x_2 - 36 x_1 x_2 + 27 x_2^2) \right]
|
||||
|
||||
|
||||
with :math:`x_i \in [-2, 2]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 3` for :math:`x = [0, -1]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-2.0] * self.N, [2.0] * self.N))
|
||||
|
||||
self.global_optimum = [[0., -1.]]
|
||||
self.fglob = 3.0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
a = (1 + (x[0] + x[1] + 1) ** 2
|
||||
* (19 - 14 * x[0] + 3 * x[0] ** 2
|
||||
- 14 * x[1] + 6 * x[0] * x[1] + 3 * x[1] ** 2))
|
||||
b = (30 + (2 * x[0] - 3 * x[1]) ** 2
|
||||
* (18 - 32 * x[0] + 12 * x[0] ** 2
|
||||
+ 48 * x[1] - 36 * x[0] * x[1] + 27 * x[1] ** 2))
|
||||
return a * b
|
||||
|
||||
|
||||
class Griewank(Benchmark):
|
||||
|
||||
r"""
|
||||
Griewank objective function.
|
||||
|
||||
This class defines the Griewank global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Griewank}}(x) = \frac{1}{4000}\sum_{i=1}^n x_i^2
|
||||
- \prod_{i=1}^n\cos\left(\frac{x_i}{\sqrt{i}}\right) + 1
|
||||
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and
|
||||
:math:`x_i \in [-600, 600]` for :math:`i = 1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x_i = 0` for
|
||||
:math:`i = 1, ..., n`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-100.0] * self.N,
|
||||
[100.0] * self.N))
|
||||
self.custom_bounds = [(-50, 50), (-50, 50)]
|
||||
|
||||
self.global_optimum = [[0 for _ in range(self.N)]]
|
||||
self.fglob = 0.0
|
||||
self.change_dimensionality = True
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
i = arange(1., np.size(x) + 1.)
|
||||
return sum(x ** 2 / 4000) - prod(cos(x / sqrt(i))) + 1
|
||||
|
||||
|
||||
class Gulf(Benchmark):
|
||||
|
||||
r"""
|
||||
Gulf objective function.
|
||||
|
||||
This class defines the Gulf [1]_ global optimization problem. This is a
|
||||
multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Gulf}}(x) = \sum_{i=1}^99 \left( e^{-\frac{\lvert y_i
|
||||
- x_2 \rvert^{x_3}}{x_1}} - t_i \right)
|
||||
|
||||
|
||||
Where, in this exercise:
|
||||
|
||||
.. math::
|
||||
|
||||
t_i = i/100 \\
|
||||
y_i = 25 + [-50 \log(t_i)]^{2/3}
|
||||
|
||||
|
||||
with :math:`x_i \in [0, 60]` for :math:`i = 1, 2, 3`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x = [50, 25, 1.5]`
|
||||
|
||||
.. [1] Gavana, A. Global Optimization Benchmarks and AMPGO retrieved 2015
|
||||
|
||||
TODO Gavana has absolute of (u - x[1]) term. Jamil doesn't... Leaving it in.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=3):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([0.0] * self.N, [50.0] * self.N))
|
||||
|
||||
self.global_optimum = [[50.0, 25.0, 1.5]]
|
||||
self.fglob = 0.0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
m = 99.
|
||||
i = arange(1., m + 1)
|
||||
u = 25 + (-50 * log(i / 100.)) ** (2 / 3.)
|
||||
vec = (exp(-((abs(u - x[1])) ** x[2] / x[0])) - i / 100.)
|
||||
return sum(vec ** 2)
|
375
go_benchmark_functions/go_funcs_H.py
Normal file
375
go_benchmark_functions/go_funcs_H.py
Normal file
|
@ -0,0 +1,375 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import numpy as np
|
||||
from numpy import abs, arctan2, asarray, cos, exp, arange, pi, sin, sqrt, sum
|
||||
from .go_benchmark import Benchmark
|
||||
|
||||
|
||||
class Hansen(Benchmark):
|
||||
|
||||
r"""
|
||||
Hansen objective function.
|
||||
|
||||
This class defines the Hansen [1]_ global optimization problem. This is a
|
||||
multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Hansen}}(x) = \left[ \sum_{i=0}^4(i+1)\cos(ix_1+i+1)\right ]
|
||||
\left[\sum_{j=0}^4(j+1)\cos[(j+2)x_2+j+1])\right ]
|
||||
|
||||
|
||||
with :math:`x_i \in [-10, 10]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = -176.54179` for
|
||||
:math:`x = [-7.58989583, -7.70831466]`.
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
|
||||
TODO Jamil #61 is missing the starting value of i.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-10.0] * self.N, [10.0] * self.N))
|
||||
|
||||
self.global_optimum = [[-7.58989583, -7.70831466]]
|
||||
self.fglob = -176.54179
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
i = arange(5.)
|
||||
a = (i + 1) * cos(i * x[0] + i + 1)
|
||||
b = (i + 1) * cos((i + 2) * x[1] + i + 1)
|
||||
|
||||
return sum(a) * sum(b)
|
||||
|
||||
|
||||
class Hartmann3(Benchmark):
|
||||
|
||||
r"""
|
||||
Hartmann3 objective function.
|
||||
|
||||
This class defines the Hartmann3 [1]_ global optimization problem. This is a
|
||||
multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Hartmann3}}(x) = -\sum\limits_{i=1}^{4} c_i
|
||||
e^{-\sum\limits_{j=1}^{n}a_{ij}(x_j - p_{ij})^2}
|
||||
|
||||
|
||||
Where, in this exercise:
|
||||
|
||||
.. math::
|
||||
|
||||
\begin{array}{l|ccc|c|ccr}
|
||||
\hline
|
||||
i & & a_{ij}& & c_i & & p_{ij} & \\
|
||||
\hline
|
||||
1 & 3.0 & 10.0 & 30.0 & 1.0 & 0.3689 & 0.1170 & 0.2673 \\
|
||||
2 & 0.1 & 10.0 & 35.0 & 1.2 & 0.4699 & 0.4387 & 0.7470 \\
|
||||
3 & 3.0 & 10.0 & 30.0 & 3.0 & 0.1091 & 0.8732 & 0.5547 \\
|
||||
4 & 0.1 & 10.0 & 35.0 & 3.2 & 0.03815 & 0.5743 & 0.8828 \\
|
||||
\hline
|
||||
\end{array}
|
||||
|
||||
|
||||
with :math:`x_i \in [0, 1]` for :math:`i = 1, 2, 3`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = -3.8627821478`
|
||||
for :math:`x = [0.11461292, 0.55564907, 0.85254697]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
|
||||
TODO Jamil #62 has an incorrect coefficient. p[1, 1] should be 0.4387
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=3):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([0.0] * self.N, [1.0] * self.N))
|
||||
|
||||
self.global_optimum = [[0.11461292, 0.55564907, 0.85254697]]
|
||||
self.fglob = -3.8627821478
|
||||
|
||||
self.a = asarray([[3.0, 10., 30.],
|
||||
[0.1, 10., 35.],
|
||||
[3.0, 10., 30.],
|
||||
[0.1, 10., 35.]])
|
||||
|
||||
self.p = asarray([[0.3689, 0.1170, 0.2673],
|
||||
[0.4699, 0.4387, 0.7470],
|
||||
[0.1091, 0.8732, 0.5547],
|
||||
[0.03815, 0.5743, 0.8828]])
|
||||
|
||||
self.c = asarray([1., 1.2, 3., 3.2])
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
XX = np.atleast_2d(x)
|
||||
d = sum(self.a * (XX - self.p) ** 2, axis=1)
|
||||
return -sum(self.c * exp(-d))
|
||||
|
||||
|
||||
class Hartmann6(Benchmark):
|
||||
|
||||
r"""
|
||||
Hartmann6 objective function.
|
||||
|
||||
This class defines the Hartmann6 [1]_ global optimization problem. This is a
|
||||
multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Hartmann6}}(x) = -\sum\limits_{i=1}^{4} c_i
|
||||
e^{-\sum\limits_{j=1}^{n}a_{ij}(x_j - p_{ij})^2}
|
||||
|
||||
|
||||
Where, in this exercise:
|
||||
|
||||
.. math::
|
||||
|
||||
\begin{array}{l|cccccc|r}
|
||||
\hline
|
||||
i & & & a_{ij} & & & & c_i \\
|
||||
\hline
|
||||
1 & 10.0 & 3.0 & 17.0 & 3.50 & 1.70 & 8.00 & 1.0 \\
|
||||
2 & 0.05 & 10.0 & 17.0 & 0.10 & 8.00 & 14.00 & 1.2 \\
|
||||
3 & 3.00 & 3.50 & 1.70 & 10.0 & 17.00 & 8.00 & 3.0 \\
|
||||
4 & 17.00 & 8.00 & 0.05 & 10.00 & 0.10 & 14.00 & 3.2 \\
|
||||
\hline
|
||||
\end{array}
|
||||
|
||||
\newline
|
||||
\
|
||||
\newline
|
||||
|
||||
\begin{array}{l|cccccr}
|
||||
\hline
|
||||
i & & & p_{ij} & & & \\
|
||||
\hline
|
||||
1 & 0.1312 & 0.1696 & 0.5569 & 0.0124 & 0.8283 & 0.5886 \\
|
||||
2 & 0.2329 & 0.4135 & 0.8307 & 0.3736 & 0.1004 & 0.9991 \\
|
||||
3 & 0.2348 & 0.1451 & 0.3522 & 0.2883 & 0.3047 & 0.6650 \\
|
||||
4 & 0.4047 & 0.8828 & 0.8732 & 0.5743 & 0.1091 & 0.0381 \\
|
||||
\hline
|
||||
\end{array}
|
||||
|
||||
|
||||
with :math:`x_i \in [0, 1]` for :math:`i = 1, ..., 6`.
|
||||
|
||||
*Global optimum*: :math:`f(x_i) = -3.32236801141551` for
|
||||
:math:`{x} = [0.20168952, 0.15001069, 0.47687398, 0.27533243, 0.31165162,
|
||||
0.65730054]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=6):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([0.0] * self.N, [1.0] * self.N))
|
||||
|
||||
self.global_optimum = [[0.20168952, 0.15001069, 0.47687398, 0.27533243,
|
||||
0.31165162, 0.65730054]]
|
||||
|
||||
self.fglob = -3.32236801141551
|
||||
|
||||
self.a = asarray([[10., 3., 17., 3.5, 1.7, 8.],
|
||||
[0.05, 10., 17., 0.1, 8., 14.],
|
||||
[3., 3.5, 1.7, 10., 17., 8.],
|
||||
[17., 8., 0.05, 10., 0.1, 14.]])
|
||||
|
||||
self.p = asarray([[0.1312, 0.1696, 0.5569, 0.0124, 0.8283, 0.5886],
|
||||
[0.2329, 0.4135, 0.8307, 0.3736, 0.1004, 0.9991],
|
||||
[0.2348, 0.1451, 0.3522, 0.2883, 0.3047, 0.665],
|
||||
[0.4047, 0.8828, 0.8732, 0.5743, 0.1091, 0.0381]])
|
||||
|
||||
self.c = asarray([1.0, 1.2, 3.0, 3.2])
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
XX = np.atleast_2d(x)
|
||||
d = sum(self.a * (XX - self.p) ** 2, axis=1)
|
||||
return -sum(self.c * exp(-d))
|
||||
|
||||
|
||||
class HelicalValley(Benchmark):
|
||||
|
||||
r"""
|
||||
HelicalValley objective function.
|
||||
|
||||
This class defines the HelicalValley [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{HelicalValley}}({x}) = 100{[z-10\Psi(x_1,x_2)]^2
|
||||
+(\sqrt{x_1^2+x_2^2}-1)^2}+x_3^2
|
||||
|
||||
|
||||
Where, in this exercise:
|
||||
|
||||
.. math::
|
||||
|
||||
2\pi\Psi(x,y) = \begin{cases} \arctan(y/x) & \textrm{for} x > 0 \\
|
||||
\pi + \arctan(y/x) & \textrm{for } x < 0 \end{cases}
|
||||
|
||||
with :math:`x_i \in [-100, 100]` for :math:`i = 1, 2, 3`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x = [1, 0, 0]`
|
||||
|
||||
.. [1] Fletcher, R. & Powell, M. A Rapidly Convergent Descent Method for
|
||||
Minimzation, Computer Journal, 1963, 62, 163-168
|
||||
|
||||
TODO: Jamil equation is different to original reference. The above paper
|
||||
can be obtained from
|
||||
http://galton.uchicago.edu/~lekheng/courses/302/classics/
|
||||
fletcher-powell.pdf
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=3):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-10.] * self.N, [10.] * self.N))
|
||||
|
||||
self.global_optimum = [[1.0, 0.0, 0.0]]
|
||||
self.fglob = 0.0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
r = sqrt(x[0] ** 2 + x[1] ** 2)
|
||||
theta = 1 / (2. * pi) * arctan2(x[1], x[0])
|
||||
|
||||
return x[2] ** 2 + 100 * ((x[2] - 10 * theta) ** 2 + (r - 1) ** 2)
|
||||
|
||||
|
||||
class HimmelBlau(Benchmark):
|
||||
|
||||
r"""
|
||||
HimmelBlau objective function.
|
||||
|
||||
This class defines the HimmelBlau [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{HimmelBlau}}({x}) = (x_1^2 + x_2 - 11)^2 + (x_1 + x_2^2 - 7)^2
|
||||
|
||||
|
||||
with :math:`x_i \in [-6, 6]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x = [3, 2]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-5.] * self.N, [5.] * self.N))
|
||||
|
||||
self.global_optimum = [[3.0, 2.0]]
|
||||
self.fglob = 0.0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return (x[0] ** 2 + x[1] - 11) ** 2 + (x[0] + x[1] ** 2 - 7) ** 2
|
||||
|
||||
|
||||
class HolderTable(Benchmark):
|
||||
|
||||
r"""
|
||||
HolderTable objective function.
|
||||
|
||||
This class defines the HolderTable [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{HolderTable}}({x}) = - \left|{e^{\left|{1
|
||||
- \frac{\sqrt{x_{1}^{2} + x_{2}^{2}}}{\pi} }\right|}
|
||||
\sin\left(x_{1}\right) \cos\left(x_{2}\right)}\right|
|
||||
|
||||
|
||||
with :math:`x_i \in [-10, 10]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = -19.20850256788675` for
|
||||
:math:`x_i = \pm 9.664590028909654` for :math:`i = 1, 2`
|
||||
|
||||
.. [1] Gavana, A. Global Optimization Benchmarks and AMPGO retrieved 2015
|
||||
|
||||
TODO: Jamil #146 equation is wrong - should be squaring the x1 and x2
|
||||
terms, but isn't. Gavana does.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-10.0] * self.N, [10.0] * self.N))
|
||||
|
||||
self.global_optimum = [(8.055023472141116, 9.664590028909654),
|
||||
(-8.055023472141116, 9.664590028909654),
|
||||
(8.055023472141116, -9.664590028909654),
|
||||
(-8.055023472141116, -9.664590028909654)]
|
||||
self.fglob = -19.20850256788675
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return -abs(sin(x[0]) * cos(x[1])
|
||||
* exp(abs(1 - sqrt(x[0] ** 2 + x[1] ** 2) / pi)))
|
||||
|
||||
|
||||
class Hosaki(Benchmark):
|
||||
|
||||
r"""
|
||||
Hosaki objective function.
|
||||
|
||||
This class defines the Hosaki [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Hosaki}}(x) = \left ( 1 - 8 x_1 + 7 x_1^2 - \frac{7}{3} x_1^3
|
||||
+ \frac{1}{4} x_1^4 \right ) x_2^2 e^{-x_1}
|
||||
|
||||
|
||||
with :math:`x_i \in [0, 10]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = -2.3458115` for :math:`x = [4, 2]`.
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = ([0., 5.], [0., 6.])
|
||||
self.custom_bounds = [(0, 5), (0, 5)]
|
||||
|
||||
self.global_optimum = [[4, 2]]
|
||||
self.fglob = -2.3458115
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
val = (1 - 8 * x[0] + 7 * x[0] ** 2 - 7 / 3. * x[0] ** 3
|
||||
+ 0.25 * x[0] ** 4)
|
||||
return val * x[1] ** 2 * exp(-x[1])
|
41
go_benchmark_functions/go_funcs_I.py
Normal file
41
go_benchmark_functions/go_funcs_I.py
Normal file
|
@ -0,0 +1,41 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from numpy import sin, sum
|
||||
from .go_benchmark import Benchmark
|
||||
|
||||
|
||||
class Infinity(Benchmark):
|
||||
|
||||
r"""
|
||||
Infinity objective function.
|
||||
|
||||
This class defines the Infinity [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Infinity}}(x) = \sum_{i=1}^{n} x_i^{6}
|
||||
\left [ \sin\left ( \frac{1}{x_i} \right ) + 2 \right ]
|
||||
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and
|
||||
:math:`x_i \in [-1, 1]` for :math:`i = 1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x_i = 0` for
|
||||
:math:`i = 1, ..., n`
|
||||
|
||||
.. [1] Gavana, A. Global Optimization Benchmarks and AMPGO retrieved 2015
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-1.0] * self.N, [1.0] * self.N))
|
||||
|
||||
self.global_optimum = [[1e-16 for _ in range(self.N)]]
|
||||
self.fglob = 0.0
|
||||
self.change_dimensionality = True
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return sum(x ** 6.0 * (sin(1.0 / x) + 2.0))
|
107
go_benchmark_functions/go_funcs_J.py
Normal file
107
go_benchmark_functions/go_funcs_J.py
Normal file
|
@ -0,0 +1,107 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from numpy import sum, asarray, arange, exp
|
||||
from .go_benchmark import Benchmark
|
||||
|
||||
|
||||
class JennrichSampson(Benchmark):
|
||||
r"""
|
||||
Jennrich-Sampson objective function.
|
||||
|
||||
This class defines the Jennrich-Sampson [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{JennrichSampson}}(x) = \sum_{i=1}^{10} \left [2 + 2i
|
||||
- (e^{ix_1} + e^{ix_2}) \right ]^2
|
||||
|
||||
|
||||
with :math:`x_i \in [-1, 1]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 124.3621824` for
|
||||
:math:`x = [0.257825, 0.257825]`.
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-1.0] * self.N, [1.0] * self.N))
|
||||
|
||||
self.global_optimum = [[0.257825, 0.257825]]
|
||||
self.custom_bounds = [(-1, 0.34), (-1, 0.34)]
|
||||
self.fglob = 124.3621824
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
i = arange(1, 11)
|
||||
return sum((2 + 2 * i - (exp(i * x[0]) + exp(i * x[1]))) ** 2)
|
||||
|
||||
|
||||
class Judge(Benchmark):
|
||||
r"""
|
||||
Judge objective function.
|
||||
|
||||
This class defines the Judge [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Judge}}(x) = \sum_{i=1}^{20}
|
||||
\left [ \left (x_1 + A_i x_2 + B x_2^2 \right ) - C_i \right ]^2
|
||||
|
||||
|
||||
Where, in this exercise:
|
||||
|
||||
.. math::
|
||||
|
||||
\begin{cases}
|
||||
C = [4.284, 4.149, 3.877, 0.533, 2.211, 2.389, 2.145,
|
||||
3.231, 1.998, 1.379, 2.106, 1.428, 1.011, 2.179, 2.858, 1.388, 1.651,
|
||||
1.593, 1.046, 2.152] \\
|
||||
A = [0.286, 0.973, 0.384, 0.276, 0.973, 0.543, 0.957, 0.948, 0.543,
|
||||
0.797, 0.936, 0.889, 0.006, 0.828, 0.399, 0.617, 0.939, 0.784,
|
||||
0.072, 0.889] \\
|
||||
B = [0.645, 0.585, 0.310, 0.058, 0.455, 0.779, 0.259, 0.202, 0.028,
|
||||
0.099, 0.142, 0.296, 0.175, 0.180, 0.842, 0.039, 0.103, 0.620,
|
||||
0.158, 0.704]
|
||||
\end{cases}
|
||||
|
||||
|
||||
with :math:`x_i \in [-10, 10]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x_i) = 16.0817307` for
|
||||
:math:`\mathbf{x} = [0.86479, 1.2357]`.
|
||||
|
||||
.. [1] Gavana, A. Global Optimization Benchmarks and AMPGO retrieved 2015
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-10.0] * self.N, [10.0] * self.N))
|
||||
|
||||
self.global_optimum = [[0.86479, 1.2357]]
|
||||
self.custom_bounds = [(-2.0, 2.0), (-2.0, 2.0)]
|
||||
self.fglob = 16.0817307
|
||||
self.c = asarray([4.284, 4.149, 3.877, 0.533, 2.211, 2.389, 2.145,
|
||||
3.231, 1.998, 1.379, 2.106, 1.428, 1.011, 2.179,
|
||||
2.858, 1.388, 1.651, 1.593, 1.046, 2.152])
|
||||
|
||||
self.a = asarray([0.286, 0.973, 0.384, 0.276, 0.973, 0.543, 0.957,
|
||||
0.948, 0.543, 0.797, 0.936, 0.889, 0.006, 0.828,
|
||||
0.399, 0.617, 0.939, 0.784, 0.072, 0.889])
|
||||
|
||||
self.b = asarray([0.645, 0.585, 0.310, 0.058, 0.455, 0.779, 0.259,
|
||||
0.202, 0.028, 0.099, 0.142, 0.296, 0.175, 0.180,
|
||||
0.842, 0.039, 0.103, 0.620, 0.158, 0.704])
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return sum(((x[0] + x[1] * self.a + (x[1] ** 2.0) * self.b) - self.c)
|
||||
** 2.0)
|
149
go_benchmark_functions/go_funcs_K.py
Normal file
149
go_benchmark_functions/go_funcs_K.py
Normal file
|
@ -0,0 +1,149 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from numpy import asarray, atleast_2d, arange, sin, sqrt, prod, sum, round
|
||||
from .go_benchmark import Benchmark
|
||||
|
||||
|
||||
class Katsuura(Benchmark):
|
||||
|
||||
r"""
|
||||
Katsuura objective function.
|
||||
|
||||
This class defines the Katsuura [1]_ global optimization problem. This is a
|
||||
multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Katsuura}}(x) = \prod_{i=0}^{n-1} \left [ 1 +
|
||||
(i+1) \sum_{k=1}^{d} \lfloor (2^k x_i) \rfloor 2^{-k} \right ]
|
||||
|
||||
|
||||
Where, in this exercise, :math:`d = 32`.
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and
|
||||
:math:`x_i \in [0, 100]` for :math:`i = 1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 1` for :math:`x_i = 0` for
|
||||
:math:`i = 1, ..., n`.
|
||||
|
||||
.. [1] Adorio, E. MVF - "Multivariate Test Functions Library in C for
|
||||
Unconstrained Global Optimization", 2005
|
||||
.. [2] Gavana, A. Global Optimization Benchmarks and AMPGO retrieved 2015
|
||||
|
||||
TODO: Adorio has wrong global minimum. Adorio uses round, Gavana docstring
|
||||
uses floor, but Gavana code uses round. We'll use round...
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([0.0] * self.N, [100.0] * self.N))
|
||||
|
||||
self.global_optimum = [[0.0 for _ in range(self.N)]]
|
||||
self.custom_bounds = [(0, 1), (0, 1)]
|
||||
self.fglob = 1.0
|
||||
self.change_dimensionality = True
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
d = 32
|
||||
k = atleast_2d(arange(1, d + 1)).T
|
||||
i = arange(0., self.N * 1.)
|
||||
inner = round(2 ** k * x) * (2. ** (-k))
|
||||
return prod(sum(inner, axis=0) * (i + 1) + 1)
|
||||
|
||||
|
||||
class Keane(Benchmark):
|
||||
|
||||
r"""
|
||||
Keane objective function.
|
||||
|
||||
This class defines the Keane [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Keane}}(x) = \frac{\sin^2(x_1 - x_2)\sin^2(x_1 + x_2)}
|
||||
{\sqrt{x_1^2 + x_2^2}}
|
||||
|
||||
|
||||
with :math:`x_i \in [0, 10]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0.0` for
|
||||
:math:`x = [7.85396153, 7.85396135]`.
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
|
||||
TODO: Jamil #69, there is no way that the function can have a negative
|
||||
value. Everything is squared. I think that they have the wrong solution.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([0.0] * self.N, [10.0] * self.N))
|
||||
|
||||
self.global_optimum = [[7.85396153, 7.85396135]]
|
||||
self.custom_bounds = [(-1, 0.34), (-1, 0.34)]
|
||||
self.fglob = 0.
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
val = sin(x[0] - x[1]) ** 2 * sin(x[0] + x[1]) ** 2
|
||||
return val / sqrt(x[0] ** 2 + x[1] ** 2)
|
||||
|
||||
|
||||
class Kowalik(Benchmark):
|
||||
|
||||
r"""
|
||||
Kowalik objective function.
|
||||
|
||||
This class defines the Kowalik [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Kowalik}}(x) = \sum_{i=0}^{10} \left [ a_i
|
||||
- \frac{x_1 (b_i^2 + b_i x_2)} {b_i^2 + b_i x_3 + x_4} \right ]^2
|
||||
|
||||
Where:
|
||||
|
||||
.. math::
|
||||
|
||||
\begin{matrix}
|
||||
a = [4, 2, 1, 1/2, 1/4 1/8, 1/10, 1/12, 1/14, 1/16] \\
|
||||
b = [0.1957, 0.1947, 0.1735, 0.1600, 0.0844, 0.0627,
|
||||
0.0456, 0.0342, 0.0323, 0.0235, 0.0246]\\
|
||||
\end{matrix}
|
||||
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and :math:`x_i \in
|
||||
[-5, 5]` for :math:`i = 1, ..., 4`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0.00030748610` for :math:`x =
|
||||
[0.192833, 0.190836, 0.123117, 0.135766]`.
|
||||
|
||||
..[1] https://www.itl.nist.gov/div898/strd/nls/data/mgh09.shtml
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=4):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-5.0] * self.N, [5.0] * self.N))
|
||||
self.global_optimum = [[0.192833, 0.190836, 0.123117, 0.135766]]
|
||||
self.fglob = 0.00030748610
|
||||
|
||||
self.a = asarray([4.0, 2.0, 1.0, 1 / 2.0, 1 / 4.0, 1 / 6.0, 1 / 8.0,
|
||||
1 / 10.0, 1 / 12.0, 1 / 14.0, 1 / 16.0])
|
||||
self.b = asarray([0.1957, 0.1947, 0.1735, 0.1600, 0.0844, 0.0627,
|
||||
0.0456, 0.0342, 0.0323, 0.0235, 0.0246])
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
vec = self.b - (x[0] * (self.a ** 2 + self.a * x[1])
|
||||
/ (self.a ** 2 + self.a * x[2] + x[3]))
|
||||
return sum(vec ** 2)
|
328
go_benchmark_functions/go_funcs_L.py
Normal file
328
go_benchmark_functions/go_funcs_L.py
Normal file
|
@ -0,0 +1,328 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from numpy import sum, cos, exp, pi, arange, sin
|
||||
from .go_benchmark import Benchmark
|
||||
|
||||
|
||||
class Langermann(Benchmark):
|
||||
|
||||
r"""
|
||||
Langermann objective function.
|
||||
|
||||
This class defines the Langermann [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Langermann}}(x) = - \sum_{i=1}^{5}
|
||||
\frac{c_i \cos\left\{\pi \left[\left(x_{1}- a_i\right)^{2}
|
||||
+ \left(x_{2} - b_i \right)^{2}\right]\right\}}{e^{\frac{\left( x_{1}
|
||||
- a_i\right)^{2} + \left( x_{2} - b_i\right)^{2}}{\pi}}}
|
||||
|
||||
|
||||
Where:
|
||||
|
||||
.. math::
|
||||
|
||||
\begin{matrix}
|
||||
a = [3, 5, 2, 1, 7]\\
|
||||
b = [5, 2, 1, 4, 9]\\
|
||||
c = [1, 2, 5, 2, 3] \\
|
||||
\end{matrix}
|
||||
|
||||
|
||||
Here :math:`x_i \in [0, 10]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = -5.1621259`
|
||||
for :math:`x = [2.00299219, 1.006096]`
|
||||
|
||||
.. [1] Gavana, A. Global Optimization Benchmarks and AMPGO retrieved 2015
|
||||
|
||||
TODO: Langermann from Gavana is _not the same_ as Jamil #68.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([0.0] * self.N, [10.0] * self.N))
|
||||
|
||||
self.global_optimum = [[2.00299219, 1.006096]]
|
||||
self.fglob = -5.1621259
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
a = [3, 5, 2, 1, 7]
|
||||
b = [5, 2, 1, 4, 9]
|
||||
c = [1, 2, 5, 2, 3]
|
||||
|
||||
return (-sum(c * exp(-(1 / pi) * ((x[0] - a) ** 2 +
|
||||
(x[1] - b) ** 2)) * cos(pi * ((x[0] - a) ** 2
|
||||
+ (x[1] - b) ** 2))))
|
||||
|
||||
|
||||
class LennardJones(Benchmark):
|
||||
|
||||
r"""
|
||||
LennardJones objective function.
|
||||
|
||||
This class defines the Lennard-Jones global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{LennardJones}}(\mathbf{x}) = \sum_{i=0}^{n-2}\sum_{j>1}^{n-1}
|
||||
\frac{1}{r_{ij}^{12}} - \frac{1}{r_{ij}^{6}}
|
||||
|
||||
|
||||
Where, in this exercise:
|
||||
|
||||
.. math::
|
||||
|
||||
r_{ij} = \sqrt{(x_{3i}-x_{3j})^2 + (x_{3i+1}-x_{3j+1})^2)
|
||||
+ (x_{3i+2}-x_{3j+2})^2}
|
||||
|
||||
|
||||
Valid for any dimension, :math:`n = 3*k, k=2 , 3, 4, ..., 20`. :math:`k`
|
||||
is the number of atoms in 3-D space constraints: unconstrained type:
|
||||
multi-modal with one global minimum; non-separable
|
||||
|
||||
Value-to-reach: :math:`minima[k-2] + 0.0001`. See array of minima below;
|
||||
additional minima available at the Cambridge cluster database:
|
||||
|
||||
http://www-wales.ch.cam.ac.uk/~jon/structures/LJ/tables.150.html
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and
|
||||
:math:`x_i \in [-4, 4]` for :math:`i = 1 ,..., n`.
|
||||
|
||||
*Global optimum*:
|
||||
|
||||
.. math::
|
||||
|
||||
\text{minima} = [-1.,-3.,-6.,-9.103852,-12.712062,-16.505384,\\
|
||||
-19.821489, -24.113360, -28.422532,-32.765970,\\
|
||||
-37.967600,-44.326801, -47.845157,-52.322627,\\
|
||||
-56.815742,-61.317995, -66.530949, -72.659782,\\
|
||||
-77.1777043]\\
|
||||
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=6):
|
||||
# dimensions is in [6:60]
|
||||
# max dimensions is going to be 60.
|
||||
if dimensions not in range(6, 61):
|
||||
raise ValueError("LJ dimensions must be in (6, 60)")
|
||||
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-4.0] * self.N, [4.0] * self.N))
|
||||
|
||||
self.global_optimum = [[]]
|
||||
|
||||
self.minima = [-1.0, -3.0, -6.0, -9.103852, -12.712062,
|
||||
-16.505384, -19.821489, -24.113360, -28.422532,
|
||||
-32.765970, -37.967600, -44.326801, -47.845157,
|
||||
-52.322627, -56.815742, -61.317995, -66.530949,
|
||||
-72.659782, -77.1777043]
|
||||
|
||||
k = int(dimensions / 3)
|
||||
self.fglob = self.minima[k - 2]
|
||||
self.change_dimensionality = True
|
||||
|
||||
def change_dimensions(self, ndim):
|
||||
if ndim not in range(6, 61):
|
||||
raise ValueError("LJ dimensions must be in (6, 60)")
|
||||
|
||||
Benchmark.change_dimensions(self, ndim)
|
||||
self.fglob = self.minima[int(self.N / 3) - 2]
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
k = int(self.N / 3)
|
||||
s = 0.0
|
||||
|
||||
for i in range(k - 1):
|
||||
for j in range(i + 1, k):
|
||||
a = 3 * i
|
||||
b = 3 * j
|
||||
xd = x[a] - x[b]
|
||||
yd = x[a + 1] - x[b + 1]
|
||||
zd = x[a + 2] - x[b + 2]
|
||||
ed = xd * xd + yd * yd + zd * zd
|
||||
ud = ed * ed * ed
|
||||
if ed > 0.0:
|
||||
s += (1.0 / ud - 2.0) / ud
|
||||
|
||||
return s
|
||||
|
||||
|
||||
class Leon(Benchmark):
|
||||
|
||||
r"""
|
||||
Leon objective function.
|
||||
|
||||
This class defines the Leon [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Leon}}(\mathbf{x}) = \left(1 - x_{1}\right)^{2}
|
||||
+ 100 \left(x_{2} - x_{1}^{2} \right)^{2}
|
||||
|
||||
|
||||
with :math:`x_i \in [-1.2, 1.2]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x = [1, 1]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-1.2] * self.N, [1.2] * self.N))
|
||||
|
||||
self.global_optimum = [[1 for _ in range(self.N)]]
|
||||
self.fglob = 0.0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return 100. * (x[1] - x[0] ** 2.0) ** 2.0 + (1 - x[0]) ** 2.0
|
||||
|
||||
|
||||
class Levy03(Benchmark):
|
||||
|
||||
r"""
|
||||
Levy 3 objective function.
|
||||
|
||||
This class defines the Levy 3 [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Levy03}}(\mathbf{x}) = \sin^2(\pi y_1)+\sum_{i=1}^{n-1}(y_i-1)^2[1+10\sin^2(\pi y_{i+1})]+(y_n-1)^2
|
||||
|
||||
Where, in this exercise:
|
||||
|
||||
.. math::
|
||||
|
||||
y_i=1+\frac{x_i-1}{4}
|
||||
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and :math:`x_i \in [-10, 10]` for :math:`i=1,...,n`.
|
||||
|
||||
*Global optimum*: :math:`f(x_i) = 0` for :math:`x_i = 1` for :math:`i=1,...,n`
|
||||
|
||||
.. [1] Mishra, S. Global Optimization by Differential Evolution and
|
||||
Particle Swarm Methods: Evaluation on Some Benchmark Functions.
|
||||
Munich Personal RePEc Archive, 2006, 1005
|
||||
|
||||
TODO: not clear what the Levy function definition is. Gavana, Mishra,
|
||||
Adorio have different forms. Indeed Levy 3 docstring from Gavana
|
||||
disagrees with the Gavana code! The following code is from the Mishra
|
||||
listing of Levy08.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-10.0] * self.N, [10.0] * self.N))
|
||||
self.custom_bounds = [(-5, 5), (-5, 5)]
|
||||
|
||||
self.global_optimum = [[1 for _ in range(self.N)]]
|
||||
self.fglob = 0.0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
y = 1 + (x - 1) / 4
|
||||
v = sum((y[:-1] - 1) ** 2 * (1 + 10 * sin(pi * y[1:]) ** 2))
|
||||
z = (y[-1] - 1) ** 2
|
||||
return sin(pi * y[0]) ** 2 + v + z
|
||||
|
||||
|
||||
class Levy05(Benchmark):
|
||||
|
||||
r"""
|
||||
Levy 5 objective function.
|
||||
|
||||
This class defines the Levy 5 [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Levy05}}(\mathbf{x}) = \sum_{i=1}^{5} i \cos \left[(i-1)x_1 + i \right] \times \sum_{j=1}^{5} j \cos \left[(j+1)x_2 + j \right] + (x_1 + 1.42513)^2 + (x_2 + 0.80032)^2
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and :math:`x_i \in [-10, 10]` for :math:`i=1,...,n`.
|
||||
|
||||
*Global optimum*: :math:`f(x_i) = -176.1375779` for :math:`\mathbf{x} = [-1.30685, -1.42485]`.
|
||||
|
||||
.. [1] Mishra, S. Global Optimization by Differential Evolution and
|
||||
Particle Swarm Methods: Evaluation on Some Benchmark Functions.
|
||||
Munich Personal RePEc Archive, 2006, 1005
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-10.0] * self.N, [10.0] * self.N))
|
||||
self.custom_bounds = ([-2.0, 2.0], [-2.0, 2.0])
|
||||
|
||||
self.global_optimum = [[-1.30685, -1.42485]]
|
||||
self.fglob = -176.1375779
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
i = arange(1, 6)
|
||||
a = i * cos((i - 1) * x[0] + i)
|
||||
b = i * cos((i + 1) * x[1] + i)
|
||||
|
||||
return sum(a) * sum(b) + (x[0] + 1.42513) ** 2 + (x[1] + 0.80032) ** 2
|
||||
|
||||
|
||||
class Levy13(Benchmark):
|
||||
|
||||
r"""
|
||||
Levy13 objective function.
|
||||
|
||||
This class defines the Levy13 [1]_ global optimization problem. This is a
|
||||
multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Levy13}}(x) = \left(x_{1} -1\right)^{2} \left[\sin^{2}
|
||||
\left(3 \pi x_{2}\right) + 1\right] + \left(x_{2}
|
||||
- 1\right)^{2} \left[\sin^{2}\left(2 \pi x_{2}\right)
|
||||
+ 1\right] + \sin^{2}\left(3 \pi x_{1}\right)
|
||||
|
||||
|
||||
with :math:`x_i \in [-10, 10]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x = [1, 1]`
|
||||
|
||||
.. [1] Mishra, S. Some new test functions for global optimization and
|
||||
performance of repulsive particle swarm method.
|
||||
Munich Personal RePEc Archive, 2006, 2718
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-10.0] * self.N, [10.0] * self.N))
|
||||
self.custom_bounds = [(-5, 5), (-5, 5)]
|
||||
|
||||
self.global_optimum = [[1 for _ in range(self.N)]]
|
||||
self.fglob = 0.0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
u = sin(3 * pi * x[0]) ** 2
|
||||
v = (x[0] - 1) ** 2 * (1 + (sin(3 * pi * x[1])) ** 2)
|
||||
w = (x[1] - 1) ** 2 * (1 + (sin(2 * pi * x[1])) ** 2)
|
||||
return u + v + w
|
719
go_benchmark_functions/go_funcs_M.py
Normal file
719
go_benchmark_functions/go_funcs_M.py
Normal file
|
@ -0,0 +1,719 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from numpy import (abs, asarray, cos, exp, log, arange, pi, prod, sin, sqrt,
|
||||
sum, tan)
|
||||
from .go_benchmark import Benchmark, safe_import
|
||||
|
||||
with safe_import():
|
||||
from scipy.special import factorial
|
||||
|
||||
|
||||
class Matyas(Benchmark):
|
||||
|
||||
r"""
|
||||
Matyas objective function.
|
||||
|
||||
This class defines the Matyas [1]_ global optimization problem. This is a
|
||||
multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Matyas}}(x) = 0.26(x_1^2 + x_2^2) - 0.48 x_1 x_2
|
||||
|
||||
|
||||
with :math:`x_i \in [-10, 10]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x = [0, 0]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-10.0] * self.N, [10.0] * self.N))
|
||||
|
||||
self.global_optimum = [[0 for _ in range(self.N)]]
|
||||
self.fglob = 0.0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return 0.26 * (x[0] ** 2 + x[1] ** 2) - 0.48 * x[0] * x[1]
|
||||
|
||||
|
||||
class McCormick(Benchmark):
|
||||
|
||||
r"""
|
||||
McCormick objective function.
|
||||
|
||||
This class defines the McCormick [1]_ global optimization problem. This is a
|
||||
multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{McCormick}}(x) = - x_{1} + 2 x_{2} + \left(x_{1}
|
||||
- x_{2}\right)^{2} + \sin\left(x_{1} + x_{2}\right) + 1
|
||||
|
||||
with :math:`x_1 \in [-1.5, 4]`, :math:`x_2 \in [-3, 4]`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = -1.913222954981037` for
|
||||
:math:`x = [-0.5471975602214493, -1.547197559268372]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = [(-1.5, 4.0), (-3.0, 3.0)]
|
||||
|
||||
self.global_optimum = [[-0.5471975602214493, -1.547197559268372]]
|
||||
self.fglob = -1.913222954981037
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return (sin(x[0] + x[1]) + (x[0] - x[1]) ** 2 - 1.5 * x[0]
|
||||
+ 2.5 * x[1] + 1)
|
||||
|
||||
|
||||
class Meyer(Benchmark):
|
||||
|
||||
r"""
|
||||
Meyer [1]_ objective function.
|
||||
|
||||
..[1] https://www.itl.nist.gov/div898/strd/nls/data/mgh10.shtml
|
||||
|
||||
TODO NIST regression standard
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=3):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([0., 100., 100.],
|
||||
[1, 1000., 500.]))
|
||||
self.global_optimum = [[5.6096364710e-3, 6.1813463463e3,
|
||||
3.4522363462e2]]
|
||||
self.fglob = 8.7945855171e1
|
||||
self.a = asarray([3.478E+04, 2.861E+04, 2.365E+04, 1.963E+04, 1.637E+04,
|
||||
1.372E+04, 1.154E+04, 9.744E+03, 8.261E+03, 7.030E+03,
|
||||
6.005E+03, 5.147E+03, 4.427E+03, 3.820E+03, 3.307E+03,
|
||||
2.872E+03])
|
||||
self.b = asarray([5.000E+01, 5.500E+01, 6.000E+01, 6.500E+01, 7.000E+01,
|
||||
7.500E+01, 8.000E+01, 8.500E+01, 9.000E+01, 9.500E+01,
|
||||
1.000E+02, 1.050E+02, 1.100E+02, 1.150E+02, 1.200E+02,
|
||||
1.250E+02])
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
vec = x[0] * exp(x[1] / (self.b + x[2]))
|
||||
return sum((self.a - vec) ** 2)
|
||||
|
||||
|
||||
class Michalewicz(Benchmark):
|
||||
|
||||
r"""
|
||||
Michalewicz objective function.
|
||||
|
||||
This class defines the Michalewicz [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Michalewicz}}(x) = - \sum_{i=1}^{2} \sin\left(x_i\right)
|
||||
\sin^{2 m}\left(\frac{i x_i^{2}}{\pi}\right)
|
||||
|
||||
|
||||
Where, in this exercise, :math:`m = 10`.
|
||||
|
||||
with :math:`x_i \in [0, \pi]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x_i) = -1.8013` for :math:`x = [0, 0]`
|
||||
|
||||
.. [1] Adorio, E. MVF - "Multivariate Test Functions Library in C for
|
||||
Unconstrained Global Optimization", 2005
|
||||
|
||||
TODO: could change dimensionality, but global minimum might change.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([0.0] * self.N, [pi] * self.N))
|
||||
|
||||
self.global_optimum = [[2.20290555, 1.570796]]
|
||||
self.fglob = -1.8013
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
m = 10.0
|
||||
i = arange(1, self.N + 1)
|
||||
return -sum(sin(x) * sin(i * x ** 2 / pi) ** (2 * m))
|
||||
|
||||
|
||||
class MieleCantrell(Benchmark):
|
||||
|
||||
r"""
|
||||
Miele-Cantrell [1]_ objective function.
|
||||
|
||||
This class defines the Miele-Cantrell global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{MieleCantrell}}({x}) = (e^{-x_1} - x_2)^4 + 100(x_2 - x_3)^6
|
||||
+ \tan^4(x_3 - x_4) + x_1^8
|
||||
|
||||
|
||||
with :math:`x_i \in [-1, 1]` for :math:`i = 1, ..., 4`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x = [0, 1, 1, 1]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=4):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-1.0] * self.N, [1.0] * self.N))
|
||||
|
||||
self.global_optimum = [[0.0, 1.0, 1.0, 1.0]]
|
||||
self.fglob = 0.0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return ((exp(-x[0]) - x[1]) ** 4 + 100 * (x[1] - x[2]) ** 6
|
||||
+ tan(x[2] - x[3]) ** 4 + x[0] ** 8)
|
||||
|
||||
|
||||
class Mishra01(Benchmark):
|
||||
|
||||
r"""
|
||||
Mishra 1 objective function.
|
||||
|
||||
This class defines the Mishra 1 [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Mishra01}}(x) = (1 + x_n)^{x_n}
|
||||
|
||||
|
||||
where
|
||||
|
||||
.. math::
|
||||
|
||||
x_n = n - \sum_{i=1}^{n-1} x_i
|
||||
|
||||
|
||||
with :math:`x_i \in [0, 1]` for :math:`i =1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 2` for :math:`x_i = 1` for
|
||||
:math:`i = 1, ..., n`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([0.0] * self.N,
|
||||
[1.0 + 1e-9] * self.N))
|
||||
|
||||
self.global_optimum = [[1.0 for _ in range(self.N)]]
|
||||
self.fglob = 2.0
|
||||
self.change_dimensionality = True
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
xn = self.N - sum(x[0:-1])
|
||||
return (1 + xn) ** xn
|
||||
|
||||
|
||||
class Mishra02(Benchmark):
|
||||
|
||||
r"""
|
||||
Mishra 2 objective function.
|
||||
|
||||
This class defines the Mishra 2 [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Mishra02}}({x}) = (1 + x_n)^{x_n}
|
||||
|
||||
|
||||
with
|
||||
|
||||
.. math::
|
||||
|
||||
x_n = n - \sum_{i=1}^{n-1} \frac{(x_i + x_{i+1})}{2}
|
||||
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and
|
||||
:math:`x_i \in [0, 1]` for :math:`i = 1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 2` for :math:`x_i = 1`
|
||||
for :math:`i = 1, ..., n`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([0.0] * self.N,
|
||||
[1.0 + 1e-9] * self.N))
|
||||
|
||||
self.global_optimum = [[1.0 for _ in range(self.N)]]
|
||||
self.fglob = 2.0
|
||||
self.change_dimensionality = True
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
xn = self.N - sum((x[:-1] + x[1:]) / 2.0)
|
||||
return (1 + xn) ** xn
|
||||
|
||||
|
||||
class Mishra03(Benchmark):
|
||||
|
||||
r"""
|
||||
Mishra 3 objective function.
|
||||
|
||||
This class defines the Mishra 3 [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Mishra03}}(x) = \sqrt{\lvert \cos{\sqrt{\lvert x_1^2
|
||||
+ x_2^2 \rvert}} \rvert} + 0.01(x_1 + x_2)
|
||||
|
||||
|
||||
with :math:`x_i \in [-10, 10]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = -0.1999` for
|
||||
:math:`x = [-9.99378322, -9.99918927]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
|
||||
TODO: I think that Jamil#76 has the wrong global minimum, a smaller one
|
||||
is possible
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-10.0] * self.N, [10.0] * self.N))
|
||||
|
||||
self.global_optimum = [[-9.99378322, -9.99918927]]
|
||||
self.fglob = -0.19990562
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return ((0.01 * (x[0] + x[1])
|
||||
+ sqrt(abs(cos(sqrt(abs(x[0] ** 2 + x[1] ** 2)))))))
|
||||
|
||||
|
||||
class Mishra04(Benchmark):
|
||||
|
||||
r"""
|
||||
Mishra 4 objective function.
|
||||
|
||||
This class defines the Mishra 4 [1]_ global optimization problem. This is a
|
||||
multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Mishra04}}({x}) = \sqrt{\lvert \sin{\sqrt{\lvert
|
||||
x_1^2 + x_2^2 \rvert}} \rvert} + 0.01(x_1 + x_2)
|
||||
|
||||
with :math:`x_i \in [-10, 10]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = -0.17767` for
|
||||
:math:`x = [-8.71499636, -9.0533148]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
|
||||
TODO: I think that Jamil#77 has the wrong minimum, not possible
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-10.0] * self.N, [10.0] * self.N))
|
||||
|
||||
self.global_optimum = [[-8.88055269734, -8.89097599857]]
|
||||
self.fglob = -0.177715264826
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return ((0.01 * (x[0] + x[1])
|
||||
+ sqrt(abs(sin(sqrt(abs(x[0] ** 2 + x[1] ** 2)))))))
|
||||
|
||||
|
||||
class Mishra05(Benchmark):
|
||||
|
||||
r"""
|
||||
Mishra 5 objective function.
|
||||
|
||||
This class defines the Mishra 5 [1]_ global optimization problem. This is a
|
||||
multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Mishra05}}(x) = \left [ \sin^2 ((\cos(x_1) + \cos(x_2))^2)
|
||||
+ \cos^2 ((\sin(x_1) + \sin(x_2))^2) + x_1 \right ]^2 + 0.01(x_1 + x_2)
|
||||
|
||||
|
||||
with :math:`x_i \in [-10, 10]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = -0.119829` for :math:`x = [-1.98682, -10]`
|
||||
|
||||
.. [1] Mishra, S. Global Optimization by Differential Evolution and
|
||||
Particle Swarm Methods: Evaluation on Some Benchmark Functions.
|
||||
Munich Personal RePEc Archive, 2006, 1005
|
||||
|
||||
TODO Line 381 in paper
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-10.0] * self.N, [10.0] * self.N))
|
||||
|
||||
self.global_optimum = [[-1.98682, -10.0]]
|
||||
self.fglob = -1.019829519930646
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return (0.01 * x[0] + 0.1 * x[1]
|
||||
+ (sin((cos(x[0]) + cos(x[1])) ** 2) ** 2
|
||||
+ cos((sin(x[0]) + sin(x[1])) ** 2) ** 2 + x[0]) ** 2)
|
||||
|
||||
|
||||
class Mishra06(Benchmark):
|
||||
|
||||
r"""
|
||||
Mishra 6 objective function.
|
||||
|
||||
This class defines the Mishra 6 [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Mishra06}}(x) = -\log{\left [ \sin^2 ((\cos(x_1)
|
||||
+ \cos(x_2))^2) - \cos^2 ((\sin(x_1) + \sin(x_2))^2) + x_1 \right ]^2}
|
||||
+ 0.01 \left[(x_1 -1)^2 + (x_2 - 1)^2 \right]
|
||||
|
||||
|
||||
with :math:`x_i \in [-10, 10]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x_i) = -2.28395` for :math:`x = [2.88631, 1.82326]`
|
||||
|
||||
.. [1] Mishra, S. Global Optimization by Differential Evolution and
|
||||
Particle Swarm Methods: Evaluation on Some Benchmark Functions.
|
||||
Munich Personal RePEc Archive, 2006, 1005
|
||||
|
||||
TODO line 397
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-10.0] * self.N, [10.0] * self.N))
|
||||
|
||||
self.global_optimum = [[2.88631, 1.82326]]
|
||||
self.fglob = -2.28395
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
a = 0.1 * ((x[0] - 1) ** 2 + (x[1] - 1) ** 2)
|
||||
u = (cos(x[0]) + cos(x[1])) ** 2
|
||||
v = (sin(x[0]) + sin(x[1])) ** 2
|
||||
return a - log((sin(u) ** 2 - cos(v) ** 2 + x[0]) ** 2)
|
||||
|
||||
|
||||
class Mishra07(Benchmark):
|
||||
|
||||
r"""
|
||||
Mishra 7 objective function.
|
||||
|
||||
This class defines the Mishra 7 [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Mishra07}}(x) = \left [\prod_{i=1}^{n} x_i - n! \right]^2
|
||||
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and
|
||||
:math:`x_i \in [-10, 10]` for :math:`i = 1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x_i = \sqrt{n}`
|
||||
for :math:`i = 1, ..., n`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-10.0] * self.N, [10.0] * self.N))
|
||||
self.custom_bounds = [(-2, 2), (-2, 2)]
|
||||
self.global_optimum = [[sqrt(self.N)
|
||||
for i in range(self.N)]]
|
||||
self.fglob = 0.0
|
||||
self.change_dimensionality = True
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return (prod(x) - factorial(self.N)) ** 2.0
|
||||
|
||||
|
||||
class Mishra08(Benchmark):
|
||||
|
||||
r"""
|
||||
Mishra 8 objective function.
|
||||
|
||||
This class defines the Mishra 8 [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Mishra08}}(x) = 0.001 \left[\lvert x_1^{10} - 20x_1^9
|
||||
+ 180x_1^8 - 960 x_1^7 + 3360x_1^6 - 8064x_1^5 + 13340x_1^4 - 15360x_1^3
|
||||
+ 11520x_1^2 - 5120x_1 + 2624 \rvert \lvert x_2^4 + 12x_2^3 + 54x_2^2
|
||||
+ 108x_2 + 81 \rvert \right]^2
|
||||
|
||||
|
||||
with :math:`x_i \in [-10, 10]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x = [2, -3]`
|
||||
|
||||
.. [1] Mishra, S. Global Optimization by Differential Evolution and
|
||||
Particle Swarm Methods: Evaluation on Some Benchmark Functions.
|
||||
Munich Personal RePEc Archive, 2006, 1005
|
||||
|
||||
TODO Line 1065
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-10.0] * self.N, [10.0] * self.N))
|
||||
self.custom_bounds = [(1.0, 2.0), (-4.0, 1.0)]
|
||||
self.global_optimum = [[2.0, -3.0]]
|
||||
self.fglob = 0.0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
val = abs(x[0] ** 10 - 20 * x[0] ** 9 + 180 * x[0] ** 8
|
||||
- 960 * x[0] ** 7 + 3360 * x[0] ** 6 - 8064 * x[0] ** 5
|
||||
+ 13340 * x[0] ** 4 - 15360 * x[0] ** 3 + 11520 * x[0] ** 2
|
||||
- 5120 * x[0] + 2624)
|
||||
val += abs(x[1] ** 4 + 12 * x[1] ** 3 +
|
||||
54 * x[1] ** 2 + 108 * x[1] + 81)
|
||||
return 0.001 * val ** 2
|
||||
|
||||
|
||||
class Mishra09(Benchmark):
|
||||
|
||||
r"""
|
||||
Mishra 9 objective function.
|
||||
|
||||
This class defines the Mishra 9 [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Mishra09}}({x}) = \left[ ab^2c + abc^2 + b^2
|
||||
+ (x_1 + x_2 - x_3)^2 \right]^2
|
||||
|
||||
|
||||
Where, in this exercise:
|
||||
|
||||
.. math::
|
||||
|
||||
\begin{cases} a = 2x_1^3 + 5x_1x_2 + 4x_3 - 2x_1^2x_3 - 18 \\
|
||||
b = x_1 + x_2^3 + x_1x_2^2 + x_1x_3^2 - 22 \\
|
||||
c = 8x_1^2 + 2x_2x_3 + 2x_2^2 + 3x_2^3 - 52 \end{cases}
|
||||
|
||||
|
||||
with :math:`x_i \in [-10, 10]` for :math:`i = 1, 2, 3`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x = [1, 2, 3]`
|
||||
|
||||
.. [1] Mishra, S. Global Optimization by Differential Evolution and
|
||||
Particle Swarm Methods: Evaluation on Some Benchmark Functions.
|
||||
Munich Personal RePEc Archive, 2006, 1005
|
||||
|
||||
TODO Line 1103
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=3):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-10.0] * self.N, [10.0] * self.N))
|
||||
self.global_optimum = [[1.0, 2.0, 3.0]]
|
||||
self.fglob = 0.0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
a = (2 * x[0] ** 3 + 5 * x[0] * x[1]
|
||||
+ 4 * x[2] - 2 * x[0] ** 2 * x[2] - 18)
|
||||
b = x[0] + x[1] ** 3 + x[0] * x[1] ** 2 + x[0] * x[2] ** 2 - 22.0
|
||||
c = (8 * x[0] ** 2 + 2 * x[1] * x[2]
|
||||
+ 2 * x[1] ** 2 + 3 * x[1] ** 3 - 52)
|
||||
|
||||
return (a * c * b ** 2 + a * b * c ** 2 + b ** 2
|
||||
+ (x[0] + x[1] - x[2]) ** 2) ** 2
|
||||
|
||||
|
||||
class Mishra10(Benchmark):
|
||||
|
||||
r"""
|
||||
Mishra 10 objective function.
|
||||
|
||||
This class defines the Mishra 10 global optimization problem. This is a
|
||||
multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
TODO - int(x) should be used instead of floor(x)!!!!!
|
||||
f_{\text{Mishra10}}({x}) = \left[ \lfloor x_1 \perp x_2 \rfloor -
|
||||
\lfloor x_1 \rfloor - \lfloor x_2 \rfloor \right]^2
|
||||
|
||||
with :math:`x_i \in [-10, 10]` for :math:`i =1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x = [2, 2]`
|
||||
|
||||
.. [1] Mishra, S. Global Optimization by Differential Evolution and
|
||||
Particle Swarm Methods: Evaluation on Some Benchmark Functions.
|
||||
Munich Personal RePEc Archive, 2006, 1005
|
||||
|
||||
TODO line 1115
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-10.0] * self.N, [10.0] * self.N))
|
||||
self.global_optimum = [[2.0, 2.0]]
|
||||
self.fglob = 0.0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
x1, x2 = int(x[0]), int(x[1])
|
||||
f1 = x1 + x2
|
||||
f2 = x1 * x2
|
||||
return (f1 - f2) ** 2.0
|
||||
|
||||
|
||||
class Mishra11(Benchmark):
|
||||
|
||||
r"""
|
||||
Mishra 11 objective function.
|
||||
|
||||
This class defines the Mishra 11 [1]_ global optimization problem. This is a
|
||||
multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Mishra11}}(x) = \left [ \frac{1}{n} \sum_{i=1}^{n} \lvert x_i
|
||||
\rvert - \left(\prod_{i=1}^{n} \lvert x_i \rvert \right )^{\frac{1}{n}}
|
||||
\right]^2
|
||||
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and
|
||||
:math:`x_i \in [-10, 10]` for :math:`i = 1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x_i = 0` for
|
||||
:math:`i = 1, ..., n`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-10.0] * self.N, [10.0] * self.N))
|
||||
self.custom_bounds = [(-3, 3), (-3, 3)]
|
||||
|
||||
self.global_optimum = [[0.0 for _ in range(self.N)]]
|
||||
self.fglob = 0.0
|
||||
self.change_dimensionality = True
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
N = self.N
|
||||
return ((1.0 / N) * sum(abs(x)) - (prod(abs(x))) ** 1.0 / N) ** 2.0
|
||||
|
||||
|
||||
class MultiModal(Benchmark):
|
||||
|
||||
r"""
|
||||
MultiModal objective function.
|
||||
|
||||
This class defines the MultiModal global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{MultiModal}}(x) = \left( \sum_{i=1}^n \lvert x_i \rvert
|
||||
\right) \left( \prod_{i=1}^n \lvert x_i \rvert \right)
|
||||
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and
|
||||
:math:`x_i \in [-10, 10]` for :math:`i = 1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x_i = 0` for
|
||||
:math:`i = 1, ..., n`
|
||||
|
||||
.. [1] Gavana, A. Global Optimization Benchmarks and AMPGO retrieved 2015
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-10.0] * self.N, [10.0] * self.N))
|
||||
self.custom_bounds = [(-5, 5), (-5, 5)]
|
||||
|
||||
self.global_optimum = [[0.0 for _ in range(self.N)]]
|
||||
self.fglob = 0.0
|
||||
self.change_dimensionality = True
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return sum(abs(x)) * prod(abs(x))
|
149
go_benchmark_functions/go_funcs_N.py
Normal file
149
go_benchmark_functions/go_funcs_N.py
Normal file
|
@ -0,0 +1,149 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from numpy import cos, sqrt, sin, abs
|
||||
from .go_benchmark import Benchmark
|
||||
|
||||
|
||||
class NeedleEye(Benchmark):
|
||||
|
||||
r"""
|
||||
NeedleEye objective function.
|
||||
|
||||
This class defines the Needle-Eye [1]_ global optimization problem. This is a
|
||||
a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{NeedleEye}}(x) =
|
||||
\begin{cases}
|
||||
1 & \textrm{if }\hspace{5pt} \lvert x_i \rvert < eye \hspace{5pt}
|
||||
\forall i \\
|
||||
\sum_{i=1}^n (100 + \lvert x_i \rvert) & \textrm{if } \hspace{5pt}
|
||||
\lvert x_i \rvert > eye \\
|
||||
0 & \textrm{otherwise}\\
|
||||
\end{cases}
|
||||
|
||||
|
||||
Where, in this exercise, :math:`eye = 0.0001`.
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and
|
||||
:math:`x_i \in [-10, 10]` for :math:`i = 1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 1` for :math:`x_i = 0` for
|
||||
:math:`i = 1, ..., n`
|
||||
|
||||
.. [1] Gavana, A. Global Optimization Benchmarks and AMPGO retrieved 2015
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-10.0] * self.N, [10.0] * self.N))
|
||||
|
||||
self.global_optimum = [[0.0 for _ in range(self.N)]]
|
||||
self.fglob = 1.0
|
||||
self.change_dimensionality = True
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
f = fp = 0.0
|
||||
eye = 0.0001
|
||||
|
||||
for val in x:
|
||||
if abs(val) >= eye:
|
||||
fp = 1.0
|
||||
f += 100.0 + abs(val)
|
||||
else:
|
||||
f += 1.0
|
||||
|
||||
if fp < 1e-6:
|
||||
f = f / self.N
|
||||
|
||||
return f
|
||||
|
||||
|
||||
class NewFunction01(Benchmark):
|
||||
|
||||
r"""
|
||||
NewFunction01 objective function.
|
||||
|
||||
This class defines the NewFunction01 [1]_ global optimization problem. This is a
|
||||
multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{NewFunction01}}(x) = \left | {\cos\left(\sqrt{\left|{x_{1}^{2}
|
||||
+ x_{2}}\right|}\right)} \right |^{0.5} + (x_{1} + x_{2})/100
|
||||
|
||||
|
||||
with :math:`x_i \in [-10, 10]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = -0.18459899925` for
|
||||
:math:`x = [-8.46669057, -9.99982177]`
|
||||
|
||||
.. [1] Mishra, S. Global Optimization by Differential Evolution and
|
||||
Particle Swarm Methods: Evaluation on Some Benchmark Functions.
|
||||
Munich Personal RePEc Archive, 2006, 1005
|
||||
|
||||
TODO line 355
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-10.0] * self.N, [10.0] * self.N))
|
||||
|
||||
self.global_optimum = [[-8.46668984648, -9.99980944557]]
|
||||
self.fglob = -0.184648852475
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return ((abs(cos(sqrt(abs(x[0] ** 2 + x[1]))))) ** 0.5
|
||||
+ 0.01 * (x[0] + x[1]))
|
||||
|
||||
|
||||
class NewFunction02(Benchmark):
|
||||
|
||||
r"""
|
||||
NewFunction02 objective function.
|
||||
|
||||
This class defines the NewFunction02 global optimization problem. This is a
|
||||
multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{NewFunction02}}(x) = \left | {\sin\left(\sqrt{\lvert{x_{1}^{2}
|
||||
+ x_{2}}\rvert}\right)} \right |^{0.5} + (x_{1} + x_{2})/100
|
||||
|
||||
|
||||
with :math:`x_i \in [-10, 10]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = -0.19933159253` for
|
||||
:math:`x = [-9.94103375, -9.99771235]`
|
||||
|
||||
.. [1] Mishra, S. Global Optimization by Differential Evolution and
|
||||
Particle Swarm Methods: Evaluation on Some Benchmark Functions.
|
||||
Munich Personal RePEc Archive, 2006, 1005
|
||||
|
||||
TODO Line 368
|
||||
TODO WARNING, minimum value is estimated from running many optimisations and
|
||||
choosing the best.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-10.0] * self.N, [10.0] * self.N))
|
||||
|
||||
self.global_optimum = [[-9.94114736324, -9.99997128772]]
|
||||
self.fglob = -0.199409030092
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return ((abs(sin(sqrt(abs(x[0] ** 2 + x[1]))))) ** 0.5
|
||||
+ 0.01 * (x[0] + x[1]))
|
||||
|
||||
|
||||
#Newfunction 3 from Gavana is entered as Mishra05.
|
62
go_benchmark_functions/go_funcs_O.py
Normal file
62
go_benchmark_functions/go_funcs_O.py
Normal file
|
@ -0,0 +1,62 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from numpy import sum, cos, exp, pi, asarray
|
||||
from .go_benchmark import Benchmark
|
||||
|
||||
|
||||
class OddSquare(Benchmark):
|
||||
|
||||
r"""
|
||||
Odd Square objective function.
|
||||
|
||||
This class defines the Odd Square [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{OddSquare}}(x) = -e^{-\frac{d}{2\pi}} \cos(\pi d)
|
||||
\left( 1 + \frac{0.02h}{d + 0.01} \right )
|
||||
|
||||
|
||||
Where, in this exercise:
|
||||
|
||||
.. math::
|
||||
|
||||
\begin{cases}
|
||||
d = n \cdot \smash{\displaystyle\max_{1 \leq i \leq n}}
|
||||
\left[ (x_i - b_i)^2 \right ] \\
|
||||
h = \sum_{i=1}^{n} (x_i - b_i)^2
|
||||
\end{cases}
|
||||
|
||||
And :math:`b = [1, 1.3, 0.8, -0.4, -1.3, 1.6, -0.2, -0.6, 0.5, 1.4, 1, 1.3,
|
||||
0.8, -0.4, -1.3, 1.6, -0.2, -0.6, 0.5, 1.4]`
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and
|
||||
:math:`x_i \in [-5 \pi, 5 \pi]` for :math:`i = 1, ..., n` and
|
||||
:math:`n \leq 20`.
|
||||
|
||||
*Global optimum*: :math:`f(x_i) = -1.0084` for :math:`x \approx b`
|
||||
|
||||
.. [1] Gavana, A. Global Optimization Benchmarks and AMPGO retrieved 2015
|
||||
|
||||
TODO The best solution changes on dimensionality
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-5.0 * pi] * self.N,
|
||||
[5.0 * pi] * self.N))
|
||||
self.custom_bounds = ([-2.0, 4.0], [-2.0, 4.0])
|
||||
self.a = asarray([1, 1.3, 0.8, -0.4, -1.3, 1.6, -0.2, -0.6, 0.5, 1.4]
|
||||
* 2)
|
||||
self.global_optimum = [[1.0873320463871847, 1.3873320456818079]]
|
||||
|
||||
self.fglob = -1.00846728102
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
b = self.a[0: self.N]
|
||||
d = self.N * max((x - b) ** 2.0)
|
||||
h = sum((x - b) ** 2.0)
|
||||
return (-exp(-d / (2.0 * pi)) * cos(pi * d)
|
||||
* (1.0 + 0.02 * h / (d + 0.01)))
|
726
go_benchmark_functions/go_funcs_P.py
Normal file
726
go_benchmark_functions/go_funcs_P.py
Normal file
|
@ -0,0 +1,726 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from numpy import (abs, sum, sin, cos, sqrt, log, prod, where, pi, exp, arange,
|
||||
floor, log10, atleast_2d, zeros)
|
||||
from .go_benchmark import Benchmark
|
||||
|
||||
|
||||
class Parsopoulos(Benchmark):
|
||||
|
||||
r"""
|
||||
Parsopoulos objective function.
|
||||
|
||||
This class defines the Parsopoulos [1]_ global optimization problem. This is a
|
||||
multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Parsopoulos}}(x) = \cos(x_1)^2 + \sin(x_2)^2
|
||||
|
||||
|
||||
with :math:`x_i \in [-5, 5]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: This function has infinite number of global minima in R2,
|
||||
at points :math:`\left(k\frac{\pi}{2}, \lambda \pi \right)`,
|
||||
where :math:`k = \pm1, \pm3, ...` and :math:`\lambda = 0, \pm1, \pm2, ...`
|
||||
|
||||
In the given domain problem, function has 12 global minima all equal to
|
||||
zero.
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-5.0] * self.N, [5.0] * self.N))
|
||||
|
||||
self.global_optimum = [[pi / 2.0, pi]]
|
||||
self.fglob = 0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return cos(x[0]) ** 2.0 + sin(x[1]) ** 2.0
|
||||
|
||||
|
||||
class Pathological(Benchmark):
|
||||
|
||||
r"""
|
||||
Pathological objective function.
|
||||
|
||||
This class defines the Pathological [1]_ global optimization problem. This is a
|
||||
multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Pathological}}(x) = \sum_{i=1}^{n -1} \frac{\sin^{2}\left(
|
||||
\sqrt{100 x_{i+1}^{2} + x_{i}^{2}}\right) -0.5}{0.001 \left(x_{i}^{2}
|
||||
- 2x_{i}x_{i+1} + x_{i+1}^{2}\right)^{2} + 0.50}
|
||||
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and
|
||||
:math:`x_i \in [-100, 100]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0.` for :math:`x = [0, 0]` for
|
||||
:math:`i = 1, 2`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-100.0] * self.N,
|
||||
[100.0] * self.N))
|
||||
|
||||
self.global_optimum = [[0 for _ in range(self.N)]]
|
||||
self.fglob = 0.
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
vec = (0.5 + (sin(sqrt(100 * x[: -1] ** 2 + x[1:] ** 2)) ** 2 - 0.5) /
|
||||
(1. + 0.001 * (x[: -1] ** 2 - 2 * x[: -1] * x[1:]
|
||||
+ x[1:] ** 2) ** 2))
|
||||
return sum(vec)
|
||||
|
||||
|
||||
class Paviani(Benchmark):
|
||||
|
||||
r"""
|
||||
Paviani objective function.
|
||||
|
||||
This class defines the Paviani [1]_ global optimization problem. This is a
|
||||
multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Paviani}}(x) = \sum_{i=1}^{10} \left[\log^{2}\left(10
|
||||
- x_i\right) + \log^{2}\left(x_i -2\right)\right]
|
||||
- \left(\prod_{i=1}^{10} x_i^{10} \right)^{0.2}
|
||||
|
||||
|
||||
with :math:`x_i \in [2.001, 9.999]` for :math:`i = 1, ... , 10`.
|
||||
|
||||
*Global optimum*: :math:`f(x_i) = -45.7784684040686` for
|
||||
:math:`x_i = 9.350266` for :math:`i = 1, ..., 10`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
|
||||
TODO: think Gavana web/code definition is wrong because final product term
|
||||
shouldn't raise x to power 10.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=10):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([2.001] * self.N, [9.999] * self.N))
|
||||
|
||||
self.global_optimum = [[9.350266 for _ in range(self.N)]]
|
||||
self.fglob = -45.7784684040686
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return sum(log(x - 2) ** 2.0 + log(10.0 - x) ** 2.0) - prod(x) ** 0.2
|
||||
|
||||
|
||||
class Penalty01(Benchmark):
|
||||
|
||||
r"""
|
||||
Penalty 1 objective function.
|
||||
|
||||
This class defines the Penalty 1 [1]_ global optimization problem. This is a
|
||||
imultimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Penalty01}}(x) = \frac{\pi}{30} \left\{10 \sin^2(\pi y_1)
|
||||
+ \sum_{i=1}^{n-1} (y_i - 1)^2 \left[1 + 10 \sin^2(\pi y_{i+1}) \right]
|
||||
+ (y_n - 1)^2 \right \} + \sum_{i=1}^n u(x_i, 10, 100, 4)
|
||||
|
||||
|
||||
Where, in this exercise:
|
||||
|
||||
.. math::
|
||||
|
||||
y_i = 1 + \frac{1}{4}(x_i + 1)
|
||||
|
||||
|
||||
And:
|
||||
|
||||
.. math::
|
||||
|
||||
u(x_i, a, k, m) =
|
||||
\begin{cases}
|
||||
k(x_i - a)^m & \textrm{if} \hspace{5pt} x_i > a \\
|
||||
0 & \textrm{if} \hspace{5pt} -a \leq x_i \leq a \\
|
||||
k(-x_i - a)^m & \textrm{if} \hspace{5pt} x_i < -a
|
||||
\end{cases}
|
||||
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and
|
||||
:math:`x_i \in [-50, 50]` for :math:`i= 1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x_i = -1` for
|
||||
:math:`i = 1, ..., n`
|
||||
|
||||
.. [1] Gavana, A. Global Optimization Benchmarks and AMPGO retrieved 2015
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-50.0] * self.N, [50.0] * self.N))
|
||||
self.custom_bounds = ([-5.0, 5.0], [-5.0, 5.0])
|
||||
|
||||
self.global_optimum = [[-1.0 for _ in range(self.N)]]
|
||||
self.fglob = 0.0
|
||||
self.change_dimensionality = True
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
a, b, c = 10.0, 100.0, 4.0
|
||||
|
||||
xx = abs(x)
|
||||
u = where(xx > a, b * (xx - a) ** c, 0.0)
|
||||
|
||||
y = 1.0 + (x + 1.0) / 4.0
|
||||
|
||||
return (sum(u) + (pi / 30.0) * (10.0 * sin(pi * y[0]) ** 2.0
|
||||
+ sum((y[: -1] - 1.0) ** 2.0
|
||||
* (1.0 + 10.0 * sin(pi * y[1:]) ** 2.0))
|
||||
+ (y[-1] - 1) ** 2.0))
|
||||
|
||||
|
||||
class Penalty02(Benchmark):
|
||||
|
||||
r"""
|
||||
Penalty 2 objective function.
|
||||
|
||||
This class defines the Penalty 2 [1]_ global optimization problem. This is a
|
||||
multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Penalty02}}(x) = 0.1 \left\{\sin^2(3\pi x_1) + \sum_{i=1}^{n-1}
|
||||
(x_i - 1)^2 \left[1 + \sin^2(3\pi x_{i+1}) \right ]
|
||||
+ (x_n - 1)^2 \left [1 + \sin^2(2 \pi x_n) \right ]\right \}
|
||||
+ \sum_{i=1}^n u(x_i, 5, 100, 4)
|
||||
|
||||
Where, in this exercise:
|
||||
|
||||
.. math::
|
||||
|
||||
u(x_i, a, k, m) =
|
||||
\begin{cases}
|
||||
k(x_i - a)^m & \textrm{if} \hspace{5pt} x_i > a \\
|
||||
0 & \textrm{if} \hspace{5pt} -a \leq x_i \leq a \\
|
||||
k(-x_i - a)^m & \textrm{if} \hspace{5pt} x_i < -a \\
|
||||
\end{cases}
|
||||
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and
|
||||
:math:`x_i \in [-50, 50]` for :math:`i = 1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x_i = 1` for
|
||||
:math:`i = 1, ..., n`
|
||||
|
||||
.. [1] Gavana, A. Global Optimization Benchmarks and AMPGO retrieved 2015
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-50.0] * self.N, [50.0] * self.N))
|
||||
self.custom_bounds = ([-4.0, 4.0], [-4.0, 4.0])
|
||||
|
||||
self.global_optimum = [[1.0 for _ in range(self.N)]]
|
||||
self.fglob = 0.0
|
||||
self.change_dimensionality = True
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
a, b, c = 5.0, 100.0, 4.0
|
||||
|
||||
xx = abs(x)
|
||||
u = where(xx > a, b * (xx - a) ** c, 0.0)
|
||||
|
||||
return (sum(u) + 0.1 * (10 * sin(3.0 * pi * x[0]) ** 2.0
|
||||
+ sum((x[:-1] - 1.0) ** 2.0
|
||||
* (1.0 + sin(3 * pi * x[1:]) ** 2.0))
|
||||
+ (x[-1] - 1) ** 2.0 * (1 + sin(2 * pi * x[-1]) ** 2.0)))
|
||||
|
||||
|
||||
class PenHolder(Benchmark):
|
||||
|
||||
r"""
|
||||
PenHolder objective function.
|
||||
|
||||
This class defines the PenHolder [1]_ global optimization problem. This is a
|
||||
multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{PenHolder}}(x) = -e^{\left|{e^{-\left|{- \frac{\sqrt{x_{1}^{2}
|
||||
+ x_{2}^{2}}}{\pi} + 1}\right|} \cos\left(x_{1}\right)
|
||||
\cos\left(x_{2}\right)}\right|^{-1}}
|
||||
|
||||
|
||||
with :math:`x_i \in [-11, 11]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x_i) = -0.9635348327265058` for
|
||||
:math:`x_i = \pm 9.646167671043401` for :math:`i = 1, 2`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-11.0] * self.N, [11.0] * self.N))
|
||||
|
||||
self.global_optimum = [[-9.646167708023526, 9.646167671043401]]
|
||||
self.fglob = -0.9635348327265058
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
a = abs(1. - (sqrt(x[0] ** 2 + x[1] ** 2) / pi))
|
||||
b = cos(x[0]) * cos(x[1]) * exp(a)
|
||||
return -exp(-abs(b) ** -1)
|
||||
|
||||
|
||||
class PermFunction01(Benchmark):
|
||||
|
||||
r"""
|
||||
PermFunction 1 objective function.
|
||||
|
||||
This class defines the PermFunction1 [1]_ global optimization problem. This is
|
||||
a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{PermFunction01}}(x) = \sum_{k=1}^n \left\{ \sum_{j=1}^n (j^k
|
||||
+ \beta) \left[ \left(\frac{x_j}{j}\right)^k - 1 \right] \right\}^2
|
||||
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and
|
||||
:math:`x_i \in [-n, n + 1]` for :math:`i = 1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x_i = i` for
|
||||
:math:`i = 1, ..., n`
|
||||
|
||||
.. [1] Mishra, S. Global Optimization by Differential Evolution and
|
||||
Particle Swarm Methods: Evaluation on Some Benchmark Functions.
|
||||
Munich Personal RePEc Archive, 2006, 1005
|
||||
|
||||
TODO: line 560
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-self.N] * self.N,
|
||||
[self.N + 1] * self.N))
|
||||
|
||||
self.global_optimum = [list(range(1, self.N + 1))]
|
||||
self.fglob = 0.0
|
||||
self.change_dimensionality = True
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
b = 0.5
|
||||
k = atleast_2d(arange(self.N) + 1).T
|
||||
j = atleast_2d(arange(self.N) + 1)
|
||||
s = (j ** k + b) * ((x / j) ** k - 1)
|
||||
return sum((sum(s, axis=1) ** 2))
|
||||
|
||||
|
||||
class PermFunction02(Benchmark):
|
||||
|
||||
r"""
|
||||
PermFunction 2 objective function.
|
||||
|
||||
This class defines the Perm Function 2 [1]_ global optimization problem. This is
|
||||
a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{PermFunction02}}(x) = \sum_{k=1}^n \left\{ \sum_{j=1}^n (j
|
||||
+ \beta) \left[ \left(x_j^k - {\frac{1}{j}}^{k} \right )
|
||||
\right] \right\}^2
|
||||
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and
|
||||
:math:`x_i \in [-n, n+1]` for :math:`i = 1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x_i = \frac{1}{i}`
|
||||
for :math:`i = 1, ..., n`
|
||||
|
||||
.. [1] Mishra, S. Global Optimization by Differential Evolution and
|
||||
Particle Swarm Methods: Evaluation on Some Benchmark Functions.
|
||||
Munich Personal RePEc Archive, 2006, 1005
|
||||
|
||||
TODO: line 582
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-self.N] * self.N,
|
||||
[self.N + 1] * self.N))
|
||||
self.custom_bounds = ([0, 1.5], [0, 1.0])
|
||||
|
||||
self.global_optimum = [1. / arange(1, self.N + 1)]
|
||||
self.fglob = 0.0
|
||||
self.change_dimensionality = True
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
b = 10
|
||||
k = atleast_2d(arange(self.N) + 1).T
|
||||
j = atleast_2d(arange(self.N) + 1)
|
||||
s = (j + b) * (x ** k - (1. / j) ** k)
|
||||
return sum((sum(s, axis=1) ** 2))
|
||||
|
||||
|
||||
class Pinter(Benchmark):
|
||||
|
||||
r"""
|
||||
Pinter objective function.
|
||||
|
||||
This class defines the Pinter [1]_ global optimization problem. This is a
|
||||
multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Pinter}}(x) = \sum_{i=1}^n ix_i^2 + \sum_{i=1}^n 20i
|
||||
\sin^2 A + \sum_{i=1}^n i \log_{10} (1 + iB^2)
|
||||
|
||||
|
||||
Where, in this exercise:
|
||||
|
||||
.. math::
|
||||
|
||||
\begin{cases}
|
||||
A = x_{i-1} \sin x_i + \sin x_{i+1} \\
|
||||
B = x_{i-1}^2 - 2x_i + 3x_{i + 1} - \cos x_i + 1\\
|
||||
\end{cases}
|
||||
|
||||
Where :math:`x_0 = x_n` and :math:`x_{n + 1} = x_1`.
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and
|
||||
:math:`x_i \in [-10, 10]` for :math:`i = 1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x_i = 0` for
|
||||
:math:`i = 1, ..., n`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-10.0] * self.N, [10.0] * self.N))
|
||||
|
||||
self.global_optimum = [[0.0 for _ in range(self.N)]]
|
||||
self.fglob = 0.0
|
||||
self.change_dimensionality = True
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
i = arange(self.N) + 1
|
||||
xx = zeros(self.N + 2)
|
||||
xx[1: - 1] = x
|
||||
xx[0] = x[-1]
|
||||
xx[-1] = x[0]
|
||||
A = xx[0: -2] * sin(xx[1: - 1]) + sin(xx[2:])
|
||||
B = xx[0: -2] ** 2 - 2 * xx[1: - 1] + 3 * xx[2:] - cos(xx[1: - 1]) + 1
|
||||
return (sum(i * x ** 2)
|
||||
+ sum(20 * i * sin(A) ** 2)
|
||||
+ sum(i * log10(1 + i * B ** 2)))
|
||||
|
||||
|
||||
class Plateau(Benchmark):
|
||||
|
||||
r"""
|
||||
Plateau objective function.
|
||||
|
||||
This class defines the Plateau [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Plateau}}(x) = 30 + \sum_{i=1}^n \lfloor \lvert x_i
|
||||
\rvert\rfloor
|
||||
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and
|
||||
:math:`x_i \in [-5.12, 5.12]` for :math:`i = 1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 30` for :math:`x_i = 0` for
|
||||
:math:`i = 1, ..., n`
|
||||
|
||||
.. [1] Gavana, A. Global Optimization Benchmarks and AMPGO retrieved 2015
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-5.12] * self.N, [5.12] * self.N))
|
||||
|
||||
self.global_optimum = [[0.0 for _ in range(self.N)]]
|
||||
self.fglob = 30.0
|
||||
self.change_dimensionality = True
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return 30.0 + sum(floor(abs(x)))
|
||||
|
||||
|
||||
class Powell(Benchmark):
|
||||
|
||||
r"""
|
||||
Powell objective function.
|
||||
|
||||
This class defines the Powell [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Powell}}(x) = (x_3+10x_1)^2 + 5(x_2-x_4)^2 + (x_1-2x_2)^4
|
||||
+ 10(x_3-x_4)^4
|
||||
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and
|
||||
:math:`x_i \in [-4, 5]` for :math:`i = 1, ..., 4`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x_i = 0` for
|
||||
:math:`i = 1, ..., 4`
|
||||
|
||||
..[1] Powell, M. An iterative method for finding stationary values of a
|
||||
function of several variables Computer Journal, 1962, 5, 147-151
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=4):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-4.0] * self.N, [5.0] * self.N))
|
||||
self.global_optimum = [[0, 0, 0, 0]]
|
||||
self.fglob = 0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return ((x[0] + 10 * x[1]) ** 2 + 5 * (x[2] - x[3]) ** 2
|
||||
+ (x[1] - 2 * x[2]) ** 4 + 10 * (x[0] - x[3]) ** 4)
|
||||
|
||||
|
||||
class PowerSum(Benchmark):
|
||||
|
||||
r"""
|
||||
Power sum objective function.
|
||||
|
||||
This class defines the Power Sum global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{PowerSum}}(x) = \sum_{k=1}^n\left[\left(\sum_{i=1}^n x_i^k
|
||||
\right) - b_k \right]^2
|
||||
|
||||
Where, in this exercise, :math:`b = [8, 18, 44, 114]`
|
||||
|
||||
Here, :math:`x_i \in [0, 4]` for :math:`i = 1, ..., 4`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x = [1, 2, 2, 3]`
|
||||
|
||||
.. [1] Gavana, A. Global Optimization Benchmarks and AMPGO retrieved 2015
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=4):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([0.0] * self.N,
|
||||
[4.0] * self.N))
|
||||
|
||||
self.global_optimum = [[1.0, 2.0, 2.0, 3.0]]
|
||||
self.fglob = 0.0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
b = [8.0, 18.0, 44.0, 114.0]
|
||||
|
||||
k = atleast_2d(arange(self.N) + 1).T
|
||||
return sum((sum(x ** k, axis=1) - b) ** 2)
|
||||
|
||||
|
||||
class Price01(Benchmark):
|
||||
|
||||
r"""
|
||||
Price 1 objective function.
|
||||
|
||||
This class defines the Price 1 [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Price01}}(x) = (\lvert x_1 \rvert - 5)^2
|
||||
+ (\lvert x_2 \rvert - 5)^2
|
||||
|
||||
|
||||
with :math:`x_i \in [-500, 500]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x_i) = 0.0` for :math:`x = [5, 5]` or
|
||||
:math:`x = [5, -5]` or :math:`x = [-5, 5]` or :math:`x = [-5, -5]`.
|
||||
|
||||
.. [1] Price, W. A controlled random search procedure for global
|
||||
optimisation Computer Journal, 1977, 20, 367-370
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-500.0] * self.N,
|
||||
[500.0] * self.N))
|
||||
self.custom_bounds = ([-10.0, 10.0], [-10.0, 10.0])
|
||||
|
||||
self.global_optimum = [[5.0, 5.0]]
|
||||
self.fglob = 0.0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return (abs(x[0]) - 5.0) ** 2.0 + (abs(x[1]) - 5.0) ** 2.0
|
||||
|
||||
|
||||
class Price02(Benchmark):
|
||||
|
||||
r"""
|
||||
Price 2 objective function.
|
||||
|
||||
This class defines the Price 2 [1]_ global optimization problem. This is a
|
||||
multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Price02}}(x) = 1 + \sin^2(x_1) + \sin^2(x_2)
|
||||
- 0.1e^{(-x_1^2 - x_2^2)}
|
||||
|
||||
|
||||
with :math:`x_i \in [-10, 10]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0.9` for :math:`x_i = [0, 0]`
|
||||
|
||||
.. [1] Price, W. A controlled random search procedure for global
|
||||
optimisation Computer Journal, 1977, 20, 367-370
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-10.0] * self.N, [10.0] * self.N))
|
||||
|
||||
self.global_optimum = [[0.0, 0.0]]
|
||||
self.fglob = 0.9
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return 1.0 + sum(sin(x) ** 2) - 0.1 * exp(-x[0] ** 2.0 - x[1] ** 2.0)
|
||||
|
||||
|
||||
class Price03(Benchmark):
|
||||
|
||||
r"""
|
||||
Price 3 objective function.
|
||||
|
||||
This class defines the Price 3 [1]_ global optimization problem. This is a
|
||||
multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Price03}}(x) = 100(x_2 - x_1^2)^2 + \left[6.4(x_2 - 0.5)^2
|
||||
- x_1 - 0.6 \right]^2
|
||||
|
||||
with :math:`x_i \in [-50, 50]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x = [-5, -5]`,
|
||||
:math:`x = [-5, 5]`, :math:`x = [5, -5]`, :math:`x = [5, 5]`.
|
||||
|
||||
.. [1] Price, W. A controlled random search procedure for global
|
||||
optimisation Computer Journal, 1977, 20, 367-370
|
||||
|
||||
TODO Jamil #96 has an erroneous factor of 6 in front of the square brackets
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-5.0] * self.N, [5.0] * self.N))
|
||||
self.custom_bounds = ([0, 2], [0, 2])
|
||||
|
||||
self.global_optimum = [[1.0, 1.0]]
|
||||
self.fglob = 0.0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return (100 * (x[1] - x[0] ** 2) ** 2
|
||||
+ (6.4 * (x[1] - 0.5) ** 2 - x[0] - 0.6) ** 2)
|
||||
|
||||
|
||||
class Price04(Benchmark):
|
||||
|
||||
r"""
|
||||
Price 4 objective function.
|
||||
|
||||
This class defines the Price 4 [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Price04}}(x) = (2 x_1^3 x_2 - x_2^3)^2
|
||||
+ (6 x_1 - x_2^2 + x_2)^2
|
||||
|
||||
with :math:`x_i \in [-50, 50]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x = [0, 0]`,
|
||||
:math:`x = [2, 4]` and :math:`x = [1.464, -2.506]`
|
||||
|
||||
.. [1] Price, W. A controlled random search procedure for global
|
||||
optimisation Computer Journal, 1977, 20, 367-370
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-50.0] * self.N, [50.0] * self.N))
|
||||
self.custom_bounds = ([0, 2], [0, 2])
|
||||
|
||||
self.global_optimum = [[2.0, 4.0]]
|
||||
self.fglob = 0.0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return ((2.0 * x[1] * x[0] ** 3.0 - x[1] ** 3.0) ** 2.0
|
||||
+ (6.0 * x[0] - x[1] ** 2.0 + x[1]) ** 2.0)
|
125
go_benchmark_functions/go_funcs_Q.py
Normal file
125
go_benchmark_functions/go_funcs_Q.py
Normal file
|
@ -0,0 +1,125 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from numpy import abs, sum, arange, sqrt
|
||||
|
||||
from .go_benchmark import Benchmark
|
||||
|
||||
|
||||
class Qing(Benchmark):
|
||||
r"""
|
||||
Qing objective function.
|
||||
|
||||
This class defines the Qing [1]_ global optimization problem. This is a
|
||||
multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Qing}}(x) = \sum_{i=1}^{n} (x_i^2 - i)^2
|
||||
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and
|
||||
:math:`x_i \in [-500, 500]` for :math:`i = 1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x_i = \pm \sqrt(i)` for
|
||||
:math:`i = 1, ..., n`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-500.0] * self.N,
|
||||
[500.0] * self.N))
|
||||
self.custom_bounds = [(-2, 2), (-2, 2)]
|
||||
self.global_optimum = [[sqrt(_) for _ in range(1, self.N + 1)]]
|
||||
self.fglob = 0
|
||||
self.change_dimensionality = True
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
i = arange(1, self.N + 1)
|
||||
return sum((x ** 2.0 - i) ** 2.0)
|
||||
|
||||
|
||||
class Quadratic(Benchmark):
|
||||
r"""
|
||||
Quadratic objective function.
|
||||
|
||||
This class defines the Quadratic [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Quadratic}}(x) = -3803.84 - 138.08x_1 - 232.92x_2 + 128.08x_1^2
|
||||
+ 203.64x_2^2 + 182.25x_1x_2
|
||||
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and
|
||||
:math:`x_i \in [-10, 10]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = -3873.72418` for
|
||||
:math:`x = [0.19388, 0.48513]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-10.0] * self.N, [10.0] * self.N))
|
||||
self.custom_bounds = [(0, 1), (0, 1)]
|
||||
self.global_optimum = [[0.19388, 0.48513]]
|
||||
self.fglob = -3873.72418
|
||||
self.change_dimensionality = True
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return (-3803.84 - 138.08 * x[0] - 232.92 * x[1] + 128.08 * x[0] ** 2.0
|
||||
+ 203.64 * x[1] ** 2.0 + 182.25 * x[0] * x[1])
|
||||
|
||||
|
||||
class Quintic(Benchmark):
|
||||
r"""
|
||||
Quintic objective function.
|
||||
|
||||
This class defines the Quintic [1]_ global optimization problem. This is a
|
||||
multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Quintic}}(x) = \sum_{i=1}^{n} \left|{x_{i}^{5} - 3 x_{i}^{4}
|
||||
+ 4 x_{i}^{3} + 2 x_{i}^{2} - 10 x_{i} -4}\right|
|
||||
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and
|
||||
:math:`x_i \in [-10, 10]` for :math:`i = 1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x_i) = 0` for :math:`x_i = -1` for
|
||||
:math:`i = 1, ..., n`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-10.0] * self.N, [10.0] * self.N))
|
||||
self.custom_bounds = [(-2, 2), (-2, 2)]
|
||||
|
||||
self.global_optimum = [[-1.0 for _ in range(self.N)]]
|
||||
self.fglob = 0
|
||||
self.change_dimensionality = True
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return sum(abs(x ** 5 - 3 * x ** 4 + 4 * x ** 3 + 2 * x ** 2
|
||||
- 10 * x - 4))
|
408
go_benchmark_functions/go_funcs_R.py
Normal file
408
go_benchmark_functions/go_funcs_R.py
Normal file
|
@ -0,0 +1,408 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from numpy import abs, sum, sin, cos, asarray, arange, pi, exp, log, sqrt
|
||||
from scipy.optimize import rosen
|
||||
from .go_benchmark import Benchmark
|
||||
|
||||
|
||||
class Rana(Benchmark):
|
||||
|
||||
r"""
|
||||
Rana objective function.
|
||||
|
||||
This class defines the Rana [1]_ global optimization problem. This is a
|
||||
multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Rana}}(x) = \sum_{i=1}^{n} \left[x_{i}
|
||||
\sin\left(\sqrt{\lvert{x_{1} - x_{i} + 1}\rvert}\right)
|
||||
\cos\left(\sqrt{\lvert{x_{1} + x_{i} + 1}\rvert}\right) +
|
||||
\left(x_{1} + 1\right) \sin\left(\sqrt{\lvert{x_{1} + x_{i} +
|
||||
1}\rvert}\right) \cos\left(\sqrt{\lvert{x_{1} - x_{i} +
|
||||
1}\rvert}\right)\right]
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and :math:`x_i \in
|
||||
[-500.0, 500.0]` for :math:`i = 1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x_i) = -928.5478` for
|
||||
:math:`x = [-300.3376, 500]`.
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
|
||||
TODO: homemade global minimum here.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-500.000001] * self.N,
|
||||
[500.000001] * self.N))
|
||||
|
||||
self.global_optimum = [[-300.3376, 500.]]
|
||||
self.fglob = -500.8021602966615
|
||||
self.change_dimensionality = True
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
t1 = sqrt(abs(x[1:] + x[: -1] + 1))
|
||||
t2 = sqrt(abs(x[1:] - x[: -1] + 1))
|
||||
v = (x[1:] + 1) * cos(t2) * sin(t1) + x[:-1] * cos(t1) * sin(t2)
|
||||
return sum(v)
|
||||
|
||||
|
||||
class Rastrigin(Benchmark):
|
||||
|
||||
r"""
|
||||
Rastrigin objective function.
|
||||
|
||||
This class defines the Rastrigin [1]_ global optimization problem. This is a
|
||||
multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Rastrigin}}(x) = 10n \sum_{i=1}^n \left[ x_i^2
|
||||
- 10 \cos(2\pi x_i) \right]
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and
|
||||
:math:`x_i \in [-5.12, 5.12]` for :math:`i = 1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x_i = 0` for
|
||||
:math:`i = 1, ..., n`
|
||||
|
||||
.. [1] Gavana, A. Global Optimization Benchmarks and AMPGO retrieved 2015
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
self._bounds = list(zip([-5.12] * self.N, [5.12] * self.N))
|
||||
|
||||
self.global_optimum = [[0 for _ in range(self.N)]]
|
||||
self.fglob = 0.0
|
||||
self.change_dimensionality = True
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return 10.0 * self.N + sum(x ** 2.0 - 10.0 * cos(2.0 * pi * x))
|
||||
|
||||
|
||||
class Ratkowsky01(Benchmark):
|
||||
|
||||
"""
|
||||
Ratkowsky objective function.
|
||||
|
||||
.. [1] https://www.itl.nist.gov/div898/strd/nls/data/ratkowsky3.shtml
|
||||
"""
|
||||
|
||||
# TODO, this is a NIST regression standard dataset
|
||||
def __init__(self, dimensions=4):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([0., 1., 0., 0.1],
|
||||
[1000, 20., 3., 6.]))
|
||||
self.global_optimum = [[6.996415127e2, 5.2771253025, 7.5962938329e-1,
|
||||
1.2792483859]]
|
||||
self.fglob = 8.786404908e3
|
||||
self.a = asarray([16.08, 33.83, 65.80, 97.20, 191.55, 326.20, 386.87,
|
||||
520.53, 590.03, 651.92, 724.93, 699.56, 689.96,
|
||||
637.56, 717.41])
|
||||
self.b = arange(1, 16.)
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
vec = x[0] / ((1 + exp(x[1] - x[2] * self.b)) ** (1 / x[3]))
|
||||
return sum((self.a - vec) ** 2)
|
||||
|
||||
|
||||
class Ratkowsky02(Benchmark):
|
||||
|
||||
r"""
|
||||
Ratkowsky02 objective function.
|
||||
|
||||
This class defines the Ratkowsky 2 [1]_ global optimization problem. This is a
|
||||
multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
f_{\text{Ratkowsky02}}(x) = \sum_{m=1}^{9}(a_m - x[0] / (1 + exp(x[1]
|
||||
- b_m x[2]))^2
|
||||
|
||||
where
|
||||
|
||||
.. math::
|
||||
|
||||
\begin{cases}
|
||||
a=[8.93, 10.8, 18.59, 22.33, 39.35, 56.11, 61.73, 64.62, 67.08]\\
|
||||
b=[9., 14., 21., 28., 42., 57., 63., 70., 79.]\\
|
||||
\end{cases}
|
||||
|
||||
|
||||
Here :math:`x_1 \in [1, 100]`, :math:`x_2 \in [0.1, 5]` and
|
||||
:math:`x_3 \in [0.01, 0.5]`
|
||||
|
||||
*Global optimum*: :math:`f(x) = 8.0565229338` for
|
||||
:math:`x = [7.2462237576e1, 2.6180768402, 6.7359200066e-2]`
|
||||
|
||||
.. [1] https://www.itl.nist.gov/div898/strd/nls/data/ratkowsky2.shtml
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=3):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([10, 0.5, 0.01],
|
||||
[200, 5., 0.5]))
|
||||
self.global_optimum = [[7.2462237576e1, 2.6180768402, 6.7359200066e-2]]
|
||||
self.fglob = 8.0565229338
|
||||
self.a = asarray([8.93, 10.8, 18.59, 22.33, 39.35, 56.11, 61.73, 64.62,
|
||||
67.08])
|
||||
self.b = asarray([9., 14., 21., 28., 42., 57., 63., 70., 79.])
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
vec = x[0] / (1 + exp(x[1] - x[2] * self.b))
|
||||
return sum((self.a - vec) ** 2)
|
||||
|
||||
|
||||
class Ripple01(Benchmark):
|
||||
|
||||
r"""
|
||||
Ripple 1 objective function.
|
||||
|
||||
This class defines the Ripple 1 [1]_ global optimization problem. This is a
|
||||
multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Ripple01}}(x) = \sum_{i=1}^2 -e^{-2 \log 2
|
||||
(\frac{x_i-0.1}{0.8})^2} \left[\sin^6(5 \pi x_i)
|
||||
+ 0.1\cos^2(500 \pi x_i) \right]
|
||||
|
||||
|
||||
with :math:`x_i \in [0, 1]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = -2.2` for :math:`x_i = 0.1` for
|
||||
:math:`i = 1, 2`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
self._bounds = list(zip([0.0] * self.N, [1.0] * self.N))
|
||||
|
||||
self.global_optimum = [[0.1 for _ in range(self.N)]]
|
||||
self.fglob = -2.2
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
u = -2.0 * log(2.0) * ((x - 0.1) / 0.8) ** 2.0
|
||||
v = sin(5.0 * pi * x) ** 6.0 + 0.1 * cos(500.0 * pi * x) ** 2.0
|
||||
return sum(-exp(u) * v)
|
||||
|
||||
|
||||
class Ripple25(Benchmark):
|
||||
|
||||
r"""
|
||||
Ripple 25 objective function.
|
||||
|
||||
This class defines the Ripple 25 [1]_ global optimization problem. This is a
|
||||
multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Ripple25}}(x) = \sum_{i=1}^2 -e^{-2
|
||||
\log 2 (\frac{x_i-0.1}{0.8})^2}
|
||||
\left[\sin^6(5 \pi x_i) \right]
|
||||
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and
|
||||
:math:`x_i \in [0, 1]` for :math:`i = 1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = -2` for :math:`x_i = 0.1` for
|
||||
:math:`i = 1, ..., n`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
self._bounds = list(zip([0.0] * self.N, [1.0] * self.N))
|
||||
|
||||
self.global_optimum = [[0.1 for _ in range(self.N)]]
|
||||
self.fglob = -2.0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
u = -2.0 * log(2.0) * ((x - 0.1) / 0.8) ** 2.0
|
||||
v = sin(5.0 * pi * x) ** 6.0
|
||||
return sum(-exp(u) * v)
|
||||
|
||||
|
||||
class Rosenbrock(Benchmark):
|
||||
|
||||
r"""
|
||||
Rosenbrock objective function.
|
||||
|
||||
This class defines the Rosenbrock [1]_ global optimization problem. This is a
|
||||
multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Rosenbrock}}(x) = \sum_{i=1}^{n-1} [100(x_i^2
|
||||
- x_{i+1})^2 + (x_i - 1)^2]
|
||||
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and
|
||||
:math:`x_i \in [-5, 10]` for :math:`i = 1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x_i = 1` for
|
||||
:math:`i = 1, ..., n`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-30.] * self.N, [30.0] * self.N))
|
||||
self.custom_bounds = [(-2, 2), (-2, 2)]
|
||||
|
||||
self.global_optimum = [[1 for _ in range(self.N)]]
|
||||
self.fglob = 0.0
|
||||
self.change_dimensionality = True
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return rosen(x)
|
||||
|
||||
|
||||
class RosenbrockModified(Benchmark):
|
||||
|
||||
r"""
|
||||
Modified Rosenbrock objective function.
|
||||
|
||||
This class defines the Modified Rosenbrock [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{RosenbrockModified}}(x) = 74 + 100(x_2 - x_1^2)^2
|
||||
+ (1 - x_1)^2 - 400 e^{-\frac{(x_1+1)^2 + (x_2 + 1)^2}{0.1}}
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and
|
||||
:math:`x_i \in [-2, 2]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 34.04024310` for
|
||||
:math:`x = [-0.90955374, -0.95057172]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
|
||||
TODO: We have different global minimum compared to Jamil #106. This is
|
||||
possibly because of the (1-x) term is using the wrong parameter.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-2.0] * self.N, [2.0] * self.N))
|
||||
self.custom_bounds = ([-1.0, 0.5], [-1.0, 1.0])
|
||||
|
||||
self.global_optimum = [[-0.90955374, -0.95057172]]
|
||||
self.fglob = 34.040243106640844
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
a = 74 + 100. * (x[1] - x[0] ** 2) ** 2 + (1 - x[0]) ** 2
|
||||
a -= 400 * exp(-((x[0] + 1.) ** 2 + (x[1] + 1.) ** 2) / 0.1)
|
||||
return a
|
||||
|
||||
|
||||
class RotatedEllipse01(Benchmark):
|
||||
|
||||
r"""
|
||||
Rotated Ellipse 1 objective function.
|
||||
|
||||
This class defines the Rotated Ellipse 1 [1]_ global optimization problem. This
|
||||
is a unimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{RotatedEllipse01}}(x) = 7x_1^2 - 6 \sqrt{3} x_1x_2 + 13x_2^2
|
||||
|
||||
with :math:`x_i \in [-500, 500]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x = [0, 0]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-500.0] * self.N,
|
||||
[500.0] * self.N))
|
||||
self.custom_bounds = ([-2.0, 2.0], [-2.0, 2.0])
|
||||
|
||||
self.global_optimum = [[0.0, 0.0]]
|
||||
self.fglob = 0.0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return (7.0 * x[0] ** 2.0 - 6.0 * sqrt(3) * x[0] * x[1]
|
||||
+ 13 * x[1] ** 2.0)
|
||||
|
||||
|
||||
class RotatedEllipse02(Benchmark):
|
||||
|
||||
r"""
|
||||
Rotated Ellipse 2 objective function.
|
||||
|
||||
This class defines the Rotated Ellipse 2 [1]_ global optimization problem. This
|
||||
is a unimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{RotatedEllipse02}}(x) = x_1^2 - x_1 x_2 + x_2^2
|
||||
|
||||
with :math:`x_i \in [-500, 500]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x = [0, 0]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-500.0] * self.N,
|
||||
[500.0] * self.N))
|
||||
self.custom_bounds = ([-2.0, 2.0], [-2.0, 2.0])
|
||||
|
||||
self.global_optimum = [[0.0, 0.0]]
|
||||
self.fglob = 0.0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return x[0] ** 2.0 - x[0] * x[1] + x[1] ** 2.0
|
1366
go_benchmark_functions/go_funcs_S.py
Normal file
1366
go_benchmark_functions/go_funcs_S.py
Normal file
File diff suppressed because it is too large
Load diff
389
go_benchmark_functions/go_funcs_T.py
Normal file
389
go_benchmark_functions/go_funcs_T.py
Normal file
|
@ -0,0 +1,389 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from numpy import abs, asarray, cos, exp, arange, pi, sin, sum, atleast_2d
|
||||
from .go_benchmark import Benchmark
|
||||
|
||||
|
||||
class TestTubeHolder(Benchmark):
|
||||
|
||||
r"""
|
||||
TestTubeHolder objective function.
|
||||
|
||||
This class defines the TestTubeHolder [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{TestTubeHolder}}(x) = - 4 \left | {e^{\left|{\cos
|
||||
\left(\frac{1}{200} x_{1}^{2} + \frac{1}{200} x_{2}^{2}\right)}
|
||||
\right|}\sin\left(x_{1}\right) \cos\left(x_{2}\right)}\right|
|
||||
|
||||
|
||||
with :math:`x_i \in [-10, 10]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = -10.872299901558` for
|
||||
:math:`x= [-\pi/2, 0]`
|
||||
|
||||
.. [1] Mishra, S. Global Optimization by Differential Evolution and
|
||||
Particle Swarm Methods: Evaluation on Some Benchmark Functions.
|
||||
Munich Personal RePEc Archive, 2006, 1005
|
||||
|
||||
TODO Jamil#148 has got incorrect equation, missing an abs around the square
|
||||
brackets
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-10.0] * self.N, [10.0] * self.N))
|
||||
|
||||
self.global_optimum = [[-pi / 2, 0.0]]
|
||||
self.fglob = -10.87229990155800
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
u = sin(x[0]) * cos(x[1])
|
||||
v = (x[0] ** 2 + x[1] ** 2) / 200
|
||||
return -4 * abs(u * exp(abs(cos(v))))
|
||||
|
||||
|
||||
class Thurber(Benchmark):
|
||||
|
||||
r"""
|
||||
Thurber [1]_ objective function.
|
||||
|
||||
.. [1] https://www.itl.nist.gov/div898/strd/nls/data/thurber.shtml
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=7):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip(
|
||||
[500., 500., 100., 10., 0.1, 0.1, 0.],
|
||||
[2000., 2000., 1000., 150., 2., 1., 0.2]))
|
||||
self.global_optimum = [[1.288139680e3, 1.4910792535e3, 5.8323836877e2,
|
||||
75.416644291, 0.96629502864, 0.39797285797,
|
||||
4.9727297349e-2]]
|
||||
self.fglob = 5642.7082397
|
||||
self.a = asarray([80.574, 84.248, 87.264, 87.195, 89.076, 89.608,
|
||||
89.868, 90.101, 92.405, 95.854, 100.696, 101.06,
|
||||
401.672, 390.724, 567.534, 635.316, 733.054, 759.087,
|
||||
894.206, 990.785, 1090.109, 1080.914, 1122.643,
|
||||
1178.351, 1260.531, 1273.514, 1288.339, 1327.543,
|
||||
1353.863, 1414.509, 1425.208, 1421.384, 1442.962,
|
||||
1464.350, 1468.705, 1447.894, 1457.628])
|
||||
self.b = asarray([-3.067, -2.981, -2.921, -2.912, -2.840, -2.797,
|
||||
-2.702, -2.699, -2.633, -2.481, -2.363, -2.322,
|
||||
-1.501, -1.460, -1.274, -1.212, -1.100, -1.046,
|
||||
-0.915, -0.714, -0.566, -0.545, -0.400, -0.309,
|
||||
-0.109, -0.103, 0.010, 0.119, 0.377, 0.790, 0.963,
|
||||
1.006, 1.115, 1.572, 1.841, 2.047, 2.200])
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
vec = x[0] + x[1] * self.b + x[2] * self.b ** 2 + x[3] * self.b ** 3
|
||||
vec /= 1 + x[4] * self.b + x[5] * self.b ** 2 + x[6] * self.b ** 3
|
||||
|
||||
return sum((self.a - vec) ** 2)
|
||||
|
||||
|
||||
class Treccani(Benchmark):
|
||||
|
||||
r"""
|
||||
Treccani objective function.
|
||||
|
||||
This class defines the Treccani [1]_ global optimization problem. This is a
|
||||
multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Treccani}}(x) = x_1^4 + 4x_1^3 + 4x_1^2 + x_2^2
|
||||
|
||||
|
||||
with :math:`x_i \in
|
||||
[-5, 5]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x = [-2, 0]` or
|
||||
:math:`x = [0, 0]`.
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-5.0] * self.N, [5.0] * self.N))
|
||||
self.custom_bounds = [(-2, 2), (-2, 2)]
|
||||
|
||||
self.global_optimum = [[-2.0, 0.0]]
|
||||
self.fglob = 0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return x[0] ** 4 + 4.0 * x[0] ** 3 + 4.0 * x[0] ** 2 + x[1] ** 2
|
||||
|
||||
|
||||
class Trefethen(Benchmark):
|
||||
|
||||
r"""
|
||||
Trefethen objective function.
|
||||
|
||||
This class defines the Trefethen [1]_ global optimization problem. This is a
|
||||
multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Trefethen}}(x) = 0.25 x_{1}^{2} + 0.25 x_{2}^{2}
|
||||
+ e^{\sin\left(50 x_{1}\right)}
|
||||
- \sin\left(10 x_{1} + 10 x_{2}\right)
|
||||
+ \sin\left(60 e^{x_{2}}\right)
|
||||
+ \sin\left[70 \sin\left(x_{1}\right)\right]
|
||||
+ \sin\left[\sin\left(80 x_{2}\right)\right]
|
||||
|
||||
|
||||
with :math:`x_i \in [-10, 10]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = -3.3068686474` for
|
||||
:math:`x = [-0.02440307923, 0.2106124261]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-10.0] * self.N, [10.0] * self.N))
|
||||
self.custom_bounds = [(-5, 5), (-5, 5)]
|
||||
|
||||
self.global_optimum = [[-0.02440307923, 0.2106124261]]
|
||||
self.fglob = -3.3068686474
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
val = 0.25 * x[0] ** 2 + 0.25 * x[1] ** 2
|
||||
val += exp(sin(50. * x[0])) - sin(10 * x[0] + 10 * x[1])
|
||||
val += sin(60 * exp(x[1]))
|
||||
val += sin(70 * sin(x[0]))
|
||||
val += sin(sin(80 * x[1]))
|
||||
return val
|
||||
|
||||
|
||||
class ThreeHumpCamel(Benchmark):
|
||||
|
||||
r"""
|
||||
Three Hump Camel objective function.
|
||||
|
||||
This class defines the Three Hump Camel [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{ThreeHumpCamel}}(x) = 2x_1^2 - 1.05x_1^4 + \frac{x_1^6}{6}
|
||||
+ x_1x_2 + x_2^2
|
||||
|
||||
|
||||
with :math:`x_i \in [-5, 5]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x = [0, 0]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-5.0] * self.N, [5.0] * self.N))
|
||||
self.custom_bounds = [(-2, 2), (-1.5, 1.5)]
|
||||
|
||||
self.global_optimum = [[0.0, 0.0]]
|
||||
self.fglob = 0.0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return (2.0 * x[0] ** 2.0 - 1.05 * x[0] ** 4.0 + x[0] ** 6 / 6.0
|
||||
+ x[0] * x[1] + x[1] ** 2.0)
|
||||
|
||||
|
||||
class Trid(Benchmark):
|
||||
|
||||
r"""
|
||||
Trid objective function.
|
||||
|
||||
This class defines the Trid [1]_ global optimization problem. This is a
|
||||
multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Trid}}(x) = \sum_{i=1}^{n} (x_i - 1)^2
|
||||
- \sum_{i=2}^{n} x_i x_{i-1}
|
||||
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and
|
||||
:math:`x_i \in [-20, 20]` for :math:`i = 1, ..., 6`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = -50` for :math:`x = [6, 10, 12, 12, 10, 6]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
|
||||
TODO Jamil#150, starting index of second summation term should be 2.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=6):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-20.0] * self.N, [20.0] * self.N))
|
||||
|
||||
self.global_optimum = [[6, 10, 12, 12, 10, 6]]
|
||||
self.fglob = -50.0
|
||||
self.change_dimensionality = True
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return sum((x - 1.0) ** 2.0) - sum(x[1:] * x[:-1])
|
||||
|
||||
|
||||
class Trigonometric01(Benchmark):
|
||||
|
||||
r"""
|
||||
Trigonometric 1 objective function.
|
||||
|
||||
This class defines the Trigonometric 1 [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Trigonometric01}}(x) = \sum_{i=1}^{n} \left [n -
|
||||
\sum_{j=1}^{n} \cos(x_j)
|
||||
+ i \left(1 - cos(x_i)
|
||||
- sin(x_i) \right ) \right]^2
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and
|
||||
:math:`x_i \in [0, \pi]` for :math:`i = 1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x_i = 0` for
|
||||
:math:`i = 1, ..., n`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
|
||||
TODO: equaiton uncertain here. Is it just supposed to be the cos term
|
||||
in the inner sum, or the whole of the second line in Jamil #153.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([0.0] * self.N, [pi] * self.N))
|
||||
|
||||
self.global_optimum = [[0.0 for _ in range(self.N)]]
|
||||
self.fglob = 0.0
|
||||
self.change_dimensionality = True
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
i = atleast_2d(arange(1.0, self.N + 1)).T
|
||||
inner = cos(x) + i * (1 - cos(x) - sin(x))
|
||||
return sum((self.N - sum(inner, axis=1)) ** 2)
|
||||
|
||||
|
||||
class Trigonometric02(Benchmark):
|
||||
|
||||
r"""
|
||||
Trigonometric 2 objective function.
|
||||
|
||||
This class defines the Trigonometric 2 [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Trigonometric2}}(x) = 1 + \sum_{i=1}^{n} 8 \sin^2
|
||||
\left[7(x_i - 0.9)^2 \right]
|
||||
+ 6 \sin^2 \left[14(x_i - 0.9)^2 \right]
|
||||
+ (x_i - 0.9)^2
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and
|
||||
:math:`x_i \in [-500, 500]` for :math:`i = 1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 1` for :math:`x_i = 0.9` for
|
||||
:math:`i = 1, ..., n`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-500.0] * self.N,
|
||||
[500.0] * self.N))
|
||||
self.custom_bounds = [(0, 2), (0, 2)]
|
||||
|
||||
self.global_optimum = [[0.9 for _ in range(self.N)]]
|
||||
self.fglob = 1.0
|
||||
self.change_dimensionality = True
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
vec = (8 * sin(7 * (x - 0.9) ** 2) ** 2
|
||||
+ 6 * sin(14 * (x - 0.9) ** 2) ** 2
|
||||
+ (x - 0.9) ** 2)
|
||||
return 1.0 + sum(vec)
|
||||
|
||||
|
||||
class Tripod(Benchmark):
|
||||
|
||||
r"""
|
||||
Tripod objective function.
|
||||
|
||||
This class defines the Tripod [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Tripod}}(x) = p(x_2) \left[1 + p(x_1) \right] +
|
||||
\lvert x_1 + 50p(x_2) \left[1 - 2p(x_1) \right]
|
||||
\rvert + \lvert x_2 + 50\left[1 - 2p(x_2)\right]
|
||||
\rvert
|
||||
|
||||
with :math:`x_i \in [-100, 100]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x = [0, -50]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-100.0] * self.N,
|
||||
[100.0] * self.N))
|
||||
|
||||
self.global_optimum = [[0.0, -50.0]]
|
||||
self.fglob = 0.0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
p1 = float(x[0] >= 0)
|
||||
p2 = float(x[1] >= 0)
|
||||
|
||||
return (p2 * (1.0 + p1) + abs(x[0] + 50.0 * p2 * (1.0 - 2.0 * p1))
|
||||
+ abs(x[1] + 50.0 * (1.0 - 2.0 * p2)))
|
166
go_benchmark_functions/go_funcs_U.py
Normal file
166
go_benchmark_functions/go_funcs_U.py
Normal file
|
@ -0,0 +1,166 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from numpy import abs, sin, cos, pi, sqrt
|
||||
from .go_benchmark import Benchmark
|
||||
|
||||
|
||||
class Ursem01(Benchmark):
|
||||
|
||||
r"""
|
||||
Ursem 1 objective function.
|
||||
|
||||
This class defines the Ursem 1 [1]_ global optimization problem. This is a
|
||||
unimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Ursem01}}(x) = - \sin(2x_1 - 0.5 \pi) - 3 \cos(x_2) - 0.5 x_1
|
||||
|
||||
with :math:`x_1 \in [-2.5, 3]` and :math:`x_2 \in [-2, 2]`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = -4.81681406371` for
|
||||
:math:`x = [1.69714, 0.0]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = [(-2.5, 3.0), (-2.0, 2.0)]
|
||||
|
||||
self.global_optimum = [[1.69714, 0.0]]
|
||||
self.fglob = -4.81681406371
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return -sin(2 * x[0] - 0.5 * pi) - 3.0 * cos(x[1]) - 0.5 * x[0]
|
||||
|
||||
|
||||
class Ursem03(Benchmark):
|
||||
|
||||
r"""
|
||||
Ursem 3 objective function.
|
||||
|
||||
This class defines the Ursem 3 [1]_ global optimization problem. This is a
|
||||
multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Ursem03}}(x) = - \sin(2.2 \pi x_1 + 0.5 \pi)
|
||||
\frac{2 - \lvert x_1 \rvert}{2}
|
||||
\frac{3 - \lvert x_1 \rvert}{2}
|
||||
- \sin(2.2 \pi x_2 + 0.5 \pi)
|
||||
\frac{2 - \lvert x_2 \rvert}{2}
|
||||
\frac{3 - \lvert x_2 \rvert}{2}
|
||||
|
||||
with :math:`x_1 \in [-2, 2]`, :math:`x_2 \in [-1.5, 1.5]`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = -3` for :math:`x = [0, 0]`
|
||||
|
||||
.. [1] Gavana, A. Global Optimization Benchmarks and AMPGO retrieved 2015
|
||||
|
||||
TODO Gavana and Jamil #157 disagree on the formulae here. Jamil squares the
|
||||
x[1] term in the sine expression. Gavana doesn't. Go with Gavana here.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = [(-2, 2), (-1.5, 1.5)]
|
||||
|
||||
self.global_optimum = [[0.0 for _ in range(self.N)]]
|
||||
self.fglob = -3.0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
u = -(sin(2.2 * pi * x[0] + 0.5 * pi)
|
||||
* ((2.0 - abs(x[0])) / 2.0) * ((3.0 - abs(x[0])) / 2))
|
||||
v = -(sin(2.2 * pi * x[1] + 0.5 * pi)
|
||||
* ((2.0 - abs(x[1])) / 2) * ((3.0 - abs(x[1])) / 2))
|
||||
return u + v
|
||||
|
||||
|
||||
class Ursem04(Benchmark):
|
||||
|
||||
r"""
|
||||
Ursem 4 objective function.
|
||||
|
||||
This class defines the Ursem 4 [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Ursem04}}(x) = -3 \sin(0.5 \pi x_1 + 0.5 \pi)
|
||||
\frac{2 - \sqrt{x_1^2 + x_2 ^ 2}}{4}
|
||||
|
||||
with :math:`x_i \in [-2, 2]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = -1.5` for :math:`x = [0, 0]` for
|
||||
:math:`i = 1, 2`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-2.0] * self.N, [2.0] * self.N))
|
||||
|
||||
self.global_optimum = [[0.0 for _ in range(self.N)]]
|
||||
self.fglob = -1.5
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return (-3 * sin(0.5 * pi * x[0] + 0.5 * pi)
|
||||
* (2 - sqrt(x[0] ** 2 + x[1] ** 2)) / 4)
|
||||
|
||||
|
||||
class UrsemWaves(Benchmark):
|
||||
|
||||
r"""
|
||||
Ursem Waves objective function.
|
||||
|
||||
This class defines the Ursem Waves [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{UrsemWaves}}(x) = -0.9x_1^2 + (x_2^2 - 4.5x_2^2)x_1x_2
|
||||
+ 4.7 \cos \left[ 2x_1 - x_2^2(2 + x_1)
|
||||
\right ] \sin(2.5 \pi x_1)
|
||||
|
||||
with :math:`x_1 \in [-0.9, 1.2]`, :math:`x_2 \in [-1.2, 1.2]`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = -8.5536` for :math:`x = [1.2, 1.2]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
|
||||
TODO Jamil #159, has an x_2^2 - 4.5 x_2^2 in the brackets. Why wasn't this
|
||||
rationalised to -5.5 x_2^2? This makes me wonder if the equation is listed
|
||||
correctly?
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = [(-0.9, 1.2), (-1.2, 1.2)]
|
||||
|
||||
self.global_optimum = [[1.2 for _ in range(self.N)]]
|
||||
self.fglob = -8.5536
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
u = -0.9 * x[0] ** 2
|
||||
v = (x[1] ** 2 - 4.5 * x[1] ** 2) * x[0] * x[1]
|
||||
w = 4.7 * cos(3 * x[0] - x[1] ** 2 * (2 + x[0])) * sin(2.5 * pi * x[0])
|
||||
return u + v + w
|
85
go_benchmark_functions/go_funcs_V.py
Normal file
85
go_benchmark_functions/go_funcs_V.py
Normal file
|
@ -0,0 +1,85 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from numpy import sum, cos, sin, log
|
||||
from .go_benchmark import Benchmark
|
||||
|
||||
|
||||
class VenterSobiezcczanskiSobieski(Benchmark):
|
||||
|
||||
r"""
|
||||
Venter Sobiezcczanski-Sobieski objective function.
|
||||
|
||||
This class defines the Venter Sobiezcczanski-Sobieski [1]_ global optimization
|
||||
problem. This is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{VenterSobiezcczanskiSobieski}}(x) = x_1^2 - 100 \cos^2(x_1)
|
||||
- 100 \cos(x_1^2/30)
|
||||
+ x_2^2 - 100 \cos^2(x_2)
|
||||
- 100 \cos(x_2^2/30)
|
||||
|
||||
|
||||
with :math:`x_i \in [-50, 50]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = -400` for :math:`x = [0, 0]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
|
||||
TODO Jamil #160 hasn't written the equation very well. Normally a cos
|
||||
squared term is written as cos^2(x) rather than cos(x)^2
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-50.0] * self.N, [50.0] * self.N))
|
||||
self.custom_bounds = ([-10, 10], [-10, 10])
|
||||
|
||||
self.global_optimum = [[0.0 for _ in range(self.N)]]
|
||||
self.fglob = -400
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
u = x[0] ** 2.0 - 100.0 * cos(x[0]) ** 2.0
|
||||
v = -100.0 * cos(x[0] ** 2.0 / 30.0) + x[1] ** 2.0
|
||||
w = - 100.0 * cos(x[1]) ** 2.0 - 100.0 * cos(x[1] ** 2.0 / 30.0)
|
||||
return u + v + w
|
||||
|
||||
|
||||
class Vincent(Benchmark):
|
||||
|
||||
r"""
|
||||
Vincent objective function.
|
||||
|
||||
This class defines the Vincent [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Vincent}}(x) = - \sum_{i=1}^{n} \sin(10 \log(x))
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and
|
||||
:math:`x_i \in [0.25, 10]` for :math:`i = 1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = -n` for :math:`x_i = 7.70628098`
|
||||
for :math:`i = 1, ..., n`
|
||||
|
||||
.. [1] Gavana, A. Global Optimization Benchmarks and AMPGO retrieved 2015
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([0.25] * self.N, [10.0] * self.N))
|
||||
|
||||
self.global_optimum = [[7.70628098 for _ in range(self.N)]]
|
||||
self.fglob = -float(self.N)
|
||||
self.change_dimensionality = True
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return -sum(sin(10.0 * log(x)))
|
323
go_benchmark_functions/go_funcs_W.py
Normal file
323
go_benchmark_functions/go_funcs_W.py
Normal file
|
@ -0,0 +1,323 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from numpy import atleast_2d, arange, sum, cos, exp, pi
|
||||
from .go_benchmark import Benchmark
|
||||
|
||||
|
||||
class Watson(Benchmark):
|
||||
|
||||
r"""
|
||||
Watson objective function.
|
||||
|
||||
This class defines the Watson [1]_ global optimization problem. This is a
|
||||
unimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Watson}}(x) = \sum_{i=0}^{29} \left\{
|
||||
\sum_{j=0}^4 ((j + 1)a_i^j x_{j+1})
|
||||
- \left[ \sum_{j=0}^5 a_i^j
|
||||
x_{j+1} \right ]^2 - 1 \right\}^2
|
||||
+ x_1^2
|
||||
|
||||
|
||||
Where, in this exercise, :math:`a_i = i/29`.
|
||||
|
||||
with :math:`x_i \in [-5, 5]` for :math:`i = 1, ..., 6`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0.002288` for
|
||||
:math:`x = [-0.0158, 1.012, -0.2329, 1.260, -1.513, 0.9928]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
|
||||
TODO Jamil #161 writes equation using (j - 1). According to code in Adorio
|
||||
and Gavana it should be (j+1). However the equations in those papers
|
||||
contain (j - 1) as well. However, I've got the right global minimum!!!
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=6):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-5.0] * self.N, [5.0] * self.N))
|
||||
|
||||
self.global_optimum = [[-0.0158, 1.012, -0.2329, 1.260, -1.513,
|
||||
0.9928]]
|
||||
self.fglob = 0.002288
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
i = atleast_2d(arange(30.)).T
|
||||
a = i / 29.
|
||||
j = arange(5.)
|
||||
k = arange(6.)
|
||||
|
||||
t1 = sum((j + 1) * a ** j * x[1:], axis=1)
|
||||
t2 = sum(a ** k * x, axis=1)
|
||||
|
||||
inner = (t1 - t2 ** 2 - 1) ** 2
|
||||
|
||||
return sum(inner) + x[0] ** 2
|
||||
|
||||
|
||||
class Wavy(Benchmark):
|
||||
|
||||
r"""
|
||||
Wavy objective function.
|
||||
|
||||
This class defines the W / Wavy [1]_ global optimization problem. This is a
|
||||
multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Wavy}}(x) = 1 - \frac{1}{n} \sum_{i=1}^{n}
|
||||
\cos(kx_i)e^{-\frac{x_i^2}{2}}
|
||||
|
||||
|
||||
Where, in this exercise, :math:`k = 10`. The number of local minima is
|
||||
:math:`kn` and :math:`(k + 1)n` for odd and even :math:`k` respectively.
|
||||
|
||||
Here, :math:`x_i \in [-\pi, \pi]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x = [0, 0]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-pi] * self.N, [pi] * self.N))
|
||||
|
||||
self.global_optimum = [[0.0 for _ in range(self.N)]]
|
||||
self.fglob = 0.0
|
||||
self.change_dimensionality = True
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return 1.0 - (1.0 / self.N) * sum(cos(10 * x) * exp(-x ** 2.0 / 2.0))
|
||||
|
||||
|
||||
class WayburnSeader01(Benchmark):
|
||||
|
||||
r"""
|
||||
Wayburn and Seader 1 objective function.
|
||||
|
||||
This class defines the Wayburn and Seader 1 [1]_ global optimization
|
||||
problem. This is a unimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{WayburnSeader01}}(x) = (x_1^6 + x_2^4 - 17)^2
|
||||
+ (2x_1 + x_2 - 4)^2
|
||||
|
||||
|
||||
with :math:`x_i \in [-5, 5]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x = [1, 2]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-5.0] * self.N, [5.0] * self.N))
|
||||
self.custom_bounds = ([-2, 2], [-2, 2])
|
||||
|
||||
self.global_optimum = [[1.0, 2.0]]
|
||||
self.fglob = 0.0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return (x[0] ** 6 + x[1] ** 4 - 17) ** 2 + (2 * x[0] + x[1] - 4) ** 2
|
||||
|
||||
|
||||
class WayburnSeader02(Benchmark):
|
||||
|
||||
r"""
|
||||
Wayburn and Seader 2 objective function.
|
||||
|
||||
This class defines the Wayburn and Seader 2 [1]_ global optimization
|
||||
problem. This is a unimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{WayburnSeader02}}(x) = \left[ 1.613 - 4(x_1 - 0.3125)^2
|
||||
- 4(x_2 - 1.625)^2 \right]^2
|
||||
+ (x_2 - 1)^2
|
||||
|
||||
|
||||
with :math:`x_i \in [-500, 500]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x = [0.2, 1]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-500.0] * self.N,
|
||||
[500.0] * self.N))
|
||||
self.custom_bounds = ([-1, 2], [-1, 2])
|
||||
|
||||
self.global_optimum = [[0.2, 1.0]]
|
||||
self.fglob = 0.0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
u = (1.613 - 4 * (x[0] - 0.3125) ** 2 - 4 * (x[1] - 1.625) ** 2) ** 2
|
||||
v = (x[1] - 1) ** 2
|
||||
return u + v
|
||||
|
||||
|
||||
class Weierstrass(Benchmark):
|
||||
|
||||
r"""
|
||||
Weierstrass objective function.
|
||||
|
||||
This class defines the Weierstrass [1]_ global optimization problem.
|
||||
This is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Weierstrass}}(x) = \sum_{i=1}^{n} \left [
|
||||
\sum_{k=0}^{kmax} a^k \cos
|
||||
\left( 2 \pi b^k (x_i + 0.5) \right) - n
|
||||
\sum_{k=0}^{kmax} a^k \cos(\pi b^k) \right ]
|
||||
|
||||
|
||||
Where, in this exercise, :math:`kmax = 20`, :math:`a = 0.5` and
|
||||
:math:`b = 3`.
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and
|
||||
:math:`x_i \in [-0.5, 0.5]` for :math:`i = 1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 4` for :math:`x_i = 0` for
|
||||
:math:`i = 1, ..., n`
|
||||
|
||||
.. [1] Mishra, S. Global Optimization by Differential Evolution and
|
||||
Particle Swarm Methods: Evaluation on Some Benchmark Functions.
|
||||
Munich Personal RePEc Archive, 2006, 1005
|
||||
|
||||
TODO line 1591.
|
||||
TODO Jamil, Gavana have got it wrong. The second term is not supposed to
|
||||
be included in the outer sum. Mishra code has it right as does the
|
||||
reference referred to in Jamil#166.
|
||||
"""
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-0.5] * self.N, [0.5] * self.N))
|
||||
|
||||
self.global_optimum = [[0.0 for _ in range(self.N)]]
|
||||
self.fglob = 0
|
||||
self.change_dimensionality = True
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
kmax = 20
|
||||
a, b = 0.5, 3.0
|
||||
|
||||
k = atleast_2d(arange(kmax + 1.)).T
|
||||
t1 = a ** k * cos(2 * pi * b ** k * (x + 0.5))
|
||||
t2 = self.N * sum(a ** k.T * cos(pi * b ** k.T))
|
||||
|
||||
return sum(sum(t1, axis=0)) - t2
|
||||
|
||||
|
||||
class Whitley(Benchmark):
|
||||
|
||||
r"""
|
||||
Whitley objective function.
|
||||
|
||||
This class defines the Whitley [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Whitley}}(x) = \sum_{i=1}^n \sum_{j=1}^n
|
||||
\left[\frac{(100(x_i^2-x_j)^2
|
||||
+ (1-x_j)^2)^2}{4000} - \cos(100(x_i^2-x_j)^2
|
||||
+ (1-x_j)^2)+1 \right]
|
||||
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and
|
||||
:math:`x_i \in [-10.24, 10.24]` for :math:`i = 1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x_i = 1` for
|
||||
:math:`i = 1, ..., n`
|
||||
|
||||
.. [1] Gavana, A. Global Optimization Benchmarks and AMPGO retrieved 2015
|
||||
|
||||
TODO Jamil#167 has '+ 1' inside the cos term, when it should be outside it.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-10.24] * self.N,
|
||||
[10.24] * self.N))
|
||||
self.custom_bounds = ([-1, 2], [-1, 2])
|
||||
|
||||
self.global_optimum = [[1.0 for _ in range(self.N)]]
|
||||
self.fglob = 0.0
|
||||
self.change_dimensionality = True
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
XI = x
|
||||
XJ = atleast_2d(x).T
|
||||
|
||||
temp = 100.0 * ((XI ** 2.0) - XJ) + (1.0 - XJ) ** 2.0
|
||||
inner = (temp ** 2.0 / 4000.0) - cos(temp) + 1.0
|
||||
return sum(sum(inner, axis=0))
|
||||
|
||||
|
||||
class Wolfe(Benchmark):
|
||||
|
||||
r"""
|
||||
Wolfe objective function.
|
||||
|
||||
This class defines the Wolfe [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Wolfe}}(x) = \frac{4}{3}(x_1^2 + x_2^2 - x_1x_2)^{0.75} + x_3
|
||||
|
||||
|
||||
with :math:`x_i \in [0, 2]` for :math:`i = 1, 2, 3`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x = [0, 0, 0]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=3):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([0.0] * self.N, [2.0] * self.N))
|
||||
|
||||
self.global_optimum = [[0.0 for _ in range(self.N)]]
|
||||
self.fglob = 0.0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return 4 / 3 * (x[0] ** 2 + x[1] ** 2 - x[0] * x[1]) ** 0.75 + x[2]
|
241
go_benchmark_functions/go_funcs_X.py
Normal file
241
go_benchmark_functions/go_funcs_X.py
Normal file
|
@ -0,0 +1,241 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import numpy as np
|
||||
from numpy import abs, sum, sin, cos, pi, exp, arange, prod, sqrt
|
||||
from .go_benchmark import Benchmark
|
||||
|
||||
|
||||
class XinSheYang01(Benchmark):
|
||||
|
||||
r"""
|
||||
Xin-She Yang 1 objective function.
|
||||
|
||||
This class defines the Xin-She Yang 1 [1]_ global optimization problem.
|
||||
This is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{XinSheYang01}}(x) = \sum_{i=1}^{n} \epsilon_i \lvert x_i
|
||||
\rvert^i
|
||||
|
||||
|
||||
The variable :math:`\epsilon_i, (i = 1, ..., n)` is a random variable
|
||||
uniformly distributed in :math:`[0, 1]`.
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and
|
||||
:math:`x_i \in [-5, 5]` for :math:`i = 1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x_i = 0` for
|
||||
:math:`i = 1, ..., n`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-5.0] * self.N, [5.0] * self.N))
|
||||
self.custom_bounds = ([-2, 2], [-2, 2])
|
||||
|
||||
self.global_optimum = [[0 for _ in range(self.N)]]
|
||||
self.fglob = 0.0
|
||||
self.change_dimensionality = True
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
i = arange(1.0, self.N + 1.0)
|
||||
return sum(np.random.random(self.N) * (abs(x) ** i))
|
||||
|
||||
|
||||
class XinSheYang02(Benchmark):
|
||||
|
||||
r"""
|
||||
Xin-She Yang 2 objective function.
|
||||
|
||||
This class defines the Xin-She Yang 2 [1]_ global optimization problem.
|
||||
This is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{XinSheYang02}}(\x) = \frac{\sum_{i=1}^{n} \lvert{x_{i}}\rvert}
|
||||
{e^{\sum_{i=1}^{n} \sin\left(x_{i}^{2.0}
|
||||
\right)}}
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and
|
||||
:math:`x_i \in [-2\pi, 2\pi]` for :math:`i = 1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x_i = 0` for
|
||||
:math:`i = 1, ..., n`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-2 * pi] * self.N,
|
||||
[2 * pi] * self.N))
|
||||
|
||||
self.global_optimum = [[0 for _ in range(self.N)]]
|
||||
self.fglob = 0.0
|
||||
self.change_dimensionality = True
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return sum(abs(x)) * exp(-sum(sin(x ** 2.0)))
|
||||
|
||||
|
||||
class XinSheYang03(Benchmark):
|
||||
|
||||
r"""
|
||||
Xin-She Yang 3 objective function.
|
||||
|
||||
This class defines the Xin-She Yang 3 [1]_ global optimization problem.
|
||||
This is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{XinSheYang03}}(x) = e^{-\sum_{i=1}^{n} (x_i/\beta)^{2m}}
|
||||
- 2e^{-\sum_{i=1}^{n} x_i^2}
|
||||
\prod_{i=1}^{n} \cos^2(x_i)
|
||||
|
||||
|
||||
Where, in this exercise, :math:`\beta = 15` and :math:`m = 3`.
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and
|
||||
:math:`x_i \in [-20, 20]` for :math:`i = 1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = -1` for :math:`x_i = 0` for
|
||||
:math:`i = 1, ..., n`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-20.0] * self.N, [20.0] * self.N))
|
||||
|
||||
self.global_optimum = [[0 for _ in range(self.N)]]
|
||||
self.fglob = -1.0
|
||||
self.change_dimensionality = True
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
beta, m = 15.0, 5.0
|
||||
u = sum((x / beta) ** (2 * m))
|
||||
v = sum(x ** 2)
|
||||
w = prod(cos(x) ** 2)
|
||||
|
||||
return exp(-u) - 2 * exp(-v) * w
|
||||
|
||||
|
||||
class XinSheYang04(Benchmark):
|
||||
|
||||
r"""
|
||||
Xin-She Yang 4 objective function.
|
||||
|
||||
This class defines the Xin-She Yang 4 [1]_ global optimization problem.
|
||||
This is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{XinSheYang04}}(x) = \left[ \sum_{i=1}^{n} \sin^2(x_i)
|
||||
- e^{-\sum_{i=1}^{n} x_i^2} \right ]
|
||||
e^{-\sum_{i=1}^{n} \sin^2 \sqrt{ \lvert
|
||||
x_i \rvert }}
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and
|
||||
:math:`x_i \in [-10, 10]` for :math:`i = 1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = -1` for :math:`x_i = 0` for
|
||||
:math:`i = 1, ..., n`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-10.0] * self.N, [10.0] * self.N))
|
||||
|
||||
self.global_optimum = [[0 for _ in range(self.N)]]
|
||||
self.fglob = -1.0
|
||||
self.change_dimensionality = True
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
u = sum(sin(x) ** 2)
|
||||
v = sum(x ** 2)
|
||||
w = sum(sin(sqrt(abs(x))) ** 2)
|
||||
return (u - exp(-v)) * exp(-w)
|
||||
|
||||
|
||||
class Xor(Benchmark):
|
||||
|
||||
r"""
|
||||
Xor objective function.
|
||||
|
||||
This class defines the Xor [1]_ global optimization problem. This is a
|
||||
multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Xor}}(x) = \left[ 1 + \exp \left( - \frac{x_7}{1 +
|
||||
\exp(-x_1 - x_2 - x_5)} - \frac{x_8}{1 + \exp(-x_3 - x_4 - x_6)}
|
||||
- x_9 \right ) \right ]^{-2} \\
|
||||
+ \left [ 1 + \exp \left( -\frac{x_7}{1 + \exp(-x_5)}
|
||||
- \frac{x_8}{1 + \exp(-x_6)} - x_9 \right ) \right] ^{-2} \\
|
||||
+ \left [1 - \left\{1 + \exp \left(-\frac{x_7}{1 + \exp(-x_1 - x_5)}
|
||||
- \frac{x_8}{1 + \exp(-x_3 - x_6)} - x_9 \right ) \right\}^{-1}
|
||||
\right ]^2 \\
|
||||
+ \left [1 - \left\{1 + \exp \left(-\frac{x_7}{1 + \exp(-x_2 - x_5)}
|
||||
- \frac{x_8}{1 + \exp(-x_4 - x_6)} - x_9 \right ) \right\}^{-1}
|
||||
\right ]^2
|
||||
|
||||
|
||||
with :math:`x_i \in [-1, 1]` for :math:`i=1,...,9`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0.9597588` for
|
||||
:math:`\x = [1, -1, 1, -1, -1, 1, 1, -1, 0.421134]`
|
||||
|
||||
.. [1] Gavana, A. Global Optimization Benchmarks and AMPGO retrieved 2015
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=9):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-1.0] * self.N, [1.0] * self.N))
|
||||
|
||||
self.global_optimum = [[1.0, -1.0, 1.0,
|
||||
-1.0, -1.0, 1.0, 1.0, -1.0, 0.421134]]
|
||||
self.fglob = 0.9597588
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
F11 = x[6] / (1.0 + exp(-x[0] - x[1] - x[4]))
|
||||
F12 = x[7] / (1.0 + exp(-x[2] - x[3] - x[5]))
|
||||
F1 = (1.0 + exp(-F11 - F12 - x[8])) ** (-2)
|
||||
F21 = x[6] / (1.0 + exp(-x[4]))
|
||||
F22 = x[7] / (1.0 + exp(-x[5]))
|
||||
F2 = (1.0 + exp(-F21 - F22 - x[8])) ** (-2)
|
||||
F31 = x[6] / (1.0 + exp(-x[0] - x[4]))
|
||||
F32 = x[7] / (1.0 + exp(-x[2] - x[5]))
|
||||
F3 = (1.0 - (1.0 + exp(-F31 - F32 - x[8])) ** (-1)) ** 2
|
||||
F41 = x[6] / (1.0 + exp(-x[1] - x[4]))
|
||||
F42 = x[7] / (1.0 + exp(-x[3] - x[5]))
|
||||
F4 = (1.0 - (1.0 + exp(-F41 - F42 - x[8])) ** (-1)) ** 2
|
||||
|
||||
return F1 + F2 + F3 + F4
|
92
go_benchmark_functions/go_funcs_Y.py
Normal file
92
go_benchmark_functions/go_funcs_Y.py
Normal file
|
@ -0,0 +1,92 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from numpy import abs, sum, cos, pi
|
||||
from .go_benchmark import Benchmark
|
||||
|
||||
|
||||
class YaoLiu04(Benchmark):
|
||||
|
||||
r"""
|
||||
Yao-Liu 4 objective function.
|
||||
|
||||
This class defines the Yao-Liu function 4 [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{YaoLiu04}}(x) = {max}_i \left\{ \left | x_i \right | ,
|
||||
1 \leq i \leq n \right\}
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and
|
||||
:math:`x_i \in [-10, 10]` for :math:`i = 1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x_i = 0` for
|
||||
:math:`i = 1, ..., n`
|
||||
|
||||
.. [1] Yao X., Liu Y. (1997) Fast evolution strategies.
|
||||
In: Angeline P.J., Reynolds R.G., McDonnell J.R., Eberhart R. (eds)
|
||||
Evolutionary Programming VI. EP 1997.
|
||||
Lecture Notes in Computer Science, vol 1213. Springer, Berlin, Heidelberg
|
||||
|
||||
.. [2] Mishra, S. Global Optimization by Differential Evolution and
|
||||
Particle Swarm Methods: Evaluation on Some Benchmark Functions.
|
||||
Munich Personal RePEc Archive, 2006, 1005
|
||||
|
||||
TODO line 1201. Gavana code and documentation differ.
|
||||
max(abs(x)) != abs(max(x))
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-10.0] * self.N, [10.0] * self.N))
|
||||
|
||||
self.global_optimum = [[0 for _ in range(self.N)]]
|
||||
self.fglob = 0.0
|
||||
self.change_dimensionality = True
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return abs(x).max()
|
||||
|
||||
|
||||
class YaoLiu09(Benchmark):
|
||||
|
||||
r"""
|
||||
Yao-Liu 9 objective function.
|
||||
|
||||
This class defines the Yao-Liu [1]_ function 9 global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{YaoLiu09}}(x) = \sum_{i=1}^n \left [ x_i^2
|
||||
- 10 \cos(2 \pi x_i ) + 10 \right ]
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and
|
||||
:math:`x_i \in [-5.12, 5.12]` for :math:`i = 1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x_i = 0` for
|
||||
:math:`i = 1, ..., n`
|
||||
|
||||
.. [1] Yao X., Liu Y. (1997) Fast evolution strategies.
|
||||
In: Angeline P.J., Reynolds R.G., McDonnell J.R., Eberhart R. (eds)
|
||||
Evolutionary Programming VI. EP 1997.
|
||||
Lecture Notes in Computer Science, vol 1213. Springer, Berlin, Heidelberg
|
||||
|
||||
.. [2] Gavana, A. Global Optimization Benchmarks and AMPGO retrieved 2015
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-5.12] * self.N, [5.12] * self.N))
|
||||
|
||||
self.global_optimum = [[0 for _ in range(self.N)]]
|
||||
self.fglob = 0.0
|
||||
self.change_dimensionality = True
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return sum(x ** 2.0 - 10.0 * cos(2 * pi * x) + 10)
|
226
go_benchmark_functions/go_funcs_Z.py
Normal file
226
go_benchmark_functions/go_funcs_Z.py
Normal file
|
@ -0,0 +1,226 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from numpy import abs, sum, sign, arange
|
||||
from .go_benchmark import Benchmark
|
||||
|
||||
|
||||
class Zacharov(Benchmark):
|
||||
|
||||
r"""
|
||||
Zacharov objective function.
|
||||
|
||||
This class defines the Zacharov [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Zacharov}}(x) = \sum_{i=1}^{n} x_i^2 + \left ( \frac{1}{2}
|
||||
\sum_{i=1}^{n} i x_i \right )^2
|
||||
+ \left ( \frac{1}{2} \sum_{i=1}^{n} i x_i
|
||||
\right )^4
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and
|
||||
:math:`x_i \in [-5, 10]` for :math:`i = 1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x_i = 0` for
|
||||
:math:`i = 1, ..., n`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-5.0] * self.N, [10.0] * self.N))
|
||||
self.custom_bounds = ([-1, 1], [-1, 1])
|
||||
|
||||
self.global_optimum = [[0 for _ in range(self.N)]]
|
||||
self.fglob = 0.0
|
||||
self.change_dimensionality = True
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
u = sum(x ** 2)
|
||||
v = sum(arange(1, self.N + 1) * x)
|
||||
return u + (0.5 * v) ** 2 + (0.5 * v) ** 4
|
||||
|
||||
|
||||
class ZeroSum(Benchmark):
|
||||
|
||||
r"""
|
||||
ZeroSum objective function.
|
||||
|
||||
This class defines the ZeroSum [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{ZeroSum}}(x) = \begin{cases}
|
||||
0 & \textrm{if} \sum_{i=1}^n x_i = 0 \\
|
||||
1 + \left(10000 \left |\sum_{i=1}^n x_i\right|
|
||||
\right)^{0.5} & \textrm{otherwise}
|
||||
\end{cases}
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and
|
||||
:math:`x_i \in [-10, 10]` for :math:`i = 1, ..., n`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` where :math:`\sum_{i=1}^n x_i = 0`
|
||||
|
||||
.. [1] Gavana, A. Global Optimization Benchmarks and AMPGO retrieved 2015
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-10.0] * self.N, [10.0] * self.N))
|
||||
|
||||
self.global_optimum = [[]]
|
||||
self.fglob = 0.0
|
||||
self.change_dimensionality = True
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
if abs(sum(x)) < 3e-16:
|
||||
return 0.0
|
||||
return 1.0 + (10000.0 * abs(sum(x))) ** 0.5
|
||||
|
||||
|
||||
class Zettl(Benchmark):
|
||||
|
||||
r"""
|
||||
Zettl objective function.
|
||||
|
||||
This class defines the Zettl [1]_ global optimization problem. This is a
|
||||
multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Zettl}}(x) = \frac{1}{4} x_{1} + \left(x_{1}^{2} - 2 x_{1}
|
||||
+ x_{2}^{2}\right)^{2}
|
||||
|
||||
|
||||
with :math:`x_i \in [-1, 5]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = -0.0037912` for :math:`x = [-0.029896, 0.0]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-5.0] * self.N, [10.0] * self.N))
|
||||
|
||||
self.global_optimum = [[-0.02989597760285287, 0.0]]
|
||||
self.fglob = -0.003791237220468656
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return (x[0] ** 2 + x[1] ** 2 - 2 * x[0]) ** 2 + 0.25 * x[0]
|
||||
|
||||
|
||||
class Zimmerman(Benchmark):
|
||||
|
||||
r"""
|
||||
Zimmerman objective function.
|
||||
|
||||
This class defines the Zimmerman [1]_ global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Zimmerman}}(x) = \max \left[Zh1(x), Zp(Zh2(x))
|
||||
\textrm{sgn}(Zh2(x)), Zp(Zh3(x))
|
||||
\textrm{sgn}(Zh3(x)),
|
||||
Zp(-x_1)\textrm{sgn}(x_1),
|
||||
Zp(-x_2)\textrm{sgn}(x_2) \right]
|
||||
|
||||
|
||||
Where, in this exercise:
|
||||
|
||||
.. math::
|
||||
|
||||
\begin{cases}
|
||||
Zh1(x) = 9 - x_1 - x_2 \\
|
||||
Zh2(x) = (x_1 - 3)^2 + (x_2 - 2)^2 \\
|
||||
Zh3(x) = x_1x_2 - 14 \\
|
||||
Zp(t) = 100(1 + t)
|
||||
\end{cases}
|
||||
|
||||
|
||||
Where :math:`x` is a vector and :math:`t` is a scalar.
|
||||
|
||||
Here, :math:`x_i \in [0, 100]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = 0` for :math:`x = [7, 2]`
|
||||
|
||||
.. [1] Gavana, A. Global Optimization Benchmarks and AMPGO retrieved 2015
|
||||
|
||||
TODO implementation from Gavana
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([0.0] * self.N, [100.0] * self.N))
|
||||
self.custom_bounds = ([0.0, 8.0], [0.0, 8.0])
|
||||
|
||||
self.global_optimum = [[7.0, 2.0]]
|
||||
self.fglob = 0.0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
Zh1 = lambda x: 9.0 - x[0] - x[1]
|
||||
Zh2 = lambda x: (x[0] - 3.0) ** 2.0 + (x[1] - 2.0) ** 2.0 - 16.0
|
||||
Zh3 = lambda x: x[0] * x[1] - 14.0
|
||||
Zp = lambda x: 100.0 * (1.0 + x)
|
||||
|
||||
return max(Zh1(x),
|
||||
Zp(Zh2(x)) * sign(Zh2(x)),
|
||||
Zp(Zh3(x)) * sign(Zh3(x)),
|
||||
Zp(-x[0]) * sign(x[0]),
|
||||
Zp(-x[1]) * sign(x[1]))
|
||||
|
||||
|
||||
class Zirilli(Benchmark):
|
||||
|
||||
r"""
|
||||
Zettl objective function.
|
||||
|
||||
This class defines the Zirilli [1]_ global optimization problem. This is a
|
||||
unimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\text{Zirilli}}(x) = 0.25x_1^4 - 0.5x_1^2 + 0.1x_1 + 0.5x_2^2
|
||||
|
||||
Here, :math:`n` represents the number of dimensions and
|
||||
:math:`x_i \in [-10, 10]` for :math:`i = 1, 2`.
|
||||
|
||||
*Global optimum*: :math:`f(x) = -0.3523` for :math:`x = [-1.0465, 0]`
|
||||
|
||||
.. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions
|
||||
For Global Optimization Problems Int. Journal of Mathematical Modelling
|
||||
and Numerical Optimisation, 2013, 4, 150-194.
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=2):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = list(zip([-10.0] * self.N, [10.0] * self.N))
|
||||
self.custom_bounds = ([-2.0, 2.0], [-2.0, 2.0])
|
||||
|
||||
self.global_optimum = [[-1.0465, 0.0]]
|
||||
self.fglob = -0.35238603
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
return 0.25 * x[0] ** 4 - 0.5 * x[0] ** 2 + 0.1 * x[0] + 0.5 * x[1] ** 2
|
729
go_benchmark_functions/go_funcs_univariate.py
Normal file
729
go_benchmark_functions/go_funcs_univariate.py
Normal file
|
@ -0,0 +1,729 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from numpy import cos, exp, log, pi, sin, sqrt
|
||||
|
||||
from .go_benchmark import Benchmark, safe_import
|
||||
|
||||
with safe_import():
|
||||
try:
|
||||
from scipy.special import factorial # new
|
||||
except ImportError:
|
||||
from scipy.misc import factorial # old
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# UNIVARIATE SINGLE-OBJECTIVE PROBLEMS
|
||||
#-----------------------------------------------------------------------
|
||||
class Problem02(Benchmark):
|
||||
|
||||
"""
|
||||
Univariate Problem02 objective function.
|
||||
|
||||
This class defines the Univariate Problem02 global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\\text{Problem02}}(x) = \\sin(x) + \\sin \\left(\\frac{10}{3}x \\right)
|
||||
|
||||
Bound constraints: :math:`x \\in [2.7, 7.5]`
|
||||
|
||||
.. figure:: figures/Problem02.png
|
||||
:alt: Univariate Problem02 function
|
||||
:align: center
|
||||
|
||||
**Univariate Problem02 function**
|
||||
|
||||
*Global optimum*: :math:`f(x)=-1.899599` for :math:`x = 5.145735`
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=1):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = [(2.7, 7.5)]
|
||||
|
||||
self.global_optimum = 5.145735
|
||||
self.fglob = -1.899599
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
x = x[0]
|
||||
return sin(x) + sin(10.0 / 3.0 * x)
|
||||
|
||||
|
||||
class Problem03(Benchmark):
|
||||
|
||||
"""
|
||||
Univariate Problem03 objective function.
|
||||
|
||||
This class defines the Univariate Problem03 global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\\text{Problem03}}(x) = - \\sum_{k=1}^6 k \\sin[(k+1)x+k]
|
||||
|
||||
Bound constraints: :math:`x \\in [-10, 10]`
|
||||
|
||||
.. figure:: figures/Problem03.png
|
||||
:alt: Univariate Problem03 function
|
||||
:align: center
|
||||
|
||||
**Univariate Problem03 function**
|
||||
|
||||
*Global optimum*: :math:`f(x)=-12.03124` for :math:`x = -6.7745761`
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=1):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = [(-10, 10)]
|
||||
|
||||
self.global_optimum = -6.7745761
|
||||
self.fglob = -12.03124
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
x = x[0]
|
||||
y = 0.0
|
||||
for k in range(1, 6):
|
||||
y += k * sin((k + 1) * x + k)
|
||||
|
||||
return -y
|
||||
|
||||
|
||||
class Problem04(Benchmark):
|
||||
|
||||
"""
|
||||
Univariate Problem04 objective function.
|
||||
|
||||
This class defines the Univariate Problem04 global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\\text{Problem04}}(x) = - \\left(16x^2 - 24x + 5 \\right) e^{-x}
|
||||
|
||||
Bound constraints: :math:`x \\in [1.9, 3.9]`
|
||||
|
||||
.. figure:: figures/Problem04.png
|
||||
:alt: Univariate Problem04 function
|
||||
:align: center
|
||||
|
||||
**Univariate Problem04 function**
|
||||
|
||||
*Global optimum*: :math:`f(x)=-3.85045` for :math:`x = 2.868034`
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=1):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = [(1.9, 3.9)]
|
||||
|
||||
self.global_optimum = 2.868034
|
||||
self.fglob = -3.85045
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
x = x[0]
|
||||
return -(16 * x ** 2 - 24 * x + 5) * exp(-x)
|
||||
|
||||
|
||||
class Problem05(Benchmark):
|
||||
|
||||
"""
|
||||
Univariate Problem05 objective function.
|
||||
|
||||
This class defines the Univariate Problem05 global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\\text{Problem05}}(x) = - \\left(1.4 - 3x \\right) \\sin(18x)
|
||||
|
||||
Bound constraints: :math:`x \\in [0, 1.2]`
|
||||
|
||||
.. figure:: figures/Problem05.png
|
||||
:alt: Univariate Problem05 function
|
||||
:align: center
|
||||
|
||||
**Univariate Problem05 function**
|
||||
|
||||
*Global optimum*: :math:`f(x)=-1.48907` for :math:`x = 0.96609`
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=1):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = [(0.0, 1.2)]
|
||||
|
||||
self.global_optimum = 0.96609
|
||||
self.fglob = -1.48907
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
x = x[0]
|
||||
return -(1.4 - 3 * x) * sin(18.0 * x)
|
||||
|
||||
|
||||
class Problem06(Benchmark):
|
||||
|
||||
"""
|
||||
Univariate Problem06 objective function.
|
||||
|
||||
This class defines the Univariate Problem06 global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\\text{Problem06}}(x) = - \\left[x + \\sin(x) \\right] e^{-x^2}
|
||||
|
||||
Bound constraints: :math:`x \\in [-10, 10]`
|
||||
|
||||
.. figure:: figures/Problem06.png
|
||||
:alt: Univariate Problem06 function
|
||||
:align: center
|
||||
|
||||
**Univariate Problem06 function**
|
||||
|
||||
*Global optimum*: :math:`f(x)=-0.824239` for :math:`x = 0.67956`
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=1):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = [(-10.0, 10.0)]
|
||||
|
||||
self.global_optimum = 0.67956
|
||||
self.fglob = -0.824239
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
x = x[0]
|
||||
return -(x + sin(x)) * exp(-x ** 2.0)
|
||||
|
||||
|
||||
class Problem07(Benchmark):
|
||||
|
||||
"""
|
||||
Univariate Problem07 objective function.
|
||||
|
||||
This class defines the Univariate Problem07 global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\\text{Problem07}}(x) = \\sin(x) + \\sin \\left(\\frac{10}{3}x \\right) + \\log(x) - 0.84x + 3
|
||||
|
||||
Bound constraints: :math:`x \\in [2.7, 7.5]`
|
||||
|
||||
.. figure:: figures/Problem07.png
|
||||
:alt: Univariate Problem07 function
|
||||
:align: center
|
||||
|
||||
**Univariate Problem07 function**
|
||||
|
||||
*Global optimum*: :math:`f(x)=-1.6013` for :math:`x = 5.19978`
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=1):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = [(2.7, 7.5)]
|
||||
|
||||
self.global_optimum = 5.19978
|
||||
self.fglob = -1.6013
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
x = x[0]
|
||||
return sin(x) + sin(10.0 / 3.0 * x) + log(x) - 0.84 * x + 3
|
||||
|
||||
|
||||
class Problem08(Benchmark):
|
||||
|
||||
"""
|
||||
Univariate Problem08 objective function.
|
||||
|
||||
This class defines the Univariate Problem08 global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\\text{Problem08}}(x) = - \\sum_{k=1}^6 k \\cos[(k+1)x+k]
|
||||
|
||||
Bound constraints: :math:`x \\in [-10, 10]`
|
||||
|
||||
.. figure:: figures/Problem08.png
|
||||
:alt: Univariate Problem08 function
|
||||
:align: center
|
||||
|
||||
**Univariate Problem08 function**
|
||||
|
||||
*Global optimum*: :math:`f(x)=-14.508` for :math:`x = -7.083506`
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=1):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = [(-10, 10)]
|
||||
|
||||
self.global_optimum = -7.083506
|
||||
self.fglob = -14.508
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
x = x[0]
|
||||
|
||||
y = 0.0
|
||||
for k in range(1, 6):
|
||||
y += k * cos((k + 1) * x + k)
|
||||
|
||||
return -y
|
||||
|
||||
|
||||
class Problem09(Benchmark):
|
||||
|
||||
"""
|
||||
Univariate Problem09 objective function.
|
||||
|
||||
This class defines the Univariate Problem09 global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\\text{Problem09}}(x) = \\sin(x) + \\sin \\left(\\frac{2}{3} x \\right)
|
||||
|
||||
Bound constraints: :math:`x \\in [3.1, 20.4]`
|
||||
|
||||
.. figure:: figures/Problem09.png
|
||||
:alt: Univariate Problem09 function
|
||||
:align: center
|
||||
|
||||
**Univariate Problem09 function**
|
||||
|
||||
*Global optimum*: :math:`f(x)=-1.90596` for :math:`x = 17.039`
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=1):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = [(3.1, 20.4)]
|
||||
|
||||
self.global_optimum = 17.039
|
||||
self.fglob = -1.90596
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
x = x[0]
|
||||
return sin(x) + sin(2.0 / 3.0 * x)
|
||||
|
||||
|
||||
class Problem10(Benchmark):
|
||||
|
||||
"""
|
||||
Univariate Problem10 objective function.
|
||||
|
||||
This class defines the Univariate Problem10 global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\\text{Problem10}}(x) = -x\\sin(x)
|
||||
|
||||
Bound constraints: :math:`x \\in [0, 10]`
|
||||
|
||||
.. figure:: figures/Problem10.png
|
||||
:alt: Univariate Problem10 function
|
||||
:align: center
|
||||
|
||||
**Univariate Problem10 function**
|
||||
|
||||
*Global optimum*: :math:`f(x)=-7.916727` for :math:`x = 7.9787`
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=1):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = [(0, 10)]
|
||||
|
||||
self.global_optimum = 7.9787
|
||||
self.fglob = -7.916727
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
x = x[0]
|
||||
return -x * sin(x)
|
||||
|
||||
|
||||
class Problem11(Benchmark):
|
||||
|
||||
"""
|
||||
Univariate Problem11 objective function.
|
||||
|
||||
This class defines the Univariate Problem11 global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\\text{Problem11}}(x) = 2\\cos(x) + \\cos(2x)
|
||||
|
||||
Bound constraints: :math:`x \\in [-\\pi/2, 2\\pi]`
|
||||
|
||||
.. figure:: figures/Problem11.png
|
||||
:alt: Univariate Problem11 function
|
||||
:align: center
|
||||
|
||||
**Univariate Problem11 function**
|
||||
|
||||
*Global optimum*: :math:`f(x)=-1.5` for :math:`x = 2.09439`
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=1):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = [(-pi / 2, 2 * pi)]
|
||||
|
||||
self.global_optimum = 2.09439
|
||||
self.fglob = -1.5
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
x = x[0]
|
||||
return 2 * cos(x) + cos(2 * x)
|
||||
|
||||
|
||||
class Problem12(Benchmark):
|
||||
|
||||
"""
|
||||
Univariate Problem12 objective function.
|
||||
|
||||
This class defines the Univariate Problem12 global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\\text{Problem12}}(x) = \\sin^3(x) + \\cos^3(x)
|
||||
|
||||
Bound constraints: :math:`x \\in [0, 2\\pi]`
|
||||
|
||||
.. figure:: figures/Problem12.png
|
||||
:alt: Univariate Problem12 function
|
||||
:align: center
|
||||
|
||||
**Univariate Problem12 function**
|
||||
|
||||
*Global optimum*: :math:`f(x)=-1` for :math:`x = \\pi`
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=1):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = [(0, 2 * pi)]
|
||||
|
||||
self.global_optimum = pi
|
||||
self.fglob = -1
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
x = x[0]
|
||||
return (sin(x)) ** 3.0 + (cos(x)) ** 3.0
|
||||
|
||||
|
||||
class Problem13(Benchmark):
|
||||
|
||||
"""
|
||||
Univariate Problem13 objective function.
|
||||
|
||||
This class defines the Univariate Problem13 global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\\text{Problem13}}(x) = -x^{2/3} - (1 - x^2)^{1/3}
|
||||
|
||||
Bound constraints: :math:`x \\in [0.001, 0.99]`
|
||||
|
||||
.. figure:: figures/Problem13.png
|
||||
:alt: Univariate Problem13 function
|
||||
:align: center
|
||||
|
||||
**Univariate Problem13 function**
|
||||
|
||||
*Global optimum*: :math:`f(x)=-1.5874` for :math:`x = 1/\\sqrt(2)`
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=1):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = [(0.001, 0.99)]
|
||||
|
||||
self.global_optimum = 1.0 / sqrt(2)
|
||||
self.fglob = -1.5874
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
x = x[0]
|
||||
return -x ** (2.0 / 3.0) - (1.0 - x ** 2) ** (1.0 / 3.0)
|
||||
|
||||
|
||||
class Problem14(Benchmark):
|
||||
|
||||
"""
|
||||
Univariate Problem14 objective function.
|
||||
|
||||
This class defines the Univariate Problem14 global optimization problem. This
|
||||
is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\\text{Problem14}}(x) = -e^{-x} \\sin(2\\pi x)
|
||||
|
||||
Bound constraints: :math:`x \\in [0, 4]`
|
||||
|
||||
.. figure:: figures/Problem14.png
|
||||
:alt: Univariate Problem14 function
|
||||
:align: center
|
||||
|
||||
**Univariate Problem14 function**
|
||||
|
||||
*Global optimum*: :math:`f(x)=-0.788685` for :math:`x = 0.224885`
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=1):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = [(0.0, 4.0)]
|
||||
|
||||
self.global_optimum = 0.224885
|
||||
self.fglob = -0.788685
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
x = x[0]
|
||||
return -exp(-x) * sin(2.0 * pi * x)
|
||||
|
||||
|
||||
class Problem15(Benchmark):
|
||||
|
||||
"""
|
||||
Univariate Problem15 objective function.
|
||||
|
||||
This class defines the Univariate Problem15 global optimization problem.
|
||||
This is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\\text{Problem15}}(x) = \\frac{x^{2} - 5 x + 6}{x^{2} + 1}
|
||||
|
||||
Bound constraints: :math:`x \\in [-5, 5]`
|
||||
|
||||
.. figure:: figures/Problem15.png
|
||||
:alt: Univariate Problem15 function
|
||||
:align: center
|
||||
|
||||
**Univariate Problem15 function**
|
||||
|
||||
*Global optimum*: :math:`f(x)=-0.03553` for :math:`x = 2.41422`
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=1):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = [(-5.0, 5.0)]
|
||||
|
||||
self.global_optimum = 2.41422
|
||||
self.fglob = -0.03553
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
x = x[0]
|
||||
return -(-x ** 2.0 + 5 * x - 6) / (x ** 2 + 1)
|
||||
|
||||
|
||||
class Problem18(Benchmark):
|
||||
|
||||
"""
|
||||
Univariate Problem18 objective function.
|
||||
|
||||
This class defines the Univariate Problem18 global optimization problem.
|
||||
This is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\\text{Problem18}}(x) = \\begin{cases}(x-2)^2 & \\textrm{if} \\hspace{5pt} x \\leq 3 \\\\
|
||||
2\\log(x-2)+1&\\textrm{otherwise}\\end{cases}
|
||||
|
||||
Bound constraints: :math:`x \\in [0, 6]`
|
||||
|
||||
.. figure:: figures/Problem18.png
|
||||
:alt: Univariate Problem18 function
|
||||
:align: center
|
||||
|
||||
**Univariate Problem18 function**
|
||||
|
||||
*Global optimum*: :math:`f(x)=0` for :math:`x = 2`
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=1):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = [(0.0, 6.0)]
|
||||
|
||||
self.global_optimum = 2
|
||||
self.fglob = 0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
x = x[0]
|
||||
|
||||
if x <= 3:
|
||||
return (x - 2.0) ** 2.0
|
||||
|
||||
return 2 * log(x - 2.0) + 1
|
||||
|
||||
|
||||
class Problem20(Benchmark):
|
||||
|
||||
"""
|
||||
Univariate Problem20 objective function.
|
||||
|
||||
This class defines the Univariate Problem20 global optimization problem.
|
||||
This is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\\text{Problem20}}(x) = -[x-\\sin(x)]e^{-x^2}
|
||||
|
||||
Bound constraints: :math:`x \\in [-10, 10]`
|
||||
|
||||
.. figure:: figures/Problem20.png
|
||||
:alt: Univariate Problem20 function
|
||||
:align: center
|
||||
|
||||
**Univariate Problem20 function**
|
||||
|
||||
*Global optimum*: :math:`f(x)=-0.0634905` for :math:`x = 1.195137`
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=1):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = [(-10, 10)]
|
||||
|
||||
self.global_optimum = 1.195137
|
||||
self.fglob = -0.0634905
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
x = x[0]
|
||||
return -(x - sin(x)) * exp(-x ** 2.0)
|
||||
|
||||
|
||||
class Problem21(Benchmark):
|
||||
|
||||
"""
|
||||
Univariate Problem21 objective function.
|
||||
|
||||
This class defines the Univariate Problem21 global optimization problem.
|
||||
This is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\\text{Problem21}}(x) = x \\sin(x) + x \\cos(2x)
|
||||
|
||||
Bound constraints: :math:`x \\in [0, 10]`
|
||||
|
||||
.. figure:: figures/Problem21.png
|
||||
:alt: Univariate Problem21 function
|
||||
:align: center
|
||||
|
||||
**Univariate Problem21 function**
|
||||
|
||||
*Global optimum*: :math:`f(x)=-9.50835` for :math:`x = 4.79507`
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=1):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = [(0, 10)]
|
||||
|
||||
self.global_optimum = 4.79507
|
||||
self.fglob = -9.50835
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
x = x[0]
|
||||
return x * sin(x) + x * cos(2.0 * x)
|
||||
|
||||
|
||||
class Problem22(Benchmark):
|
||||
|
||||
"""
|
||||
Univariate Problem22 objective function.
|
||||
|
||||
This class defines the Univariate Problem22 global optimization problem.
|
||||
This is a multimodal minimization problem defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
f_{\\text{Problem22}}(x) = e^{-3x} - \\sin^3(x)
|
||||
|
||||
Bound constraints: :math:`x \\in [0, 20]`
|
||||
|
||||
.. figure:: figures/Problem22.png
|
||||
:alt: Univariate Problem22 function
|
||||
:align: center
|
||||
|
||||
**Univariate Problem22 function**
|
||||
|
||||
*Global optimum*: :math:`f(x)=e^{-27\\pi/2} - 1` for :math:`x = 9\\pi/2`
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, dimensions=1):
|
||||
Benchmark.__init__(self, dimensions)
|
||||
|
||||
self._bounds = [(0, 20)]
|
||||
|
||||
self.global_optimum = 9.0 * pi / 2.0
|
||||
self.fglob = exp(-27.0 * pi / 2.0) - 1.0
|
||||
|
||||
def fun(self, x, *args):
|
||||
self.nfev += 1
|
||||
|
||||
x = x[0]
|
||||
return exp(-3.0 * x) - (sin(x)) ** 3.0
|
Loading…
Reference in a new issue