Nesting NMaximize

• To: mathgroup at smc.vnet.net
• Subject: [mg60376] Nesting NMaximize
• From: Derek James Gurney <dgurney at stanford.edu>
• Date: Wed, 14 Sep 2005 03:27:52 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

Summary :
I think I want to nest one NMaximize problem within another, but I can't get Mathematica to do it.

Details, in English and Pseudo-code:
I have a problem where one agent is choosing p to maximize f[p,Delta gamma,other parameters], taking Delta gamma as given, and then another agent choses Delta gamma to maximize WA[OptimumP(Delta gamma),Delta gamma, other parameters], where OptimumP(gamma) is the 1st agent's optimal choice of p.

f and g cannot be solved analytically, so I need NMaximize, and when I specify other parameters and Delta gamma, Mathematica will solve NMaximize[f,{p}]

However, when I try the equivalent of the pseudo-code below, Mathematica gives an error:

OptimumP := NMaximize[f,{p}]
Set parameters except Delta gamma
NMaximize[WA /. OptimumP,{Delta gamma}]

Mathematica error:

"The function value  is not a number at "  p = Mathematica's initial value for p

I recognize that the problem is that Mathematica is trying to solve OptimumP without a value for Delta gamma before it solves the outer NMaximize problem.  How do I tell Mathematica to do the reverse: try to solve the outer NMaximize first and use the guesses for Delta gamma to solve for OptimumP?

I've included the actual code I'm using below.  Thanks for any help.

Derek

\!\(Clear["\<Global`*\>"]\ \ \[IndentingNewLine]
\(Qmax\  := \ M;\)\[IndentingNewLine]
\(shareA1\  := \ 0;\)\[IndentingNewLine]
\(M1\  := \ 0;\)\[IndentingNewLine]
\(M2\  := \ M;\)\[IndentingNewLine]
\(M3\  := \ M;\)\[IndentingNewLine]
\(RA1\  := \ 0;\)\[IndentingNewLine]
\(qAj1\  := \ M1\ shareA1;\)\[IndentingNewLine]
\(\[CapitalDelta]RA2\  := \ \ \((\[Gamma] - \[CapitalDelta]\[Gamma])\)\ \
qAj1/Qmax;\)\[IndentingNewLine]
\(RA2\  := \ RA1\  + \ \[CapitalDelta]RA2;\)\[IndentingNewLine]
\(RU2\  := \ 0;\)\[IndentingNewLine]\[IndentingNewLine]
\(shareA2 := \ \ \[ExponentialE]\^\(\(-\[Alpha]\)\ PA2 + \[Beta]\ \((1 - \
RA2)\) + \[Xi]A2\)\/\(\[ExponentialE]\^\(\(-\[Alpha]\)\ PU2 + \[Beta]\ \((1 - \
RU2)\) + \[Xi]U2\) + \[ExponentialE]\^\(\(-\[Alpha]\)\ PA2 + \[Beta]\ \((1 - \
RA2)\) + \[Xi]A2\)\);\)\[IndentingNewLine]\[IndentingNewLine]
\(qAj2\  := \ shareA2\ M2;\)\[IndentingNewLine]
\(revAj2\  := PA2\ qAj2;\)\[IndentingNewLine]
\(varcostAj2\  := \ c\ qAj2;\)\[IndentingNewLine]
\(profitAj2\  := revAj2 - varcostAj2\  - oF;\)\[IndentingNewLine]
\(profitA2\  := \ n\ profitAj2;\)\[IndentingNewLine]\[IndentingNewLine]
\(CSA2 := \
M \((2 + \ \(-\[Alpha]\)\ PA2 + \[Beta]\ \((1 -
RA2)\) + \ \[Xi]A2)\);\)\[IndentingNewLine]
\(WA2 := \ CSA2 + profitA2;\)\[IndentingNewLine]
\(\[CapitalDelta]RA3\  := \ \((\[Gamma] - \[CapitalDelta]\[Gamma])\)\ \
\((qAj2\  + \ \((n - 1)\) qJ2)\)/Qmax;\)\[IndentingNewLine] (*\
have\ to\ adjust\ for\ non - monopoly*) \[IndentingNewLine]
\(RA3\  := \ RA2\  + \ \[CapitalDelta]RA3;\)\[IndentingNewLine]
\(RB3\  := \ 0;\)\[IndentingNewLine]
\(RU3\  := \ 0;\)\[IndentingNewLine]\[IndentingNewLine]
\(shareA3 := \ \ \[ExponentialE]\^\(\(-\[Alpha]\)\ PA3 + \[Beta]\ \((1 - \
RA3)\) + \[Xi]A3\)/\((\[ExponentialE]\^\(\(-\[Alpha]\)\ PU3 + \[Beta]\ \((1 - \
RU3)\) + \[Xi]U3\) + \[ExponentialE]\^\(\(\(-\[Alpha]\)\ PA3\)\(+\)\(\[Beta] \
\((1 - \ RA3)\)\)\(+\)\(\[Xi]A3\)\(\ \)\) +
x\ \[ExponentialE]\^\(\(\(-\[Alpha]\)\ PB\)\(+\)\(\[Beta]\ \((1 - \
RB)\)\)\(+\)\(\[Xi]B\)\(\ \)\))\);\)\[IndentingNewLine]
\(qAj3\  := \ shareA3\ M3;\)\[IndentingNewLine]
\(revAj3\  := PA3\ qAj3;\)\[IndentingNewLine]
\(varcostAj3\  := \ c\ qAj3;\)\[IndentingNewLine]
\(profitAj3\  := revAj3 - varcostAj3 - oF;\)\[IndentingNewLine]
\(profitA3\  := \ n\ profitAj3;\)\[IndentingNewLine]
\(CSA3 := \
M \((\(-\[Alpha]\)\ PA3 + \[Beta]\ \((1 -
RA3)\) + \ \[Xi]A3)\);\)\[IndentingNewLine]
\(WA3 := \ CSA3 + profitA3;\)\[IndentingNewLine]
\(WA := \ WA2\  + \ m\[Beta]\ WA3;\)\[IndentingNewLine]
\(profitAj\  := \
profitAj2\  + \
m\[Beta]\ profitAj3;\)\[IndentingNewLine]\[IndentingNewLine]\
\[IndentingNewLine]\[IndentingNewLine]
\(PrevCost\  := c1\ \[CapitalDelta]\[Gamma]^c2;\)\[IndentingNewLine]
\(ProfitMaxed\  := \
NMaximize[
profitAj, {PA2, PA3}];\)\[IndentingNewLine]\[IndentingNewLine]
\(mPA2opt\  := \ \(ProfitMaxed[\([2]\)]\)[\([1]\)];\)\[IndentingNewLine]
\(mPA3opt\  := \ \(ProfitMaxed[\([2]\)]\)[\([2]\)];\)\[IndentingNewLine]\
\[IndentingNewLine]\[IndentingNewLine]
"\<---------------------------------------------------------\>"\
\[IndentingNewLine]\[IndentingNewLine] (*\
Central\ Case\ *) \[IndentingNewLine]
\[Alpha] = 1; b = 2; c = 0.1; oF\  = \ 0.1; R1\  = \ 0; m\[Beta]\  = \ 1;
o\[Beta]\  = \ 1; \[Gamma]dflt = 0.5;\[IndentingNewLine]\[IndentingNewLine]
\(\[Gamma]\  = \ \[Gamma]dflt;\)\[IndentingNewLine]
\(\[CapitalDelta]\[Gamma]\  = 0;\)\[IndentingNewLine]
\(n\  = 1;\)\[IndentingNewLine]\[IndentingNewLine]\[IndentingNewLine]
\(\[Beta]\  = \ 1;\)\[IndentingNewLine]
\(M\  = \ 1000;\)\[IndentingNewLine]
\(\[Xi]A2\  = \ 0;\)\[IndentingNewLine]
\(\[Xi]A3\  = \ 0;\)\[IndentingNewLine]
\(PB\  = \ 10;\)\[IndentingNewLine]
\(RB = \ 0;\)\[IndentingNewLine]
\(\[Xi]B\  = \ 0;\)\[IndentingNewLine]
\(RU = \ 0;\)\[IndentingNewLine]
\(PU2\  = \ 100;\)\[IndentingNewLine]
\(PU3\  = \ 100;\)\[IndentingNewLine]
\(\[Xi]U2\  = \ 0;\)\[IndentingNewLine]
\(\[Xi]U3\  = \ 0;\)\[IndentingNewLine]\[IndentingNewLine]
\(x = 0;\)\[IndentingNewLine]\[IndentingNewLine]
\(c2\  = 2;\)\[IndentingNewLine]
\(c1\  =
5000/c2;\)\[IndentingNewLine]\[IndentingNewLine]\[IndentingNewLine]
\(WA\  /. \ mPA3opt\)\  /. mPA2opt\[IndentingNewLine]
mPA3opt\[IndentingNewLine]
\(\[CapitalDelta]\[Gamma]\  =. ;\)\[IndentingNewLine]
mPA3opt\[IndentingNewLine]
\(NMaximize[{Evaluate[\(WA\  /. \ mPA3opt\)\  /. mPA2opt] - \
PrevCost, \[CapitalDelta]\[Gamma]\  >=
0, \[CapitalDelta]\[Gamma]\  <= \[Gamma]}, \
{\[CapitalDelta]\[Gamma]}];\)\[IndentingNewLine]
\)

• Prev by Date: Re: Re: smooth eigenvalues and eigenvectors as a function of frequency
• Next by Date: Re: Options in user-defined functions...
• Previous by thread: Re: Question concerning MakeBoxes
• Next by thread: Other Way than Print[] for Intermediate Results