e04us {NAGFWrappers}R Documentation

e04us: Minimum of a sum of squares, nonlinear constraints, sequential QP method, using function values and optionally first derivatives (comprehensive)

Description

e04us is designed to minimize an arbitrary smooth sum of squares function subject to constraints (which may include simple bounds on the variables, linear constraints and smooth nonlinear constraints) using a sequential quadratic programming (SQP) method. As many first derivatives as possible should be supplied by you; any unspecified derivatives are approximated by finite differences. See the description of the optional argument derivativelevel, in the Fortran library documentation. It is not intended for large sparse problems.

e04us may also be used for unconstrained, bound-constrained and linearly constrained optimization.

Usage

e04us(a, bl, bu, y, confun, objfun, istate, cjac, fjac, clamda, r, x, optlist,
      m = nrow(y),
      n = nrow(x),
      nclin = nrow(a),
      ncnln = nrow(cjac))

Arguments

a

double array

The ith row of a contains the ith row of the matrix A_L of general linear constraints in eqn1. That is, the ith row contains the coefficients of the ith general linear constraint for i=1 . . . nclin.

bl

double array

bu

double array

Must contain the lower bounds and bu the upper bounds, for all the constraints in the following order. The first n elements of each array must contain the bounds on the variables, the next n_L elements the bounds for the general linear constraints (if any) and the next n_N elements the bounds for the general nonlinear constraints (if any). To specify a nonexistent lower bound (i.e., l_j = - infinity), set bl[j] <= - bigbnd, and to specify a nonexistent upper bound (i.e., u_j = + infinity), set bu[j] >= bigbnd; the default value of bigbnd is 10^20, but this may be changed by the optional argument infiniteboundsize. To specify the jth constraint as an equality, set bl[j] = bu[j] = β, say, where abs(β) < bigbnd.

y

double array

The coefficients of the constant vector y of the objective function.

confun

function

confun must calculate the vector c(x) of nonlinear constraint functions and (optionally) its Jacobian ( = ( \partial c)/( \partial x)) for a specified n element vector x. If there are no nonlinear constraints (i.e., ncnln = 0), confun will never be called by e04us and confun may be the dummy function e04udm. (e04udm is included in the NAG Library.) If there are nonlinear constraints, the first call to confun will occur before the first call to objfun.

(MODE,C,CJAC) = confun(mode,ncnln,n,needc,x,cjac,nstate)

objfun

function

objfun must calculate either the ith element of the vector f(x) = (f_1(x)f_2(x) . . . f_m(x))^T or all m elements of f(x) and (optionally) its Jacobian ( = ( \partial f)/( \partial x)) for a specified n element vector x.

(MODE,F,FJAC) = objfun(mode,m,n,needfi,x,fjac,nstate)

istate

integer array

Need not be set if the (default) optional argument coldstart is used.

cjac

double array

In general, cjac need not be initialized before the call to e04us. However, if derivativelevel=3, you may optionally set the constant elements of cjac (see argument nstate in the description of confun). Such constant elements need not be re-assigned on subsequent calls to confun.

fjac

double array

In general, fjac need not be initialized before the call to e04us. However, if derivativelevel=3, you may optionally set the constant elements of fjac (see argument nstate in the description of objfun). Such constant elements need not be re-assigned on subsequent calls to objfun.

clamda

double array

Need not be set if the (default) optional argument coldstart is used.

r

double array

Need not be initialized if the (default) optional argument coldstart is used.

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
Central Difference Interval double Default values are computed
Cold Start Default
Warm Start
Crash Tolerance double Default = 0.01
Defaults
Derivative Level integer Default = 3
Difference Interval double Default values are computed
Feasibility Tolerance double Default = sqrt(ε)
Function Precision double Default = ε^0.9
Hessian no Default = NO
Infinite Bound Size double Default = 10^20
Infinite Step Size double Default = max(bigbnd, 10^20)
JTJ Initial Hessian Default
Unit Initial Hessian
Line Search Tolerance double Default = 0.9
Linear Feasibility Tolerance double Default = sqrt(ε)
Nonlinear Feasibility Tolerance double Default = ε^0.33 or sqrt(ε)
List Default for e04us = list
Nolist Default for e04us = nolist
Major Iteration Limit integer Default = max(50, 3(n + n_L) + 10n_N)
Iteration Limit
Iters
Itns
Major Print Level integer
Print Level = 0
Minor Iteration Limit integer Default = max(50, 3(n + n_L + n_N))
Minor Print Level integer Default = 0
Monitoring File integer Default = - 1
Optimality Tolerance double Default = ε_R^0.8
Reset Frequency integer Default = 2
Start Objective Check At Variable integer Default = 1
Stop Objective Check At Variable integer Default = n
Start Constraint Check At Variable integer Default = 1
Stop Constraint Check At Variable integer Default = n
Step Limit double Default = 2.0
Verify Level integer Default = 0
Verify
Verify Constraint Gradients
Verify Gradients
Verify Objective Gradients
m

integer: default = nrow(y)

m

, the number of subfunctions associated with F(x).

n

integer: default = nrow(x)

n

, the number of variables.

nclin

integer: default = nrow(a)

n_L

, the number of general linear constraints.

ncnln

integer: default = nrow(cjac)

n_N

, the number of nonlinear constraints.

Details

R interface to the NAG Fortran routine E04USF.

Value

ITER

integer

The number of major iterations performed.

ISTATE

integer array

The status of the constraints in the QP working set at the point returned in x. The significance of each possible value of istate[j] is as follows:

C

double array

If ncnln > 0, c[i] contains the value of the ith nonlinear constraint function c_i at the final iterate for i=1 . . . ncnln.

CJAC

double array

If ncnln > 0, cjac contains the Jacobian matrix of the nonlinear constraint functions at the final iterate, i.e., cjac[i, j] contains the partial derivative of the ith constraint function with respect to the jth variable for j=1 . . . n for i=1 . . . ncnln. (See the discussion of argument cjac under confun.)

F

double array

f[i]

contains the value of the ith function f_i at the final iterate for i=1 . . . m.

FJAC

double array

The Jacobian matrix of the functions f_1 , f_2 , . . . , f_m at the final iterate, i.e., fjac[i, j] contains the partial derivative of the ith function with respect to the jth variable for j=1 . . . n for i=1 . . . m. (See also the discussion of argument fjac under objfun.)

CLAMDA

double array

The values of the QP multipliers from the last QP subproblem. clamda[j] should be non-negative if istate[j] = 1 and non-positive if istate[j] = 2.

OBJF

double

The value of the objective function at the final iterate.

R

double array

If hessian=NO, r contains the upper triangular Cholesky factor R of Q^TtildeHQ, an estimate of the transformed and reordered Hessian of the Lagrangian at x (see eqn6). If hessian=YES, r contains the upper triangular Cholesky factor R of H, the approximate (untransformed) Hessian of the Lagrangian, with the variables in the natural order.

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

Examples


optlist <- list()

ifail <- 0
confun = function(mode, ncnln, n, needc, x, cjac, 
    nstate) {
    ldcj <- nrow(cjac)
    
    c <- as.matrix(mat.or.vec(ncnln, 1))
    
    if (nstate == 1) {
        
        cjac <- as.matrix(mat.or.vec(ncnln, n))
        
    }
    
    if (needc[1] > 0) {
        
        if (mode == 0 || mode == 2) {
            
            c[1] <- -0.09 - x[1] %*% x[2] + 0.49 %*% x[2]
            
        }
        if (mode == 1 || mode == 2) {
            
            cjac[1, 1] <- -x[2]
            
            cjac[1, 2] <- -x[1] + 0.49
            
        }
    }
    list(MODE = as.integer(mode), C = as.matrix(c), CJAC = as.matrix(cjac))
}
objfun = function(mode, m, n, needfi, x, fjac, nstate) {
    ldfj <- nrow(fjac)
    
    f <- as.matrix(mat.or.vec(m, 1))
    a <- matrix(c(8, 8, 10, 10, 10, 10, 12, 12, 12, 12, 14, 14, 
        14, 16, 16, 16, 18, 18, 20, 20, 20, 22, 22, 22, 24, 24, 
        24, 26, 26, 26, 28, 28, 30, 30, 30, 32, 32, 34, 36, 36, 
        38, 38, 40, 42), nrow = 1, ncol = 44, byrow = TRUE)
    for (i in c(1:m)) {
        temp <- exp(-x[2] %*% (a[i] - 8))
        
        if (mode == 0 || mode == 2) {
            
            f[i] <- x[1] + (0.49 - x[1]) %*% temp
            
        }
        if (mode == 1 || mode == 2) {
            
            fjac[i, 1] <- 1 - temp
            
            fjac[i, 2] <- -(0.49 - x[1]) %*% (a[i] - 8) %*% temp
            
        }
    }
    list(MODE = as.integer(mode), F = as.matrix(f), FJAC = as.matrix(fjac))
}

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



bl <- matrix(c(0.4, -4, 1, 0), nrow = 4, ncol = 1, 
    byrow = TRUE)



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



y <- matrix(c(0.49, 0.49, 0.48, 0.47, 0.48, 0.47, 
    0.46, 0.46, 0.45, 0.43, 0.45, 0.43, 0.43, 0.44, 0.43, 0.43, 
    0.46, 0.45, 0.42, 0.42, 0.43, 0.41, 0.41, 0.4, 0.42, 0.4, 
    0.4, 0.41, 0.4, 0.41, 0.41, 0.4, 0.4, 0.4, 0.38, 0.41, 0.4, 
    0.4, 0.41, 0.38, 0.4, 0.4, 0.39, 0.39), nrow = 44, ncol = 1, 
    byrow = TRUE)



istate <- as.matrix(mat.or.vec(4, 1))

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



fjac <- matrix(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0), nrow = 44, ncol = 2, byrow = TRUE)



clamda <- as.matrix(mat.or.vec(4, 1))

r <- matrix(c(0, 0, 0, 0), nrow = 2, ncol = 2, byrow = TRUE)



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



e04us(a, bl, bu, y, confun, objfun, istate, cjac, 
    fjac, clamda, r, x, optlist) 


[Package NAGFWrappers version 24.0 Index]