e04kz {NAGFWrappers} R Documentation

## e04kz: Minimum, function of several variables, modified Newton algorithm, simple bounds, using first derivatives (easy-to-use)

### Description

e04kz is an easy-to-use modified Newton algorithm for finding a minimum of a function F(x_1x_2 . . . x_n), subject to fixed upper and lower bounds on the independent variables x_1 , x_2 , . . . , x_n, when first derivatives of F are available. It is intended for functions which are continuous and which have continuous first and second derivatives (although it will usually work even if the derivatives have occasional discontinuities).

### Usage

e04kz(ibound, funct2, bl, bu, x,
n=nrow(bl)
)


### Arguments

 ibound integer Indicates whether the facility for dealing with bounds of special forms is to be used. It must be set to one of the following values: ibound = 0: If you are supplying all the l_j and u_j individually. ibound = 1: If there are no bounds on any x_j. ibound = 2: If all the bounds are of the form 0 <= x_j. ibound = 3: If l_1 = l_2 = \cdots = l_n and u_1 = u_2 = \cdots = u_n. funct2 void function You must supply this function to calculate the values of the function F(x) and its first derivatives ( \partial F)/( \partial x_j) at any point x. It should be tested separately before being used in conjunction with e04kz (see the E04 chapter). bl double array The lower bounds l_j. bu double array The upper bounds u_j. x double array x(j) must be set to a guess at the jth component of the position of the minimum for j=1 . . . n. The function checks the gradient at the starting point, and is more likely to detect any error in your programming if the initial x(j) are nonzero and mutually distinct. n integer: default = nrow(bl) The number n of independent variables.

### Details

R interface to the NAG Fortran routine E04KZF.

### Value

 bl double array The lower bounds actually used by e04kz. bu double array The upper bounds actually used by e04kz. x double array The lowest point found during the calculations of the position of the minimum. f double The value of F(x) corresponding to the final point stored in x. g double array The value of ( \partial F)/( \partial x_j) corresponding to the final point stored in x for j=1 . . . n; the value of g(j) for variables not on a bound should normally be close to zero.

NAG

### Examples

e04kz_funct2 = function(n, xc, fc, gc) {

gc <- as.matrix(mat.or.vec(n, 1))
fc <- (xc + 10 * xc)^2 + 5 * (xc - xc)^2 + (xc -
2 * xc)^4 + 10 * (xc - xc)^4
gc <- 2 * (xc + 10 * xc) + 40 * (xc - xc)^3
gc <- 20 * (xc + 10 * xc) + 4 * (xc - 2 * xc)^3
gc <- 10 * (xc - xc) - 8 * (xc - 2 * xc)^3
gc <- -10 * (xc - xc) - 40 * (xc - xc)^3
list(FC = fc, GC = as.matrix(gc))
}

ibound <- 0
bl <- matrix(c(1, -2, -1e+06, 1), nrow = 4, ncol = 1,
byrow = TRUE)

bu <- matrix(c(3, 0, 1e+06, 3), nrow = 4, ncol = 1,
byrow = TRUE)

x <- matrix(c(3, -1, 0, 1), nrow = 4, ncol = 1, byrow = TRUE)

e04kz(ibound, e04kz_funct2, bl, bu, x)



[Package NAGFWrappers version 24.0 Index]