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

.volume() of polyhedron does not handle unbounded polyhedron properly #22558

Closed
jplab opened this issue Mar 9, 2017 · 29 comments
Closed

.volume() of polyhedron does not handle unbounded polyhedron properly #22558

jplab opened this issue Mar 9, 2017 · 29 comments

Comments

@jplab
Copy link

jplab commented Mar 9, 2017

Currently, the method .volume() of the polyhedron class (see .volume()) does not handle unbounded polyhedron internally and lets .triangulate() return an error:


sage: P = Polyhedron(vertices = [[1, 0], [0, 1]], rays = [[1, 1]])
sage: P.volume()
Traceback (most recent call last):
...
in triangulate(self, engine, connected, fine, regular, star)
...
NotImplementedError: I can only triangulate compact polytopes.

One possibility would be to return infinity oo in this case.

Depends on #16045

CC: @fchapoton @videlec @mkoeppe @mo271 @jplab

Component: geometry

Keywords: days84, volume, days88

Author: Moritz Firsching

Branch/Commit: 3e0ada5

Reviewer: Jean-Philippe Labbé, Franco Saliola

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

@jplab jplab added this to the sage-7.6 milestone Mar 9, 2017
@novoselt
Copy link
Member

comment:1

Or zero depending on whether it is full-dimensional or not?

@jplab
Copy link
Author

jplab commented Mar 10, 2017

comment:2

Or zero depending on whether it is full-dimensional or not?

This is related to #16045, the user may want a different output in this case: the volume in the euclidean sense, or the "area" relative to the affine space, or even relative to the lattice index...

@jplab
Copy link
Author

jplab commented Mar 10, 2017

Branch: u/jipilab/22558

@jplab
Copy link
Author

jplab commented Mar 10, 2017

New commits:

0429a92Added infinite volume

@jplab
Copy link
Author

jplab commented Mar 10, 2017

Commit: 0429a92

@jplab
Copy link
Author

jplab commented Mar 10, 2017

Author: Jean-Philippe Labbé

@mo271
Copy link
Contributor

mo271 commented Mar 12, 2017

comment:5

What should be the expected behavior for non-compact non-fulldimensional polyhedra?

From reading #16045 it seems that currently engine='lrs' provides the volume in the affine hull while auto provides the volume in the ambient space. To make your new function agree with this, I would expect the following output:

sage: Q = Polyhedron(ieqs=[[0, 1, 0], [0, -1, 0], [0, 0, 1]]); Q
A 1-dimensional polyhedron in QQ^2 defined as the convex hull of 1 vertex and 1 ray
sage: Q.volume()
0
sage: Q.volume(engine='lrs')
+Infinity

Your version give +Infinity in both cases.
I added the changes necessary for this, feel free to reset to your commit, if you don't like it. Perhaps it would be best to fix #16045 first.

@mo271
Copy link
Contributor

mo271 commented Mar 12, 2017

Changed branch from u/jipilab/22558 to u/moritz/22558

@jplab
Copy link
Author

jplab commented Mar 15, 2017

comment:7

Yes, I agree to your changes. Looks good to me.

Yes, one should first agree on #16045 and set this properly here afterwards. I put it as a dependency.


New commits:

3269ed2handle the case of non-full-dimensional polyhedra

@jplab
Copy link
Author

jplab commented Mar 15, 2017

Dependencies: #16045

@jplab
Copy link
Author

jplab commented Mar 15, 2017

Changed commit from 0429a92 to 3269ed2

@jplab
Copy link
Author

jplab commented Aug 21, 2017

Changed keywords from days84, volume to days84, volume, days88

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 23, 2017

Changed commit from 3269ed2 to 166f0f7

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 23, 2017

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

b602072add measure option
09fb035using new affine_hull function to provide induced measure
5b68b13added one forgotten line in a doctest
5f452f5doctest for 'induced_rational'
b7b10dasmall improvements suggested by JP
fa46ceeabs tol marker added
2b0fb6dMerge branch 'u/moritz/16045' of git://trac.sagemath.org/sage into 16045
f5d47cfCorrected some indentations
b9cb458Merge branch 'u/jipilab/16045' of git://trac.sagemath.org/sage into volume
166f0f7catch volume for non-compact polyhedra

@mo271
Copy link
Contributor

mo271 commented Aug 23, 2017

Changed author from Jean-Philippe Labbé to Moritz Firsching

@jplab
Copy link
Author

jplab commented Aug 23, 2017

comment:11

What about:

sage: P = Polyhedron(ieqs = [[1,1,1],[-1,-1,-1],[3,1,0]]); P
A 1-dimensional polyhedron in QQ^2 defined as the convex hull of 1 vertex and 1 ray
sage: P.volume(measure='induced_rational')
Traceback (most recent call last):
...
RuntimeError: LattE integrale program failed (exit code -6):
This is LattE integrale 1.7.3
Available from http://www.math.ucdavis.edu/~latte/

Invocation: integrate --valuation=volume --triangulate --redundancy-check=none --cdd /dev/stdin 
Warning: Not performing check for empty polytope, because it is unimplemented for the CDD-style input format. 
size = 2 x 3
Number Type = rational
Ax <= b, given as (b|-A):
=========================
[3 1 0]

Ax = b, given as (b|-A):
========================
[1 1 1]

Computing hermitean normal form.
sol:
[1 0]
Particular solution:
Basis:
New inequalities:
[2 -1 0]
Time for reading and preprocessing: 0 sec
(First dualizing back... Dualizing all cones...All cones are now dualized.
Time for dualizing general cones: 0 sec
done!) Triangulating cone... done.
determinant: nonsquare matrix

Sage should return directly +Infinity in this case as well.

@jplab
Copy link
Author

jplab commented Aug 23, 2017

comment:12

Further, in the docstring, I would change:

* ``induced_rational``: Scaling of the Lebesgue measure for lattice polytopes

for

* ``induced_rational``: Scaling of the Lebesgue measure for rational polytopes

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 24, 2017

Changed commit from 166f0f7 to b9ddbdc

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 24, 2017

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

b9ddbdccatch non-compact also for 'induced_rational'

@mo271
Copy link
Contributor

mo271 commented Aug 24, 2017

comment:14

I did as you suggested, JP!

@saliola
Copy link

saliola commented Aug 25, 2017

comment:15

There is a line in a doctest that is not needed; please delete:

+            sage: v = Dexact.faces(2)[0].as_polyhedron().volume(measure='induced', engine='internal')

Otherwise, this looks good to me!

@saliola
Copy link

saliola commented Aug 25, 2017

Changed branch from u/moritz/22558 to u/saliola/22558

@saliola
Copy link

saliola commented Aug 25, 2017

comment:17

I made the change myself and pushed it.

JP says that the last thing to do is the run the optional tests.


New commits:

3e0ada5trac 22558: delete unneeded line in doctest

@saliola
Copy link

saliola commented Aug 25, 2017

Work Issues: run optional doctests

@saliola
Copy link

saliola commented Aug 25, 2017

Changed commit from b9ddbdc to 3e0ada5

@saliola
Copy link

saliola commented Aug 25, 2017

Reviewer: Jean-Philippe Labbé, Franco Saliola

@jplab
Copy link
Author

jplab commented Aug 30, 2017

Changed work issues from run optional doctests to none

@jplab
Copy link
Author

jplab commented Aug 30, 2017

comment:18

Ok!

jplab$ sage -t base.py --optional=4ti2,bliss,latte_int,lidia,lrslib,mpir,normaliz,openssl,pynormaliz,python2,sage,polymake
Git branch: 22558
Using --optional=4ti2,bliss,latte_int,lidia,lrslib,mpir,normaliz,openssl,polymake,pynormaliz,python2,sage
Doctesting 1 file.
sage -t base.py
    [999 tests, 157.35 s]
----------------------------------------------------------------------
All tests passed!
----------------------------------------------------------------------

Looks good to go! The bot seems to get unrelated errors. The one done at 2017-08-27 22:33:58 seems to be fine.

I set this as positive review.

@vbraun
Copy link
Member

vbraun commented Sep 10, 2017

Changed branch from u/saliola/22558 to 3e0ada5

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