4
$\begingroup$

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.

$\endgroup$
4
$\begingroup$

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.


$\endgroup$
2
  • 2
    $\begingroup$ @quantum_loser You're welcome. Depending on the function, one might use both local optimization functions 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
  • 1
    $\begingroup$ Related to this MSE thread on bilevel optimization. $\endgroup$ – Daniel Lichtblau Aug 29 '14 at 15:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.