lsqlin

Find the least squares minimum of a constrained real system of linear equations.

Syntax

x = lsqlin(C,d,A,b,Aeq,beq,lb,ub,x0)

x = lsqlin(C,d,A,b,Aeq,beq,lb,ub,x0,options)

[x,resnorm,residual,exitflag,output] = lsqlin(...)

Inputs

C
A matrix that provides the left hand side of Cx = d.
d
A column vector that provides right hand side of Cx = d.
A
A matrix used to compute A*x for inequality constraints.
Use [ ] if unneeded.
b
The upper bound of the inequality constraints A*x<=b.
Use [ ] if unneeded.
Aeq
A matrix used to compute Aeq*x for equality constraints.
Use [ ] if unneeded.
beq
The upper bound of the equality constraints Aeq*x=beq.
Use [ ] if unneeded.
lb
The design variable lower bounds.
Use [ ] if unbounded. Support for this option is limited. See Comments.
ub
The design variable upper bounds.
Use [ ] if unbounded. Support for this option is limited. See Comments.
x0
An estimate of the location of the minimum.
options
A struct containing option settings.
See optimset for details.

Outputs

x
The location of the function minimum.
resnorm
The squared length of the residuals vector.
residual
The residuals vector.
exitflag
The convergence status flag.
info = 3
Converged with a constraint violation within TolCon.
info = 1
Function value converged to within TolX or TolKKT.
info = 0
Reached maximum number of iterations or function calls, or the algorithm aborted because it was not converging.
info = -2
The function did not converge.
output
A struct containing iteration details. The members are as follows:
iterations
The number of iterations.
nfev
The number of function evaluations.
xiter
The candidate solution at each iteration.
fvaliter
The objective function value square root at each iteration.
coniter
The constraint values at each iteration. The columns contain the constraint function values in the following order: linear inequality constraints, linear equality constraints.

Examples

Minimize the function 0.5*|Cx - f'x|^0.5, subject to the linear inequality constraints: Ax < b.

C = [2, -2.5; 0, sqrt(1.75)];
d = [1; sqrt(7)];
A = [-1, -3; -1, -5];
b = [-22; -32];
lowerBound = [-10; -10];
upperBound = [10; 10];
init = [8; 6];
[x,resnorm,residual,exitflag] = lsqlin(C,d,A,b,[],[],lowerBound,upperBound,init)
x = [Matrix] 2 x 1 7.00000 5.00000 resnorm = 16 residual = [Matrix] 2 x 1 0.50000 3.96863 exitflag = 1

The function converts the problem into a quadratic program and implements it through an SQP algorithm. A specific QP algorithm will be more efficient when available.

If large lb and ub values are specified then it is essential to use option TolX in optimset. The default TolX is likely too large, since it is applied relative to the interval size.

The unbounded lb and ub options are not fully supported due to their relationship to TolX. The unbounded options are defaulted to -1000 and 1000, respectively.

The optimset options and defaults are as follows:

  • MaxIter: 400
  • MaxFunEvals: 1,000,000
  • MaxFail: 20,000
  • TolX: 1.0e-7
  • TolCon: 0.5%
  • TolKKT: 1.0e-7
  • Display: 'off'