himmelblau: Himmelblau's Function

View source: R/testfunctions.R

himmelblauR Documentation

Himmelblau's Function

Description

Himmelblau's function is defined by

f_{\rm himmelblau}(x_1, x_2) = (x_1^2 + x_2 - 11)^2 + (x_1 + x_2^2 -7)^2

with x_1, x_2 \in [-5, 5].

Usage

himmelblau(x)
himmelblauGrad(x)

Arguments

x

a numeric vector of length 2 or a numeric matrix with n rows and 2 columns.

Details

The gradient of Himmelblau's function is

\nabla f_{\rm himmelblau}(x_1, x_2) = \begin{pmatrix} 4 x_1 (x_1^2 + x_2 - 11) + 2 (x_1 + x_2^2 - 7) \\ 2 (x_1^2 + x_2 - 11) + 4 x_2 (x_1 + x_2^2 - 7) \end{pmatrix}.

Himmelblau's function has four global minima f_{\rm himmelblau}(x^{\star}) = 0 at x^{\star} = (3, 2), x^{\star} = (-2.805118, 3.131312), x^{\star} = (-3.779310, -3.283186) and x^{\star} = (3.584428, -1.848126).

Value

himmelblau returns the function value of Himmelblau's function at x.

himmelblauGrad returns the gradient of Himmelblau's function at x.

Author(s)

Carmen van Meegen

References

Himmelblau, D. (1972). Applied Nonlinear Programming. McGraw-Hill. ISBN 0-07-028921-2.

Jamil, M. and Yang, X.-S. (2013). A Literature Survey of Benchmark Functions for Global Optimization Problems. International Journal of Mathematical Modelling and Numerical Optimisation, 4(2):150-–194. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1504/IJMMNO.2013.055204")}.

Surjanovic, S. and Bingham, D. (2013). Virtual Library of Simulation Experiments: Test Functions and Datasets. https://www.sfu.ca/~ssurjano/ (retrieved January 19, 2024).

Examples

# Contour plot of Himmelblau's function 
n.grid <- 50
x1 <- x2 <- seq(-5, 5, length.out = n.grid)
y <- outer(x1, x2, function(x1, x2) himmelblau(cbind(x1, x2)))
contour(x1, x2, y, xaxs = "i", yaxs = "i", nlevels = 25, xlab = "x1", ylab = "x2")

# Perspective plot of Himmelblau's function
col.pal <- colorRampPalette(c("#00007F", "blue", "#007FFF", "cyan", "#7FFF7F", "yellow",
	"#FF7F00", "red", "#7F0000"))
colors <- col.pal(100)
y.facet.center <- (y[-1, -1] + y[-1, -n.grid] + y[-n.grid, -1] + y[-n.grid, -n.grid])/4
y.facet.range <- cut(y.facet.center, 100)
persp(x1, x2, y, phi = 30, theta = -315, expand = 0.75, ticktype = "detailed", 
	col = colors[y.facet.range])

gek documentation built on April 4, 2025, 12:35 a.m.

Related to himmelblau in gek...