MathGroup Archive 2002

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Optimization

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

  • Prev by Date: AppendTo VERY slow
  • Next by Date: Re: Art Graphics in Mathematica
  • Previous by thread: Re: Optimization
  • Next by thread: Optimization package