lsqlincon: Linear Least-Squares Fitting with linear constraints In pracma: Practical Numerical Math Functions

Description

Solves linearly constrained linear least-squares problems.

Usage

 1 2 lsqlincon(C, d, A = NULL, b = NULL, Aeq = NULL, beq = NULL, lb = NULL, ub = NULL)

Arguments

 C mxn-matrix defining the least-squares problem. d vector or a one colum matrix with m rows A pxn-matrix for the linear inequality constraints. b vector or px1-matrix, right hand side for the constraints. Aeq qxn-matrix for the linear equality constraints. beq vector or qx1-matrix, right hand side for the constraints. lb lower bounds, a scalar will be extended to length n. ub upper bounds, a scalar will be extended to length n.

Details

lsqlincon(C, d, A, b, Aeq, beq, lb, ub) minimizes ||C*x - d|| (i.e., in the least-squares sense) subject to the following constraints: A*x <= b, Aeq*x = beq, and lb <= x <= ub.

If some constraints are NULL (the default), they will not be taken into account. In case no constraints are given at all, it simply uses qr.solve.

Value

Returns the least-squares solution as a vector.

Note

Function lsqlin in pracma solves this for equality constraints only, by computing a base for the nullspace of Aeq. But for linear inequality constraints there is no simple linear algebra ‘trick’, thus a real optimization solver is needed.

References

Trefethen, L. N., and D. Bau III. (1997). Numerical Linear Algebra. SIAM, Society for Industrial and Applied Mathematics, Philadelphia.