From: Emma W. on
I'm using MATLAB 2009a.

I used fminsearch to minimize a function, and the variable x is a 20-by-1 vector. The function involves large matrix multiplications and other complicated integrations. To fasten the calculation, I used parfor in the function.

When using fminsearch, I used:
>>newx=fminsearch(@myfun,x0,optimset('TolX',1e-5, 'MaxIter', 8, 'Display','iter'));
where x0 is a initial value.

The command window output for the 1st iteration is:

Iteration Func-count min f(x) Procedure
0 1 2.8136e+07
myfun time: 7.016515e+03
myfun time: 7.027179e+03
myfun time: 7.035043e+03
myfun time: 7.005710e+03
myfun time: 7.000346e+03
myfun time: 7.017593e+03
myfun time: 7.015270e+03
....

where the 'myfun time' output shows how long it takes to evaluate the function based on tic,toc commands I set inside 'myfun'. I couldn't finish even the first iteration as it is taking too much time.

Question:
Does this output show that fminsearch evaluates the function many times within each single iteration? Why is it so? Is it calculating the gradient of the function by finite difference, although I believe fminsearch doesn't use gradient?

Look forward to any response and thank you in advance!
From: Matt J on
"Emma W." <emmawq(a)gmail.com> wrote in message <hsc042$gqq$1(a)fred.mathworks.com>...

> Does this output show that fminsearch evaluates the function many times within each single iteration? Why is it so?
=============

Yes, it evaluates the function multiple times, but not for gradient computation. Here is a description of the algorithm used by fminsearch and the variety fo function evaluations that it must perform per iteration:

http://en.wikipedia.org/wiki/Nelder%E2%80%93Mead_method
From: Emma W. on
Thank you very much!


"Matt J " <mattjacREMOVE(a)THISieee.spam> wrote in message <hsc1cs$9aq$1(a)fred.mathworks.com>...
> "Emma W." <emmawq(a)gmail.com> wrote in message <hsc042$gqq$1(a)fred.mathworks.com>...
>
> > Does this output show that fminsearch evaluates the function many times within each single iteration? Why is it so?
> =============
>
> Yes, it evaluates the function multiple times, but not for gradient computation. Here is a description of the algorithm used by fminsearch and the variety fo function evaluations that it must perform per iteration:
>
> http://en.wikipedia.org/wiki/Nelder%E2%80%93Mead_method