From: James Allison on
As long as the objective function is smooth (i.e., continuous first
derivative, which is the case in your sample objective), then fminunc
should be much more efficient.

Some tips:

- Keep in mind that both of these algorithms are local optimizers; if
you try to apply them to an objective function with multiple optima, you
are not guaranteed to find the global optimum. Simple quadratic
functions like your example function do not have multiple local optima.

- Also, scaling your optimization variables so that they are all about
the same magnitude can help speed up the fminunc solution significantly.

-James

Raul wrote:
> "John D'Errico" <woodchips(a)rochester.rr.com> wrote in message
> <hp20s8$78h$1(a)fred.mathworks.com>...
>> "Raul " <ragonzal(a)alum.mit.edu> wrote in message
>> <hp1u7s$qud$1(a)fred.mathworks.com>...
>> > Hi All,
>> > > I have the following issue. Suppose I have an objective function
>> such as:
>> > > function x = myfun(a,c)
>> > x=(a*c')^2;
>> > end
>> > > where a and c are two vectors of size 1xN. If I want to search for
>> the minimum of myfun, provided a given value, for example c=[1,1,1], I
>> can simply type:
>> > > c=[1,1,1];
>> > x = fminsearch(@(a) myfun(a,c),[1,1,1])
>> > > and matlab will minimize over the components of a. However, if I
>> want to minimize over BOTH a and c, I don't see a way to incorporate
>> two vectors as intial conditions into fminsearch. is this possible? Is
>> there another function that does this?
>> >
>> Is it possible to pass in only one vector into
>> a function, then break it up into two distinct
>> vectors inside your function? Nah, that would
>> never work.
>>
>> By the way, if you have more than a half dozen
>> or so parameters that you will be optimizing,
>> fminsearch is a poor choice for the optimizer.
>>
>> John
>
> Thank you guys very much!
> Another question: If the number of parameters is large, would it be
> better to use fminunc then?
>
> Thanks
>
> --raul
From: John D'Errico on
"Raul " <ragonzal(a)alum.mit.edu> wrote in message <hp21oc$jq3$1(a)fred.mathworks.com>...

> Another question: If the number of parameters is large, would it be better to use fminunc then?
>

If you actually have the optimization toolbox, it is rarely
a good idea to use fminsearch instead.

John
First  |  Prev  | 
Pages: 1 2
Prev: problems with adquisition card
Next: bad image