### 2.7 Linear least squares with linear constraints. ¶

(This function does not fit well into this chapter because it is actually a special case of quadratic programming).

Function File: lsqlin `(C, d, A, b)` ¶
Function File: lsqlin `(C, d, A, b, Aeq, beq, lb, ub)` ¶
Function File: lsqlin `(C, d, A, b, Aeq, beq, lb, ub, x0)` ¶
Function File: lsqlin `(C, d, A, b, Aeq, beq, lb, ub, x0, options)` ¶
Function File: `[x, resnorm, residual, exitflag, output, lambda] =` lsqlin `(…)` ¶

  Solve the linear least squares program

      min 0.5 sumsq(C*x - d)
      x

  subject to

      A*x <= b,
      Aeq*x = beq,
      lb <= x <= ub.

  The initial guess x0 and the constraint arguments (A and b, Aeq and beq, lb and ub) can be set to the empty matrix (`[]`) if not given. If the initial guess x0 is feasible the algorithm is faster.

  options can be set with `optimset`, currently the only option is `MaxIter`, the maximum number of iterations (default: 200).

  Returned values:

  x

    Position of minimum.

  resnorm

    Scalar value of objective as sumsq(C*x - d).

  residual

    Vector of solution residuals C*x - d.

  exitflag

    Status of solution:

    `0`

      Maximum number of iterations reached.

    `-2`

      The problem is infeasible.

    `-3`

      The problem is not convex and unbounded.

    `1`

      Global solution found.

  output

    Structure with additional information, currently the only field is `iterations`, the number of used iterations.

  lambda

    Structure containing Lagrange multipliers corresponding to the constraints.

  This function calls the more general function `quadprog` internally.

  See also: quadprog.