Re: Finding the optimum by repeteadly zooming on the solution space

• To: mathgroup at smc.vnet.net
• Subject: [mg92651] Re: Finding the optimum by repeteadly zooming on the solution space
• From: Mark Westwood <markc.westwood at gmail.com>
• Date: Thu, 9 Oct 2008 06:38:12 -0400 (EDT)
• References: <200810060814.EAA28778@smc.vnet.net> <gcfibj\$gja\$1@smc.vnet.net>

```Hi Mauricio

I'd second Bill's suggestion -- use the inbuilt functions and
NMinimize is the obvious one for what you are trying to do.

As for speeding up the process, I make 2 observations:

a) You are unlikely, within Mathematica, to write a routine which
solves your equations more quickly than NMinimize, so long as you
stick to machine precision.  If you do, let us know, I for one will be
seriously impressed.

b) Think carefully about what you are trying to optimise.  Fast code
is good, but getting a fast solution to your problem is better -- it's
often the case with Mathematica that the time it takes to (slowly
compared with, say, Fortran on an MPP machine) compute is more than
offset by the rapid development time.  For one-off code I wouldn't
even think about using Fortran unless I had good reason to think that
it would be O(100) times faster than Mathematica or that the total run
time would exceed about 2 days.

Regards

Mark Westwood

On Oct 7, 12:49 pm, "Mauricio Esteban Cuak" <cuak2... at gmail.com>
wrote:
> I appreciate both your help!
> I was trying it the other way because I'm more interested in the speed of
> the solution than in the precision. Ultimately, what I need to do is to f=
ind
> the optimum "a" for at least thousands of values of r.
> Say, for a couple of values:
>
> Table[NMaximize[{obj, cpoAg1 == 0 && cpoAg2 == 0 && x > 0.1 && y =
> 0.1}, {a,
>
>     x, y}], {r, 0.4, 1, 0.2}]]
>
> It seems that my approach doesn't improve the speed for most values of r,=
so
>
> If someone can suggest me a way of speeding things up, I'd really appreci=
ate
> it.
>
> Kind Regards,
>
> cd
>
> 2008/10/6 Bill Rowe <readn... at sbcglobal.net>
>
>
>
> > On 10/5/08 at 6:05 AM, cuak2... at gmail.com (Mauricio Esteban Cuak)
> > wrote:
>
> > >Hello everyone.I know somebody has probably writ mathematica code on
> > >this problem. A general answer would probably benefit more people,
> > >but I'll do the specific example, 'cause I'm not sure how to explain
> > >it in another way.
>
> > >I have these restrictions:
>
> > >cpoAg1= ( -x + (70*a*(x^0.4 + y^0.4)^0.75)/x^0.6);
>
> > >(*and*)
>
> > >cpoAg2= ((70*(1 - a)*(x^0.4 + y^0.4)^0.75)/y^0.6 - 2*y);
>
> > >(* And I need to find the "a" that will maximise this following
> > >function. I don't need and exact solution, but something that is
> > >sufficiently near *)
>
> > >obj =  -x^2/2 + 100*(x^0.4 + y^0.4)^1.75 - y^2;
>
> > >(* "A" goes between 0 and 1 so I discretise to obtain the {x,y} that
> > >maximise every "a"
>
> > >the Table command gives me the list of rules which I can replace on
> > >"obj" later to find the maximum. No problem here*)
>
> > >rules = Table[
> > >FindRoot[{cpoAg1 == 0, cpoAg2 == 0}, {{x, 0.1}, {y, 0.1}}], {a=
, 0.=
> > 1,
> > >1, 0.1}
> > >];
>
> > >(*the maximum is found with this following function *)
>
>
> > >So far so good...I could discretise "a" as thinly as I want, but I
> > >can't afford the luxury of being that inneficient, 'cause I've got
> > >to do other things later with this part of the program.
>
> > I don't understand why you would take this approach. Why not use
> > the built-in function NMaximize, That is:
>
> > In[20]:= NMaximize[{obj,
> >   cpoAg1 == 0 && cpoAg2 == 0 && x > 0.1 && y > 0.1}, {a, x, y=
}]
>
> > Out[20]= {2084.72,{a->0.527688,x->22.6727,y->13.7173}}
>
> --
> Por favor eviten enviarme archivos adjuntos de Word o Powerpoint (http://=
www.gnu.org/philosophy/no-word-attachments.es.html)

```

• Prev by Date: Re: How to print TraditionalForm without evaluation
• Next by Date: Re: How to print TraditionalForm without evaluation
• Previous by thread: Re: Re: Finding the optimum by repeteadly zooming on the solution space (or something like that)
• Next by thread: an interesting problem of supplying boundary condition for a PDE