From: Jason Park on
I am currently using LSQNONLIN to minimize my objective function, since I heard FMINCON is somewhat slower than this for nonlinear least squares minimisation, not to mention PATTERNSEARCH or FMINSEARCH which usually take longer due to their non-gradient-based algorithm.

There are some options to specify, MaxFunEvals and MaxIter and I've limited them to 100 each. Since my function embeds a loop in it and every calculation is conducted within each, I've set a stopwatch for each number of the loop executed, which not only tells me the time but also the number of loop execution. At the moment, the number has gone as far as 261.

To my understanding, for the limited number of iterations pre-specified, I thought it shouldn't exceed 100; either terminated as it hits 100 times or converge before it. Yet, how come is it possible that it is running 261 right at the moment I am writing this with no termination?

Please correct me if my understanding on MaxFunEvals and MaxIter is wrong, which is the most probable case since it is anyway running, but I don't know what I need to do with lack of knowledge on this. For each loop-execution, it takes about 630 sec (10.5 min), and what I want to see is if that anyhow runs properly yielding estimates of some reasonable range. Then the matter can narrow down to the number of iterations/whatever that is until convergence, which I hope to be done by a high-performance computer at my university.

Please help me somebody, and it will be much appreciated.

Jason

From: Steven Lord on

"Jason Park" <jason.park(a)buseco.monash.edu.au> wrote in message
news:hoc9r1$l66$1(a)fred.mathworks.com...
>I am currently using LSQNONLIN to minimize my objective function, since I
>heard FMINCON is somewhat slower than this for nonlinear least squares
>minimisation, not to mention PATTERNSEARCH or FMINSEARCH which usually take
>longer due to their non-gradient-based algorithm.
>
> There are some options to specify, MaxFunEvals and MaxIter and I've
> limited them to 100 each. Since my function embeds a loop in it and every
> calculation is conducted within each, I've set a stopwatch for each number
> of the loop executed, which not only tells me the time but also the number
> of loop execution. At the moment, the number has gone as far as 261.

You can set the Display option in your options structure to have LSQNONLIN
display some information (including the iteration number) each iteration.
Remember, though, that you need to actually pass the options structure
returned by OPTIMSET into LSQNONLIN as an input for LSQNONLIN to recognize
that change to the options; OPTIMSET does NOT make a "global change" to the
options for the optimization functions. That's a common mistake; if that's
the cause of the behavior you're seeing, as I suspect it is, you're not the
first nor are you likely to be the last person to encounter it.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ


From: Jason Park on
QUOTE:
Remember, though, that you need to actually pass the options structure
returned by OPTIMSET into LSQNONLIN as an input for LSQNONLIN to recognize
that change to the options; OPTIMSET does NOT make a "global change" to the
options for the optimization functions. That's a common mistake; if that's
the cause of the behavior you're seeing, as I suspect it is, you're not the
first nor are you likely to be the last person to encounter it.

On one hand, good to know that I am not the first nor the last making this mistake, but on the other hand, having checked the code, unfortunately I didn't pass the OPTIMSET function in LSQNONLIN! Now everything makes perfect sense, which however catches me up in a dilemma - do I have to quit it running or should I just leave it there no matter how longer it takes to convergence?

By the way, thanks to that tic-toc function set up for each iteration, I have the number of iterations made so far: 380 iterations, and it has been running nearly 66 hours (roughly 10 minutes per each). Is this lying in a normal/standard range?

Thanks lots and lots Steven,
Jason
From: Steven Lord on

"Jason Park" <jason.park(a)buseco.monash.edu.au> wrote in message
news:hoehjt$m3$1(a)fred.mathworks.com...
> QUOTE:
> Remember, though, that you need to actually pass the options structure
> returned by OPTIMSET into LSQNONLIN as an input for LSQNONLIN to recognize
> that change to the options; OPTIMSET does NOT make a "global change" to
> the options for the optimization functions. That's a common mistake; if
> that's the cause of the behavior you're seeing, as I suspect it is, you're
> not the first nor are you likely to be the last person to encounter it.
>
> On one hand, good to know that I am not the first nor the last making this
> mistake, but on the other hand, having checked the code, unfortunately I
> didn't pass the OPTIMSET function in LSQNONLIN! Now everything makes
> perfect sense, which however catches me up in a dilemma - do I have to
> quit it running or should I just leave it there no matter how longer it
> takes to convergence?
>
> By the way, thanks to that tic-toc function set up for each iteration, I
> have the number of iterations made so far: 380 iterations, and it has been
> running nearly 66 hours (roughly 10 minutes per each). Is this lying in a
> normal/standard range?

It depends. What are you doing in each function evaluation? If you're just
computing something like x.^2 in each function evaluate then something's
wrong. If you were doing some sort of simulation that takes 30 seconds to
run for function evaluation, it could take 60 minutes for each iteration if
you have a large number of variables.

Whether you should kill the current run or not depends on how much longer
you think it would take to converge. If it's likely to converge in the next
iteration, I'd say wait. If it's going to take another day or two to run,
maybe not. Keep in mind that the default MaxFunEvals and MaxIter parameter
values are likely larger than the 100 you said you wanted to use as the
limits on those parameters, so if it didn't finish with your specified
initial guess and the default values for the parameters, it probably won't
finish with the tighter limits. You could try to relax your tolerances or
start from a different starting point to try to speed its convergence.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ


From: Jason Park on
Thanks for your reply.
Mine has about 600 data points with roughly 120 variables/parameters to estimate out of daily calibration. x.^2 is the objective function I'd like to minimise but x is defined as the difference between model and market prices, and my model has QUADL to evaluation and a couple of loops within, and that's why I think it's taking as much. What is worse is that I have 13 of them, and hence I am going to book the high-performance computer to run them faster in a parallel manner.

I am not sure when that will finally reach convergence, and that's why I was asking you how many iterations are standard. I will probably wait for another day, and if that doesn't work, I will kill that and pass the OPTIMSET function in to briefly check whether it anyway returns estimates in a reasonable range or errors. When some questions I've sent through to your email are answered, I can do it with some better idea what may be going on inside that.

I Can't thank enough,
Jason