# [SciPy-user] Matlab lsqlin equivalent: Constrained least squares

Sebastian Haase haase at msg.ucsf.edu
Sat Jun 24 00:45:30 CDT 2006

```Robert Kern wrote:
> Sebastian Haase wrote:
>> Hi,
>> A friend of mine needs a constrained least squares solver.
>> He says that Matlab's lsqlin
>> http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/lsqlin.shtml
>> would look like it should do the trick.
>>
>> Is there already some function in scipy.optimize
>> that is equivalent ?
>
> Depends. What kind of bounds does he actually need?
>
I think for now he is looking for a linear least square with "simple
upper bound like:
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.

Does that make sense !?

Sebastian

>    Constrained Optimizers (multivariate)
>
>     fmin_l_bfgs_b -- Zhu, Byrd, and Nocedal's L-BFGS-B constrained optimizer
>                        (if you use this please quote their papers -- see help)
>
>     fmin_tnc      -- Truncated Newton Code originally written by Stephen Nash and
>                        adapted to C by Jean-Sebastien Roy.
>
>     fmin_cobyla   -- Constrained Optimization BY Linear Approximation
>
>
> fmin_l_bfgs_b and fmin_tnc only do rectilinear min-max bounds. fmin_cobyla
> allows arbitrary sets of (possibly nonlinear) "f(x)>=b" bounds.
>
> The equality contraints in lsqlin can probably by transforming the problem into
> the solution space of Aeq*x=b.
>

```