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..::..Int32On entry: , the number of problem functions in , including the objective function (if any) and the linear and nonlinear constraints. Simple upper and lower bounds on can be defined using the parameters xlow and xupp and should not be included in .Constraint: .
- n
- Type: System..::..Int32On entry: , the number of variables.Constraint: .
- usrfun
- Type: NagLibrary..::..E04..::..E04VJ_USRFUNusrfun must define the problem functions . 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 and values of the nonzero elements of the linear part of the function .In particular, nea triples define the row and column indices and of the element .
- javar
- Type: array<System..::..Int32>[]()[][]An array of size [lena]On exit: define the coordinates and values of the nonzero elements of the linear part of the function .In particular, nea triples define the row and column indices and of the element .
- nea
- Type: System..::..Int32%On exit: is the number of nonzero entries in such that .
- a
- Type: array<System..::..Double>[]()[][]An array of size [lena]On exit: define the coordinates and values of the nonzero elements of the linear part of the function .In particular, nea triples define the row and column indices and of the element .
- igfun
- Type: array<System..::..Int32>[]()[][]An array of size [leng]On exit: define the coordinates of the nonzero elements of , the nonlinear part of the derivatives of the function .
- jgvar
- Type: array<System..::..Int32>[]()[][]An array of size [leng]On exit: define the coordinates of the nonzero elements of , the nonlinear part of the derivatives of the function .
- neg
- Type: System..::..Int32%On exit: the number of nonzero entries in .
- x
- Type: array<System..::..Double>[]()[][]An array of size [n]
- xlow
- Type: array<System..::..Double>[]()[][]An array of size [n]On entry: contain the lower and upper bounds and on the variables .To specify a nonexistent lower bound , set , where is the optional parameter Infinite Bound Size. To specify a nonexistent upper bound .To fix the th variable (say, , where ), set .
- xupp
- Type: array<System..::..Double>[]()[][]An array of size [n]On entry: contain the lower and upper bounds and on the variables .To specify a nonexistent lower bound , set , where is the optional parameter Infinite Bound Size. To specify a nonexistent upper bound .To fix the th variable (say, , where ), set .
- options
- Type: NagLibrary..::..E04..::..e04vhOptionsAn Object of type E04.e04vjOptions. Used to configure optional parameters to this method.
- ifail
- Type: System..::..Int32%On exit: 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 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, , at three random perturbations of the given initial point . 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:
where , and are constant. Note that 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 by setting them to zero before calling usrfun. A knowledgeable user would be able to move such elements from 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:
- An input parameter is invalid. The output message provides more details of the invalid parameter.
- Undefined user-supplied function.
- User requested termination.
- Unable to estimate the Jacobian structure.
- Internal memory allocation failed when attempting to obtain the required workspace. Please contact NAG.
- Internal memory allocation insufficient. Please contact NAG.
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
subject to the bounds
to the nonlinear constraints
and to the linear constraints
The initial point, which is infeasible, is
and .
The optimal solution (to five figures) is
and . All the nonlinear constraints are active at the solution.
The formulation of the problem combines the constraints and the objective into a single vector ().
Example program (C#): e04vje.cs