Re: Optimization
- To: mathgroup at smc.vnet.net
- Subject: [mg35284] Re: [mg35273] Optimization
- From: Brett Champion <brettc at wolfram.com>
- Date: Sat, 6 Jul 2002 05:44:32 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
On Fri, 5 Jul 2002, Etienne wrote:
> Is there a Mathematica package that minimizes a constrained non-linear
> function containing Min and Max. For example, f[x_,y_] := Min[ Cos[x-y]
> Sin[2 x] Cos[y] - Cos[x y] , Cos[x]].
> Thanks in advance.
NMinimize in Mathematica 4.2 will do this.
In[1]:= <<NumericalMath`NMinimize`
In[2]:= f[x_,y_]:=Min[Cos[x - y] Sin[2 x] Cos[y] - Cos[x y], Cos[x]]
In[3]:= NMinimize[f[x,y],{x,y}]
Out[3]= {-1.78936, {x -> -2.5056, y -> 0.0722398}}
In[4]:= NMinimize[f[x,y], {x,y}, Method->"DifferentialEvolution"]
Out[4]= {-1.84785, {x -> -0.668632, y -> -0.271995}}
In[5]:= NMinimize[f[x,y],{x,y}, Method->{"NelderMead", RandomSeed->101}]
Out[5]= {-1.84785, {x -> -0.668632, y -> -0.272001}}
With the default method (NelderMead) NMinimize was trapped by a local
minimum. DifferentialEvolution did much better, as did NelderMead with a
non-default random seed. Looking at a contour plot of the function, this
appears to be the correct minimum.
Brett Champion