I want to maximize a function $f(b, h)$ with respect to its arguments and subject to some additional constraints. If these constraints are satisfied, $f$ is increasing in $h$. I then want to find an upper bound $u$ on $h$ such that the maximized value of $f$ remains smaller or equal than some threshold level.
More precisely, I have the following function:
f[h_, b_] := .1 (1 + b) + (0.3 b (-b + h))/(-1 + h)
A standard numerical maximization of $f$, NMaximize[{f[h, b], 1 <= b <= h <= u}, {h, b}]
yields {1.50833, {h -> 10., b -> 6.5}}
for $u = 10$.
What I would like to have is another function which maximizes the value of the upper bound $u$ subject to a constraint on the maximized function value.
For example:
If the maximized function value of $f$ was to remain below 1.4, $u$ would have to be less than 9.18125, since NMaximize[{f[h, b], 1 <= b <= h <= 9.18125}, {h, b}]
yields {1.4, {h -> 9.18125, b -> 5.95418}}
.
The following function $f_m(u)$ captures the first part of what I want to do:
fm[u_?NumericQ] := Block[{h, b}, {h, b} /. NMaximize[{f[h, b], 1 <= b <= h <= u}, {h, b}]]
Calling $f_m(u)$ for different $u$ generates different values of the maximized function that are increasing in $u$, as can be seen from tabulating the results by Table[fm[u][[2]], {u, 2, 10}]
:
{0.508, {h -> 2., b -> 1.167}}
{0.604, {h -> 3., b -> 1.833}}
{0.725, {h -> 4., b -> 2.500}}
{0.852, {h -> 5., b -> 3.167}}
{0.981, {h -> 6., b -> 3.834}}
{1.112, {h -> 7., b -> 4.500}}
{1.244, {h -> 8., b -> 5.169}}
{1.376, {h -> 9., b -> 5.835}}
{1.508, {h -> 10., b -> 6.500}}
What I would now like to do is something like this (which does not work, however): NMaximize[{fm[u], fm[[u]][[2]][[1]] < 1.4}, {u}]
. That is, I want to select the highest value of $u$ such that the value of $f_m(u)$ does not exceed the threshold of 1.4.
What also does not work is NMaximize[{f[h, b], 1 <= b <= h <= u, f[h, b] < 1.4}, {h, b}]
yielding {1.4, {h -> 9.5519, b -> 5.01912}}
because it picks one point on the level curve at which $f$ equals 1.4. I am looking for a specific point on that curve, however, namely the point where, given $b$ is maximized, $h$ approaches the upper bound $u$.
I have tried several variants of what has been suggested here: Combined numerical minimization and maximization, adapted to two successive maximizations for $b$ and $h$. I did not get this to work, however, with the constraints on $b$ included in the inner NMaximize
command.
I also tried to work around the bi-variate maximization by using using the envelope theorem to express the maximum of $b$ in terms of $h$ and then compute the threshold. This also did not work, however, because it disregards the constraints on $b$ and $h$, but $f$ approaches infinity as $h$ goes to 1 for $b \le h$ , so NMaximize
finds the maximum at $h = 1$.
Any suggestions are greatly appreciated!
h
subject to a constraint onf[h,b]
. So it could be cast asIn[256]:= NMaximize[{h, f[h, b] <= 1.4, 1 <= b <= h <= 9.18125}, {h, b}] Out[256]= {9.18125, {h -> 9.18125, b -> 4.49908104251}}
$\endgroup$(1 - d)*b*((h - b)/(h - l)) + d^2*((l + b)/2)*(1/(d + 1))
, where the expression(h - b)/(h - l)
is derived from the $cdf$ of a uniform distribution with support $[l,h]$, which explains why I need $l ≤ b ≤ h$. In the example, I have fixed $l=1$; $d$ is a discount factor, which I have also fixed. $\endgroup$