High dimension convex hull library in python

97 Views Asked by At

I tried to compute some high dimension convex hull in python. The computation had to be precise and "QJ" in Qhull was not quite an acceptable option.

I found scipy.spatial.ConvexHull to be able to compute the convex hull at high dimension, but encountered the precision issue.

hull=ConvexHull( points )
QhullError: QH6347 qhull precision error (qh_mergefacet): wide merge for facet f40487 into f40486 for mergetype 3 (concave).  maxdist  0 (0.0x) mindist -0.0036 (501.9x) vertexdist 8e+02  Allow with 'Q12' (allow-wide)
ERRONEOUS FACET:
- f40487
    - flags: bottom newfacet tested newmerge
    - merges: 6
    - normal:  0.004859       -1 -5.183e-07 4.138e-07 -2.304e-07 7.062e-05
    - offset:  -1.015026
    - center: 1201.673206636632 10989.79522797083 4820.321704992604 4545.351456156274 8367776.853656252 155567882.6656116 
    - vertices: p6(v120) p2773(v108) p2782(v101) p5(v59) p2776(v57) p2772(v56) p2785(v34) p2774(v24) p2779(v14) p23(v6) p2770(v4) p2789(v3)
    - neighboring facets: f27430 f40485 f40486 f40545 f40484 f40842 f40929 f40542 f40920 f40638 f40541 f41141 f40591 f40632 f40766 f40629 f40846 f40760 f40694 f40936 f40753 f40850
    - ridges:
     - r1937 tested simplicialtop simplicialbot
           vertices: p5(v59) p2785(v34) p23(v6) p2770(v4) p2789(v3)
           between f27430 and f40487
     - r1919 tested
           vertices: p2782(v101) p5(v59) p2785(v34) p23(v6) p2770(v4)
           between f40487 and f27430
     - r1901 tested
           vertices: p2782(v101) p5(v59) p2779(v14) p23(v6) p2770(v4)
           between f27430 and f40487
     - r1548 tested
           vertices: p2773(v108) p5(v59) p2772(v56) p2774(v24) p23(v6)
           between f40487 and f27430
     - r1883 tested
           vertices: p5(v59) p2776(v57) p2779(v14) p23(v6) p2770(v4)
           between f27430 and f40487
     - r1855 tested
           vertices: p5(v59) p2776(v57) p2774(v24) p23(v6) p2770(v4)
           between f40487 and f27430
     - r1544 tested
           vertices: p5(v59) p2772(v56) p2774(v24) p23(v6) p2770(v4)
           between f27430 and f40487
     - r1938 tested simplicialtop simplicialbot
           vertices: p6(v120) p2785(v34) p23(v6) p2770(v4) p2789(v3)
           between f40487 and f40485
     - r1939 tested simplicialtop simplicialbot
           vertices: p6(v120) p5(v59) p23(v6) p2770(v4) p2789(v3)
           between f40486 and f40487
     - r1940 tested simplicialtop simplicialbot
           vertices: p6(v120) p5(v59) p2785(v34) p2770(v4) p2789(v3)
           between f40487 and f40545
     - r1941 tested simplicialtop simplicialbot
           vertices: p6(v120) p5(v59) p2785(v34) p23(v6) p2789(v3)
           between f40484 and f40487
     - r1862 tested simplicialtop
           vertices: p6(v120) p2773(v108) p5(v59) p2774(v24) p23(v6)
           between f40842 and f40487
     - r1879 tested simplicialtop
           vertices: p6(v120) p2776(v57) p2774(v24) p23(v6) p2770(v4)
           between f40929 and f40487
     - r1921 tested simplicialbot
           vertices: p6(v120) p2782(v101) p2785(v34) p23(v6) p2770(v4)
           between f40487 and f40542
     - r1882 tested simplicialtop
           vertices: p6(v120) p5(v59) p2776(v57) p2774(v24) p23(v6)
           between f40920 and f40487
     - r1922 tested simplicialbot
           vertices: p6(v120) p2782(v101) p5(v59) p2785(v34) p2770(v4)
           between f40487 and f40638
     - r1923 tested simplicialtop
           vertices: p6(v120) p2782(v101) p5(v59) p2785(v34) p23(v6)
           between f40541 and f40487
     - r1881 tested simplicialbot
           vertices: p6(v120) p5(v59) p2776(v57) p2774(v24) p2770(v4)
           between f40487 and f41141
     - r1866 tested simplicialbot
           vertices: p6(v120) p5(v59) p2772(v56) p23(v6) p2770(v4)
           between f40487 and f40591
     - r1902 tested simplicialtop
           vertices: p6(v120) p2782(v101) p2779(v14) p23(v6) p2770(v4)
           between f40632 and f40487
     - r1904 tested simplicialtop
           vertices: p6(v120) p2782(v101) p5(v59) p2779(v14) p2770(v4)
           between f40766 and f40487
     - r1905 tested simplicialbot
           vertices: p6(v120) p2782(v101) p5(v59) p2779(v14) p23(v6)
           between f40487 and f40629
     - r1861 tested
           vertices: p6(v120) p2773(v108) p2772(v56) p2774(v24) p23(v6)
           between f40487 and f40846
     - r1864 tested simplicialbot
           vertices: p6(v120) p2772(v56) p2774(v24) p23(v6) p2770(v4)
           between f40487 and f40846
     - r1884 tested simplicialbot
           vertices: p6(v120) p2776(v57) p2779(v14) p23(v6) p2770(v4)
           between f40487 and f40760
     - r1863 tested simplicialbot
           vertices: p6(v120) p2773(v108) p5(v59) p2772(v56) p23(v6)
           between f40487 and f40694
     - r1886 tested simplicialtop
           vertices: p6(v120) p5(v59) p2776(v57) p2779(v14) p2770(v4)
           between f40936 and f40487
     - r1887 tested simplicialbot
           vertices: p6(v120) p5(v59) p2776(v57) p2779(v14) p23(v6)
           between f40487 and f40753
     - r1851 tested nonconvex simplicialtop
           vertices: p6(v120) p5(v59) p2772(v56) p2774(v24) p2770(v4)
           between f40850 and f40487
     - r1854 tested simplicialtop
           vertices: p6(v120) p2773(v108) p5(v59) p2772(v56) p2774(v24)
           between f40850 and f40487
ERRONEOUS OTHER FACET:
- f40486
    - flags: top simplicial newfacet tested
    - normal:  0.004859       -1 -1.489e-06 1.361e-06 -2.305e-07 7.062e-05
    - offset:  -1.018131
    - center: 2414.957730667852 4889.8993845348 2714.755506575487 7583.523244594927 16887988.65529773 69141294.75300574 
    - vertices: p6(v120) p5(v59) p32(v20) p23(v6) p2770(v4) p2789(v3)
    - neighboring facets: f27381 f40485 f40487 f40482 f40431 f40617
    - ridges:
     - r1939 tested simplicialtop simplicialbot
           vertices: p6(v120) p5(v59) p23(v6) p2770(v4) p2789(v3)
           between f40486 and f40487

While executing:  | qhull i Qx Qt
Options selected for Qhull 2019.1.r 2019/06/21:
  run-id 814845471  incidence  Qxact-merge  Qtriangulate  _zero-centrum
  _max-width 2.1e+08  Error-roundoff 5.1e-07  _one-merge 6.7e-06
  _near-inside 3.3e-05  Visible-distance 3.1e-06  U-max-coplanar 3.1e-06
  Width-outside 6.2e-06  _wide-facet 1.9e-05  _maxoutside 7.2e-06
Last point added to hull was p6.  Last merge was #352.

At error exit:

Convex hull of 2790 points in 6-d:

  Number of vertices: 120
  Number of facets: 16079
  Number of non-simplicial facets: 114

Statistics for:  | qhull i Qx Qt

  Number of points processed: 120
  Number of hyperplanes created: 41372
  Number of distance tests for qhull: 314432
  Number of distance tests for merging: 338622
  Number of distance tests for checking: 0
  Number of merged facets: 363
  Maximum distance of point above facet: 3.5e-06 (0.5x)
  Maximum distance of vertex below facet: -0.00041 (57.5x)

And it mentioned that

precision problems (corrected unless 'Q0' or an error)
    215 coplanar horizon facets for new vertices
      2 nearly singular or axis-parallel hyperplanes

A wide merge error has occurred.  Qhull has produced a wide facet due to facet merges and vertex merges.
This usually occurs when the input is nearly degenerate and substantial merging has occurred.
See http://www.qhull.org/html/qh-impre.htm#limit

I used mpmath library and increased the precision from 53 to 106, but the error persisted. That the scipy's ConvexHull algorithm did not seem to be able to utilize the mpmath's utility.

Is there any other convex hull library that can be used to implement the precision computation of the convex hull vertices in python?

0

There are 0 best solutions below