1

Given a continuous and bounded function $f(t,s)$, $t,s\in[0,1]$, I would like to compute $$\max_{t_2\in [0,1]}\min_{t_1\in [0,1]} |f(t_1,s_1)-f(t_2,s_2)|,$$ for each numeric values of $s_1$ and $s_2$. I tried by combining NMaxValue and NMinValue but the time is prohibitively large.

I read on the Internet that this distance is sometimes referred to as Fréchet or Hausdorff distance. Is there a built-in function in Mathematica that solves this max-min problem (something like NMaxMinValue)? Or which would be the correct algorithm to proceed with?

user65970
  • 73
  • 3
  • Is the domain of the variable in the question the same as the real problem you want to solve? – Xminer Jun 05 '19 at 09:04
  • @Xminer Yes. I have a particular function on $[0,1]\times[0,1]$. I tried to apply NMaxValue of NMinValue. Although after a long time I obtain the correct max-min value, I would like a faster procedure than just combining these two functions. I would expect something as NMaxMinValue. As this distance has a well-known name (Fréchet or Hausdorff), maybe it has been already implemented in Mathematica. – user65970 Jun 05 '19 at 09:11
  • I searched this community and documents,but no builtin-function for Hausdorff distance here. so,we have to build new one. – Xminer Jun 05 '19 at 10:08
  • Some undocumented minmax routines exists here – Ulrich Neumann Jun 05 '19 at 13:43
  • @UlrichNeumann Oh, I've re-invented the degraded wheels... – Xminer Jun 05 '19 at 14:42
  • @ Xminer No, no , a very interesting approach! – Ulrich Neumann Jun 05 '19 at 14:44
  • Might do a web search on "bilevel optimization stack exchange mathematica" (but without the quotes) – Daniel Lichtblau Jun 05 '19 at 19:05

1 Answers1

1

(This is example)
There is No Built-in,Documented Function for Hausdorff distance.
Anyway,my code is the following:


f[t_, s_] := Cos[t]*Cos[s];
domain = Range[0, 1, 0.01];
Do[
  Do[
    funvalue[i, j] = f[i, j];
    ,
    {i, domain}];
  , {j, domain}];

AbsoluteTiming[
 data = Outer[
   With[{s1 = #1, s2 = #2},
     Max[
      MapThread[
       With[{x = #},
         Min[
          MapThread[
           (Abs[funvalue[x, s1] - funvalue[#, s2]]) &
           , {domain}]
          ]
         ] &,
       {domain}]
      ]
     ] &,
   domain, domain];

 ArrayPlot[data]]

enter image description here

Xminer
  • 1
  • 7
  • 15