shortHorse's blog

By shortHorse, 7 years ago, In Russian

Hello community! Please consider the following two problems.

Given $$$N$$$ points on 2D plane, we need to calculate:

A) Coordinates of a new point such that the sum of Euclidean distances from that point to all of given points is minimal (Geometric median finding problem);

B) The index of one of initial points such that the sum of Euclidean distances from that point to all other given points is minimal (Medoid finding problem).

My first hypothesis claims that problem (A) could be solved in $$$O(N\log^2(C))$$$ time (and $$$C$$$ is the absolute value of the maximal coordinate of point) with two nested ternary searches. It is so because of Euclidean distance between given point and some other point is a convex function, and the sum of convex functions is still a convex function, so we can find the global extremum point with ternary search.

I believe I saw that idea a time or two as a suggested solution for Fermat point problem, but I still can't find any mention of this algorithm in papers considering problem (A). So I have some doubts that it may give wrong answer, but I can't find a counterexample.

For the problem (B), my idea is that we can use the solution of problem (A) and then find the point from given array that is closest to the calculated one (or any of such points if there are multiple). But, again, I could not find any mention of this approach in papers.

So I tried to make a stress-test via Polygon to find a counterexample. I use the code that implements an approach described above and a bruteforce code that juct checks all possible points in $$$O(N^2)$$$ time.

Ternary searches code
Brute force code

Unfortunately stress-testing gave nothing, so I come with two questions for geometry-skilled colleagues:

  1. Is my approach for problem (A) right? (I believe it is)
  2. Is my approach for problem (B) right? (I believe it is not). How may the counterexample look like?

Thanks in advance!

  • Vote: I like it
  • 0
  • Vote: I do not like it

»
7 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it
  1. Yes, and you proved it. The reason you cannot find any papers about it is probably because nested ternary search is not a go-to method for optimization problems on convex functions.

  2. I'm too lazy to check, but basically you need to construct some test where near optimum you have different derivatives along different directions, then repeat it many times so that effect of added points (real optimum and what your algo will find) will be negligible. This should work:

repeated 1000 times {
-1000000 -1
-1000000 1
1000000 -1
1000000 1
}
2 0
-2 0
0 1
0 -1
  • »
    »
    7 years ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    Oh, thank you, you are right. When we change 2 and 1 in the last 4 lines to 10 and 5 respectively, the error increases so that it becomes noticeable by checker.

    Thank you again for your help!

»
6 years ago, hide # |
 
Vote: I like it +8 Vote: I do not like it

You seem to be using the following theorem(?):

If $$$\displaystyle f:R^n \rightarrow R$$$ is a convex function, then the function $$$g(x_2, x_3, \ldots, x_n) = \displaystyle \min_{x_1} f(x_1, x_2, \ldots x_n)$$$ is also convex.

I was unable to prove/disprove this. Is it well known?