MathGroup Archive 2003

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

Search the Archive

NMinimize

  • To: mathgroup at smc.vnet.net
  • Subject: [mg40793] NMinimize
  • From: "Ming Hsu" <hsu at charter.net>
  • Date: Thu, 17 Apr 2003 23:17:03 -0400 (EDT)
  • Organization: California Institute of Technology, Pasadena
  • Sender: owner-wri-mathgroup at wolfram.com

Hi, thanks to Andrzej Kozlowski about the answer to the Distribute question.
Here is another one in the same project, which involves the numerical
optimization package NMinimize.  I've narrowed the problem down to one area.
Here are the functions I am using

============================================================
Dist[point1_,point2_]:=(point1-point2).(point1-point2);

thetaList={{0.,-1.},{-1,0},{1,1.}};

f[x_,y_]:=Plus@@g[x,y]

g1[x_,y_]:=Take[Sort[h[x,y]],1]

g[x_,y_]:=Min[h[x,y]]

h[x_,y_]:=DeleteCases[
    {Dist[thetaList[[1]] ]- Dist[{x,y}, thetaList[[1]] ],
      Dist[thetaList[[2]] ]- Dist[{x,y}, thetaList[[2]] ] }, _?(#<0&)]

NMaximize[
  {f[x, y],  (x - thetaList[[1, 1]])^2 + (y - thetaList[[1, 2]])^2 ?
Dist[thetaList[[1]]]^2 && (x - thetaList[[2,1]])^2 + (y - thetaList[[2,
2]])^2 ? Dist[thetaList[[2]]]^2 && (x - thetaList[[3, 1]])^2 + (y -
thetaList[[3, 2]])^2 ? Dist[thetaList[[3]]]^2}, {x, y}]
==========================================================

If I use the function g[.], it works fine, but if I use g1[.], which is
exactly the same thing, it gives me the wrong answer.  In fact, the output
is completely wrong, the output should be {1.,{x->-0.5,y->-0.5}}, but it
gives {0.828483,{x->-0.706851,y->-0.292541}}.  But f[-0.706851, -0.292541]
evaluates to 0.02.

Sorry about the really indecipherable functions...  And oh yeah, I tried all
the algorithms there, and they all give the same wrong answer.

Ming




  • Prev by Date: Re: nonlinear equation
  • Next by Date: Re: Solving for a function in an Integral
  • Previous by thread: Specifying Graphics Size
  • Next by thread: Minimisation Problem