Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Annoying behavior of Matlab's fminsearch...

122 views
Skip to first unread message

Linus Utopia

unread,
Jul 13, 2007, 10:28:59 PM7/13/07
to
Hi all,

I am asking this for my friend -- he could not access Internet currently. So
he asked me but I don't know how to answer.

When using "fminsearch",

options = optimset('fminsearch');
options = optimset(options, 'Display','iter');
[xstar fstar flags]=fminsearch(@(x)ObjectiveFunction(x), x_0, options);


It prints out the following instantly:

-------------------------

x =

0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000


Iteration Func-count min f(x) Procedure
0 1 1.64236
1 11 1.64236 initial simplex
2 23 1.64236 shrink
3 35 1.64236 shrink
4 47 1.64236 shrink
5 59 1.64236 shrink
6 71 1.64236 shrink
7 83 1.64236 shrink
8 95 1.64236 shrink
9 107 1.64236 shrink
10 119 1.64236 shrink
11 131 1.64236 shrink
12 143 1.64236 shrink
13 155 1.64236 shrink
14 167 1.64236 shrink
15 179 1.64236 shrink
16 191 1.64236 shrink

-------------------------------

And then it continued for about 1 minute with staying at the initial x:

-------------------------------

x =

0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000


... ...

(all the same)

... ...

x =

0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000

17 203 1.64236 shrink

Optimization terminated:
the current x satisfies the termination criteria using OPTIONS.TolX of
1.000000e-004
and F(X) satisfies the convergence criteria using OPTIONS.TolFun of
1.000000e-004

-------------------------------------

What's wrong with the program? It didn't search away from the initial values
at all. Since each function evaluation is very costly -- about 1 minute, it
was not possible for the "fminsearch" to finish 203 function evaluations
within a minute and got the final result to be the same as the initial
values. The above print-out information was definitely wrong.

Any thoughts?

Thanks a lot!


toni.l...@gmail.com

unread,
Jul 14, 2007, 3:11:47 AM7/14/07
to
On 14 heinä, 05:28, "Linus Utopia" <linus_uto...@gmail.com> wrote:
> Hi all,
>
> I am asking this for my friend -- he could not access Internet currently. So
> he asked me but I don't know how to answer.
>
> When using "fminsearch",
>
> options = optimset('fminsearch');
> options = optimset(options, 'Display','iter');
> [xstar fstar flags]=fminsearch(@(x)ObjectiveFunction(x), x_0, options);
> -------------------------------------
>
> What's wrong with the program? It didn't search away from the initial values
> at all. Since each function evaluation is very costly -- about 1 minute, it
> was not possible for the "fminsearch" to finish 203 function evaluations
> within a minute and got the final result to be the same as the initial
> values. The above print-out information was definitely wrong.

I'm guessing there is something wrong with the objective function, and
instead of evaluating properly it just returns a constant value. The
behaviour of Nelder-Mead on a constant function is similar to what
your friend experienced.

Sherry

unread,
Mar 29, 2011, 7:39:04 PM3/29/11
to
Dear Linus,
Is the problem solved in the end? I am experiencing the similar problem with fminsearch...I am sure my objective function is not constant but it keeps giving me whatever initial para as best para... Just wondering how you solved the issue. Thank you very much! :-)

"Linus Utopia" <linus_...@gmail.com> wrote in message <f79cgv$k66$1...@news.Stanford.EDU>...

Matt J

unread,
Mar 29, 2011, 11:35:04 PM3/29/11
to
"Linus Utopia" <linus_...@gmail.com> wrote in message <f79cgv$k66$1...@news.Stanford.EDU>...
>
>
> What's wrong with the program? It didn't search away from the initial values
> at all. Since each function evaluation is very costly -- about 1 minute, it
> was not possible for the "fminsearch" to finish 203 function evaluations
> within a minute and got the final result to be the same as the initial
> values. The above print-out information was definitely wrong.
=================

This can happen when the objective function contains quantization operations, which make it piecewise constant. For example,


>> staircase=@(x) interp1(0:10,0:10,x,'nearest'); % global minimum at x=0

>> x=fminsearch(staircase,1.1)

x =

1.1000

>> x=fminsearch(staircase,2.4)

x =

2.4000

>> x=fminsearch(staircase,3.01)

x =

3.0100

Sherry

unread,
Mar 30, 2011, 5:03:19 PM3/30/11
to
Thanks a lot, Matt! That definitely make sense. But in my case, I created a mesh plot of my objective function with respect to two of the para(total three), and it did not show quantization/staircase-like behavior... Do you happen to know what else I should test on the objective function? Thanks a lot~~ :)

"Matt J" wrote in message <imu8d8$t8p$1...@fred.mathworks.com>...

Matt J

unread,
Mar 30, 2011, 5:25:05 PM3/30/11
to
"Sherry " <xy...@umich.edu> wrote in message <in05qn$j1l$1...@fred.mathworks.com>...

>
> Thanks a lot, Matt! That definitely make sense. But in my case, I created a mesh plot of my objective function with respect to two of the para(total three), and it did not show quantization/staircase-like behavior... Do you happen to know what else I should test on the objective function? Thanks a lot~~ :)
==============

The plot may not reveal much if you've plotted too coarsely. Basically, you want to assess whether there are any operations like ROUND, CEIL, FLOOR, and similar quantization operations used inside your objective function. If so, it means trouble.

You should also make a finely sampled plot around what you think are false solutions to see if, indeed, they are local minima.

Sherry

unread,
Mar 30, 2011, 6:15:21 PM3/30/11
to
Thanks so much for your valuable comments, Matt! I will take a closer look into the objective function and see what happened there. Again, many thanks!~ :D

"Matt J" wrote in message <in073h$c8v$1...@fred.mathworks.com>...

0 new messages