NAG Library Routine Document
E04VJF
1 Purpose
E04VJF may be used before
E04VHF to determine the sparsity pattern for the Jacobian.
2 Specification
SUBROUTINE E04VJF ( |
NF, N, USRFUN, IAFUN, JAVAR, A, LENA, NEA, IGFUN, JGVAR, LENG, NEG, X, XLOW, XUPP, CW, LENCW, IW, LENIW, RW, LENRW, CUSER, IUSER, RUSER, IFAIL) |
INTEGER |
NF, N, IAFUN(LENA), JAVAR(LENA), LENA, NEA, IGFUN(LENG), JGVAR(LENG), LENG, NEG, LENCW, IW(LENIW), LENIW, LENRW, IUSER(*), IFAIL |
REAL (KIND=nag_wp) |
A(LENA), X(N), XLOW(N), XUPP(N), RW(LENRW), RUSER(*) |
CHARACTER(8) |
CW(LENCW), CUSER(*) |
EXTERNAL |
USRFUN |
|
3 Description
When using
E04VHF, if you set the optional parameter
and
USRFUN provides none of the derivatives, you may need to call E04VJF 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
CALL E04VGF (CW, LENCW, ... )
CALL E04VJF (NF, N, ... )
CALL E04VLF ('Derivative Option = 0', CW, ... )
CALL E04VHF (START, NF, ... )
E04VJF determines the sparsity pattern for the Jacobian and identifies the constant elements automatically. To do so, E04VJF 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, E04VJF finds that the Jacobian can be permuted to the form:
where
,
and
are constant. Note that
might contain elements that are also constant, but E04VJF must classify them as nonlinear. This is because
E04VHF ‘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
E04VHF.
4 References
Hock W and Schittkowski K (1981) Test Examples for Nonlinear Programming Codes. Lecture Notes in Economics and Mathematical Systems 187 Springer–Verlag
5 Parameters
Note: all optional parameters are described in detail in
Section 12.1 in E04VHF.
- 1: – INTEGERInput
-
On 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:
.
- 2: – INTEGERInput
-
On entry: , the number of variables.
Constraint:
.
- 3: – SUBROUTINE, supplied by the user.External Procedure
-
USRFUN must define the problem functions
. This subroutine is passed to E04VJF as the external parameter
USRFUN.
The specification of
USRFUN is:
SUBROUTINE USRFUN ( |
STATUS, N, X, NEEDF, NF, F, NEEDG, LENG, G, CUSER, IUSER, RUSER) |
INTEGER |
STATUS, N, NEEDF, NF, NEEDG, LENG, IUSER(*) |
REAL (KIND=nag_wp) |
X(N), F(NF), G(LENG), RUSER(*) |
CHARACTER(8) |
CUSER(*) |
|
- 1: – INTEGERInput/Output
-
On entry: indicates the first call to
USRFUN.
- There is nothing special about the current call to USRFUN.
- E04VJF is calling your subroutine for the first time. Some data may need to be input or computed and saved.
On exit: may be used to indicate that you are unable to evaluate
at the current
. (For example, the problem functions may not be defined there).
E04VJF evaluates at random perturbation of the initial point , say . If the functions cannot be evaluated at , you can set , E04VJF will use another random perturbation.
If for some reason you wish to terminate the current problem, set .
- 2: – INTEGERInput
-
On entry: , the number of variables, as defined in the call to E04VJF.
- 3: – REAL (KIND=nag_wp) arrayInput
-
On entry: the variables at which the problem functions are to be calculated. The array must not be altered.
- 4: – INTEGERInput
-
On entry: indicates if
F must be assigned during the call to
USRFUN (see
F).
- 5: – INTEGERInput
-
On entry: , the number of problem functions.
- 6: – REAL (KIND=nag_wp) arrayInput/Output
-
On entry: this will be set by E04VJF.
On exit: the computed
according to the setting of
NEEDF.
If
,
F is not required and is ignored.
If
, the components of
must be calculated and assigned to
F. E04VJF will always call
USRFUN with
.
To simplify the code, you may ignore the value of
NEEDF and compute
on every entry to
USRFUN.
- 7: – INTEGERInput
-
On entry: E04VJF will call
USRFUN with
to indicate that
G is not required.
- 8: – INTEGERInput
-
On entry: the dimension of the array
G as declared in the (sub)program from which E04VJF is called.
- 9: – REAL (KIND=nag_wp) arrayInput/Output
-
On entry: concerns the calculations of the derivatives of the function .
On exit: E04VJF will always call
USRFUN with
:
G is not required to be set on exit but must be declared correctly.
- 10: – CHARACTER(8) arrayUser Workspace
- 11: – INTEGER arrayUser Workspace
- 12: – REAL (KIND=nag_wp) arrayUser Workspace
-
USRFUN is called with the parameters
CUSER,
IUSER and
RUSER as supplied to E04VJF. You are free to use the arrays
CUSER,
IUSER and
RUSER to supply information to
USRFUN as an alternative to using COMMON global variables.
USRFUN must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which E04VJF is called. Parameters denoted as
Input must
not be changed by this procedure.
- 4: – INTEGER arrayOutput
- 5: – INTEGER arrayOutput
- 6: – REAL (KIND=nag_wp) arrayOutput
-
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
.
- 7: – INTEGERInput
-
On entry: the dimension of the arrays
IAFUN,
JAVAR and
A that hold
as declared in the (sub)program from which E04VJF is called.
LENA should be an
overestimate of the number of elements in the linear part of the Jacobian.
Constraint:
.
- 8: – INTEGEROutput
-
On exit: is the number of nonzero entries in such that .
- 9: – INTEGER arrayOutput
- 10: – INTEGER arrayOutput
-
On exit: define the coordinates of the nonzero elements of , the nonlinear part of the derivatives of the function .
- 11: – INTEGERInput
-
On entry: the dimension of the arrays
IGFUN and
JGVAR that define the varying Jacobian elements
as declared in the (sub)program from which E04VJF is called.
LENG should be an
overestimate of the number of elements in the nonlinear part of the Jacobian.
Constraint:
.
- 12: – INTEGEROutput
-
On exit: the number of nonzero entries in .
- 13: – REAL (KIND=nag_wp) arrayInput
-
On entry: an initial estimate of the variables
. The contents of
will be used by E04VJF in the call of
USRFUN, and so each element of
X should be within the bounds given by
XLOW and
XUPP.
- 14: – REAL (KIND=nag_wp) arrayInput
- 15: – REAL (KIND=nag_wp) arrayInput
-
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 .
- 16: – CHARACTER(8) arrayCommunication Array
- 17: – INTEGERInput
-
On entry: the dimension of the array
CW as declared in the (sub)program from which E04VJF is called.
Constraint:
.
- 18: – INTEGER arrayCommunication Array
- 19: – INTEGERInput
-
On entry: the dimension of the array
IW as declared in the (sub)program from which E04VJF is called.
Constraint:
.
- 20: – REAL (KIND=nag_wp) arrayCommunication Array
- 21: – INTEGERInput
-
On entry: the dimension of the array
RW as declared in the (sub)program from which E04VJF is called.
Constraint:
.
- 22: – CHARACTER(8) arrayUser Workspace
- 23: – INTEGER arrayUser Workspace
- 24: – REAL (KIND=nag_wp) arrayUser Workspace
-
CUSER,
IUSER and
RUSER are not used by E04VJF, but are passed directly to
USRFUN and may be used to pass information to this routine as an alternative to using COMMON global variables.
- 25: – INTEGERInput/Output
-
On entry:
IFAIL must be set to
,
. If you are unfamiliar with this parameter you should refer to
Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is
.
When the value is used it is essential to test the value of IFAIL on exit.
On exit:
unless the routine detects an error or a warning has been flagged (see
Section 6).
6 Error Indicators and Warnings
If on entry
or
, explanatory error messages are output on the current error message unit (as defined by
X04AAF).
Errors or warnings detected by the routine:
-
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
The initialization routine
E04VGF has not been called.
-
On entry, .
Constraint: .
On entry, .
Constraint: .
-
User-supplied routine
USRFUN indicates that functions are undefined near given point
X.
You have indicated that the problem functions are undefined by setting on exit from USRFUN. This exit occurs if E04VJF is unable to find a point at which the functions are defined.
-
User-supplied routine
USRFUN requested termination.
You have indicated the wish to terminate the call to E04VJF by setting STATUS to a value on exit from USRFUN.
-
Either
LENA or
LENG is too small. Increase both of them and corresponding array sizes.
and
.
-
Cannot estimate Jacobian structure at given point
X.
-
Internal error: memory allocation failed when attempting to allocate workspace sizes
,
and
. Please contact
NAG.
-
Internal memory allocation was insufficient. Please contact
NAG.
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 3.8 in the Essential Introduction for further information.
Your licence key may have expired or may not have been installed correctly.
See
Section 3.7 in the Essential Introduction for further information.
Dynamic memory allocation failed.
See
Section 3.6 in the Essential Introduction for further information.
7 Accuracy
Not applicable.
8 Parallelism and Performance
E04VJF is not threaded by NAG in any implementation.
E04VJF makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the
X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the
Users' Note for your implementation for any additional implementation-specific information.
None.
10 Example
This example shows how to call E04VJF to determine the sparsity pattern of the Jacobian before calling
E04VHF to solve a sparse nonlinear programming problem without providing the Jacobian information in
USRFUN.
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 (
).
10.1 Program Text
Program Text (e04vjfe.f90)
10.2 Program Data
Program Data (e04vjfe.d)
10.3 Program Results
Program Results (e04vjfe.r)