NAG AD Library
e04uc (nlp1_solve)

Settings help

AD Name Style:


AD Specification Language:

1 Purpose

e04uc is the AD Library version of the primal routine e04ucf. Based (in the C++ interface) on overload resolution, e04uc can be used for primal, tangent and adjoint evaluation. It supports tangents and adjoints of first order.

2 Specification

Fortran Interface
Subroutine e04uc_AD_f ( n, nclin, ncnln, lda, ldcj, ldr, a, bl, bu, confun, objfun, iter, istate, c, cjac, clamda, objf, objgrd, r, x, iwork, liwork, work, lwork, iuser, ruser, lwsav, iwsav, rwsav, ifail)
Integer, Intent (In) :: n, nclin, ncnln, lda, ldcj, ldr, liwork, lwork
Integer, Intent (Inout) :: istate(n+nclin+ncnln), iuser(*), iwsav(610), ifail
Integer, Intent (Out) :: iter, iwork(liwork)
ADTYPE, Intent (In) :: a(lda,*), bl(n+nclin+ncnln), bu(n+nclin+ncnln)
ADTYPE, Intent (Inout) :: cjac(ldcj,*), clamda(n+nclin+ncnln), r(ldr,n), x(n), ruser(*), rwsav(475)
ADTYPE, Intent (Out) :: c(max(1,ncnln)), objf, objgrd(n), work(lwork)
Logical, Intent (Inout) :: lwsav(120)
Type (c_ptr), Intent (Inout) :: ad_handle
External :: confun, objfun
Corresponding to the overloaded C++ function, the Fortran interface provides five routines with names reflecting the type used for active real arguments. The actual subroutine and type names are formed by replacing AD and ADTYPE in the above as follows:
when ADTYPE is Real(kind=nag_wp) then AD is p0w
when ADTYPE is Type(nagad_a1w_w_rtype) then AD is a1w
when ADTYPE is Type(nagad_t1w_w_rtype) then AD is t1w
C++ Interface
#include <dco.hpp>
#include <nagad.h>
namespace nag {
namespace ad {
template <typename CONFUN_T, typename OBJFUN_T>
void e04uc ( handle_t &ad_handle, const Integer &n, const Integer &nclin, const Integer &ncnln, const Integer &lda, const Integer &ldcj, const Integer &ldr, const ADTYPE a[], const ADTYPE bl[], const ADTYPE bu[], CONFUN_T &&confun, OBJFUN_T &&objfun, Integer &iter, Integer istate[], ADTYPE c[], ADTYPE cjac[], ADTYPE clamda[], ADTYPE &objf, ADTYPE objgrd[], ADTYPE r[], ADTYPE x[], Integer iwork[], const Integer &liwork, ADTYPE work[], const Integer &lwork, logical lwsav[], Integer iwsav[], ADTYPE rwsav[], Integer &ifail)
}
}
The function is overloaded on ADTYPE which represents the type of active arguments. ADTYPE may be any of the following types:
double,
dco::ga1s<double>::type,
dco::gt1s<double>::type
Note: this function can be used with AD tools other than dco/c++. For details, please contact NAG.

3 Description

e04uc is the AD Library version of the primal routine e04ucf.
e04ucf is designed to minimize an arbitrary smooth 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. It is not intended for large sparse problems.
e04ucf may also be used for unconstrained, bound-constrained and linearly constrained optimization.
e04ucf uses forward communication for evaluating the objective function, the nonlinear constraint functions, and any of their derivatives. For further information see Section 3 in the documentation for e04ucf.

4 References

Dennis J E Jr and Moré J J (1977) Quasi-Newton methods, motivation and theory SIAM Rev. 19 46–89
Dennis J E Jr and Schnabel R B (1981) A new derivation of symmetric positive-definite secant updates nonlinear programming (eds O L Mangasarian, R R Meyer and S M Robinson) 4 167–199 Academic Press
Dennis J E Jr and Schnabel R B (1983) Numerical Methods for Unconstrained Optimization and Nonlinear Equations Prentice–Hall
Fletcher R (1987) Practical Methods of Optimization (2nd Edition) Wiley
Gill P E, Hammarling S, Murray W, Saunders M A and Wright M H (1986) Users' guide for LSSOL (Version 1.0) Report SOL 86-1 Department of Operations Research, Stanford University
Gill P E, Murray W, Saunders M A and Wright M H (1984a) Procedures for optimization problems with a mixture of bounds and general linear constraints ACM Trans. Math. Software 10 282–298
Gill P E, Murray W, Saunders M A and Wright M H (1984b) Users' guide for SOL/QPSOL version 3.2 Report SOL 84–5 Department of Operations Research, Stanford University
Gill P E, Murray W, Saunders M A and Wright M H (1986a) Some theoretical properties of an augmented Lagrangian merit function Report SOL 86–6R Department of Operations Research, Stanford University
Gill P E, Murray W, Saunders M A and Wright M H (1986b) Users' guide for NPSOL (Version 4.0): a Fortran package for nonlinear programming Report SOL 86-2 Department of Operations Research, Stanford University
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
Powell M J D (1974) Introduction to constrained optimization Numerical Methods for Constrained Optimization (eds P E Gill and W Murray) 1–28 Academic Press
Powell M J D (1983) Variable metric methods in constrained optimization Mathematical Programming: the State of the Art (eds A Bachem, M Grötschel and B Korte) 288–311 Springer–Verlag

5 Arguments

In addition to the arguments present in the interface of the primal routine, e04uc 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_handlenag::ad::handle_t Input/Output
On entry: a configuration object that holds information on the differentiation strategy. Details on setting the AD strategy are described in AD handle object in the NAG AD Library Introduction.
2: n – Integer Input
3: nclin – Integer Input
4: ncnln – Integer Input
5: lda – Integer Input
6: ldcj – Integer Input
7: ldr – Integer Input
8: a(lda, *) – ADTYPE array Input
9: bl(n+nclin+ncnln) – ADTYPE array Input
10: bu(n+nclin+ncnln) – ADTYPE array Input
11: confun – Callable Input
confun needs to be callable with the specification listed below. This can be a C++ lambda, a functor or a (static member) function pointer. If using a lambda, parameters can be captured safely by reference. No copies of the callable are made internally.
If a null pointer is used as the argument, then a NAG supplied routine will be used as the argument for this parameter (C++ only).
For the Fortran interface, the NAG supplied routine e04ud_AD_m may be used as the actual argument for this parameter.
The specification of confun is:
Fortran Interface
Subroutine confun ( 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(*)
ADTYPE, Intent (In) :: x(n)
ADTYPE, Intent (Inout) :: cjac(ldcj,n), ruser(*)
ADTYPE, Intent (Out) :: c(ncnln)
Type (c_ptr), Intent (Inout) :: ad_handle
C++ Interface
auto confun = [&]( const handle_t &ad_handle, Integer &mode, const Integer &ncnln, const Integer &n, const Integer &ldcj, const Integer needc[], const ADTYPE x[], ADTYPE c[], ADTYPE cjac[], const Integer &nstate)
1: ad_handlenag::ad::handle_t Input/Output
On entry: a handle to the AD handle object.
2: mode – Integer Input/Output
3: ncnln – Integer Input
4: n – Integer Input
5: ldcj – Integer Input
6: needc – Integer array Input
7: xADTYPE array Input
8: cADTYPE array Output
9: cjacADTYPE array Input/Output
10: nstate – Integer Input
*: iuser – Integer array User Workspace
*: ruserADTYPE array User Workspace
12: objfun – Callable Input
objfun needs to be callable with the specification listed below. This can be a C++ lambda, a functor or a (static member) function pointer. If using a lambda, parameters can be captured safely by reference. No copies of the callable are made internally.
The specification of objfun is:
Fortran Interface
Subroutine objfun ( mode, n, x, objf, objgrd, nstate, iuser, ruser)
Integer, Intent (In) :: n, nstate
Integer, Intent (Inout) :: mode, iuser(*)
ADTYPE, Intent (In) :: x(n)
ADTYPE, Intent (Inout) :: objgrd(n), ruser(*)
ADTYPE, Intent (Out) :: objf
Type (c_ptr), Intent (Inout) :: ad_handle
C++ Interface
auto objfun = [&]( const handle_t &ad_handle, Integer &mode, const Integer &n, const ADTYPE x[], ADTYPE &objf, ADTYPE objgrd[], const Integer &nstate)
1: ad_handlenag::ad::handle_t Input/Output
On entry: a handle to the AD handle object.
2: mode – Integer Input/Output
3: n – Integer Input
4: xADTYPE array Input
5: objfADTYPE Output
6: objgrdADTYPE array Input/Output
7: nstate – Integer Input
*: iuser – Integer array User Workspace
*: ruserADTYPE array User Workspace
13: iter – Integer Output
14: istate(n+nclin+ncnln) – Integer array Input/Output
15: c(max(1,ncnln)) – ADTYPE array Output
16: cjac(ldcj, *) – ADTYPE array Input/Output
Please consult Overwriting of Inputs in the NAG AD Library Introduction.
17: clamda(n+nclin+ncnln) – ADTYPE array Input/Output
Please consult Overwriting of Inputs in the NAG AD Library Introduction.
18: objfADTYPE Output
19: objgrd(n) – ADTYPE array Output
20: r(ldr, n) – ADTYPE array Input/Output
Please consult Overwriting of Inputs in the NAG AD Library Introduction.
21: x(n) – ADTYPE array Input/Output
Please consult Overwriting of Inputs in the NAG AD Library Introduction.
22: iwork(liwork) – Integer array Workspace
23: liwork – Integer Input
24: work(lwork) – ADTYPE array Workspace
25: lwork – Integer Input
*: iuser(*) – Integer array User Workspace
*: ruser(*) – ADTYPE array User Workspace
Please consult Overwriting of Inputs in the NAG AD Library Introduction.
26: 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.
27: 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.
28: rwsav(475) – ADTYPE array Communication Array
The arrays lwsav, iwsav and rwsav must not be altered between calls to any of the routines routine, routine or routine.
29: ifail – Integer Input/Output

6 Error Indicators and Warnings

e04uc preserves all error codes from e04ucf and in addition can return:
ifail=-89
An unexpected AD error has been triggered by this routine. Please contact NAG.
See Error Handling in the NAG AD Library Introduction for further information.
ifail=-199
The routine was called using a strategy that has not yet been implemented.
See AD Strategies in the NAG AD Library Introduction for further information.
ifail=-444
A C++ exception was thrown.
The error message will show the details of the C++ exception text.
ifail=-899
Dynamic memory allocation failed for AD.
See Error Handling in the NAG AD Library Introduction for further information.

7 Accuracy

Not applicable.

8 Parallelism and Performance

e04uc is not threaded in any implementation.

9 Further Comments

None.

10 Example

The following examples are variants of the example for e04ucf, modified to demonstrate calling the NAG AD Library.
Description of the primal example.
This is based on Problem 71 in Hock and Schittkowski (1981) and involves the minimization of the nonlinear function
F(x)=x1x4(x1+x2+x3)+x3  
subject to the bounds
1x1 5 1x2 5 1x3 5 1x4 5  
to the general linear constraint
x1+x2+x3+x420,  
and to the nonlinear constraints
x12+x22+x32+x42 40, x1x2x3x4 25.  
The initial point, which is infeasible, is
x0=(1,5,5,1)T,  
and F(x0)=16.
The optimal solution (to five figures) is
x*=(1.0,4.7430,3.8211,1.3794)T,  
and F(x*)=17.014. One bound constraint and both nonlinear constraints are active at the solution.
The document for e04ud includes an example program to solve the same problem using some of the optional parameters described in Section 12.

10.1 Adjoint modes

Language Source File Data Results
Fortran e04uc_a1w_fe.f90 e04uc_a1w_fe.d e04uc_a1w_fe.r
C++ e04uc_a1w_hcppe.cpp e04uc_a1w_hcppe.d e04uc_a1w_hcppe.r

10.2 Tangent modes

Language Source File Data Results
Fortran e04uc_t1w_fe.f90 e04uc_t1w_fe.d e04uc_t1w_fe.r
C++ e04uc_t1w_hcppe.cpp e04uc_t1w_hcppe.d e04uc_t1w_hcppe.r

10.3 Passive mode

Language Source File Data Results
Fortran e04uc_p0w_fe.f90 e04uc_p0w_fe.d e04uc_p0w_fe.r
C++ e04uc_p0w_hcppe.cpp e04uc_p0w_hcppe.d e04uc_p0w_hcppe.r