Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Minimize maximum manhattan distance of a point to a set of points

For 3 points in 2D :

P1(x1,y1), 
P2(x2,y2), 
P3(x3,y3) 

I need to find a point P(x,y), such that the maximum of the manhattan distances

max(dist(P,P1), 
    dist(P,P2), 
    dist(P,P3))

will be minimal.

Any ideas about the algorithm?

I would really prefer an exact algorithm.

like image 998
Yakov Avatar asked Mar 11 '13 18:03

Yakov


People also ask

How can Manhattan distance be reduced?

Approach: To minimize the Manhattan distance, all we have to do is just sort the points in all K dimensions and output the middle elements of each of the K dimensions.

How do you find the maximum distance between two points on a Manhattan?

The Manhattan Distance between two points (X1, Y1) and (X2, Y2) is given by |X1 – X2| + |Y1 – Y2|.

What is the formula for calculating Manhattan distance?

The Manhattan distance is defined by(6.2)Dm(x,y)=∑i=1D|xi−yi|, which is its L1-norm.

How do you find the Euclidean and Manhattan distance between two points?

The Pythagorean theorem states that c = a 2 + b 2 c = \sqrt{a^2+b^2} c=a2+b2 . While this is true, it gives you the Euclidean distance. If you were to rewrite the Pythagorean theorem for the Manhattan distance, it would instead be c = a + b c = a + b c=a+b.


1 Answers

There is an exact, noniterative algorithm for the problem; as Knoothe pointed out, the Manhattan distance is rotationally equivalent to the Chebyshev distance, and P is trivially computable for the Chebyshev distance as the mean of the extreme coordinates.

The points reachable from P within the Manhattan distance x form a diamond around P. Therefore, we need to find the minimum diamond that encloses all points, and its center will be P.

If we rotate the coordinate system by 45 degrees, the diamond is a square. Therefore, the problem can be reduced to finding the smallest enclosing square of the points.

The center of a smallest enclosing square can be found as the center of the smallest enclosing rectangle (which is trivially computed as the max and min of the coordinates). There is an infinite number of smallest enclosing squares, since you can shift the center along the shorter edge of the minimum rectangle and still have a minimal enclosing square. For our purposes, we can simply use the one whose center coincides with the enclosing rectangle.

So, in algorithmic form:

  1. Rotate and scale the coordinate system by assigning x' = x/sqrt(2) - y/sqrt(2), y' = x/sqrt(2) + y/sqrt(2)
  2. Compute x'_c = (max(x'_i) + min(x'_i))/2, y'_c = (max(y'_i) + min(y'_i))/2
  3. Rotate back with x_c = x'_c/sqrt(2) + y'_c/sqrt(2), y_c = - x'_c/sqrt(2) + y'_c/sqrt(2)

Then x_c and y_c give the coordinates of P.

like image 87
thiton Avatar answered Oct 05 '22 21:10

thiton