e04nq {NAGFWrappers}R Documentation

e04nq: LP or QP problem (suitable for sparse problems)

Description

e04nq solves sparse linear programming or convex quadratic programming problems. The initialization function e04np must have been called before calling e04nq.

Usage

e04nq(start, qphx, m, n, lenc, ncolh, iobj, objadd, prob, acol, inda, loca, bl, bu, c, names, helast, hs, x, ns, optlist,
      ne = nrow(acol),
      nname = nrow(names))

Arguments

start

string

Indicates how a starting basis (and certain other items) will be obtained.

start='C'

: Requests that an internal Crash procedure be used to choose an initial basis, unless a Basis file is provided via optional arguments oldbasisfile, insertfile or loadfile.

start='B'

: Is the same as start='C' but is more meaningful when a Basis file is given.

start='W'

: Means that a basis is already defined in hs and a start point is already defined in x (probably from an earlier call).

qphx

function

For QP problems, you must supply a version of qphx to compute the matrix product Hx for a given vector x. If H has rows and columns of zeros, it is most efficient to order x so that the nonlinear variables appear first. For example, if x = (yz)^T and only y enters the objective quadratically then

Hx = ( H_1 0 0 0 ) ( y z ) = ( H_1y 0 ) .

In this case, ncolh should be the dimension of y, and qphx should compute H_1y. For FP and LP problems, qphx will never be called by e04nq and hence qphx may be the dummy function e04nsh.

(HX) = qphx(ncolh,x,nstate)

m

integer

m

, the number of general linear constraints (or slacks). This is the number of rows in the linear constraint matrix A, including the free row (if any; see iobj). Note that A must have at least one row. If your problem has no constraints, or only upper or lower bounds on the variables, then you must include a dummy row with sufficiently wide upper and lower bounds (see also acol, inda and loca).

n

integer

n

, the number of variables (excluding slacks). This is the number of columns in the linear constraint matrix A.

lenc

integer

The number of elements in the constant objective vector c.

ncolh

integer

n_H

, the number of leading nonzero columns of the Hessian matrix H. For FP and LP problems, ncolh must be set to zero.

iobj

integer

If iobj > 0, row iobj of A is a free row containing the nonzero elements of the vector c appearing in the linear objective term c^Tx.

objadd

double

The constant q, to be added to the objective for printing purposes. Typically objadd = 0.0E0.

prob

string

The name for the problem. It is used in the printed solution and in some functions that output Basis files. A blank name may be used.

acol

double array

The nonzero elements of A, ordered by increasing column index. Note that all elements must be assigned a value in the calling program.

inda

integer array

inda[i]

must contain the row index of the nonzero element stored in acol[i] for i=1 . . . ne. Thus a pair of values (acol[i]inda[i]) contains a matrix element and its corresponding row index.

loca

integer array

loca[j]

must contain the index in acol and inda of the start of the jth column for j=1 . . . n. Thus for j = 1 : n, the entries of column j are held in acol[k:l] and their corresponding row indices are in inda[k:l], where k = loca[j] and l = loca[j+1] - 1. To specify the jth column as empty, set loca[j] = loca[j+1]. Note that the first and last elements of loca must be loca[1] = 1 and loca[n+1] = ne + 1. If your problem has no constraints, or just bounds on the variables, you may include a dummy ‘free’ row with a single (zero) element by setting ne = 1, acol[1] = 0.0, inda[1] = 1, loca[1] = 1, and loca[j] = 2, for j = 2 : n + 1. This row is made ‘free’ by setting its bounds to be bl[n+1] = - bigbnd and bu[n+1] = bigbnd, where bigbnd is the value of the optional argument infiniteboundsize.

bl

double array

l

, the lower bounds for all the variables and general constraints, in the following order. The first n elements of bl must contain the bounds on the variables x, and the next m elements the bounds for the general linear constraints Ax (which, equivalently, are the bounds for the slacks, s) and the free row (if any). To fix the jth variable, set bl[j] = bu[j] = β, say, where abs(β) < bigbnd. To specify a nonexistent lower bound (i.e., l_j = - infinity), set bl[j] <= - bigbnd. Here, bigbnd is the value of the optional argument infiniteboundsize. To specify the jth constraint as an equality, set bl[n+j] = bu[n+j] = β, say, where abs(β) < bigbnd. Note that the lower bound corresponding to the free row must be set to - infinity and stored in bl[n+iobj].

bu

double array

u

, the upper bounds for all the variables and general constraints, in the following order. The first n elements of bu must contain the bounds on the variables x, and the next m elements the bounds for the general linear constraints Ax (which, equivalently, are the bounds for the slacks, s) and the free row (if any). To specify a nonexistent upper bound (i.e., u_j = + infinity), set bu[j] >= bigbnd. Note that the upper bound corresponding to the free row must be set to + infinity and stored in bu[n+iobj].

c

double array

Contains the explicit objective vector c (if any). If the problem is of type FP, or if lenc = 0, then c is not referenced. (In that case, c may be dimensioned eqn1, or it could be any convenient array.)

double array

Contains the explicit objective vector c (if any). If the problem is of type FP, or if lenc = 0, then c is not referenced. (In that case, c may be dimensioned eqn1, or it could be any convenient array.)

names

string array

The optional column and row names, respectively.

helast

integer array

Defines which variables are to be treated as being elastic in elastic mode. The allowed values of helast are: helast need not be assigned if optional argument elasticmode=0.

hs

integer array

If start='C', 'B', and a Basis file of some sort is to be input (see the description of the optional arguments oldbasisfile, insertfile or loadfile), then hs and x need not be set at all.

x

double array

The initial values of the variables x, and, if start='W', the slacks s, i.e., (xs). (See the description for argument hs.)

ns

integer

n_S

, the number of superbasics. For QP problems, ns need not be specified if start='C', but must retain its value from a previous call when start='W'. For FP and LP problems, ns need not be initialized.

optlist

options list

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

Name Type Default
Check Frequency integer Default = 60
Crash Option integer Default = 3
Crash Tolerance double Default = 0.1
Defaults
Dump File integer Default = 0
Load File integer Default = 0
Elastic Mode integer Default = 1
Elastic Objective integer Default = 1
Elastic Weight double Default = 1.0
Expand Frequency integer Default = 10000
Factorization Frequency integer Default = 100(LP) or 50(QP)
Feasibility Tolerance double Default = max10^ - 6sqrt(ε)
Infinite Bound Size double Default = 10^20
Iterations Limit integer Default = max1000010maxmn
LU Density Tolerance double Default = 0.6
LU Singularity Tolerance double Default = ε^(2)/(3)
LU Factor Tolerance double Default = 100.0
LU Update Tolerance double Default = 10.0
LU Partial Pivoting Default
LU Complete Pivoting
LU Rook Pivoting
Minimize Default
Maximize
Feasible Point
New Basis File integer Default = 0
Backup Basis File integer Default = 0
Save Frequency integer Default = 100
Nolist Default
List
Old Basis File integer Default = 0
Optimality Tolerance double Default = max10^ - 6sqrt(ε)
Partial Price integer Default = 10(LP) or 1(QP)
Pivot Tolerance double Default = ε^(2)/(3)
Print File integer Default = 0
Print Frequency integer Default = 100
Print Level integer Default = 1
Punch File integer Default = 0
Insert File integer Default = 0
QPSolver Cholesky Default
QPSolver CG
QPSolver QN
Reduced Hessian Dimension integer Default = 1(LP) or min(2000n_H + 1n)(QP)
Scale Option integer Default = 2
Scale Tolerance double Default = 0.9
Scale Print
Solution File integer Default = 0
Summary File integer Default = 0
Summary Frequency integer Default = 100
Superbasics Limit integer Default = 1(LP) or minn_H + 1n(QP)
Suppress Parameters
System Information No Default
System Information Yes
Timing Level integer Default = 0
Unbounded Step Size double Default = infbnd
ne

integer: default = nrow(acol)

The number of nonzero elements in A.

nname

integer: default = nrow(names)

The number of column (i.e., variable) and row names supplied in the array names.

nname = 1

: There are no names. Default names will be used in the printed output.

nname = n + m

: All names must be supplied.

Details

R interface to the NAG Fortran routine E04NQF.

Value

HS

integer array

The final states of the variables and slacks (xs). The significance of each possible value of hs[j] is as follows:

X

double array

The final values of the variables and slacks (xs).

PI

double array

Contains the dual variables π (a set of Lagrange multipliers (shadow prices) for the general constraints).

RC

double array

Contains the reduced costs, g - ( A -I ) ^Tπ. The vector g is the gradient of the objective if x is feasible, otherwise it is the gradient of the Phase 1 objective. In the former case, g(i) = 0, for i = n + 1 : m, hence rc(n + 1 : m) = π.

NS

integer

The final number of superbasics. This will be zero for FP and LP problems.

NINF

integer

The number of infeasibilities.

SINF

double

The sum of the scaled infeasibilities. This will be zero if ninf = 0, and is most meaningful when scaleoption=0.

OBJ

double

The value of the objective function.

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

Examples


optlist<-list()

ifail<-0
qphx=function(ncolh,x,nstate){

hx<-as.matrix(mat.or.vec(ncolh,1))
hx[1]<-2%*%x[1]
hx[2]<-2%*%x[2]
hx[3]<-2%*%(x[3]+x[4])
hx[4]<-hx[3]
hx[5]<-2%*%x[5]
hx[6]<-2%*%(x[6]+x[7])
hx[7]<-hx[6]
list(HX=as.matrix(hx))
}

start<-'C'

m<-8

n<-7

lenc<-0

ncolh<-7

iobj<-8

objadd<-0

prob<-''

acol<-matrix(c(0.02,0.02,0.03,1,0.7,0.02,0.15,-200,0.06,0.75,0.03,0.04,0.05,0.04,1,-2000,0.02,1,0.01,0.08,0.08,0.8,-2000,1,0.12,0.02,0.02,0.75,0.04,-2000,0.01,0.8,0.02,1,0.02,0.06,0.02,-2000,1,0.01,0.01,0.97,0.01,400,0.97,0.03,1,400),nrow=48,ncol=1,byrow=TRUE)



inda<-matrix(c(7,5,3,1,6,4,2,8,7,6,5,4,3,2,1,8,2,1,4,3,7,6,8,1,7,3,4,6,2,8,5,6,7,1,2,3,4,8,1,2,3,6,7,8,7,2,1,8),nrow=48,ncol=1,byrow=TRUE)



loca<-matrix(c(1,9,17,24,31,39,45,49),nrow=8,ncol=1,byrow=TRUE)



bl<-matrix(c(0,0,400,100,0,0,0,2000,-9.999999999999999e+24,-9.999999999999999e+24,-9.999999999999999e+24,-9.999999999999999e+24,1500,250,-9.999999999999999e+24),nrow=15,ncol=1,byrow=TRUE)



bu<-matrix(c(200,2500,800,700,1500,9.999999999999999e+24,9.999999999999999e+24,2000,60,100,40,30,9.999999999999999e+24,300,9.999999999999999e+24),nrow=15,ncol=1,byrow=TRUE)



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



names<-matrix(c('...X1...','...X2...','...X3...','...X4...','...X5...','...X6...','...X7...','..ROW1..','..ROW2..','..ROW3..','..ROW4..','..ROW5..','..ROW6..','..ROW7..','..COST..'),nrow=15,byrow=TRUE)



helast<-matrix(c(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),nrow=15,ncol=1,byrow=TRUE)



hs<-matrix(c(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),nrow=15,ncol=1,byrow=TRUE)



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



ns<-0

e04nq(start,qphx,m,n,lenc,ncolh,iobj,objadd,prob,acol,inda,loca,bl,bu,c,names,helast,hs,x,ns,optlist)


[Package NAGFWrappers version 24.0 Index]