Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
lsqlin getting stuck[?]

Subject: lsqlin getting stuck[?]

From: Cory

Date: 4 Oct, 2011 21:45:26

Message: 1 of 10

Hi all,

I'm having an issue with lsqlin converging. I have a least-squares problem I'd like to solve. So I try this:

>> options = optimset('Display','off','LargeScale','off','MaxIter',234);
>> [x,r1,r2,f] = lsqlin(alC,alD,[],[],Aeq,Beq,lb,[],[],options);
>> r1

r1 =

    0.0577

>> f

f =

     0


OK, seems easy: I should increase MaxIter. But no go:

>> options = optimset('Display','off','LargeScale','off','MaxIter',10000);
>> [x,r1,r2,f] = lsqlin(alC,alD,[],[],Aeq,Beq,lb,[],[],options);
>> r1

r1 =

    0.0577

>> f

f =

     0


OK, fine. Instead, I'll just use the last guess as a new starting point. This helps some, but it still gets stuck:

>> options = optimset('Display','off','LargeScale','off','MaxIter',234);
>> [x,r1,r2,f] = lsqlin(alC,alD,[],[],Aeq,Beq,lb,[],[],options);
>> [x2,r1,r2,f] = lsqlin(alC,alD,[],[],Aeq,Beq,lb,[],x,options);
>> r1

r1 =

  2.6851e-008

>> f

f =

     0

>> [x3,r1,r2,f] = lsqlin(alC,alD,[],[],Aeq,Beq,lb,[],x2,options);
>> r1

r1 =

  2.6851e-008

>> f

f =

     0

In fact, MATLAB thinks x3 == x2 (i.e. for every value in each vector). The residual may seem small, but precision is very important in my application (when f = 1 for similar problems the precision is fine; I just want to get the exit flag to one).

I can write my own code to resolve the lsqlin errors here, but would rather not resort to that. For the intrepid, I'm posting the values of my variables below. I am using 7.11.0 / R2010b. Any advice on getting lsqlin to converge (or resolving some stupid error I made) would be much-appreciated. Thanks!!

--Cory

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


>> mat2str(alC)

ans =

[1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;0 0 0 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;1;1;1;1;1;1;1]

>> mat2str(lb)

ans =

[0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0]

Subject: lsqlin getting stuck[?]

From: Matt J

Date: 4 Oct, 2011 22:30:24

Message: 2 of 10

"Cory" wrote in message <j6fupm$8e4$1@newscl01ah.mathworks.com>...
>
> I can write my own code to resolve the lsqlin errors here, but would rather not resort to that. For the intrepid, I'm posting the values of my variables below. I am using 7.11.0 / R2010b. Any advice on getting lsqlin to converge (or resolving some stupid error I made) would be much-appreciated. Thanks!!
=================


Well, I can't check anything myself since I don't have the required toolbox. Here are just some miscellaneous thoughts:

(1) Your vector alD technically speaking should be a column vector, as opposed to a row vector as you now have it. Seems kind of doubtful that that's causing the problems, but you never know.

(2) Your problem seems highly under-determined. You have 27 unknowns but
size([alC;Aeq],1) is only 18. Possibly the ill-conditioning could be interfering with convergence.

(3) Note that the final residual is not necessarily expected to be small for constrained problems. As an extreme example, if I constrained x=0, the residual would always be the norm of alD. That doesn't explain why you go from 0.0577 down to
  2.6851e-008, but I'm just saying

(4) You could try adding ub bounds. Your other constraints imply upper bounds of
ub(i)=1 for all i. It would be interesting to see what impact that has.

Subject: lsqlin getting stuck[?]

From: Cory

Date: 4 Oct, 2011 23:11:26

Message: 3 of 10

Thanks for these suggestions. Actually, adding upper bounds (3) does get this individual problem to converge. I'm solving a number of them, though, and it doesn't resolve the issue generally (to be candid, it is only in issue in ~3% of cases).

Just as a quick note on the other ideas: addressing (1), as you anticipated, doesn't seem to change the result. (4) Definitely. I can tell whether it has gotten the "right" answer, though, since subsequent steps of a larger program rely on this answer being right (whenever f = 1 it's fine). (2) Yes, this is true. I am not sure how to address the ill-conditioning, though. It's true that lsqlin starts failing only when there are a lot of variables in the problems I am giving it. Unfortunately, it's not obvious (to me) how to pick an arbitrary value for some of the variables (or do something else) to stop the problem from being under-determined.

So far I am hoping that some combination of 1) Setting an upper bound 2) Increasing MaxIter and 3) Using previous values to keep on iterating will help get lsqlin to converge. Even ignoring that this is a bit ugly, I am not sure whether it will work for all cases. Any thoughts on other solutions (e.g. how to address (2) )?

Thanks once again!

Subject: lsqlin getting stuck[?]

From: Matt J

Date: 5 Oct, 2011 14:34:13

Message: 4 of 10

"Cory" wrote in message <j6g3qu$mvb$1@newscl01ah.mathworks.com>...
>
>Any thoughts on other solutions (e.g. how to address (2) )?
=============

That's a physical modeling question (and therefore one only you can answer).
You need to think about whether there are system equations and/or constraints that you forgot, that could more uniquely identify the solution you're looking for.

Subject: lsqlin getting stuck[?]

From: Cory

Date: 5 Oct, 2011 15:31:29

Message: 5 of 10

I'm pretty certain that's it. There's nothing, for my purposes, to distinguish one solution from another.

I guess another thing I could try is getting an equivalent problem by substituting the linear equations implied in Aeq to reduce the number of variables (if not the degrees of freedom). Do you think this would help?

Subject: lsqlin getting stuck[?]

From: Cory

Date: 5 Oct, 2011 15:34:25

Message: 6 of 10

For anyone who wants to play around, here is a more resistant problem.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

>> mat2str(alC)

ans =

[1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 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0 0 0 0 0 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1]

>> mat2str(Beq)

ans =

[1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1]

>> mat2str(lb)

ans =

[0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0]

>> mat2str(ub)

ans =

[1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1]

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>>

Subject: lsqlin getting stuck[?]

From: Matt J

Date: 5 Oct, 2011 15:51:28

Message: 7 of 10

"Cory" wrote in message <j6ht8h$hen$1@newscl01ah.mathworks.com>...
> I'm pretty certain that's it. There's nothing, for my purposes, to distinguish one solution from another.
>
> I guess another thing I could try is getting an equivalent problem by substituting the linear equations implied in Aeq to reduce the number of variables (if not the degrees of freedom). Do you think this would help?
==============

No. The equivalent problem will be equivalently ill-posed...
 I'm having a hard time understanding, though, how you could be indifferent between non-unique solutions. If you are indifferent, then maybe just add a penalty on ||x||^2 to force LSQLIN to give you minimum-norm solution for x.
Equivalently change
alC to [alC;eye(size(x))*smallpositivenumber]

Subject: lsqlin getting stuck[?]

From: Cory

Date: 5 Oct, 2011 16:21:27

Message: 8 of 10

> No. The equivalent problem will be equivalently ill-posed...

Fair enough. Since adding the upper bounds helped in some cases I wondered if different equivalent problems might be better-solved by lsqlin.

> I'm having a hard time understanding, though, how you could be indifferent between non-unique solutions.

Well, one part is that a lot of variables will end up hitting the lower bound (if it were obvious which ones, I would just set them equal to zero and continue with a better problem). Any other equivalences are "real" equivalences: it's an economic model, so it would describe the allocation decision of two equivalent objects. I don't really care which of the equivalent objects takes a certain action given that together their actions add up to a certain amount.

>If you are indifferent, then maybe just add a penalty on ||x||^2 to force LSQLIN to give you minimum-norm solution for x.
> Equivalently change
> alC to [alC;eye(size(x))*smallpositivenumber]

Unfortunately this does not make the example I posted above converge. It could also reduce the precision of the algorithm, which is a problem for my application. :-/

Again, thanks for all the help. I really appreciate it!

Subject: lsqlin getting stuck[?]

From: Matt J

Date: 5 Oct, 2011 17:21:27

Message: 9 of 10

"Cory" wrote in message <j6i067$rmo$1@newscl01ah.mathworks.com>...
>Any other equivalences are "real" equivalences: it's an economic model, so it would describe the allocation decision of two equivalent objects. I don't really care which of the equivalent objects takes a certain action given that together their actions add up to a certain amount.
==============

But then you do understand where the equivalences are occuring?
If you don't care which equivalent solution you get, choose a tie-breaking rule and add it as a constraint to your problem. This will remove the ill-posedness.

Subject: lsqlin getting stuck[?]

From: Cory

Date: 5 Oct, 2011 18:58:28

Message: 10 of 10

> But then you do understand where the equivalences are occuring?
> If you don't care which equivalent solution you get, choose a tie-breaking rule and add it as a constraint to your problem. This will remove the ill-posedness.

Thanks, I'll think on this. Unfortunately, it's not obvious where equivalences are occurring until there is a solution which makes it hard to pick a tie-breaking rule.

To be more specific, the model relates to the portion of a field allocated to a given crop ("labor"). Given a set of prices and data on how much of a crop a field can produce, you know which crops it makes sense for the fields to produce (revenue maximization). Given a set of fields and a price, we want the labor allocation which most closely matches some aggregate labor allocation, i.e. x amount of labor to crop A, y amount to crop B, etc.

Now, if two fields look alike in crops A & B and they both produce them, then there is a real equivalence. If the labor allocation is field1: 0.5 0.5 (in A & B) and field 2: 0.5 0.5, then f1: 0.1 0.9 f2: 0.9 0.1 (and many others) are both fine. So, both answers are really "the same." On the other hand, a priori you don't whether there will be this equivalence because field1 and field2 might differ in, say, how much crop C they can produce.

Anyway, at the moment lsqlin is only bailing on me in ~1% of cases, so things are probably fine for now. If it turns out that the 1% matter a lot, I'll see what I can do about a tie-breaker (though I'm a little worried that adding rows to alC and alD did not help convergence). Thanks for all the help!

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us