e04vj may be used before e04vh to determine the sparsity pattern for the Jacobian.

Syntax

C#
public static void e04vj(
	int nf,
	int n,
	E04..::..E04VJ_USRFUN usrfun,
	int[] iafun,
	int[] javar,
	out int nea,
	double[] a,
	int[] igfun,
	int[] jgvar,
	out int neg,
	double[] x,
	double[] xlow,
	double[] xupp,
	E04..::..e04vhOptions options,
	out int ifail
)
Visual Basic
Public Shared Sub e04vj ( _
	nf As Integer, _
	n As Integer, _
	usrfun As E04..::..E04VJ_USRFUN, _
	iafun As Integer(), _
	javar As Integer(), _
	<OutAttribute> ByRef nea As Integer, _
	a As Double(), _
	igfun As Integer(), _
	jgvar As Integer(), _
	<OutAttribute> ByRef neg As Integer, _
	x As Double(), _
	xlow As Double(), _
	xupp As Double(), _
	options As E04..::..e04vhOptions, _
	<OutAttribute> ByRef ifail As Integer _
)
Visual C++
public:
static void e04vj(
	int nf, 
	int n, 
	E04..::..E04VJ_USRFUN^ usrfun, 
	array<int>^ iafun, 
	array<int>^ javar, 
	[OutAttribute] int% nea, 
	array<double>^ a, 
	array<int>^ igfun, 
	array<int>^ jgvar, 
	[OutAttribute] int% neg, 
	array<double>^ x, 
	array<double>^ xlow, 
	array<double>^ xupp, 
	E04..::..e04vhOptions^ options, 
	[OutAttribute] int% ifail
)
F#
static member e04vj : 
        nf : int * 
        n : int * 
        usrfun : E04..::..E04VJ_USRFUN * 
        iafun : int[] * 
        javar : int[] * 
        nea : int byref * 
        a : float[] * 
        igfun : int[] * 
        jgvar : int[] * 
        neg : int byref * 
        x : float[] * 
        xlow : float[] * 
        xupp : float[] * 
        options : E04..::..e04vhOptions * 
        ifail : int byref -> unit 

Parameters

nf
Type: System..::..Int32
On entry: nf, the number of problem functions in Fx, including the objective function (if any) and the linear and nonlinear constraints. Simple upper and lower bounds on x can be defined using the parameters xlow and xupp and should not be included in F.
Constraint: nf>0.
n
Type: System..::..Int32
On entry: n, the number of variables.
Constraint: n>0.
usrfun
Type: NagLibrary..::..E04..::..E04VJ_USRFUN
usrfun must define the problem functions Fx. This method is passed to e04vj as the external parameter usrfun.

A delegate of type E04VJ_USRFUN.

iafun
Type: array<System..::..Int32>[]()[][]
An array of size [lena]
On exit: define the coordinates i,j and values Aij of the nonzero elements of the linear part A of the function Fx=fx+Ax.
In particular, nea triples iafun[k-1],javar[k-1],a[k-1] define the row and column indices i=iafun[k-1] and j=javar[k-1] of the element Aij=a[k-1].
javar
Type: array<System..::..Int32>[]()[][]
An array of size [lena]
On exit: define the coordinates i,j and values Aij of the nonzero elements of the linear part A of the function Fx=fx+Ax.
In particular, nea triples iafun[k-1],javar[k-1],a[k-1] define the row and column indices i=iafun[k-1] and j=javar[k-1] of the element Aij=a[k-1].
nea
Type: System..::..Int32%
On exit: is the number of nonzero entries in A such that Fx=fx+Ax.
a
Type: array<System..::..Double>[]()[][]
An array of size [lena]
On exit: define the coordinates i,j and values Aij of the nonzero elements of the linear part A of the function Fx=fx+Ax.
In particular, nea triples iafun[k-1],javar[k-1],a[k-1] define the row and column indices i=iafun[k-1] and j=javar[k-1] of the element Aij=a[k-1].
igfun
Type: array<System..::..Int32>[]()[][]
An array of size [leng]
On exit: define the coordinates i,j of the nonzero elements of G, the nonlinear part of the derivatives Jx=Gx+A of the function Fx=fx+Ax.
jgvar
Type: array<System..::..Int32>[]()[][]
An array of size [leng]
On exit: define the coordinates i,j of the nonzero elements of G, the nonlinear part of the derivatives Jx=Gx+A of the function Fx=fx+Ax.
neg
Type: System..::..Int32%
On exit: the number of nonzero entries in G.
x
Type: array<System..::..Double>[]()[][]
An array of size [n]
On entry: an initial estimate of the variables x. The contents of x will be used by e04vj in the call of usrfun, and so each element of x should be within the bounds given by xlow and xupp.
xlow
Type: array<System..::..Double>[]()[][]
An array of size [n]
On entry: contain the lower and upper bounds lx and ux on the variables x.
To specify a nonexistent lower bound lxj=-, set xlow[j-1]-bigbnd, where bigbnd is the optional parameter Infinite Bound Size. To specify a nonexistent upper bound xupp[j-1]bigbnd.
To fix the jth variable (say, xj=β, where β<bigbnd), set xlow[j-1]=xupp[j-1]=β.
xupp
Type: array<System..::..Double>[]()[][]
An array of size [n]
On entry: contain the lower and upper bounds lx and ux on the variables x.
To specify a nonexistent lower bound lxj=-, set xlow[j-1]-bigbnd, where bigbnd is the optional parameter Infinite Bound Size. To specify a nonexistent upper bound xupp[j-1]bigbnd.
To fix the jth variable (say, xj=β, where β<bigbnd), set xlow[j-1]=xupp[j-1]=β.
options
Type: NagLibrary..::..E04..::..e04vhOptions
An Object of type E04.e04vjOptions. Used to configure optional parameters to this method.
ifail
Type: System..::..Int32%
On exit: ifail=0 unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).

Description

When using e04vh, if you set the optional parameter Derivative Option=0 and usrfun provides none of the derivatives, you may need to call e04vj to determine the input arrays iafun, javar, a, igfun and jgvar. These arrays define the pattern of nonzeros in the Jacobian matrix. A typical sequence of calls could be
e04vj determines the sparsity pattern for the Jacobian and identifies the constant elements automatically. To do so, e04vj approximates the problem functions, Fx, at three random perturbations of the given initial point x. If an element of the approximate Jacobian is the same at all three points, then it is taken to be constant. If it is zero, it is taken to be identically zero. Since the random points are not chosen close together, the heuristic will correctly classify the Jacobian elements in the vast majority of cases. In general, e04vj finds that the Jacobian can be permuted to the form:
GxA3A2A4,
where A2, A3 and A4 are constant. Note that Gx might contain elements that are also constant, but e04vj must classify them as nonlinear. This is because e04vh ‘removes’ linear variables from the calculation of F by setting them to zero before calling usrfun. A knowledgeable user would be able to move such elements from Fx in usrfun and enter them as part of iafun, javar and a for e04vh.

References

Hock W and Schittkowski K (1981) Test Examples for Nonlinear Programming Codes. Lecture Notes in Economics and Mathematical Systems 187 Springer–Verlag

Error Indicators and Warnings

Errors or warnings detected by the method:
ifail=1
The initialization method (E04VGF not in this release) has not been called or at least one of lencwleniw or lenrw is less than 600.
ifail=2
An input parameter is invalid. The output message provides more details of the invalid parameter.
ifail=3
Undefined user-supplied function.
You have indicated that the problem functions are undefined by setting status=-1 on exit from usrfun. This exit occurs if e04vj is unable to find a point at which the functions are defined.
ifail=4
User requested termination.
You have indicated the wish to terminate the call to e04vj by setting status to a value <-1 on exit from usrfun.
ifail=5
Either lena or leng is too small, resulting in insufficient array to store the Jacobian information. Increase lena and/or leng
ifail=6
Unable to estimate the Jacobian structure.
ifail=7
Internal memory allocation failed when attempting to obtain the required workspace. Please contact NAG.
ifail=8
Internal memory allocation insufficient. Please contact NAG.
ifail=-9000
An error occured, see message report.
ifail=-1000
The array lengths are not the same for arrays
ifail=-1000
The array lengths are not the same for arrays
ifail=-8000
Negative dimension for array value
ifail=-6000
Invalid Parameters value

Accuracy

Not applicable.

Parallelism and Performance

None.

Further Comments

None.

Example

It is a reformulation of Problem 74 from Hock and Schittkowski (1981) and involves the minimization of the nonlinear function
fx=10-6x33+23×10-6x43+3x3+2x4
subject to the bounds
-0.55x10.55,-0.55x20.55,0x31200,0x41200,
to the nonlinear constraints
1000sin-x1-0.25+1000sin-x2-0.25-x3=-894.8,1000sinx1-0.25+1000sinx1-x2-0.25-x4=-894.8,1000sinx2-0.25+1000sinx2-x1-0.25=-1294.8,
and to the linear constraints
-x1+x2-0.55,-x1-x2-0.55.
The initial point, which is infeasible, is
x0=0,0,0,0T,
and fx0=0.
The optimal solution (to five figures) is
x*=0.11887,-0.39623,679.94,1026.0T,
and fx*=5126.4. All the nonlinear constraints are active at the solution.
The formulation of the problem combines the constraints and the objective into a single vector (F).
F=1000sin-x1-0.25+1000sin-x2-0.25-x31000sinx1-0.25+1000sinx1-x2-0.25-x41000sinx2-0.25+1000sinx2-x1-0.25-x1+x2x1-x210-6x33+23×10-6x43+3x3+2x4

Example program (C#): e04vje.cs

Example program data: e04vje.d

Example program results: e04vje.r

See Also