Thread Subject: Understanding lsqnonlin error

Subject: Understanding lsqnonlin error

From: Micik

Date: 22 Nov, 2009 12:42:01

Message: 1 of 2

Hello,
I'm trying to use Matlab lsqnonlin function to find vector X that
minimize the function:

function F = func_for_nonlin(x)
        A = x(1);
        B = x(2);
        F = 0.5*exp(-0.1*A)-0.2*exp(0.2*B)-1;

In Matlab workspace I'm calling lsqnonlin using teh following sytnax:

X=lsqnonlin('func_for_nonlin', [1 1], [-2 -2],[2 2])

Initial solution is [1 1]
and I want constraints to be: -2<X(1)<2 and -2<X(2)<2

However when I try to execute this, I'm getting the following warning:

Large-scale method requires at least as many equations as variables;
 using line-search method instead. Upper and lower bounds will be
ignored.
> In optim\private\lsqncommon at 160
  In lsqnonlin at 181
Optimization terminated: directional derivative along
 search direction less than TolFun and infinity-norm of
 gradient less than 10*(TolFun+TolX).

X =

   -7.3366 -7.8815

Now, my question is why constraints are ignored?

Why I need more equations?

Online documentation for lsqnonlin can be found here:

http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/lsqnonlin.html

Thank you very much.

Subject: Understanding lsqnonlin error

From: Marcelo Marazzi

Date: 23 Nov, 2009 23:00:28

Message: 2 of 2

Micik,

If what you want to do is minimize the function func_for_nonlin
subject to both variables being between -2 and 2, then you
should use the solver fmincon instead.

By calling lsqnonlin as described in your post, you are minimizing
the square of the function, that is

  (0.5*exp(-0.1*A)-0.2*exp(0.2*B)-1)^2.

What the message is telling you is that lsqnonlin doesn't handle
least squares problems that are both under-determined (more unknowns,
A and B, than equations, F) and that has bounds on the variables.

If you really mean to solve the least squares problem as posed, then
you should also call fmincon: square the objective first, and then
call fmincon.

-Marcelo

Micik wrote:
> Hello,
> I'm trying to use Matlab lsqnonlin function to find vector X that
> minimize the function:
>
> function F = func_for_nonlin(x)
> A = x(1);
> B = x(2);
> F = 0.5*exp(-0.1*A)-0.2*exp(0.2*B)-1;
>
> In Matlab workspace I'm calling lsqnonlin using teh following sytnax:
>
> X=lsqnonlin('func_for_nonlin', [1 1], [-2 -2],[2 2])
>
> Initial solution is [1 1]
> and I want constraints to be: -2<X(1)<2 and -2<X(2)<2
>
> However when I try to execute this, I'm getting the following warning:
>
> Large-scale method requires at least as many equations as variables;
> using line-search method instead. Upper and lower bounds will be
> ignored.
>> In optim\private\lsqncommon at 160
> In lsqnonlin at 181
> Optimization terminated: directional derivative along
> search direction less than TolFun and infinity-norm of
> gradient less than 10*(TolFun+TolX).
>
> X =
>
> -7.3366 -7.8815
>
> Now, my question is why constraints are ignored?
>
> Why I need more equations?
>
> Online documentation for lsqnonlin can be found here:
>
> http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/lsqnonlin.html
>
> Thank you very much.

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

rssFeed for this Thread

Contact us at files@mathworks.com