e04cb {NAGFWrappers}R Documentation

e04cb: Unconstrained minimization using simplex algorithm, function of several variables using function values only

Description

e04cb minimizes a general function F(x) of n independent variables x = (x_1x_2 . . . x_n)^T by the Nelder and Mead simplex method (see [Nelder J A Mead R (1965)]). Derivatives of the function need not be supplied.

Usage

e04cb(x, tolf, tolx, funct, monit, maxcal,
      n = nrow(x))

Arguments

x

double array

A guess at the position of the minimum. Note that the problem should be scaled so that the values of the x[i] are of order unity.

tolf

double

The error tolerable in the function values, in the following sense. If f_i for i=1 . . . n+1, are the individual function values at the vertices of the current simplex, and if f_m is the mean of these values, then you can request that e04cb should terminate if

sqrt((1)/(n + 1)∑_i = 1^n + 1(f_i - f_m)^2) < tolf.

tolx

double

The error tolerable in the spatial values, in the following sense. If LV denotes the ‘linearized’ volume of the current simplex, and if LV_init denotes the ‘linearized’ volume of the initial simplex, then you can request that e04cb should terminate if

(LV)/(LV_init) < tolx.

funct

function

funct must evaluate the function F at a specified point. It should be tested separately before being used in conjunction with e04cb.

(FC) = funct(n,xc)

monit

function

monit may be used to monitor the optimization process. It is invoked once every iteration.

() = monit(fmin,fmax,sim,n,ncall,serror,vratio)

maxcal

integer

The maximum number of function evaluations to be allowed.

n

integer: default = nrow(x)

n

, the number of variables.

Details

R interface to the NAG Fortran routine E04CBF.

Value

X

double array

The value of x corresponding to the function value in f.

F

double

The lowest function value found.

IFAIL

integer

ifail =0

unless the function detects an error or a warning has been flagged (see the Errors section in Fortran library documentation).

Author(s)

NAG

References

http://www.nag.co.uk/numeric/FL/nagdoc_fl23/pdf/E04/e04cbf.pdf

Examples


ifail <- 0
funct = function(n, xc) {
    
    fc <- exp(xc[1]) %*% (4 %*% xc[1] %*% (xc[1] + xc[2]) + 2 %*% 
        xc[2] %*% (xc[2] + 1) + 1)
    list(FC = fc)
}
monit = function(fmin, fmax, sim, n, ncall, serror, 
    vratio) {
    
    
    if (user(1) != 0) {
        
        writeLines(toString(cat(sprintf("\nThere have been %d function calls\n", 
            ncall, "\n"))))
        
        
        writeLines(toString(cat(sprintf("The smallest function value is %10.4f\n", 
            fmin, "\n"))))
        
        
        writeLines(toString(cat(sprintf("The simplex is\n", "\n"))))
        
        
        writeLines(toString(cat(sprintf(sim, "\n"))))
        
        
        writeLines(toString(cat(sprintf("The standard deviation in function values at the vertices of the simplex is %10.4f\n", 
            serror, "\n"))))
        
        
        writeLines(toString(cat(sprintf("The linearized volume ratio of the current simplex to the starting one is %10.4f\n", 
            vratio, "\n"))))
        
        
    }
    list()
}

x <- matrix(c(-1, 1), nrow = 2, ncol = 1, byrow = TRUE)



tolf <- sqrt(x02aj()[["result"]])

tolx <- sqrt(tolf)

maxcal <- 100

user <- function(switch_integer) {
    switch(switch_integer, 0)
}

e04cb(x, tolf, tolx, funct, monit, maxcal) 


[Package NAGFWrappers version 24.0 Index]