NAG AD Library
e04nc (lsq_lincon_solve)

Settings help

AD Name Style:


AD Specification Language:

1 Purpose

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

2 Specification

Fortran Interface
Subroutine e04nc_AD_f ( m, n, nclin, ldc, lda, c, bl, bu, cvec, istate, kx, x, a, b, iter, obj, clamda, iwork, liwork, work, lwork, lwsav, iwsav, rwsav, ifail)
Integer, Intent (In) :: m, n, nclin, ldc, lda, liwork, lwork
Integer, Intent (Inout) :: istate(n+nclin), kx(n), iwsav(610), ifail
Integer, Intent (Out) :: iter, iwork(liwork)
ADTYPE, Intent (In) :: c(ldc,*), bl(n+nclin), bu(n+nclin), cvec(*)
ADTYPE, Intent (Inout) :: x(n), a(lda,*), b(*), rwsav(475)
ADTYPE, Intent (Out) :: obj, clamda(n+nclin), work(lwork)
Logical, Intent (Inout) :: lwsav(120)
Type (c_ptr), Intent (Inout) :: ad_handle
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 {
void e04nc ( handle_t &ad_handle, const Integer &m, const Integer &n, const Integer &nclin, const Integer &ldc, const Integer &lda, const ADTYPE c[], const ADTYPE bl[], const ADTYPE bu[], const ADTYPE cvec[], Integer istate[], Integer kx[], ADTYPE x[], ADTYPE a[], ADTYPE b[], Integer &iter, ADTYPE &obj, ADTYPE clamda[], 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

e04nc is the AD Library version of the primal routine e04ncf.
e04ncf solves linearly constrained linear least squares problems and convex quadratic programming problems. It is not intended for large sparse problems. For further information see Section 3 in the documentation for e04ncf.

4 References

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 (1984) 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 and Wright M H (1981) Practical Optimization Academic Press
Stoer J (1971) On the numerical solution of constrained least squares problems SIAM J. Numer. Anal. 8 382–411

5 Arguments

In addition to the arguments present in the interface of the primal routine, e04nc 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: m – Integer Input
3: n – Integer Input
4: nclin – Integer Input
5: ldc – Integer Input
6: lda – Integer Input
7: c(ldc, *) – ADTYPE array Input
8: bl(n+nclin) – ADTYPE array Input
9: bu(n+nclin) – ADTYPE array Input
10: cvec(*) – ADTYPE array Input
11: istate(n+nclin) – Integer array Input/Output
12: kx(n) – Integer array Input/Output
13: x(n) – ADTYPE array Input/Output
Please consult Overwriting of Inputs in the NAG AD Library Introduction.
14: a(lda, *) – ADTYPE array Input/Output
Please consult Overwriting of Inputs in the NAG AD Library Introduction.
15: b(*) – ADTYPE array Input/Output
Please consult Overwriting of Inputs in the NAG AD Library Introduction.
16: iter – Integer Output
17: objADTYPE Output
18: clamda(n+nclin) – ADTYPE array Output
19: iwork(liwork) – Integer array Workspace
20: liwork – Integer Input
21: work(lwork) – ADTYPE array Workspace
22: lwork – Integer Input
23: 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.
24: 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.
25: 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.
26: ifail – Integer Input/Output

6 Error Indicators and Warnings

e04nc preserves all error codes from e04ncf 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

e04nc is not threaded in any implementation.

9 Further Comments

None.

10 Example

The following examples are variants of the example for e04ncf, modified to demonstrate calling the NAG AD Library.
Description of the primal example.
This example minimizes the function 12b-Ax2, where
A= ( 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 2 0 0 1 1 3 1 1 1 −1 −1 −3 1 1 1 4 1 1 1 1 1 1 1 1 3 1 1 1 1 1 1 1 2 1 1 0 0 0 −1 1 1 1 1 0 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 0 1 1 1 2 2 3 1 0 1 1 1 1 0 2 2 )   and   b= ( 1 1 1 1 1 1 1 1 1 1 )  
subject to the bounds
0x12 0x22 -x32 0x42 0x52 0x62 0x72 0x82 0x92  
and to the general constraints
2.0 x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + 4x9 - x1 + 2x2 + 3x3 + 4x4 - 2x5 + x6 + x7 + x8 + x9 2.0 1.0 x1 - x2 + x3 - x4 + x5 + x6 + x7 + x8 + x9 4.0.  
The initial point, which is infeasible, is
x0=(1.0,0.5,0.3333,0.25,0.2,0.1667,0.1428,0.125,0.1111)T,  
and F(x0)=9.4746 (to five figures).
The optimal solution (to five figures) is
x*=(0.0,0.041526,0.58718,0.0,0.099643,0.0,0.04906,0.0,0.30565)T,  
and F(x*)=0.081341. Four bound constraints and all three general constraints are active at the solution.
The document for e04nd includes an example program to solve a convex quadratic programming problem, using some of the optional parameters described in Section 12.

10.1 Adjoint modes

Language Source File Data Results
Fortran e04nc_a1w_fe.f90 e04nc_a1w_fe.d e04nc_a1w_fe.r
C++ e04nc_a1w_hcppe.cpp e04nc_a1w_hcppe.d e04nc_a1w_hcppe.r

10.2 Tangent modes

Language Source File Data Results
Fortran e04nc_t1w_fe.f90 e04nc_t1w_fe.d e04nc_t1w_fe.r
C++ e04nc_t1w_hcppe.cpp e04nc_t1w_hcppe.d e04nc_t1w_hcppe.r

10.3 Passive mode

Language Source File Data Results
Fortran e04nc_p0w_fe.f90 e04nc_p0w_fe.d e04nc_p0w_fe.r
C++ e04nc_p0w_hcppe.cpp e04nc_p0w_hcppe.d e04nc_p0w_hcppe.r