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. Further implementations, for example for higher order differentiation or using the tangent linear approach, may become available at later marks of the NAG AD Library. The method of codifying AD implementations in the routine name and corresponding argument types is described in the NAG AD Library Introduction.

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, iuser, ruser, lwsav, iwsav, rwsav, 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 (In) :: 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, nagad_a1w_w_rtype a[], nagad_a1w_w_rtype bl[], nagad_a1w_w_rtype bu[], nagad_a1w_w_rtype y[],
void (NAG_CALL confun)(void *&ad_handle, Integer &mode, const Integer &ncnln, const Integer &n, const Integer &ldcj, Integer needc[], 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, 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, Integer iuser[], nagad_a1w_w_rtype ruser[], logical lwsav[], Integer iwsav[], nagad_a1w_w_rtype rwsav[], Integer &ifail)
The routine may be called by the names e04us_a1w_f or nagf_opt_lsq_gencon_deriv_a1w.

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

None.

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
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 (In) :: ad_handle
C++ Interface
#include <nagad.h>
void confun ( void *&ad_handle, Integer &mode, const Integer &ncnln, const Integer &n, const Integer &ldcj, Integer needc[], 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
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 (In) :: ad_handle
C++ Interface
#include <nagad.h>
void objfun ( void *&ad_handle, Integer &mode, const Integer &m, const Integer &n, const Integer &ldfj, const Integer &needfi, 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
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(max1,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: iuser(*) – Integer array User Workspace
31: ruser(*) – Type (nagad_a1w_w_rtype) array User Workspace
32: 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.
33: 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.
34: 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.
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.5.2 in the NAG AD Library Introduction for further information.
ifail=-899
Dynamic memory allocation failed for AD.
See Section 4.5.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.
LanguageSource FileDataResults
Fortane04us_a1w_fe.f90e04us_a1w_fe.de04us_a1w_fe.r
C++e04us_a1w_hcppe.cppe04us_a1w_hcppe.de04us_a1w_hcppe.r