4

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.

b.gates.you.know.what
  • 20,103
  • 2
  • 43
  • 84
quantum_loser
  • 329
  • 1
  • 9

1 Answers1

4

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.


Michael E2
  • 235,386
  • 17
  • 334
  • 747