From: student melaku fekadu on

John,

thanks for your swift response.

As my problem is numerical opt, I am not giving derivatives. so with fminunc I get some warning which says that line search method is used. I am running it now just for an hour, and it did not do yet the first iteration. Does it take a long time until it does the first iteration? Fminsearch does this within 5 minutes or so.

Should I wait or I am missing something?

 

Thanks John,
Melaku
 

"John D'Errico" <woodchips(a)rochester.rr.com> wrote in message <i2dc2k$8kn$1(a)fred.mathworks.com>...
> "student melaku fekadu" <melaku.fekadu(a)gmail.com> wrote in message <i2daf3$237$1(a)fred.mathworks.com>...
> > hellow users,
> > i am not a matlab user, but i need to use it to do numerical optimization. ineed to estimate 54 parameters and fminsearch is not helping. i am really having a hard time with fminsearch. so i wanted to use fminunc instead. i just replaced fminunc instead of fminsearch as seen below. my question: is the way i use fminunc as written below okay?
> >
> > if not, how should i write it?
> > if yes, how fast is fminunc compared to fminsearch!
> >
> > i really appreciate any help.
> > thanks,
> > melaku
> >
> > my_options = optimset;
> > my_options.Display = 'iter';
> > my_options.TolFun = 1e-3;
> > my_options.MaxIter = 500;
> > my_func = @(x) objective_function(x, bla, blabla, blablabla)
> > disp(sprintf('now minimizing (simplex) %s parameters...')
> > [x fval exitflag output] = fminunc(my_func, x0, my_options)
>
> You were wasting your time trying to optimize over 54
> parameters with fminsearch. 6 is my recommended
> upper limit. In a desperate moment, 8 or so will run.
>
> 54 parameters in fminsearch will run like a dog with
> 1 leg.
>
> Your call to fminunc is fine.
>
> John
From: John D'Errico on
"student melaku fekadu" <melaku.fekadu(a)gmail.com> wrote in message <i2de4a$ceu$1(a)fred.mathworks.com>...
>
> John,
>
> thanks for your swift response.
>
> As my problem is numerical opt, I am not giving derivatives. so with fminunc I get some warning which says that line search method is used. I am running it now just for an hour, and it did not do yet the first iteration. Does it take a long time until it does the first iteration? Fminsearch does this within 5 minutes or so.
>
> Should I wait or I am missing something?

No, this is not really a "warning". It is merely a
statement of fact.

In 54 dimensions, fminunc will need to call your
objective function roughly 55 times before it starts
to iterate. After all, it needs to compute a gradient
vector.

If your optimization takes roughly a minute per
function call (or longer) then, yes, I would expect
to need to wait that long.

Perhaps you might consider using the profile tool
to find ways to speed up your code.

John
From: student melaku fekadu on
"John D'Errico" <woodchips(a)rochester.rr.com> wrote in message <i2der9$p5q$1(a)fred.mathworks.com>...
> "student melaku fekadu" <melaku.fekadu(a)gmail.com> wrote in message <i2de4a$ceu$1(a)fred.mathworks.com>...
> >
> > John,
> >
> > thanks for your swift response.
> >
> > As my problem is numerical opt, I am not giving derivatives. so with fminunc I get some warning which says that line search method is used. I am running it now just for an hour, and it did not do yet the first iteration. Does it take a long time until it does the first iteration? Fminsearch does this within 5 minutes or so.
> >
> > Should I wait or I am missing something?
>
> No, this is not really a "warning". It is merely a
> statement of fact.
>
> In 54 dimensions, fminunc will need to call your
> objective function roughly 55 times before it starts
> to iterate. After all, it needs to compute a gradient
> vector.
>
> If your optimization takes roughly a minute per
> function call (or longer) then, yes, I would expect
> to need to wait that long.
>
> Perhaps you might consider using the profile tool
> to find ways to speed up your code.
>
> John

John,

I hope you see this reply of mine, if not I will send it as an independent post.

You don't know how much of a help you are because this thing is really messing my life.

If it is a matteR of waiting I will wait so long as it is better than fminsearch. I am just afraid that it is not able to compute the gradient in my case because one element of my function is that it draws random numbers to simulate shocks (that Is why I myself do not not give gradients). So my question: could it be the case that fminunc is not able to calculate the gradients?

It is about two hours now and It did not do the first iteration.

You don't know how much thanks you are going to get if this thing runs:)
Can I send you my codes if you want to have a quick look at them?

Melaku