Title says it all, really.
I want to find some set of values for which a function of those values can't be made larger than a certain number, when some other values (on which that function is also dependent) are unknown.
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communityTitle says it all, really.
I want to find some set of values for which a function of those values can't be made larger than a certain number, when some other values (on which that function is also dependent) are unknown.
Guard against premature evaluation of the inside minimization by putting it inside a function which won't evaluate until a numeric argument is supplied:
f[x_, y_] = 1 + x^2 - y^2;
fminx[y_?NumericQ] := NMinValue[f[x, y], {x}];
FindMaximum[fminx[y], {y, 1.}] // AbsoluteTiming
(*
{0.515133, {1., {y -> -7.45058*10^-9}}}
*)
NMaximize[fminx[y], {y}] // AbsoluteTiming
(*
{47.629574, {1., {y -> -5.83182*10^-9}}}
*)
NMaximize
takes a lot longer. You might want to tune constraints and methods to suit your objective function.
FindMinimum
and FindMaximum
, which would be fastest. (But local optimization only works reliably if there is only one extremum.)
$\endgroup$
– Michael E2
Aug 29 '14 at 13:24