ParaMonte MATLAB 3.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
getFunc.m File Reference

Go to the source code of this file.

Functions

function getFunc (in x, in y)
 Return the value of the 2-dimensional Himmelblau function at the specified input value. More...
 

Function Documentation

◆ getFunc()

function getFunc ( in  x,
in  y 
)

Return the value of the 2-dimensional Himmelblau function at the specified input value.

Himmelblau's function is a multi-modal function, used to test the performance of optimization algorithms. The function is defined by:

\begin{equation} H(x, y) = (x^{2} + y - 11)^{2} + (x + y^{2} - 7)^{2} ~. \end{equation}

It has one local maximum at \(x = -0.270845\) and \(y = -0.923039\) where \(H(x, y) = 181.617\), and four identical local minima:

\begin{eqnarray} H(3.0,2.0) &=& 0.0 ~,\\ H(-2.805118, 3.131312) &=& 0.0 ~,\\ H(-3.779310, -3.283186) &=& 0.0 ~,\\ H(3.584428, -1.848126) &=& 0.0 ~. \end{eqnarray}

The function is named after David Mautner Himmelblau (1924–2011), who introduced it.
The locations of all the minima can be found analytically.

Parameters
[in]x: The input scalar or array of the same rank and shape as other input array-like arguments of type MATLAB double, representing the x-component of the state within the domain of Himmelblau function at which the function value must be computed.
[in]y: The input scalar or array of the same rank and shape as other input array-like arguments of type MATLAB double, representing the y-component of the state within the domain of Himmelblau function at which the function value must be computed.
Returns
func : The output scalar or array of the same rank and shape as the input array-like arguments representing the value of the Himmelblau function at the specified input x and y.


Possible calling interfaces

func = pm.stats.himmelblau.getFunc(x, y);
See also
pm.stats.himmelblau.getFunc
pm.stats.himmelblau.getLogUDF
pm.sampling.Paradram


Example usage

1cd(fileparts(mfilename('fullpath'))); % Change working directory to source code directory.
2addpath('../../../../../'); % Add the ParaMonte library root directory to the search path.
3
4range = -6 : 0.01 : 6;
5[x, y] = meshgrid(range, range);
6z = pm.math.func.himmelblau.getFunc(x, y);
7for dim = 2 : 3
8 figure("color", "white");
9 if dim == 2
10 contourf(x, y, z, 50);
11 else
12 surf(x, y, z, "EdgeColor", "none");
13 zlabel("Z");
14 end
15 xlabel("X");
16 ylabel("Y");
17 cbar = colorbar();
18 ylabel(cbar, "Function Value")
19 pm.vis.figure.savefig("himmelblau.getFunc." + string(dim) + "d.png", "-m3");
20end
function getFunc(in x, in y)
Return the value of the 2-dimensional Himmelblau function at the specified input value.
function root()
Return a scalar MATLAB string containing the root directory of the ParaMonte library package.
function savefig(in varargin)
Export figures in a publication-quality format.

Visualization of the example output


Final Remarks


If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.

  1. If you use any parts or concepts from this library to any extent, please acknowledge the usage by citing the relevant publications of the ParaMonte library.
  2. If you regenerate any parts/ideas from this library in a programming environment other than those currently supported by this ParaMonte library (i.e., other than C, C++, Fortran, MATLAB, Python, R), please also ask the end users to cite this original ParaMonte library.

This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.

Author:
Amir Shahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin