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

Fix Polyhedron.volume() in 0-dimensional space #27673

Closed
kliem opened this issue Apr 15, 2019 · 39 comments
Closed

Fix Polyhedron.volume() in 0-dimensional space #27673

kliem opened this issue Apr 15, 2019 · 39 comments

Comments

@kliem
Copy link
Contributor

kliem commented Apr 15, 2019

In dimension 0, we now use the counting measure for volume:

sage: Polyhedron(vertices=[[]]).volume()
1
sage: Polyhedron(vertices=[]).volume()
0

Originally there was an attribute error:

sage: Polyhedron(vertices=[[]]).volume()
Traceback (most recent call last)
...
AttributeError: 'int' object has no attribute 'set_immutable'

CC: @jplab

Component: geometry

Keywords: polytopes, volume

Author: Jonathan Kliem

Branch/Commit: a7bf147

Reviewer: Jean-Philippe Labbé

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

@kliem kliem added this to the sage-8.8 milestone Apr 15, 2019
@kliem

This comment has been minimized.

@kliem
Copy link
Contributor Author

kliem commented Apr 15, 2019

Branch: public/27673

@kliem
Copy link
Contributor Author

kliem commented Apr 15, 2019

New commits:

3bd7a03fixed AttributeError of Polyhedron.volume()

@kliem
Copy link
Contributor Author

kliem commented Apr 15, 2019

Commit: 3bd7a03

@kliem
Copy link
Contributor Author

kliem commented Apr 16, 2019

comment:4

When thinking about it again, I'm not sure anymore that this is the correct output.

However, an AttributeError is strange and the dostring does not indicate, what should happen.

Also it's confusing that the empty Polyhedron gives an output.

@kliem

This comment has been minimized.

@jplab
Copy link

jplab commented Apr 16, 2019

comment:5

This might be related to #17339. If you want to have fun in the maze of defaulting behaviour, I challenge you to come up with a full-proof default behavior that will please everyone.

One thing that you should be aware of, is the current handling of things via different H and V inputs.

sage: P = Polyhedron(vertices=[])
sage: Q = Polyhedron(vertices=[[]])
sage: P
The empty polyhedron in ZZ^0
sage: Q
A 0-dimensional polyhedron in ZZ^0 defined as the convex hull of 1 vertex

The first one is the empty polyhedron. The second one is just one point, i.e. the full space. They are __not__ the same.

@kliem
Copy link
Contributor Author

kliem commented Apr 16, 2019

comment:7

Well, I can live with a meaningful 'NotImplementedError'.

Either there is a measure with ambient dimension zero or not. So the empty and the one point polyhedron in zero dimensional space should either have a well-defined behaiviour or not.

The reason I looked into it is that the original error is hard to trace back. It took me a bit to figure out, what went wrong there.

Replying to @jplab:

This might be related to #17339. If you want to have fun in the maze of defaulting behaviour, I challenge you to come up with a full-proof default behavior that will please everyone.

One thing that you should be aware of, is the current handling of things via different H and V inputs.

sage: P = Polyhedron(vertices=[])
sage: Q = Polyhedron(vertices=[[]])
sage: P
The empty polyhedron in ZZ^0
sage: Q
A 0-dimensional polyhedron in ZZ^0 defined as the convex hull of 1 vertex

The first one is the empty polyhedron. The second one is just one point, i.e. the full space. They are __not__ the same.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 16, 2019

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

cfa12c7volume in dimension 0 is counting measure

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 16, 2019

Changed commit from 3bd7a03 to cfa12c7

@kliem

This comment has been minimized.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 16, 2019

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

7995b24a bit nicer documentation

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 16, 2019

Changed commit from cfa12c7 to 7995b24

@jplab
Copy link

jplab commented Apr 26, 2019

comment:11

You should change the title and description of the ticket to reflect faithfully the changes inside the ticket.

@jplab
Copy link

jplab commented Apr 26, 2019

comment:12

Failed doctest:

sage -t --long src/sage/geometry/polyhedron/base.py
**********************************************************************
File "src/sage/geometry/polyhedron/base.py", line 5251, in sage.geometry.polyhedron.base.Polyhedron_base.volume
Failed example:
    P = Polyhedron(vertices=[]); P
Expected:
    The empty polyhedron in ZZ^0
    0
Got:
    The empty polyhedron in ZZ^0
**********************************************************************

@kliem

This comment has been minimized.

@kliem kliem changed the title AttributeError of Polyhedron.volume() Fix Polyhedron.volume() in 0-dimensional space May 7, 2019
@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 7, 2019

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

dd6f981Merge branch 'develop' of git://trac.sagemath.org/sage into public/27673
98e05b5fixed doctest mistake

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 7, 2019

Changed commit from 7995b24 to 98e05b5

@jplab
Copy link

jplab commented May 10, 2019

comment:16

Looks good to me now.

@jplab
Copy link

jplab commented May 10, 2019

Changed keywords from none to polytopes, volume

@vbraun
Copy link
Member

vbraun commented May 11, 2019

comment:17

Merge conflict, but isn't it also also mathematically wrong:

  • In the "ambient" measure, if ambient dim > 0, the volume of a point is 0
  • In the "ambient" measure, if ambient dim == 0, the volume of a point is 1
  • In the induced measures, the volume of a point is 1
  • The volume of the empty polyhedron is always 0

@kliem
Copy link
Contributor Author

kliem commented May 11, 2019

comment:18

Replying to @vbraun:

Merge conflict, but isn't it also also mathematically wrong:

  • In the "ambient" measure, if ambient dim > 0, the volume of a point is 0

See line above. Which returns 0 in that case.

  • In the "ambient" measure, if ambient dim == 0, the volume of a point is 1
  • In the induced measures, the volume of a point is 1

A point is projected to 0-dimensional space an then 1 is returned.

  • The volume of the empty polyhedron is always 0

It has dimension -1 but ambient dimension at least 0, so zero will be returned.

I don't see which criteria is not met.

@vbraun
Copy link
Member

vbraun commented May 11, 2019

comment:19

Oh ok, I misread the docstring.

Still a merge conflict though.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 12, 2019

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

b543c6dremove an obsolete note in schemes, pep cleanup of zariski_vankampen
12373c6Change format of a 'not tested' doc test annotation
8783becleave GMP's spkg-configure.m4 as it was
64f4b4dupdate docs, as discussed on #24905
2fa1373Mention libterm-readkey-perl
406ece2Mention libterm-readline-gnu-perl
a031f09polymake: Mention MOngoDB for polydb
473178epolymake: Update info on macOS
9a4bac1polymake: update MongoDB information for linux distros
343130cUpdated [SageMath](../wiki/SageMath) version to 8.8.beta5

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 12, 2019

Changed commit from 98e05b5 to 343130c

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 12, 2019

Changed commit from 343130c to 33b1ff9

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 12, 2019

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

33b1ff9fixed 0-dimensional volume

@kliem
Copy link
Contributor Author

kliem commented May 28, 2019

comment:23

Why does the merge fail again?

Last time I fixed it, was appearently a waste of time.
I guess I could start a new branch again, but only if someone sets it to positive review before the merge fails again.

@jplab
Copy link

jplab commented May 29, 2019

comment:24

Replying to @kliem:

Why does the merge fail again?

Last time I fixed it, was appearently a waste of time.
I guess I could start a new branch again, but only if someone sets it to positive review before the merge fails again.

#25091 Modified the volume function and got merged in 8.8.beta6 that's most likely the conflict.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 31, 2019

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

7a7e57dvolume in dimension 0 is counting measure

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 31, 2019

Changed commit from 33b1ff9 to 7a7e57d

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 31, 2019

Changed commit from 7a7e57d to df1f549

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 31, 2019

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

df1f549should be back to the original

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 31, 2019

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

a7bf147fixed 0-dimensional volume

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 31, 2019

Changed commit from df1f549 to a7bf147

@kliem
Copy link
Contributor Author

kliem commented May 31, 2019

comment:29

I have no idea, how one is supposed to get rebase to work.

This is basically just writing the old text in the newest develop again.

@jplab
Copy link

jplab commented Jun 1, 2019

comment:30

Looks good to me now.

@vbraun
Copy link
Member

vbraun commented Jun 5, 2019

Changed branch from public/27673 to a7bf147

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

3 participants