E02 Chapter Contents
E02 Chapter Introduction
NAG Library Manual

NAG Library Routine DocumentE02GBF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

1  Purpose

E02GBF calculates an ${l}_{1}$ solution to an over-determined system of linear equations, possibly subject to linear inequality constraints.

2  Specification

 SUBROUTINE E02GBF ( M, N, MPL, E, LDE, F, X, MXS, MONIT, IPRINT, K, EL1N, INDX, W, IW, IFAIL)
 INTEGER M, N, MPL, LDE, MXS, IPRINT, K, INDX(MPL), IW, IFAIL REAL (KIND=nag_wp) E(LDE,MPL), F(MPL), X(N), EL1N, W(IW) EXTERNAL MONIT

3  Description

Given a matrix $A$ with $m$ rows and $n$ columns $\left(m\ge n\right)$ and a vector $b$ with $m$ elements, the routine calculates an ${l}_{1}$ solution to the over-determined system of equations
 $Ax=b.$
That is to say, it calculates a vector $x$, with $n$ elements, which minimizes the ${l}_{1}$-norm (the sum of the absolute values) of the residuals
 $rx=∑i=1mri,$
where the residuals ${r}_{i}$ are given by
 $ri=bi-∑j=1naijxj, i=1,2,…,m.$
Here ${a}_{ij}$ is the element in row $i$ and column $j$ of $A$, ${b}_{i}$ is the $i$th element of $b$ and ${x}_{j}$ the $j$th element of $x$.
If, in addition, a matrix $C$ with $l$ rows and $n$ columns and a vector $d$ with $l$ elements, are given, the vector $x$ computed by the routine is such as to minimize the ${l}_{1}$-norm $r\left(x\right)$ subject to the set of inequality constraints $Cx\ge d$.
The matrices $A$ and $C$ need not be of full rank.
Typically in applications to data fitting, data consisting of $m$ points with coordinates $\left({t}_{i},{y}_{i}\right)$ is to be approximated by a linear combination of known functions ${\varphi }_{i}\left(t\right)$,
 $α1ϕ1t+α2ϕ2t+⋯+αnϕnt,$
in the ${l}_{1}$-norm, possibly subject to linear inequality constraints on the coefficients ${\alpha }_{j}$ of the form $C\alpha \ge d$ where $\alpha$ is the vector of the ${\alpha }_{j}$ and $C$ and $d$ are as in the previous paragraph. This is equivalent to finding an ${l}_{1}$ solution to the over-determined system of equations
 $∑j=1nϕjtiαj=yi, i=1,2,…,m,$
subject to $C\alpha \ge d$.
Thus if, for each value of $i$ and $j$, the element ${a}_{ij}$ of the matrix $A$ above is set equal to the value of ${\varphi }_{j}\left({t}_{i}\right)$ and ${b}_{i}$ is equal to ${y}_{i}$ and $C$ and $d$ are also supplied to the routine, the solution vector $x$ will contain the required values of the ${\alpha }_{j}$. Note that the independent variable $t$ above can, instead, be a vector of several independent variables (this includes the case where each of ${\varphi }_{i}$ is a function of a different variable, or set of variables).
The algorithm follows the Conn–Pietrzykowski approach (see Bartels et al. (1978) and Conn and Pietrzykowski (1977)), which is via an exact penalty function
 $gx = γ rx - ∑ i=1 l min0, ciT x-di ,$
where $\gamma$ is a penalty parameter, ${c}_{i}^{\mathrm{T}}$ is the $i$th row of the matrix $C$, and ${d}_{i}$ is the $i$th element of the vector $d$. It proceeds in a step-by-step manner much like the simplex method for linear programming but does not move from vertex to vertex and does not require the problem to be cast in a form containing only non-negative unknowns. It uses stable procedures to update an orthogonal factorization of the current set of active equations and constraints.

4  References

Bartels R H, Conn A R and Charalambous C (1976) Minimisation techniques for piecewise Differentiable functions – the ${l}_{\infty }$ solution to an overdetermined linear system Technical Report No. 247, CORR 76/30 Mathematical Sciences Department, The John Hopkins University
Bartels R H, Conn A R and Sinclair J W (1976) A Fortran program for solving overdetermined systems of linear equations in the ${l}_{1}$ Sense Technical Report No. 236, CORR 76/7 Mathematical Sciences Department, The John Hopkins University
Bartels R H, Conn A R and Sinclair J W (1978) Minimisation techniques for piecewise differentiable functions – the ${l}_{1}$ solution to an overdetermined linear system SIAM J. Numer. Anal. 15 224–241
Conn A R and Pietrzykowski T (1977) A penalty-function method converging directly to a constrained optimum SIAM J. Numer. Anal. 14 348–375

5  Parameters

1:     M – INTEGERInput
On entry: the number of equations in the over-determined system, $m$ (i.e., the number of rows of the matrix $A$).
Constraint: ${\mathbf{M}}\ge 2$.
2:     N – INTEGERInput
On entry: the number of unknowns, $n$ (the number of columns of the matrix $A$).
Constraint: ${\mathbf{N}}\ge 2$.
3:     MPL – INTEGERInput
On entry: $m+l$, where $l$ is the number of constraints (which may be zero).
Constraint: ${\mathbf{MPL}}\ge {\mathbf{M}}$.
4:     E(LDE,MPL) – REAL (KIND=nag_wp) arrayInput/Output
On entry: the equation and constraint matrices stored in the following manner.
The first $m$ columns contain the $m$ rows of the matrix $A$; element ${\mathbf{E}}\left(\mathit{i},\mathit{j}\right)$ specifying the element ${a}_{\mathit{j}\mathit{i}}$ in the $\mathit{j}$th row and $\mathit{i}$th column of $A$ (the coefficient of the $\mathit{i}$th unknown in the $\mathit{j}$th equation), for $\mathit{i}=1,2,\dots ,n$ and $\mathit{j}=1,2,\dots ,m$. The next $l$ columns contain the $l$ rows of the constraint matrix $C$; element ${\mathbf{E}}\left(\mathit{i},\mathit{j}+m\right)$ containing the element ${c}_{\mathit{j}\mathit{i}}$ in the $\mathit{j}$th row and $\mathit{i}$th column of $C$ (the coefficient of the $\mathit{i}$th unknown in the $\mathit{j}$th constraint), for $\mathit{i}=1,2,\dots ,n$ and $\mathit{j}=1,2,\dots ,l$.
On exit: unchanged, except possibly to the extent of a small multiple of the machine precision. (See Section 8.)
5:     LDE – INTEGERInput
On entry: the first dimension of the array E as declared in the (sub)program from which E02GBF is called.
Constraint: ${\mathbf{LDE}}\ge {\mathbf{N}}$.
6:     F(MPL) – REAL (KIND=nag_wp) arrayInput
On entry: ${\mathbf{F}}\left(\mathit{i}\right)$, for $\mathit{i}=1,2,\dots ,m$, must contain ${b}_{\mathit{i}}$ (the $\mathit{i}$th element of the right-hand side vector of the over-determined system of equations) and ${\mathbf{F}}\left(m+\mathit{i}\right)$, for $\mathit{i}=1,2,\dots ,l$, must contain ${d}_{i}$ (the $i$th element of the right-hand side vector of the constraints), where $l$ is the number of constraints.
7:     X(N) – REAL (KIND=nag_wp) arrayInput/Output
On entry: ${\mathbf{X}}\left(\mathit{i}\right)$ must contain an estimate of the $\mathit{i}$th unknown, for $\mathit{i}=1,2,\dots ,n$. If no better initial estimate for ${\mathbf{X}}\left(i\right)$ is available, set ${\mathbf{X}}\left(i\right)=0.0$.
On exit: the latest estimate of the $\mathit{i}$th unknown, for $\mathit{i}=1,2,\dots ,n$. If ${\mathbf{IFAIL}}={\mathbf{0}}$ on exit, these are the solution values.
8:     MXS – INTEGERInput
On entry: the maximum number of steps to be allowed for the solution of the unconstrained problem. Typically this may be a modest multiple of $n$. If, on entry, MXS is zero or negative, the value returned by X02BBF is used.
9:     MONIT – SUBROUTINE, supplied by the user.External Procedure
MONIT can be used to print out the current values of any selection of its parameters. The frequency with which MONIT is called in E02GBF is controlled by IPRINT.
The specification of MONIT is:
 SUBROUTINE MONIT ( N, X, NITER, K, EL1N)
 INTEGER N, NITER, K REAL (KIND=nag_wp) X(N), EL1N
1:     N – INTEGERInput
On entry: the number $n$ of unknowns (the number of columns of the matrix $A$).
2:     X(N) – REAL (KIND=nag_wp) arrayInput
On entry: the latest estimate of the unknowns.
3:     NITER – INTEGERInput
On entry: the number of iterations so far carried out.
4:     K – INTEGERInput
On entry: the total number of equations and constraints which are currently active (i.e., the number of equations with zero residuals plus the number of constraints which are satisfied as equations).
5:     EL1N – REAL (KIND=nag_wp)Input
On entry: the ${l}_{1}$-norm of the current residuals of the over-determined system of equations.
MONIT must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which E02GBF is called. Parameters denoted as Input must not be changed by this procedure.
10:   IPRINT – INTEGERInput
On entry: the frequency of iteration print out.
${\mathbf{IPRINT}}>0$
MONIT is called every IPRINT iterations and at the solution.
${\mathbf{IPRINT}}=0$
Information is printed out at the solution only. Otherwise MONIT is not called (but a dummy routine must still be provided).
11:   K – INTEGEROutput
On exit: the total number of equations and constraints which are then active (i.e., the number of equations with zero residuals plus the number of constraints which are satisfied as equalities).
12:   EL1N – REAL (KIND=nag_wp)Output
On exit: the ${l}_{1}$-norm (sum of absolute values) of the equation residuals.
13:   INDX(MPL) – INTEGER arrayOutput
On exit: specifies which columns of E relate to the inactive equations and constraints. ${\mathbf{INDX}}\left(1\right)$ up to ${\mathbf{INDX}}\left({\mathbf{K}}\right)$ number the active columns and ${\mathbf{INDX}}\left({\mathbf{K}}+1\right)$ up to ${\mathbf{INDX}}\left({\mathbf{MPL}}\right)$ number the inactive columns.
14:   W(IW) – REAL (KIND=nag_wp) arrayWorkspace
15:   IW – INTEGERInput
On entry: the dimension of the array W as declared in the (sub)program from which E02GBF is called.
Constraint: ${\mathbf{IW}}\ge 3×{\mathbf{MPL}}+5×{\mathbf{N}}+{{\mathbf{N}}}^{2}+\left({\mathbf{N}}+1\right)×\left({\mathbf{N}}+2\right)/2$.
16:   IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to $0$, $-1\text{​ or ​}1$. 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 $-1\text{​ or ​}1$ is recommended. If the output of error messages is undesirable, then the value $1$ is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is $0$. When the value $-\mathbf{1}\text{​ or ​}\mathbf{1}$ is used it is essential to test the value of IFAIL on exit.
On exit: ${\mathbf{IFAIL}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

6  Error Indicators and Warnings

If on entry ${\mathbf{IFAIL}}={\mathbf{0}}$ or $-{\mathbf{1}}$, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Errors or warnings detected by the routine:
${\mathbf{IFAIL}}=1$
The constraints cannot all be satisfied simultaneously: they are not compatible with one another. Hence no solution is possible.
${\mathbf{IFAIL}}=2$
The limit imposed by MXS has been reached without finding a solution. Consider restarting from the current point by simply calling E02GBF again without changing the parameters.
${\mathbf{IFAIL}}=3$
The routine has failed because of numerical difficulties; the problem is too ill-conditioned. Consider rescaling the unknowns.
${\mathbf{IFAIL}}=4$
On entry, one or more of the following conditions are violated:
• ${\mathbf{M}}\ge {\mathbf{N}}\ge 2$,
• or ${\mathbf{MPL}}\ge {\mathbf{M}}$,
• or ${\mathbf{IW}}\ge 3×{\mathbf{MPL}}+5×{\mathbf{N}}+{{\mathbf{N}}}^{2}+\left({\mathbf{N}}+1\right)×\left({\mathbf{N}}+2\right)/2$,
• or ${\mathbf{LDE}}\ge {\mathbf{N}}$.
Alternatively elements $1$ to M of one of the first MPL columns of the array E are all zero – this corresponds to a zero row in either of the matrices $A$ or $C$.

7  Accuracy

The method is stable.

The effect of $m$ and $n$ on the time and on the number of iterations varies from problem to problem, but typically the number of iterations is a small multiple of $n$ and the total time taken is approximately proportional to $m{n}^{2}$.
Linear dependencies among the rows or columns of $A$ and $C$ are not necessarily a problem to the algorithm. Solutions can be obtained from rank-deficient $A$ and $C$. However, the algorithm requires that at every step the currently active columns of E form a linearly independent set. If this is not the case at any step, small, random perturbations of the order of rounding error are added to the appropriate columns of E. Normally this perturbation process will not affect the solution significantly. It does mean, however, that results may not be exactly reproducible.

9  Example

Suppose we wish to approximate in $\left[0,1\right]$ a set of data by a curve of the form
 $y=ax3+bx2+cx+d$
which has non-negative slope at the data points. Given points $\left({t}_{i},{y}_{i}\right)$ we may form the equations
 $yi=ati3+bti2+cti+d$
for $\mathit{i}=1,2,\dots ,6$, for the $6$ data points. The requirement of a non-negative slope at the data points demands
 $3ati2+2bti+c≥0$
for each ${t}_{i}$ and these form the constraints.
(Note that, for fitting with polynomials, it would usually be advisable to work with the polynomial expressed in Chebyshev series form (see the E02 Chapter Introduction). The power series form is used here for simplicity of exposition.)

9.1  Program Text

Program Text (e02gbfe.f90)

9.2  Program Data

Program Data (e02gbfe.d)

9.3  Program Results

Program Results (e02gbfe.r)