Finding the minimum point in the convex hull of a finite set of points

Based on the work of Philip Wolf [1] and the recursive algorithm of Kazuyuki Sekitani and Yoshitsugu Yamamoto [2].

The algorithm in [2] has 3 epsilon to avoid comparison problems in three parts of the algorithm. The code below has few changes and only one epsilon. The aim of the change is to avoid infinite loops.

Code

   1 
   2 from numpy import array, matrix, sin, sqrt, dot, cos, ix_, zeros, concatenate, abs, log10, exp, ones
   3 from numpy.linalg import norm
   4 
   5 from mpmath import mpf, mp
   6 mp.dps=80
   7 
   8 def find_min_point(P):
   9 #    print "Calling find_min with P: ", P
  10 
  11     if len(P) == 1:
  12         return P[0]
  13 
  14     eps = mpf(10)**-40
  15 
  16     P = [array([mpf(i) for i in p]) for p in P]
  17 
  18     # Step 0. Choose a point from C(P)
  19     x  = P[array([dot(p,p) for p in P]).argmin()]
  20 
  21     while True:
  22 
  23         # Step 1. \alpha_k := min{x_{k-1}^T p | p \in P}
  24         p_alpha = P[array([dot(x,p) for p in P]).argmin()]
  25 
  26         if dot(x,x-p_alpha) < eps:
  27             return array([float(i) for i in x])
  28 
  29         Pk = [p for p in P if abs(dot(x,p-p_alpha)) < eps]
  30 
  31         # Step 2. P_k := { p | p \in P and x_{k-1}^T p = \alpha_k}
  32         P_Pk = [p for p in P if not array([(p == q).all() for q in Pk]).any()]
  33 
  34         if len(Pk) == len(P):
  35             return array([float(i) for i in x])
  36 
  37         y = find_min_point(Pk)
  38 
  39 
  40         p_beta = P_Pk[array([dot(y,p) for p in P_Pk]).argmin()]
  41 
  42         if dot(y,y-p_beta) < eps:
  43             return array([float(i) for i in y])
  44 
  45 
  46         # Step 4. 
  47         P_aux = [p for p in P_Pk if (dot(y-x,y-p)>eps) and (dot(x,y-p)!=0)]
  48         p_lambda = P_aux[array([dot(y,y-p)/dot(x,y-p) for p in P_aux]).argmin()]
  49         lam = dot(x,p_lambda-y) / dot(y-x,y-p_lambda)
  50 
  51         x += lam * (y-x)
  52 
  53 
  54 
  55 if __name__ == '__main__':
  56     print find_min_point( [array([ -4.83907292e+00,   2.22438863e+04,  -2.67496763e+04]), array([   9.71147604, -351.46404195, -292.18064276]), array([  4.60452808e+00,   1.07020174e+05,  -1.25310230e+05]), array([  2.16080134e+00,   5.12019937e+04,  -5.96167833e+04]), array([  2.65472146e+00,   6.70546443e+04,  -7.71619656e+04]), array([  1.55775358e+00,  -1.34347516e+05,   1.53209265e+05]), array([   13.22464295,  1869.01251292, -2137.61850989])])
  57 
  58 
  59     print find_min_point( [array([ -4.83907292e+00,   2.22438863e+04,  -2.67496763e+04]), array([   9.71147604, -351.46404195, -292.18064276]), array([  4.60452808e+00,   1.07020174e+05,  -1.25310230e+05]), array([  2.16080134e+00,   5.12019937e+04,  -5.96167833e+04]), array([  2.65472146e+00,   6.70546443e+04,  -7.71619656e+04]), array([  1.55775358e+00,  -1.34347516e+05,   1.53209265e+05]), array([   13.22464295,  1869.01251292, -2137.61850989]), array([ 12273.18670123,  -1233.32015854,  61690.10864825])])

References

  1. Finding the nearest point in A polytope

  2. A recursive algorithm for finding the minimum norm point in a polytope and a pair of closest points in two polytopes

Cookbook/Finding Convex Hull Minimum Point (last edited 2009-12-02 04:37:34 by JorgeEduardoCardona)