hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_fit_glinc_l1sol (e02gb)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_fit_glinc_l1sol (e02gb) calculates an l1 solution to an over-determined system of linear equations, possibly subject to linear inequality constraints.

Syntax

[e, x, k, el1n, indx, ifail] = e02gb(m, e, f, x, mxs, monit, iprint, 'n', n, 'mpl', mpl)
[e, x, k, el1n, indx, ifail] = nag_fit_glinc_l1sol(m, e, f, x, mxs, monit, iprint, 'n', n, 'mpl', mpl)

Description

Given a matrix A with m rows and n columns mn and a vector b with m elements, the function calculates an l1 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 l1-norm (the sum of the absolute values) of the residuals
rx=i=1mri,  
where the residuals ri are given by
ri=bi-j=1naijxj,  i=1,2,,m.  
Here aij is the element in row i and column j of A, bi is the ith element of b and xj the jth 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 function is such as to minimize the l1-norm rx subject to the set of inequality constraints Cxd.
The matrices A and C need not be of full rank.
Typically in applications to data fitting, data consisting of m points with coordinates ti,yi is to be approximated by a linear combination of known functions ϕit,
α1ϕ1t+α2ϕ2t++αnϕnt,  
in the l1-norm, possibly subject to linear inequality constraints on the coefficients αj of the form Cαd where α is the vector of the αj and C and d are as in the previous paragraph. This is equivalent to finding an l1 solution to the over-determined system of equations
j=1nϕjtiαj=yi,  i=1,2,,m,  
subject to Cαd.
Thus if, for each value of i and j, the element aij of the matrix A above is set equal to the value of ϕjti and bi is equal to yi and C and d are also supplied to the function, the solution vector x will contain the required values of the αj. Note that the independent variable t above can, instead, be a vector of several independent variables (this includes the case where each of ϕ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 γ is a penalty parameter, ciT  is the ith row of the matrix C, and di is the ith 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.

References

Bartels R H, Conn A R and Charalambous C (1976) Minimisation techniques for piecewise Differentiable functions – the l 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 l1 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 l1 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

Parameters

Compulsory Input Parameters

1:     m int64int32nag_int scalar
The number of equations in the over-determined system, m (i.e., the number of rows of the matrix A).
Constraint: mn.
2:     eldempl – double array
lde, the first dimension of the array, must satisfy the constraint lden.
The equation and constraint matrices stored in the following manner.
The first m columns contain the m rows of the matrix A; element eij specifying the element aji in the jth row and ith column of A (the coefficient of the ith unknown in the jth equation), for i=1,2,,n and j=1,2,,m. The next l columns contain the l rows of the constraint matrix C; element eij+m containing the element cji in the jth row and ith column of C (the coefficient of the ith unknown in the jth constraint), for i=1,2,,n and j=1,2,,l.
3:     fmpl – double array
fi, for i=1,2,,m, must contain bi (the ith element of the right-hand side vector of the over-determined system of equations) and fm+i, for i=1,2,,l, must contain di (the ith element of the right-hand side vector of the constraints), where l is the number of constraints.
4:     xn – double array
xi must contain an estimate of the ith unknown, for i=1,2,,n. If no better initial estimate for xi is available, set xi=0.0.
5:     mxs int64int32nag_int scalar
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 nag_machine_integer_max (x02bb) is used.
6:     monit – function handle or string containing name of m-file
monit can be used to print out the current values of any selection of its arguments. The frequency with which monit is called in nag_fit_glinc_l1sol (e02gb) is controlled by iprint.
monit(n, x, niter, k, el1n)

Input Parameters

1:     n int64int32nag_int scalar
The number n of unknowns (the number of columns of the matrix A).
2:     xn – double array
The latest estimate of the unknowns.
3:     niter int64int32nag_int scalar
The number of iterations so far carried out.
4:     k int64int32nag_int scalar
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 – double scalar
The l1-norm of the current residuals of the over-determined system of equations.
7:     iprint int64int32nag_int scalar
The frequency of iteration print out.
iprint>0
monit is called every iprint iterations and at the solution.
iprint=0
Information is printed out at the solution only. Otherwise monit is not called (but a dummy function must still be provided).

Optional Input Parameters

1:     n int64int32nag_int scalar
Default: the dimension of the array x and the first dimension of the array e. (An error is raised if these dimensions are not equal.)
The number of unknowns, n (the number of columns of the matrix A).
Constraint: n2.
2:     mpl int64int32nag_int scalar
Default: the dimension of the array f and the second dimension of the array e. (An error is raised if these dimensions are not equal.)
m+l, where l is the number of constraints (which may be zero).
Constraint: mplm.

Output Parameters

1:     eldempl – double array
Unchanged, except possibly to the extent of a small multiple of the machine precision. (See Further Comments.)
2:     xn – double array
The latest estimate of the ith unknown, for i=1,2,,n. If ifail=0 on exit, these are the solution values.
3:     k int64int32nag_int scalar
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).
4:     el1n – double scalar
The l1-norm (sum of absolute values) of the equation residuals.
5:     indxmpl int64int32nag_int array
Specifies which columns of e relate to the inactive equations and constraints. indx1 up to indxk number the active columns and indxk+1 up to indxmpl number the inactive columns.
6:     ifail int64int32nag_int scalar
ifail=0 unless the function detects an error (see Error Indicators and Warnings).

Error Indicators and Warnings

Errors or warnings detected by the function:
   ifail=1
The constraints cannot all be satisfied simultaneously: they are not compatible with one another. Hence no solution is possible.
   ifail=2
The limit imposed by mxs has been reached without finding a solution. Consider restarting from the current point by simply calling nag_fit_glinc_l1sol (e02gb) again without changing the arguments.
   ifail=3
The function has failed because of numerical difficulties; the problem is too ill-conditioned. Consider rescaling the unknowns.
   ifail=4
Constraint: lden.
Constraint: mplm.
Constraint: mn.
Constraint: n2.
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.
On entry, iw is too small.
   ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
   ifail=-399
Your licence key may have expired or may not have been installed correctly.
   ifail=-999
Dynamic memory allocation failed.

Accuracy

The method is stable.

Further Comments

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 mn2.
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.

Example

Suppose we wish to approximate in 0,1 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 ti,yi we may form the equations
yi=ati3+bti2+cti+d  
for i=1,2,,6, for the 6 data points. The requirement of a non-negative slope at the data points demands
3ati2+2bti+c0  
for each ti 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.)
function e02gb_example


fprintf('e02gb example results\n\n');

n = 4;
m = int64(6);
f = zeros(2*m,1);
e = zeros(n,2*m);
x = zeros(n,1);

% Data to fit by constrained cubic polynomial
f(1:m) = [0, 0.07,  0.07,  0.11,  0.27,  0.68];

% coefficient multipliers for cubic and its derivative
for i = 1:m
  t = 0.2*double(i-1);
  e(1:4,i) = [1,t,t^2,t^3];
  e(1:4,m+i) = [0,1,2*t,3*t^2];
end

mxs    = int64(100);
iprint = int64(0);
[e, x, k, l1nrm, indx, ifail] = e02gb(m, e, f, x, mxs, @monit, iprint);



function [] = monit(n, x, niter, k, elin)

  fprintf('\n Results at iteration %d\n', niter);
  fprintf('Constrained cubic polynomial:\n\n');
  fprintf('p(t) = %7.4f + %7.4f t + %7.4f t^2 + %7.4f t^3\n\n',x(1:4));
  fprintf('Norm of residuals = %12.5f\n', elin);
e02gb example results


 Results at iteration 8
Constrained cubic polynomial:

p(t) =  0.0000 +  0.6943 t + -2.1482 t^2 +  2.1339 t^3

Norm of residuals =      0.00957

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015