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

A lot of polytope constructors are broken #18213

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

A lot of polytope constructors are broken #18213

videlec opened this issue Apr 15, 2015 · 64 comments

Comments

@videlec
Copy link
Contributor

videlec commented Apr 15, 2015

A lot of polytopes constructors in sage.geometry.polyhedron.library. For example

  1. The Rhombicuboctahedron does not return what it should (as Python division was thought as Sage integer divisions). There is in the code
verts = [ [-3/2, -1/2, -1/2], [-3/2, -1/2, 1/2], [-3/2, 1/2, -1/2],
...
  1. The great_rhombicuboctahedron is defined over QQ but it should be defined over QQ[sqrt(2)]! There are in two places rough approximation of sqrt(2) in the code
v1 = QQ(131739771357/54568400000)   # ~ sqrt(2) + 1 but actually 2 due to Python division
v2 = QQ(104455571357/27284200000)   # ~ 2 sqrt(2) but actually 3 due to Python division

Instead, we should use the base_ring argument (with appropriate defaults) and use base_ring(2).sqrt() instead.

  1. The functions unrelated to construction of Polytopes are moved out of the class Polytopes:
    • Polytopes.orthonormal_1, Polytopes.project_1 will be renamed respectively zero_sum_projection and project_points
    • the one line Polytopes._pfunc is just removed

While we're at it, remove the deprecations from #11634.

During the process I discovered two annoying bugs:

Depends on #18211

CC: @nathanncohen

Component: geometry

Author: Vincent Delecroix

Branch/Commit: a58da00

Reviewer: Nathann Cohen

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

@videlec videlec added this to the sage-6.7 milestone Apr 15, 2015
@jdemeyer

This comment has been minimized.

@videlec
Copy link
Contributor Author

videlec commented Apr 16, 2015

Author: Vincent Delecroix

@videlec
Copy link
Contributor Author

videlec commented Apr 16, 2015

comment:3

I have a big commit to push in few minutes...

@videlec
Copy link
Contributor Author

videlec commented Apr 16, 2015

New commits:

5110cc9Trac 18211: use LattE to compute the Ehrhart polynomial
cf2a10fTrac 18211: another example using Birkhoff_polytope
ca8da5aTrac 18211: fixed spelling LattE integral*e*
d52053cTrac 18211: check error + options
0f5122bTrac 18211: fix command line arguments
b877932Trac 18211: fix arguments + doctests + cwd=SAGE_TMP
3b30bc8Trac 18213: rewrite the polyhedron library
e598e28Trac 18123: fix doctests

@videlec
Copy link
Contributor Author

videlec commented Apr 16, 2015

Branch: u/vdelecroix/18123

@videlec
Copy link
Contributor Author

videlec commented Apr 16, 2015

Commit: e598e28

@videlec

This comment has been minimized.

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented Apr 16, 2015

comment:5

Depends on #18211?

@videlec
Copy link
Contributor Author

videlec commented Apr 16, 2015

Dependencies: #18211

@videlec
Copy link
Contributor Author

videlec commented Apr 16, 2015

comment:6

Replying to @nathanncohen:

Depends on #18211?

Yes


New commits:

c44b53eTrac 18213: fix doctests

@videlec
Copy link
Contributor Author

videlec commented Apr 16, 2015

Changed commit from e598e28 to c44b53e

@videlec
Copy link
Contributor Author

videlec commented Apr 16, 2015

Changed branch from u/vdelecroix/18123 to u/vdelecroix/18213

@videlec

This comment has been minimized.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 16, 2015

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

6e7cf21trac #18211: Seealsos

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 16, 2015

Changed commit from c44b53e to 6e7cf21

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 16, 2015

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

227e14aTrac 18213: Seealsos
eef42afTrac 18213: documentation

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 16, 2015

Changed commit from 6e7cf21 to eef42af

@videlec

This comment has been minimized.

@jdemeyer
Copy link

comment:11

The golden_ratio() can obviously be defined in terms of sqrt(5), so I don't see the need for that. I'm also really wondering whether you need the custom sqrt() function, doesn't QuadraticField(n) work?

@videlec
Copy link
Contributor Author

videlec commented Apr 16, 2015

comment:12

Replying to @jdemeyer:

The golden_ratio() can obviously be defined in terms of sqrt(5), so I don't see the need for that. I'm also really wondering whether you need the custom sqrt() function, doesn't QuadraticField(n) work?

Right. The problem of embedding should be done elsewhere (my version embedds in QQbar whereas the generic QuadraticField(n) embedds into RLF).

@videlec
Copy link
Contributor Author

videlec commented Apr 16, 2015

comment:13

Replying to @videlec:

Replying to @jdemeyer:

The golden_ratio() can obviously be defined in terms of sqrt(5), so I don't see the need for that. I'm also really wondering whether you need the custom sqrt() function, doesn't QuadraticField(n) work?

Right. The problem of embedding should be done elsewhere (my version embedds in QQbar whereas the generic QuadraticField(n) embedds into RLF).

Here is one reason. The generator name of QuadraticField(2) is a and it better be sqrt2 in this case. For the golden ratio, the advantage is that its get printed as phi. In particular you have

sage: polytopes.icosahedron().volume()
5/6*phi + 5/6

The answer 5/6*a + 5/6 would have been terrible here. I have nothing against using phi = (sqrt5+1)/2. So I will at least remove this one. For the quadratic fields, one option is to globally make this change in another ticket. What do you think?

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 17, 2015

Changed commit from eef42af to c1804d5

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 17, 2015

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

c1804d5Trac 18213: (review) remove sqrt/golden_ratio + doc

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented Apr 17, 2015

comment:35
        OUTPUT: 

        EXAMPLES::

@videlec
Copy link
Contributor Author

videlec commented Apr 17, 2015

comment:36

Replying to @nathanncohen:

Funny. There is no automorphism_group function for polytopes O_o

Yes! This is very sad... But you have to be careful about what it means. There is the combinatorial automorphism group and the isometry group. I have no idea how to implement the latter efficiently.

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented Apr 17, 2015

comment:37

Most probably the ugliest thing I ever saw

sage: Sequence([Graph()]).universe()
<class 'sage.graphs.graph.Graph'>
sage: Sequence([Graph(),1]).universe()
Category of objects
sage: Sequence([1]).universe()
Integer Ring

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented Apr 17, 2015

comment:38

HMmmmmmmm... I don't exactly know what the isometry group is, but let's try anyway: what about defining a complete graph on your points, in which each edge has a color associated to its length. Wouldn't the automorphism group of that be what you want?

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented Apr 17, 2015

comment:39

Okayyyyyyyyyyyyyy. End of the review. Nothing else to add ;-)

Very good job. This code needed to be cleaned, and it is much better now.

But please, next time: smaller patches. You waste your reviewers' health :-P

Nathann

@videlec
Copy link
Contributor Author

videlec commented Apr 17, 2015

comment:40

Replying to @nathanncohen:

HMmmmmmmm... I don't exactly know what the isometry group is, but let's try anyway: what about defining a complete graph on your points, in which each edge has a color associated to its length. Wouldn't the automorphism group of that be what you want?

That is a valid definition. But the standard one is the set of orthogonal matrices that preserve the polyhedron. And it would be nice for isometry_group to be a finite matrix group (and not permutations)!

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 17, 2015

Changed commit from fac3cff to 1a82754

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 17, 2015

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

21e70a7Trac 18213: review commit
1a82754Trac 18213: doctest fix

@videlec
Copy link
Contributor Author

videlec commented Apr 17, 2015

comment:42

Patchbot should be happy after that.

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented Apr 18, 2015

comment:43

Some broken doctests in the patchbot's report. Also, can you be sure that the sqrt(6.) / factorial(5) are not subject to numerical noise? There is no #tol on them right now.

Nathann

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented Apr 18, 2015

comment:44

Hmmmmmm.. I can't seem to find on google an implementation of an isometry group function anywhere O_o

@sagetrac-jkeitel
Copy link
Mannequin

sagetrac-jkeitel mannequin commented Apr 18, 2015

comment:45

Hi Vincent and Nathann

Just a quick comment, as I'm not sure how useful this will be for general polyhedra: There is a method for lattice polytopes:
LatticePolytope_PPL (in sage.geometry.polyhedron.ppl_lattice_polytope) has a method lattice_automorphism_group()

Cheers,
Jan

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 18, 2015

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

120c1e9Trac 18213: more abs tol in doctests
d09d8a5Trac 18211: forgot a # optional in the doctest
a58da00Trac 18213: merge failed doctest from #18211

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 18, 2015

Changed commit from 1a82754 to a58da00

@videlec
Copy link
Contributor Author

videlec commented Apr 18, 2015

comment:48

Replying to @nathanncohen:

Some broken doctests in the patchbot's report. Also, can you be sure that the sqrt(6.) / factorial(5) are not subject to numerical noise? There is no #tol on them right now.

I don't know... Patchbot did not complain about this.

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented Apr 18, 2015

comment:50

Okayyyyyyy. Then positive_review!

Nathann

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented Apr 18, 2015

Reviewer: Nathann Cohen

@videlec videlec changed the title A lot of polytopes constructor are broken A lot of polytope constructors are broken Apr 18, 2015
@vbraun
Copy link
Member

vbraun commented Apr 19, 2015

Changed branch from u/vdelecroix/18213 to a58da00

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