polarcbo.objectives.Rosenbrock

class polarcbo.objectives.Rosenbrock(a=1.0, b=100.0)[source]

Bases: objective

Rosenbrock’s function

Rosenbrock’s function is a multimodal function with 4 global minima at \((1,1)\), \((1,1)\), \((1,1)\), and \((1,1)\). The function is defined as

\[f(x,y) = (a-x)^2 + b(y-x^2)^2\]

See Rosenbrock’s function.

Parameters:
  • a (float, optional) – The first parameter of the function. The default is 1.0.

  • b (float, optional) – The second parameter of the function. The default is 100.0.

Examples

>>> import numpy as np
>>> from polarcbo.objectives import Rosenbrock
>>> x = np.array([[1,2], [3,4], [5,6]])
>>> f = Rosenbrock()
>>> f(x)
array([  0.,  76.,  76.])
__call__(x)[source]

Call method for classes that inherit from objective

Parameters:

x (array_like, shape (J, d)) – For a system of \(J\) particles, the i-th row of this array x[i,:] represents the position of the i-th particle.

Returns:

y – The value of the objective function at the positions x.

Return type:

array_like, shape (J,)