Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in volume computation of polyhedron #18214

Closed
videlec opened this issue Apr 15, 2015 · 29 comments
Closed

Bug in volume computation of polyhedron #18214

videlec opened this issue Apr 15, 2015 · 29 comments

Comments

@videlec
Copy link
Contributor

videlec commented Apr 15, 2015

sage: polytopes.dodecahedron(base_ring=RDF).volume()
Traceback (most recent call last):
...
ZeroDivisionError: input matrix must be nonsingular

The same error is triggered by

sage: D=polytopes.dodecahedron(base_ring=RDF)
sage: D.triangulate()

CC: @jplab @mo271 @tom111

Component: geometry

Keywords: bug

Author: Dima Pasechnik

Branch/Commit: b6758cd

Reviewer: Matthias Koeppe,Frédéric Chapoton

Issue created by migration from https://trac.sagemath.org/ticket/18214

@videlec videlec added this to the sage-6.7 milestone Apr 15, 2015
@videlec
Copy link
Contributor Author

videlec commented Apr 16, 2015

Changed keywords from none to bug

@mkoeppe mkoeppe modified the milestones: sage-6.7, sage-7.3 Jul 26, 2016
@fchapoton

This comment has been minimized.

@fchapoton
Copy link
Contributor

comment:4

Here is a proposal for a solution. In case of inexact base ring, I introduce a non-zero epsilon constant, to take care of approximate equality of points. Maybe this could become a parameter.


New commits:

d409a4ctrac 18214 triangulation over inexact base rings

@fchapoton
Copy link
Contributor

Branch: u/chapoton/18214

@fchapoton
Copy link
Contributor

Commit: d409a4c

@fchapoton
Copy link
Contributor

Author: Frédéric Chapoton

@mkoeppe
Copy link
Contributor

mkoeppe commented Aug 17, 2016

comment:5

I think you also need to change method PointConfiguration.contained_simplex.

And that epsilon should indeed be customizable. And when PointConfiguration is called from Polyhedron_RDF, it should use the epsilons from Polyhedron_RDF._is_zero etc.

@mkoeppe
Copy link
Contributor

mkoeppe commented Aug 17, 2016

Reviewer: Matthias Koeppe

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Nov 22, 2016

Branch pushed to git repo; I updated commit sha1. New commits:

11dc033Merge branch 'u/chapoton/18214' in 7.5.b3

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Nov 22, 2016

Changed commit from d409a4c to 11dc033

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 28, 2018

Branch pushed to git repo; I updated commit sha1. New commits:

f086a14Merge branch 'u/chapoton/18214' in 8.2.b6
e042c42trac 18214 adding abs tol to volume doctest

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 28, 2018

Changed commit from 11dc033 to e042c42

@fchapoton
Copy link
Contributor

New commits:

f086a14Merge branch 'u/chapoton/18214' in 8.2.b6
e042c42trac 18214 adding abs tol to volume doctest

@fchapoton fchapoton modified the milestones: sage-7.4, sage-8.2 Feb 28, 2018
@vbraun
Copy link
Member

vbraun commented Nov 3, 2018

comment:13

Is this still reproducable? I get

sage: polytopes.dodecahedron(base_ring=RDF).volume()
6.4520359589542045

@videlec
Copy link
Contributor Author

videlec commented Nov 3, 2018

comment:14

Replying to @vbraun:

Is this still reproducable? I get

sage: polytopes.dodecahedron(base_ring=RDF).volume()
6.4520359589542045

On my computer it is.

@fchapoton
Copy link
Contributor

comment:15

patchbot petitbonum is seeing this as a random failure:

./sage -t --long --warn-long 54.5 src/sage/geometry/polyhedron/library.py
...
sage: ico.volume()
...
      File "/home/chapoton/sage/local/lib/python2.7/site-packages/sage/geometry/triangulation/point_configuration.py", line 1994, in facets_of_simplex
        normals = span.inverse().columns()
      File "sage/matrix/matrix2.pyx", line 8854, in sage.matrix.matrix2.Matrix.inverse (build/cythonized/sage/matrix/matrix2.c:71887)
        return ~self
      File "sage/matrix/matrix_double_dense.pyx", line 466, in sage.matrix.matrix_double_dense.Matrix_double_dense.__invert__ (build/cythonized/sage/matrix/matrix_double_dense.c:6026)
        raise ZeroDivisionError("input matrix must be nonsingular")
    ZeroDivisionError: input matrix must be nonsingular

@dimpase
Copy link
Member

dimpase commented Jan 14, 2019

comment:16

Replying to @videlec:

Replying to @vbraun:

Is this still reproducable? I get

sage: polytopes.dodecahedron(base_ring=RDF).volume()
6.4520359589542045

On my computer it is.

Also reproducible on my Google CE host, with 8 Xeon CPUs:
$ uname -a
Linux linux 4.9.0-8-amd64 #1 SMP Debian 4.9.130-2 (2018-10-27) x86_64 GNU/Linux

@dimpase
Copy link
Member

dimpase commented Jan 14, 2019

comment:17

with random test order I get more errors like this:

...
File "src/sage/geometry/polyhedron/library.py", line 1158, in sage.geometry.polyhedron.library.Polytopes.truncated_dodecahedron
Failed example:
    td = polytopes.truncated_dodecahedron(exact=False)
Expected:
    doctest:warning
    ...
    UserWarning: This polyhedron data is numerically complicated; cdd could not convert between the inexact V and H representation without loss of data. The resulting object might show inconsistencies.
Got:
    <BLANKLINE>
...
2 items had failures:
   1 of   9 in sage.geometry.polyhedron.library.Polytopes.truncated_dodecahedron
   1 of   7 in sage.geometry.polyhedron.library.Polytopes.truncated_icosidodecahedron
    [196 tests, 2 failures, 9.83 s]
----------------------------------------------------------------------
sage -t src/sage/geometry/polyhedron/library.py  # 2 doctests failed
----------------------------------------------------------------------
Total time for all tests: 10.0 seconds
    cpu time: 7.9 seconds
    cumulative wall time: 9.8 seconds
dimpase@linux:~/sage$ ./sage -tp --randorder 127 src/sage/geometry/polyhedron/library.py

@vbraun
Copy link
Member

vbraun commented Jan 14, 2019

comment:18

Degenerate polyhedra over floating-point numbers aren't really supported; Usually you are lucky and numerical errors triangulate your faces. But if you are unlucky then numerical fuzz leads to inconsistent incidence relations where a point is on both (or neither) side of a plane. Just adding fuzzy zero is afaik not enough.

@dimpase
Copy link
Member

dimpase commented Jan 14, 2019

comment:19

This seems to be state of the art: https://dl.acm.org/citation.cfm?id=3194656

Surely, naive triangulation approach is doomed to fail...
Should we just mark the corresponding tests are "known bug" and move on?

@dimpase
Copy link
Member

dimpase commented Jan 14, 2019

comment:20

And here is the code: https://github.com/GeomScale/volume_approximation (it's C++).

@dimpase
Copy link
Member

dimpase commented Jan 14, 2019

Changed branch from u/chapoton/18214 to u/dimpase/GQ

@dimpase
Copy link
Member

dimpase commented Jan 14, 2019

Changed author from Frédéric Chapoton to Frédéric Chapoton, Dima Pasechnik

@dimpase
Copy link
Member

dimpase commented Jan 14, 2019

Changed commit from e042c42 to b6758cd

@dimpase
Copy link
Member

dimpase commented Jan 14, 2019

comment:21

see #27056 for a follow-up


New commits:

b6758cdvolume computation of fuzzy RDF polytope might fail

@fchapoton
Copy link
Contributor

comment:22

ok

@fchapoton
Copy link
Contributor

Changed author from Frédéric Chapoton, Dima Pasechnik to Dima Pasechnik

@fchapoton
Copy link
Contributor

Changed reviewer from Matthias Koeppe to Matthias Koeppe,Frédéric Chapoton

@vbraun
Copy link
Member

vbraun commented Jan 23, 2019

Changed branch from u/dimpase/GQ to b6758cd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants