NAG AD Library
e04us_a1w_f (lsq_gencon_deriv_a1w)

Note: a1w denotes that first order adjoints are computed in working precision; this has the corresponding argument type nagad_a1w_w_rtype. Also available is the t1w (first order tangent linear) mode, the interface of which is implied by replacing a1w by t1w throughout this document. Additionally, the p0w (passive interface, as alternative to the FL interface) mode is available and can be inferred by replacing of active types by the corresponding passive types. The method of codifying AD implementations in the routine name and corresponding argument types is described in the NAG AD Library Introduction.
Settings help

AD Name Style:


AD Specification Language:

1 Purpose

e04us_a1w_f is the adjoint version of the primal routine e04usf.

2 Specification

Fortran Interface
Subroutine e04us_a1w_f ( ad_handle, m, n, nclin, ncnln, lda, ldcj, ldfj, ldr, a, bl, bu, y, confun, objfun, iter, istate, c, cjac, f, fjac, clamda, objf, r, x, iwork, liwork, work, lwork, lwsav, iwsav, rwsav, iuser, ruser, ifail)
Integer, Intent (In) :: m, n, nclin, ncnln, lda, ldcj, ldfj, ldr, liwork, lwork
Integer, Intent (Inout) :: istate(n+nclin+ncnln), iuser(*), iwsav(610), ifail
Integer, Intent (Out) :: iter, iwork(liwork)
Type (nagad_a1w_w_rtype), Intent (In) :: a(lda,*), bl(n+nclin+ncnln), bu(n+nclin+ncnln), y(m)
Type (nagad_a1w_w_rtype), Intent (Inout) :: cjac(ldcj,*), fjac(ldfj,n), clamda(n+nclin+ncnln), r(ldr,n), x(n), ruser(*), rwsav(475)
Type (nagad_a1w_w_rtype), Intent (Out) :: c(max(1,ncnln)), f(m), objf, work(lwork)
Logical, Intent (Inout) :: lwsav(120)
Type (c_ptr), Intent (Inout) :: ad_handle
External :: confun, objfun
C++ Header Interface
#include <nagad.h>
void e04us_a1w_f_ ( void *&ad_handle, const Integer &m, const Integer &n, const Integer &nclin, const Integer &ncnln, const Integer &lda, const Integer &ldcj, const Integer &ldfj, const Integer &ldr, const nagad_a1w_w_rtype a[], const nagad_a1w_w_rtype bl[], const nagad_a1w_w_rtype bu[], const nagad_a1w_w_rtype y[],
void (NAG_CALL confun)(void *&ad_handle, Integer &mode, const Integer &ncnln, const Integer &n, const Integer &ldcj, const Integer needc[], const nagad_a1w_w_rtype x[], nagad_a1w_w_rtype c[], nagad_a1w_w_rtype cjac[], const Integer &nstate, Integer iuser[], nagad_a1w_w_rtype ruser[]),
void (NAG_CALL objfun)(void *&ad_handle, Integer &mode, const Integer &m, const Integer &n, const Integer &ldfj, const Integer &needfi, const nagad_a1w_w_rtype x[], nagad_a1w_w_rtype f[], nagad_a1w_w_rtype fjac[], const Integer &nstate, Integer iuser[], nagad_a1w_w_rtype ruser[]),
Integer &iter, Integer istate[], nagad_a1w_w_rtype c[], nagad_a1w_w_rtype cjac[], nagad_a1w_w_rtype f[], nagad_a1w_w_rtype fjac[], nagad_a1w_w_rtype clamda[], nagad_a1w_w_rtype &objf, nagad_a1w_w_rtype r[], nagad_a1w_w_rtype x[], Integer iwork[], const Integer &liwork, nagad_a1w_w_rtype work[], const Integer &lwork, logical lwsav[], Integer iwsav[], nagad_a1w_w_rtype rwsav[], Integer iuser[], nagad_a1w_w_rtype ruser[], Integer &ifail)
The routine may be called by the names e04us_a1w_f or nagf_opt_lsq_gencon_deriv_a1w. The corresponding t1w and p0w variants of this routine are also available.

3 Description

e04us_a1w_f is the adjoint version of the primal routine e04usf.
e04usf 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 parameter Derivative Level, in Section 12.1. It is not intended for large sparse problems.
e04usf may also be used for unconstrained, bound-constrained and linearly constrained optimization. For further information see Section 3 in the documentation for e04usf.

4 References

Gill P E, Murray W and Wright M H (1981) Practical Optimization Academic Press
Hock W and Schittkowski K (1981) Test Examples for Nonlinear Programming Codes. Lecture Notes in Economics and Mathematical Systems 187 Springer–Verlag

5 Arguments

In addition to the arguments present in the interface of the primal routine, e04us_a1w_f includes some arguments specific to AD.
A brief summary of the AD specific arguments is given below. For the remainder, links are provided to the corresponding argument from the primal routine. A tooltip popup for all arguments can be found by hovering over the argument name in Section 2 and in this section.
1: ad_handle – Type (c_ptr) Input/Output
On entry: a handle to the AD configuration data object, as created by x10aa_a1w_f.
2: m – Integer Input
3: n – Integer Input
4: nclin – Integer Input
5: ncnln – Integer Input
6: lda – Integer Input
7: ldcj – Integer Input
8: ldfj – Integer Input
9: ldr – Integer Input
10: a(lda, *) – Type (nagad_a1w_w_rtype) array Input
11: bl(n+nclin+ncnln) – Type (nagad_a1w_w_rtype) array Input
12: bu(n+nclin+ncnln) – Type (nagad_a1w_w_rtype) array Input
13: y(m) – Type (nagad_a1w_w_rtype) array Input
14: confun – Subroutine External Procedure
The specification of confun is:
Fortran Interface
Subroutine confun ( ad_handle, mode, ncnln, n, ldcj, needc, x, c, cjac, nstate, iuser, ruser)
Integer, Intent (In) :: ncnln, n, ldcj, needc(ncnln), nstate
Integer, Intent (Inout) :: mode, iuser(*)
Type (nagad_a1w_w_rtype), Intent (In) :: x(n)
Type (nagad_a1w_w_rtype), Intent (Inout) :: cjac(ldcj,n), ruser(*)
Type (nagad_a1w_w_rtype), Intent (Out) :: c(ncnln)
Type (c_ptr), Intent (Inout) :: ad_handle
C++ Header Interface
#include <nagad.h>
void confun ( void *&ad_handle, Integer &mode, const Integer &ncnln, const Integer &n, const Integer &ldcj, const Integer needc[], const nagad_a1w_w_rtype x[], nagad_a1w_w_rtype c[], nagad_a1w_w_rtype cjac[], const Integer &nstate, Integer iuser[], nagad_a1w_w_rtype ruser[])
1: ad_handle – Type (c_ptr) Input/Output
On entry: a handle to the AD configuration data object.
2: mode – Integer Input/Output
3: ncnln – Integer Input
4: n – Integer Input
5: ldcj – Integer Input
6: needc – Integer array Input
7: xType (nagad_a1w_w_rtype) array Input
8: cType (nagad_a1w_w_rtype) array Output
9: cjacType (nagad_a1w_w_rtype) array Input/Output
10: nstate – Integer Input
11: iuser – Integer array User Workspace
12: ruserType (nagad_a1w_w_rtype) array User Workspace
15: objfun – Subroutine External Procedure
The specification of objfun is:
Fortran Interface
Subroutine objfun ( ad_handle, mode, m, n, ldfj, needfi, x, f, fjac, nstate, iuser, ruser)
Integer, Intent (In) :: m, n, ldfj, needfi, nstate
Integer, Intent (Inout) :: mode, iuser(*)
Type (nagad_a1w_w_rtype), Intent (In) :: x(n)
Type (nagad_a1w_w_rtype), Intent (Inout) :: fjac(ldfj,n), ruser(*)
Type (nagad_a1w_w_rtype), Intent (Out) :: f(m)
Type (c_ptr), Intent (Inout) :: ad_handle
C++ Header Interface
#include <nagad.h>
void objfun ( void *&ad_handle, Integer &mode, const Integer &m, const Integer &n, const Integer &ldfj, const Integer &needfi, const nagad_a1w_w_rtype x[], nagad_a1w_w_rtype f[], nagad_a1w_w_rtype fjac[], const Integer &nstate, Integer iuser[], nagad_a1w_w_rtype ruser[])
1: ad_handle – Type (c_ptr) Input/Output
On entry: a handle to the AD configuration data object.
2: mode – Integer Input/Output
3: m – Integer Input
4: n – Integer Input
5: ldfj – Integer Input
6: needfi – Integer Input
7: xType (nagad_a1w_w_rtype) array Input
8: fType (nagad_a1w_w_rtype) array Output
9: fjacType (nagad_a1w_w_rtype) array Input/Output
10: nstate – Integer Input
11: iuser – Integer array User Workspace
12: ruserType (nagad_a1w_w_rtype) array User Workspace
16: iter – Integer Output
17: istate(n+nclin+ncnln) – Integer array Input/Output
18: c(max(1,ncnln)) – Type (nagad_a1w_w_rtype) array Output
19: cjac(ldcj, *) – Type (nagad_a1w_w_rtype) array Input/Output
20: f(m) – Type (nagad_a1w_w_rtype) array Output
21: fjac(ldfj, n) – Type (nagad_a1w_w_rtype) array Input/Output
22: clamda(n+nclin+ncnln) – Type (nagad_a1w_w_rtype) array Input/Output
23: objfType (nagad_a1w_w_rtype) Output
24: r(ldr, n) – Type (nagad_a1w_w_rtype) array Input/Output
25: x(n) – Type (nagad_a1w_w_rtype) array Input/Output
26: iwork(liwork) – Integer array Workspace
27: liwork – Integer Input
28: work(lwork) – Type (nagad_a1w_w_rtype) array Workspace
29: lwork – Integer Input
30: lwsav(120) – logical array Communication Array
The arrays lwsav, iwsav and rwsav must not be altered between calls to any of the routines routine, routine or routine.
31: iwsav(610) – Integer array Communication Array
The arrays lwsav, iwsav and rwsav must not be altered between calls to any of the routines routine, routine or routine.
32: rwsav(475) – Type (nagad_a1w_w_rtype) array Communication Array
The arrays lwsav, iwsav and rwsav must not be altered between calls to any of the routines routine, routine or routine.
33: iuser(*) – Integer array User Workspace
34: ruser(*) – Type (nagad_a1w_w_rtype) array User Workspace
35: ifail – Integer Input/Output

6 Error Indicators and Warnings

e04us_a1w_f preserves all error codes from e04usf and in addition can return:
ifail=-89
An unexpected AD error has been triggered by this routine. Please contact NAG.
See Section 4.8.2 in the NAG AD Library Introduction for further information.
ifail=-899
Dynamic memory allocation failed for AD.
See Section 4.8.1 in the NAG AD Library Introduction for further information.

7 Accuracy

Not applicable.

8 Parallelism and Performance

e04us_a1w_f is not threaded in any implementation.

9 Further Comments

None.

10 Example

The following examples are variants of the example for e04usf, modified to demonstrate calling the NAG AD Library.

10.1 Adjoint mode (a1w)

LanguageSource FileDataResults
Fortrane04us_a1w_fe.f90e04us_a1w_fe.de04us_a1w_fe.r
C++e04us_a1w_hcppe.cppe04us_a1w_hcppe.de04us_a1w_hcppe.r

10.2 Tangent mode (t1w)

LanguageSource FileDataResults
Fortrane04us_t1w_fe.f90e04us_t1w_fe.de04us_t1w_fe.r
C++e04us_t1w_hcppe.cppe04us_t1w_hcppe.de04us_t1w_hcppe.r

10.3 Passive mode (p0w)

LanguageSource FileDataResults
Fortrane04us_p0w_fe.f90e04us_p0w_fe.de04us_p0w_fe.r
C++e04us_p0w_hcppe.cppe04us_p0w_hcppe.de04us_p0w_hcppe.r