From: Dushyant Kumar on
Alan Weiss <aweiss(a)mathworks.com> wrote in message
>
> Exitflag 3 means "Change in the residual was smaller than the specified
> tolerance." So you could try setting TolFun to 10*eps, as I suggested
> above. You could even set it a little smaller, but don't set it less
> than eps.
>
> Did you misname your tes function above, or did you really use lsqnonneg
> instead of lsqlin?
>
> Alan Weiss
> MATLAB mathematical toolbox documentation

I did that; no change.
I am still getting:
resnorm =

1.3057e-007


exitflag =

3


> Did you misname your tes function above, or did you really use lsqnonneg
> instead of lsqlin?

My initial code was using lsqnonneg and it works fine. However, I am planning to implement it on large scale problem and hence I am looking at lsqlin.

In the very beginning of my code, there is any option of choosing which solver to use:

Solver = 'lsqnonneg';

vs
Solver = 'lsqlin';

Can I work trust lsqnonneg for large scale problem?

I have also plotted sparisity pattern at
http://docs.google.com/fileview?id=0B0Ah9soYnrlIOWRlMGE1M2MtYjNkNy00NWI0LTlhNWQtMDkwMThiMWE1MzNj&hl=en

Only discussed for 4 voxels case and each diagonal block is ~ 151 x 100. I would like to process 10000 voxels (a single slice of MRI) or 1 mil (entire brain) at a time.

I have access to matlab cluster at Cornell.
From: Alan Weiss on
On 5/26/2010 12:18 PM, Dushyant Kumar wrote:
> Alan Weiss <aweiss(a)mathworks.com> wrote in message
>>
>> Exitflag 3 means "Change in the residual was smaller than the
>> specified tolerance." So you could try setting TolFun to 10*eps, as I
>> suggested above. You could even set it a little smaller, but don't set
>> it less than eps.
>>
>> Did you misname your tes function above, or did you really use
>> lsqnonneg instead of lsqlin?
>>
>> Alan Weiss
>> MATLAB mathematical toolbox documentation
>
> I did that; no change. I am still getting:
> resnorm =
>
> 1.3057e-007
>
>
> exitflag =
>
> 3
>
>
>> Did you misname your tes function above, or did you really use
>> lsqnonneg instead of lsqlin?
>
> My initial code was using lsqnonneg and it works fine. However, I am
> planning to implement it on large scale problem and hence I am looking
> at lsqlin.
>
> In the very beginning of my code, there is any option of choosing which
> solver to use:
>
> Solver = 'lsqnonneg';
>
> vs
> Solver = 'lsqlin';
>
> Can I work trust lsqnonneg for large scale problem?
>
> I have also plotted sparisity pattern at
> http://docs.google.com/fileview?id=0B0Ah9soYnrlIOWRlMGE1M2MtYjNkNy00NWI0LTlhNWQtMDkwMThiMWE1MzNj&hl=en
>
>
> Only discussed for 4 voxels case and each diagonal block is ~ 151 x 100.
> I would like to process 10000 voxels (a single slice of MRI) or 1 mil
> (entire brain) at a time.
>
> I have access to matlab cluster at Cornell.

lsqnonneg is a large-scale algorithm, in the sense that it uses and
maintains sparsity of matrices. It was refactored to preserve and use
sparsity in R2008b, as described here:
http://www.mathworks.com/access/helpdesk/help/toolbox/optim/rn/bro3heq-1.html
It is not a particularly fast algorithm in some cases, but you can test
it and decide for yourself whether it is sufficiently fast for your
purposes.

Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
From: Dushyant Kumar on
Alan Weiss <aweiss(a)mathworks.com> wrote in message <htjimi$gnv$1(a)fred.mathworks.com>...
>
> lsqnonneg is a large-scale algorithm, in the sense that it uses and
> maintains sparsity of matrices. It was refactored to preserve and use
> sparsity in R2008b, as described here:
> http://www.mathworks.com/access/helpdesk/help/toolbox/optim/rn/bro3heq-1.html
> It is not a particularly fast algorithm in some cases, but you can test
> it and decide for yourself whether it is sufficiently fast for your
> purposes.
>
> Good luck,
> Alan Weiss
> MATLAB mathematical toolbox documentation

I will try running it on cluster and time it.

However, still I am frustrated that resnorm is unaffected by changes in TolFun in most of the optimization algorithm. Can you/someone explain why this happening?

I do get into trouble even with LSQNONNEG if I try to normize my data:
In general if I normalize my data as
y(TE) = y(TE)./y(0)

In the case, I am having the same problem with LSQNONNEG as well. It reports me the identical solution to LSQLIN and I can reduce RESNORM by changing TolFun.

===============================
The problem I am trying to solve is ill-posed:

y(TE) = (sum over i) A_i exp(-TE/T2_i) + (sum over j) B_j exp(-TE/T2_j) + one more similar term

I converted this to
y = A X

where I have defined
T2_Scale = logspace(log10(5e-3), log10(600e-3), 100);
A = exp(-kron(TE, 1./T2_Scale));

and X consists of prefactor A_i and B_j etc.

Finally from X, I would like to deduce area under the curve and then the fraction:

area under the curve 1/ area under the curve 2.
===================================
From: Dushyant Kumar on

The problem is still TOO time consuming. I CAN NOT use LSQNONNEG.

Lsqnonneg is working,BUT it&#8217;s taking way too much time if I would have used lsqlin solver instead.
Here I am doing for 36 voxels only. Remember, I intend to do it for 10000 at least.

===========
In case of solver lsqlin, the top 5 time taking codes, their no of calls and time taken are respectively:
lsqnonneg-----1-----7.5079
lsqlin-----1-----1.432
optim\private\sllsbox-----1-----1.408
optim\private\drqpbox-----2-----1.257
aprecon-----2-----0.81899

Total time taken = 9.9762

Here even if my primary solver is lsqlin, I do use lsqnonneg for much smaller problem.
===========

In case of solver lsqnonneg, the top 5 time taking codes, their no of calls and time taken are respectively:
lsqnonneg-----2-----509.8306
kron-----39-----0.207
Test_LSQNONNEG_n_SpatialReg>Create_AComp_Matrix-----1-----0.206
newplot-----72-----0.189
Test_LSQNONNEG_n_SpatialReg>calculate_Ds_row-----36-----0.18

Total time taken = 510.5874
===========
From: Dushyant Kumar on
Here is what I am doing:
===========
My problem is ill-posed. 100 variables, 50 experimental data.

I use lsqnonneg to solve for no regularization case. Then take it as x0 (initial guess).

Now, I add regularization and since I have now more equations than unknown, I can use lsqlin as well.

Now, I can use either lsqlin or lsqnonneg.
===========

I believe that if I can change resnorm of lsqlin by changing TolFun, it would give me similar result as lsqnonneg. However, changing TolFun does not change resnorm.