Optimization Toolbox
  Go to function:
    Search    Help Desk 
lsqlin    Examples   See Also

Solve the constrained linear least-squares problem

where C, A, and Aeq are matrices and d, b, beq, lb, ub, and x are vectors.

Syntax

Description

x = lsqlin(C,d,A,b) solves the linear system C*x=d in the least-squares sense subject to A*x<=b, where C is m-by-n.

x = lsqlin(C,d,A,b,Aeq,beq) solves the problem above while additionally satisfying the equality constraints Aeq*x = beq. Set A=[] and b=[] if no inequalities exist.

x = lsqlin(C,d,A,b,Aeq,beq,lb,ub) defines a set of lower and upper bounds on the design variables, x, so that the solution is always in the range lb <= x <= ub. Set Aeq=[] and beq=[] if no equalities exist.

x = lsqlin(C,d,A,b,Aeq,beq,lb,ub,x0) sets the starting point to x0.

x = lsqlin(C,d,A,b,Aeq,beq,lb,ub,x0,options) minimizes with the optimization parameters specified in the structure options.

[x,resnorm] = lsqlin(...) returns the value of the squared 2-norm of the residual: norm(C*x-d)^2.

[x,resnorm,residual] = lsqlin(...) returns the residual, C*x-d.

[x,resnorm,residual,exitflag] = lsqlin(...) returns a value exitflag that describes the exit condition.

[x,resnorm,residual,exitflag,output] = lsqlin(...) returns a structure output that contains information about the optimization.

[x,resnorm,residual,exitflag,output,lambda] = lsqlin(...) returns a structure lambda whose fields contain the Lagrange multipliers at the solution x.

Arguments

The arguments passed into the function are described in Table 1-1. The arguments returned by the function are described in Table 1-2. Details relevant to lsqlin are included below for options, exitflag, lambda, and output.

options
Optimization parameter options. You can set or change the values of these parameters using the optimset function. Some parameters apply to all algorithms, some are only relevant when using the large-scale algorithm, and others are only relevant when using the medium-scale algorithm.

We start by describing the LargeScale option since it states a preference for which algorithm to use. It is only a preference since certain conditions must be met to use the large-scale algorithm. For lsqlin, when the problem has only upper and lower bounds, i.e., no linear inequalities or equalities are specified, the default algorithm is the large-scale method. Otherwise the medium-scale algorithm will be used.

The parameter to set an algorithm preference:


Parameters used by both the large-scale and medium-scale algorithms:



Parameters used by the large-scale algorithm only:

exitflag
Describes the exit condition:

lambda
A structure containing the Lagrange multipliers at the solution x (separated by constraint type):

output
A structure whose fields contain information about the optimization:

Examples

Find the least-squares solution to the over-determined system subject to and .

First, enter the coefficient matrices and the lower and upper bounds:

Next, call the constrained linear least-squares routine:

Entering x, lambda.ineqlin, lambda.lower, lambda.upper gets

Nonzero elements of the vectors in the fields of lambda indicate active constraints at the solution. In this case, the second inequality constraint (in lambda.ineqlin) and the first lower and second lower bound constraints (in lambda.lower) are active constraints (i.e., the solution is on their constraint boundaries).

Notes

For problems with no constraints, \ should be used: x= A\b.

In general lsqlin locates a local solution.

Better numerical results are likely if you specify equalities explicitly using Aeq and beq, instead of implicitly using lb and ub.

Large-scale optimization.    If x0 is not strictly feasible, lsqlin chooses a new strictly feasible (centered) starting point.

If components of x have no upper (or lower) bounds, then lsqlin prefers that the corresponding components of ub (or lb) be set to Inf (or -Inf for lb) as opposed to an arbitrary but very large positive (or negative in the case of lower bounds) number.

Algorithm

Large-scale optimization.    When the problem given to lsqlin has only upper and lower bounds, i.e., no linear inequalities or equalities are specified, and the matrix C has at least as many rows as columns, the default algorithm is the large-scale method. This method is a subspace trust-region method based on the interior-reflective Newton method described in [2]. Each iteration involves the approximate solution of a large linear system using the method of preconditioned conjugate gradients (PCG). See the trust-region and preconditioned conjugate gradient method descriptions in the Large-Scale Algorithms chapter.

Medium-scale optimization.    lsqlin with options.LargeScale set to 'off', or when linear inequalities or equalities are given, is based on quadprog, which uses an active set method similar to that described in [1]. It finds an initial feasible solution by first solving a linear programming problem. See the quadratic programming method discussed in the Introduction to Algorithms chapter.

Diagnostics

Large-scale optimization.    The large-scale code does not allow equal upper and lower bounds. For example if lb(2)==ub(2), then lsqlin gives the error:

At this time, the medium-scale algorithm must be used to solve equality constrained problems.

Medium-scale optimization.    If the matrices C, A or Aeq are sparse, and the problem formulation is not solvable using the large-scale code, lsqlin warns that the matrices will be converted to full:

lsqlin gives a warning when the solution is infeasible:

In this case, lsqlin produces a result that minimizes the worst case constraint violation.

When the equality constraints are inconsistent, lsqlin gives

Limitations

At this time, the only levels of display, using the Display parameter in options, are 'off' and 'final'; iterative output using 'iter' is not available.

See Also

lsqnonneg, quadprog, \

References

[1] Gill, P.E., W. Murray, and M.H. Wright, Practical Optimization, Academic Press, London, UK, 1981.

[2] Coleman, T.F. and Y. Li, "A Reflective Newton Method for Minimizing a Quadratic Function Subject to Bounds on Some of the Variables", SIAM Journal on Optimization, Vol. 6, Number 4, pp. 1040-1058, 1996.



[ Previous | Help Desk | Next ]