|
Hi Mary,
As Nico says, the exit message is trying to tell you that the objective function gradient is so small that lsqcurvefit determines that no further progress can be made.
Looking at your problem, I notice that the lower bound for the third parameter (2), is larger than the upper bound (0.1). You should ensure that the upper bound is larger than the lower bound.
You also say that you do not need xdata and ydata for lsqcurvefit and you can just replace xdata with 0. The idea behind lsqcurvefit is that you vary the 5 (in your case) parameters of your objective function to try and fit the curve specified by multiple points defined in xdata and ydata. What you appear to be trying to do is minimize (where p denotes your "parameters" vector)
(costfunction_V1(p, 0) - 0)^2 + (costfunction_V1(p, 0) - 0)^2
= 2(costfunction_V1(p, 0)^2
Do you really mean this? The reason I ask is that you mention a SIMULINK model, and a typical optimization problem here is to try to fit the output of a SIMULINK model to a set of (xdata, ydata) points. If this is really what you're trying to do, then there is an example in the Optimization documentation which may help you:
<<http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/brn4noo.html#f11160>>
This example uses lsqnonlin, which uses the same underlying algorithm as lsqcurvefit, to fit parameters of a closed loop controller defined in SIMULINK.
Hope this helps
Best regards,
Paul
"nico cruz" <m.nicolas.cruz@mailbox.tu-berlin.de> wrote in message <hn52qd$43$1@fred.mathworks.com>...
>
> Hi,
>
> I dontknow if I am the best to answer this question :)
>
>
>
> regarding the small changes in your parameters:
>
> the optimizer makes one small change on the parameters to calculate the derivatives (gradients) numerically.
> Like in math where dx/dt ~ (x2-x1)/(t2-t1)
>
> after this, it moves in the direction where the objective function seems to decrease.
>
> when the optimizer shows this message:
> > %%%%%%%
> > Optimization terminated: directional derivative along search direction less than TolFun and infinity-norm of gradient less than 10*(TolFun+TolX).
> > %%%%%%%
>
> it is trying to tell you that in the point where he is, the derivatives (meaning the change of the objective function when the parameters are changed) is very small.
>
> the optimizer sees in your obj. func. df/dx = 0, a flat surface (in 3-D problems), though he stops because he has no direction where to move.
>
> hope I could help
>
> "maria " <mariaame@gmail.com> wrote in message <hn2sib$ih0$1@fred.mathworks.com>...
> > "nico cruz" <m.nicolas.cruz@mailbox.tu-berlin.de> wrote in message <hmoduv$nbh$1@fred.mathworks.com>...
> > > I know it sounds pretty obvious,
> > >
> > > but did you check the order of your parameter vector?
> > >
> > > also why are xdata and ydata so small and not equal?
> > >
> > > coudl you maybe send some more info about your problem?
> > >
> > > nico
> > >
> > > "maria " <mariaame@gmail.com> wrote in message <hmocec$fkn$1@fred.mathworks.com>...
> > > > Hi,
> > > > I am using lsqcurvefit to solve an optimization problem. I specify upper and lower bounds for the solutuion, how ever, watching ont the parameters evolution, I have noticed that my fourth parameter goes out of the bounds, it is suppose to be smaller that 0.5 and the algorithm is testing in 30!. Problem is that the algorithm might have found a local minimun there and for this reason, it keeps on trying in this region, which is actually physically imposible.
> > > >
> > > > Anybody has any idea about why is the algorithm testing outside the bounds?. My cost function gives a vector of size 2 which should be near to 0.
> > > >
> > > >
> > > > lb=[0.05, 0.05, 2, 1e-6, 300];
> > > > ub=[2 ,3 , 0.1, 0.5, 600];
> > > > options=optimset('TolFun',tol);
> > > > x2=lsqcurvefit(@costfunction_V1,parameters,0,[0,0],lb,ub,options);
> > > >
> > > > Thanks in advance.
> > > >
> > > > Mary
> >
> > Hi Nico,
> >
> > Yes I did it, so I guess it was not the problem. Maybe I have a problem on the definiton of the xdata, I will check. the question is that the function I am trying to fit is a measure which comes from a simulink simulation, so I do not need to define an xdata, I defined it as 0 just because to compute lsqcurvefit it is necessary to have a function like F(x,xdata). ydata is small because it is a cost function in time which has to be close form 0...
> > By now I found a "solution", I redefined my cost function so it is testing inside the boudns, I guess that I reduced somehow the work that the algorithm has to do... however, now I have another problem...
> >
> > When I try to define the TolFun and TolX parameters, the algorithm ends with this message:
> >
> > %%%%%%%
> > Optimization terminated: directional derivative along search direction less than TolFun and infinity-norm of gradient less than 10*(TolFun+TolX).
> > %%%%%%%
> >
> > I know that terminated is a synonimum of end, but, I already know one solution for the function parameters (question is that I need to repeat the procedure with 930 more functions..), which is optimal than the one that I have when I get this message, The algorithm is doing changes in the parameters in the 1e-4 magnitude, which is too small, they are not significative for my problem, In order to solve that, I tried with TolX=1e-2, but when I do that, I get the message that I wrote..
> >
> > Any idea about how to solve that?
> >
> > Thanks in advance,
> >
> > Mary
|