Ask Your Question
1

Global Dependency in Polyhedron Volume

asked 2018-12-17 19:10:30 +0100

MichaelR gravatar image

updated 2019-08-29 16:03:17 +0100

FrédéricC gravatar image

Hi all,

I am new to sage and want to use it in one of my python scripts to calculate the volume of higher dimensional polyhedrons. When executing my script I get a "ZeroDivisionError" for some of the polyhedrons. However when run in an individual script they work perfectly fine as long as there is no other calculation beforehand.

Here is an example, the file is called DebugSageVolume.py and I execute it with "sage -python DebugSageVolume.py" under Ubuntu 18.04, SageMath version 8.1

#!/usr/lib/python2.7/dist-packages/sage -python
from sage.all import *

# this works fine
matrix1 = matrix(RR, [[0, 1, 0, 0, 0], [1, -1, 0, 0, 0],
                      [0, 0, 1, 0, 0], [1, 0, -1, 0, 0],
                      [0, 0, 0, 1, 0], [1, 0, 0, -1, 0],
                      [0, 0, 0, 0, 1], [1, 0, 0, 0, -1],
                      [0.5, -0.5, -0.5, -0.5, -0.5], [-0.5, 0.5, 0.5, 0.5, 0.5]])
poly1 = Polyhedron(ieqs=matrix1)
volume1 = poly1.volume(measure="induced")
print(volume1)

#this results in an error when executed after the above. But when commenting the above this works fine
matrix2 = matrix(RR, [[0, 1, 0, 0, 0], [1, -1, 0, 0, 0],
                      [0, 0, 1, 0, 0], [1, 0, -1, 0, 0],
                      [0, 0, 0, 1, 0], [1, 0, 0, -1, 0],
                      [0, 0, 0, 0, 1], [1, 0, 0, 0, -1],
                      [0.75, -0.5, -0.5, -0.5, -0.5], [-0.75, 0.5, 0.5, 0.5, 0.5]])
poly2 = Polyhedron(ieqs=matrix2)
volume2 = poly2.volume(measure="induced")
print(volume2)

Any help would be greatly appreciated, thank you. Michael

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
2

answered 2018-12-18 09:59:52 +0100

FrédéricC gravatar image

There is a known issue with volume computations when coefficients are in RR. Try if possible to use coefficients in QQ.

See https://trac.sagemath.org/ticket/18214 for the known bug.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2018-12-17 19:10:30 +0100

Seen: 330 times

Last updated: Dec 17 '18