f

#### lsqlin error msg --"out of memory"

```I was doing a simple linear least square fit using lsqlin with constraints:
min||Ax-(b-c)|| with -Ax<=c, A is a m*n sparse matrix. m = 65536 and n = 83.
x , c are vectors with length 83 and 65536 respectively.
>> x=lsqlin(A,b-c,-A,c);
Matlab msg:

??? Error using ==> vertcat
Out of memory. Type HELP MEMORY for your options.

Error in ==> lsqlin at 216
if isempty([Aeq;A]) && isempty([beq;b]) && all(isinf([lb;ub]))

Is this problem too large for Matlab to handle? It seems hard to imagine it will run out of memory.
```
 0
iloveyu
9/3/2010 12:10:05 AM
comp.soft-sys.matlab 211266 articles. 19 followers. lunamoonmoon (257) is leader.

2 Replies
719 Views

Similar Articles

[PageSpeed] 23

```On 9/2/2010 8:10 PM, iloveyu wang wrote:
> I was doing a simple linear least square fit using lsqlin with constraints:
> min||Ax-(b-c)|| with -Ax<=c, A is a m*n sparse matrix. m = 65536 and n =
> 83.
> x , c are vectors with length 83 and 65536 respectively.
>>> x=lsqlin(A,b-c,-A,c);
> Matlab msg:
>
> ??? Error using ==> vertcat
> Out of memory. Type HELP MEMORY for your options.
>
> Error in ==> lsqlin at 216
> if isempty([Aeq;A]) && isempty([beq;b]) && all(isinf([lb;ub]))
>
> Is this problem too large for Matlab to handle? It seems hard to imagine
> it will run out of memory.

The function reference pages for LSQLIN state:
"The large-scale algorithm requires only upper and lower bounds, meaning
no linear inequalities or equalities. Otherwise, lsqlin uses the
medium-scale algorithm."

The pages that describe what medium-scale means say:
"Large-Scale vs. Medium-Scale Algorithms.  An optimization algorithm is
large scale when it uses linear algebra that does not need to store, nor
operate on, full matrices. This may be done internally by storing sparse
matrices, and by using sparse linear algebra for computations whenever
possible....In contrast, medium-scale methods internally create full
matrices and use dense linear algebra."
See
http://www.mathworks.com/help/toolbox/optim/ug/f12471.html#brppuoz

So I am sorry, but for your problem (with inequalities), LSQLIN uses
dense linear algebra, not sparse.

You could try using one of the sparse solvers on your problem, ones that
might be less efficient, but could handle the problem using sparse
linear algebra. Perhaps fmincon interior-point would work for you. Or
perhaps you can reformulate your problem to work with the large-scale
lsqlin solver.

Alan Weiss
MATLAB mathematical toolbox documentation
```
 0
Alan
9/3/2010 2:50:33 PM
```You can try a few options in TOMLAB, for example TLSQR, LSSOL and
SNOPT.

Best wishes, Marcus
Tomlab Optimization Inc.
http://tomopt.com/
http://tomsym.com/

> Is this problem too large for Matlab to handle? It seems hard to imagine it will run out of memory.

```
 0
Marcus
9/4/2010 1:23:30 AM