Re: NMinimize--problem with a min-max problem
- To: mathgroup at smc.vnet.net
- Subject: [mg55779] Re: NMinimize--problem with a min-max problem
- From: dh <dh at metrohm.ch>
- Date: Wed, 6 Apr 2005 03:11:08 -0400 (EDT)
- References: <d2tfro$qpe$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hello David, to understand what goes wrong look at how Mathematica evaluates function arguments. Provided we have a normal function (not Attribute "HoldFirst" or "HoldAll") Mathematica first evaluates an argument before it passes it to the function. Therefore, when you write: NMinimize[fun1[z], z] Mathematica first evaluates fun1[z]. At this moment, z has no value and you get an error message. To prevent this, tell Mathematica only to evaluate fun1 if the argument is Real, e.g.: fun1[z_Real]:=.... You will still get some messages when Mathematica tries to evaluate fun1 at points where it is not defined, but this messages has no adverse effect, you still get the right result: {-0.462098, {z -> 0.75}} sincerely, Daniel David wrote: > Hello, > > I'm trying to solve numerically the following problem: > > min{z}max{y,x} f{x,y,z} > > I first do the maximization: > > fun1[z_] := NMaximize[{( > Log[x] + 4/3 z Log[ > y])/(2 (3/4 + z)), x > 0, y > 0, x + y == 1}, {x, y}][[1]] > > I can plot fun1[z] (the solution is at z=.75,x=y=1/2) however NMinimize > does accept the definition of fun1[z] as: > > NMinimize[fun1[z], z] > > yields error. > > Any suggestion? > > Thank you in advance, > > David >