branin: Branin-Hoo 2-dimensional test function

Description Usage Arguments Details Value Author(s) Examples

Description

Branin-Hoo 2-dimensional test function.

Usage

1
branin(x)

Arguments

x

Numeric vector with length 2.

Details

The Branin-Hoo function is defined here over [0, 1] x [0, 1], instead of [-5, 0] x [10, 15] as usual. It has 3 global minima at (nearly) : x1 = c(0.96, 0.15), x2 = c(0.12, 0.82) and x3 = c(0.54, 0.15).

Value

The Branin-Hoo function's value.

Author(s)

David Ginsbourger

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
GD <- Grid(nlevels = c("x" = 20, "y" = 20))
x <- levels(GD)[[1]]; y <- levels(GD)[[2]]
f  <- apply_Grid(GD, branin)
dim(f) <- nlevels(GD)
contour(x = x, y = y, z = f, nlevels = 40)
nOut <- 100; Xout2 <- array(runif(nOut * 2), dim = c(nOut, 2))
colnames(Xout2) <- c("x", "y")

## interpolate using default method (Lagrange)
GIL <- interp_Grid(X = GD, Y = f, Xout = Xout2)

## interpolate using a natural spline
GIS <- interp_Grid(X = GD, Y = f, Xout = Xout2,
                 cardinalBasis1d = function(x, xout) {
                     cardinalBasis_natSpline(x = x, xout = xout)$CB
                  })
F <- apply(Xout2, 1, branin)
mat <- cbind(Xout2, fTrue = F, fIntL = GIL, errorLag = F - GIL,
             fIntS = GIS, errorSpline = F - GIS)
apply(mat[ , c("errorLag", "errorSpline")], 2, function(x) mean(abs(x)))
## Not run: 
## for the users of the "rgl" package only...
library(rgl)
persp3d(x = x, y = y, z = f, aspect = c(1, 1, 0.5), col = "lightblue", alpha = 0.8)
spheres3d(Xout2[ , 1], Xout2[ , 2], GIS, col = "orangered",
          radius = 2)

## End(Not run)

smint documentation built on April 14, 2017, 1:49 p.m.