e04dg {NAGFWrappers}R Documentation

e04dg: Unconstrained minimum, preconditioned conjugate gradient algorithm, function of several variables using first derivatives (comprehensive)

Description

e04dg minimizes an unconstrained nonlinear function of several variables using a pre-conditioned, limited memory quasi-Newton conjugate gradient method. First derivatives (or an ‘acceptable’ finite difference approximation to them) are required. It is intended for use on large scale problems.

Usage

e04dg(objfun, x, optlist,
      n = nrow(x))

Arguments

objfun

function

objfun must calculate the objective function F(x) and possibly its gradient as well for a specified n element vector x.

(MODE,OBJF,OBJGRD) = objfun(mode,n,x,nstate)

x

double array

An initial estimate of the solution.

optlist

options list

Optional parameters may be listed, as shown in the following table:

Name Type Default
Defaults
Estimated Optimal Function Value double
Function Precision double Default = ε^0.9
Iteration Limit integer Default = max(50, 5n)
Iters
Itns
Linesearch Tolerance double Default = 0.9
List Default for e04dg = list
Nolist Default for e04dg = nolist
Maximum Step Length double Default = 10^20
Optimality Tolerance double Default = ε_R^0.8
Print Level integer = 0
Start Objective Check at Variable integer Default = 1
Stop Objective Check at Variable integer Default = n
Verify Level integer Default = 0
Verify
Verify Gradients
Verify Objective Gradients
n

integer: default = nrow(x)

n

, the number of variables.

Details

R interface to the NAG Fortran routine E04DGF.

Value

ITER

integer

The total number of iterations performed.

OBJF

double

The value of the objective function at the final iterate.

OBJGRD

double array

The gradient of the objective function at the final iterate (or its finite difference approximation).

X

double array

The final estimate of the solution.

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/e04dgf.pdf

Examples


optlist <- list()

ifail <- 0
objfun = function(mode, n, x, nstate) {
    
    objgrd <- as.matrix(mat.or.vec(2, 1))
    expx1 <- exp(x[1])
    objf <- expx1 %*% (4 %*% x[1]^2 + 2 %*% x[2]^2 + 4 %*% x[1] %*% 
        x[2] + 2 %*% x[2] + 1)
    
    if (mode == 2) {
        
        objgrd[1] <- 4 %*% expx1 %*% (2 %*% x[1] + x[2]) + objf
        
        objgrd[2] <- 2 %*% expx1 %*% (2 %*% x[2] + 2 %*% x[1] + 
            1)
        
    }
    else {
        
        objgrd <- as.matrix(mat.or.vec(2, 1))
    }
    list(MODE = as.integer(mode), OBJF = objf, OBJGRD = as.matrix(objgrd))
}

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



e04dg(objfun, x, optlist) 


[Package NAGFWrappers version 24.0 Index]