moptipy.examples.vectors package

Examples for continuous vector-based objective functions.

Submodules

moptipy.examples.vectors.ackley module

Ackley’s Function.

Ackley’s function is a continuous, multimodal, differentiable, non-separable, and scalable benchmark function for continuous optimization.

  1. David H. Ackley. A Connectionist Machine for Genetic Hillclimbing. 1987. Volume 28 of The Kluwer International Series in Engineering and Computer Science. Norwell, MA, USA: Kluwer Academic Publisher. ISBN: 978-1-4612-9192. doi:10.1007/978-1-4613-199

class moptipy.examples.vectors.ackley.Ackley[source]

Bases: Objective

Ackley’s function.

lower_bound()[source]

Get the lower bound of the sphere problem.

Return type:

float

Returns:

0

>>> print(Ackley().lower_bound())
0.0
moptipy.examples.vectors.ackley.ackley(x)[source]

Compute Ackley’s function.

Parameters:

x (ndarray) – the np array

Return type:

float

Returns:

the result of Ackley’s function

>>> from numpy import array
>>> print(ackley(array([0.0, 0.0, 0.0])))
0.0
>>> ackley(array([0.0, 0.0, 0.0, 0.0, 0.0, 0.0]))
0.0
>>> print(abs(ackley(array([0.0, 0.0, 0.0]))) < 1e-15)
True
>>> print(ackley(array([2.0, 2.0])))
6.593599079287213
>>> print(ackley(array([-3.0, 2.0])))
7.9889108105187

moptipy.examples.vectors.sphere module

The well-known sphere function.

class moptipy.examples.vectors.sphere.Sphere[source]

Bases: Objective

The well-known sphere function.

lower_bound()[source]

Get the lower bound of the sphere problem.

Return type:

float

Returns:

0

>>> print(Sphere().lower_bound())
0.0
moptipy.examples.vectors.sphere.sphere(x)[source]

Get the sum of the squares of the elements in an array.

Parameters:

x (ndarray) – the np array

Return type:

float

Returns:

the sum of the squares of all elements

>>> print(sphere(np.array([1.0, -2.0, 3.0])))
14.0
>>> print(sphere(np.array([0.0, 0.0, 0.0])))
0.0