Re: Finding the optimum by repeteadly zooming on the solution space (or something like that)
- To: mathgroup at smc.vnet.net
- Subject: [mg92575] Re: Finding the optimum by repeteadly zooming on the solution space (or something like that)
- From: Bill Rowe <readnews at sbcglobal.net>
- Date: Mon, 6 Oct 2008 04:14:14 -0400 (EDT)
On 10/5/08 at 6:05 AM, cuak2000 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 *) >Max[Thread[ReplaceAll[obj, rules]]]; >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}}
- Follow-Ups:
- Re: Re: Finding the optimum by repeteadly zooming on the solution space (or something like that)
- From: "Mauricio Esteban Cuak" <cuak2000@gmail.com>
- Re: Re: Finding the optimum by repeteadly zooming on the solution space (or something like that)