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

Add .boundary_complex() method for simplicial polytopes #28248

Closed
jplab opened this issue Jul 24, 2019 · 25 comments
Closed

Add .boundary_complex() method for simplicial polytopes #28248

jplab opened this issue Jul 24, 2019 · 25 comments

Comments

@jplab
Copy link

jplab commented Jul 24, 2019

The boundary of polytopes are nice and relatively well-behaved cell complexes.

When the polytope is simplicial, its boundary is a simplicial complex. This ticket implements a method to return that simplicial complex.

Depends on #27974

CC: @LaisRast @kliem @tscrim @jhpalmieri

Component: geometry

Keywords: polytopes, simplicial complex, days100

Author: Jean-Philippe Labbé

Branch: 7432567

Reviewer: Laith Rastanawi

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

@jplab jplab added this to the sage-8.9 milestone Jul 24, 2019
@jplab
Copy link
Author

jplab commented Jul 24, 2019

Dependencies: #27974

@jplab
Copy link
Author

jplab commented Jul 24, 2019

Branch: u/jipilab/28248

@jplab
Copy link
Author

jplab commented Jul 24, 2019

Commit: 21ae478

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jul 24, 2019

Changed commit from 21ae478 to 890c350

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jul 24, 2019

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

890c350Added to quickref

@sagetrac-coulbois
Copy link
Mannequin

sagetrac-coulbois mannequin commented Jul 26, 2019

Author: Jean-Philippe Labbé

@LaisRast
Copy link

comment:5

Since you only need the combinatorial data of the polytope, it would be much faster to use the .incidence_matrix() instead of the .faces() (or facets() here).
(You can see the difference, for instance, clearly if you take the dual of the 7-permutahedron)

@kliem
Copy link
Contributor

kliem commented Jul 26, 2019

comment:6

Replying to @LaisRast:

Since you only need the combinatorial data of the polytope, it would be much faster to use the .incidence_matrix() instead of the .faces() (or facets() here).
(You can see the difference, for instance, clearly if you take the dual of the 7-

The difference will only be minor, once #27063 is done.
It's still going to be faster to just take the incidence matrix, but not by much.

Try it out tuple(CombinatorialPolyhedron(P).face_iter(P.dimension()-1)) vs P.incidence_matrix().

Be aware that the incidence matrix is cashed.

@LaisRast
Copy link

comment:7

Replying to @kliem:

Replying to @LaisRast:

Since you only need the combinatorial data of the polytope, it would be much faster to use the .incidence_matrix() instead of the .faces() (or facets() here).
(You can see the difference, for instance, clearly if you take the dual of the 7-

The difference will only be minor, once #27063 is done.
It's still going to be faster to just take the incidence matrix, but not by much.

Try it out tuple(CombinatorialPolyhedron(P).face_iter(P.dimension()-1)) vs P.incidence_matrix().

Be aware that the incidence matrix is cashed.

Actually no. Running CombinatorialPolyhedron(P) will compute the incidence matrix of P to initialize the CombinatorialPolyhedron.
P.incidence_matrix() is still far faster.

@kliem
Copy link
Contributor

kliem commented Jul 26, 2019

comment:8

I know that it will compute the incidence matrix anyway.
However, I disagree that it is far faster.
Almost all the time initializing CombinatorialPolyhedron is spent on the incidence matrix.
To obtain all the facets (in CombinatorialPolyhedron) is really quick, because there is nothing to compute anymore.

Overall, I don't think your suggested change is going to make a big difference (yes it will be slightly faster).

@LaisRast
Copy link

comment:9

Replying to @kliem:

I know that it will compute the incidence matrix anyway.
However, I disagree that it is far faster.
Almost all the time initializing CombinatorialPolyhedron is spent on the incidence matrix.
To obtain all the facets (in CombinatorialPolyhedron) is really quick, because there is nothing to compute anymore.

Overall, I don't think your suggested change is going to make a big difference (yes it will be slightly faster).

For the Polyhedron class (which this method is implemented for), you can see that there is a big difference.

For your suggested method:

sage: P = polytopes.permutahedron(7)
sage: %time I = P.incidence_matrix()
CPU times: user 2.85 s, sys: 72.4 ms, total: 2.92 s
Wall time: 2.83 s
sage: Q = polytopes.permutahedron(7)
sage: %time I = tuple(CombinatorialPolyhedron(Q).face_iter(Q.dimension()-1))
CPU times: user 3.99 s, sys: 287 ms, total: 4.28 s
Wall time: 3.98 s

My suggested change is still faster since it computes less.

Anyway, since #27063 is not yet done, and since the class is Polyhedron, there is a big difference in using the incidence_matrix instead of faces.

@jplab
Copy link
Author

jplab commented Jul 28, 2019

comment:10

Replying to @LaisRast:

Replying to @kliem:

I know that it will compute the incidence matrix anyway.
However, I disagree that it is far faster.
Almost all the time initializing CombinatorialPolyhedron is spent on the incidence matrix.
To obtain all the facets (in CombinatorialPolyhedron) is really quick, because there is nothing to compute anymore.

Overall, I don't think your suggested change is going to make a big difference (yes it will be slightly faster).

For the Polyhedron class (which this method is implemented for), you can see that there is a big difference.

For your suggested method:

sage: P = polytopes.permutahedron(7)
sage: %time I = P.incidence_matrix()
CPU times: user 2.85 s, sys: 72.4 ms, total: 2.92 s
Wall time: 2.83 s
sage: Q = polytopes.permutahedron(7)
sage: %time I = tuple(CombinatorialPolyhedron(Q).face_iter(Q.dimension()-1))
CPU times: user 3.99 s, sys: 287 ms, total: 4.28 s
Wall time: 3.98 s

My suggested change is still faster since it computes less.

Anyway, since #27063 is not yet done, and since the class is Polyhedron, there is a big difference in using the incidence_matrix instead of faces.

+1

I will replace to incidence_matrix. Once #27063 is done, the discussion may resume and check what is best, for now, incidence_matrix does the job.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jul 28, 2019

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

388d7feChanged to incidence matrix

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jul 28, 2019

Changed commit from 890c350 to 388d7fe

@LaisRast
Copy link

Reviewer: Laith Rastanawi

@LaisRast
Copy link

comment:13

Beside the implementaion of facets method, which is going to be taken care of in #27974, the code looks good to me. The tests seem to pass on my machine and on the patchbot. Thus, I will consider this as a positive review.

@fchapoton fchapoton removed this from the sage-8.9 milestone Jul 31, 2019
@fchapoton fchapoton added this to the sage-8.9 milestone Sep 10, 2019
@fchapoton fchapoton removed the pending label Sep 10, 2019
@jplab
Copy link
Author

jplab commented Sep 11, 2019

comment:16

There's a small conflict due to the facets methods. I'll fix it.

@jplab
Copy link
Author

jplab commented Sep 12, 2019

Changed branch from u/jipilab/28248 to u/jipilab/28248_v2

@jplab
Copy link
Author

jplab commented Sep 12, 2019

New commits:

fbc3ad3First version
877eaa5added cross-references, changed faces examples to facets where appropriate
6457c02Added examples
112c30ffixed tests
e6fe7a8Added to quickref
7432567Changed to incidence matrix

@jplab
Copy link
Author

jplab commented Sep 12, 2019

Changed commit from 388d7fe to 7432567

@jplab
Copy link
Author

jplab commented Sep 12, 2019

comment:19

Rebased on sage8.9.rc0 and fixed conflict.

@LaisRast
Copy link

comment:20

Since the conflict is now resolved, I will put the ticket on positive review again.

@fchapoton
Copy link
Contributor

comment:21

moving milestone to 9.0 (after release of 8.9)

@fchapoton fchapoton modified the milestones: sage-8.9, sage-9.0 Sep 30, 2019
@vbraun
Copy link
Member

vbraun commented Oct 3, 2019

Changed branch from u/jipilab/28248_v2 to 7432567

@fchapoton
Copy link
Contributor

Changed commit from 7432567 to none

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