polarcbo.objectives.McCormick

class polarcbo.objectives.McCormick[source]

Bases: objective

McCormick’s function

McCormick’s function is a multimodal function with two global minima at \((-0.54719,-1.54719)\) and \((1.54719,0.54719)\). The function is defined as

\[f(x,y) = \sin(x+y) + (x-y)^2 - 1.5x + 2.5y + 1\]

See McCormick’s function.

Examples

>>> import numpy as np
>>> from polarcbo.objectives import McCormick
>>> x = np.array([[1,2], [3,4], [5,6]])
>>> f = McCormick()
>>> f(x)
array([5.64112001, 8.1569866 , 8.50000979])
__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,)