Mathematical Definition

\[f(x, y)=x^2 + 2y^2 -0.3cos(3\pi x)cos(4\pi y)+0.3\]

Plots

Bohachevsky N. 2 Function

Bohachevsky N. 2 Function

Bohachevsky N. 2 Function

Bohachevsky N. 2 Function

A contour of the function is presented below: Bohachevsky N. 2 Function

Description and Features

  • The function is not convex.
  • The function is defined on 2-dimensional space.
  • The function is non-separable.
  • The function is differentiable.

Input Domain

The function can be defined on any input domain but it is usually evaluated on $x_i \in [-100, 100]$ for $i=1, 2$.

Global Minima

The function has one global minimum $f(\textbf{x}^{\ast}) = 0$ located at $\mathbf{x^\ast}=(0, 0)$.

Implementation

Python

For Python, the function is implemented in the benchmarkfcns package, which can be installed from command line with pip install benchmarkfcns.

from benchmarkfcns import bohachevsky2

print(bohachevsky2([[0, 0],
              [1, 1]]))

MATLAB

An implementation of the Bohachevsky N. 2 Function with MATLAB is provided below.

% Computes the value of Bohachevsky N. 2 benchmark function.
% SCORES = BOHACHEVSKYN2FCN(X) computes the value of the Bohachevsky N. 2
% function at point X. BOHACHEVSKYN2FCN accepts a matrix of size M-by-N and 
% returns a vetor SCORES of size M-by-1 in which each row contains the 
% function value for each row of X.
% 
% Author: Mazhar Ansari Ardeh
% Please forward any comments or bug reports to mazhar.ansari.ardeh at
% Google's e-mail service or feel free to kindly modify the repository.
function scores = bohachevskyn2fcn(x)
    n = size(x, 2);
    assert(n == 2, 'The Bohachevsky N. 2 function is only defined on a 2D space.')
    X = x(:, 1);
    Y = x(:, 2);
    
    scores = (X .^ 2) + (2 * Y .^ 2) - (0.3 * cos(3 * pi * X)) .* (cos(4 * pi * Y)) + 0.3;
end

The function can be represented in Latex as follows:

f(x, y)=x^2 + 2y^2 -0.3cos(3\pi x)cos(4\pi y)+0.3

References:

  • 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), arXiv:1308.4008
  • I. O. Bohachevsky, M. E. Johnson, M. L. Stein, “General Simulated Annealing for Function Optimization,” Technometrics, vol. 28, no. 3, pp. 209-217, 1986.