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

Improve the zonotope construction #31038

Closed
kliem opened this issue Dec 11, 2020 · 8 comments
Closed

Improve the zonotope construction #31038

kliem opened this issue Dec 11, 2020 · 8 comments

Comments

@kliem
Copy link
Contributor

kliem commented Dec 11, 2020

Currently the zonotope just takes the convex hull of the sum of all combinations of the input. With n generators it takes therefor the convex hull of 2^n points.

However, most of those points, will be redundant. Reducing via the Minkowski sum, allows to use this.

Before this ticket:

sage: from itertools import combinations                                                                                                                                            
sage: cu = polytopes.cube()                                                                                                                                                         
sage: sgmt = [p.vector()-q.vector() for p,q in combinations(cu.vertices(),2)]                                                                                                       
sage: sgmt2 = set(tuple(x) for x in sgmt)                                                                                                                                           
sage: # %time polytopes.zonotope(sgmt)  # killed due to memory overflow                                                                                                                                              
sage: %time polytopes.zonotope(sgmt2)                                                                                                                                               
CPU times: user 2.06 s, sys: 23.9 ms, total: 2.09 s
Wall time: 2.09 s
A 3-dimensional polyhedron in ZZ^3 defined as the convex hull of 96 vertices

With this ticket:

sage: from itertools import combinations                                                                                                                                            
sage: cu = polytopes.cube()                                                                                                                                                         
sage: sgmt = [p.vector()-q.vector() for p,q in combinations(cu.vertices(),2)]                                                                                                       
sage: sgmt2 = set(tuple(x) for x in sgmt)                                                                                                                                           
sage: %time polytopes.zonotope(sgmt)                                                                                                                                                
CPU times: user 138 ms, sys: 0 ns, total: 138 ms
Wall time: 138 ms
A 3-dimensional polyhedron in ZZ^3 defined as the convex hull of 96 vertices
sage: %time polytopes.zonotope(sgmt2)                                                                                                                                               
CPU times: user 58 ms, sys: 0 ns, total: 58 ms
Wall time: 57.6 ms
A 3-dimensional polyhedron in ZZ^3 defined as the convex hull of 96 vertices

CC: @jplab @LaisRast

Component: geometry

Keywords: zonotope

Author: Jean-Philippe Labbé, Jonathan Kliem

Branch/Commit: 90a0d60

Reviewer: Jonathan Kliem, Frédéric Chapoton

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

@kliem kliem added this to the sage-9.3 milestone Dec 11, 2020
@jplab jplab changed the title Improve the zonotope Improve the zonotope construction Dec 11, 2020
@fchapoton
Copy link
Contributor

comment:3

hmm, reduce is not very pythonic. Why not use sum ?

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Dec 13, 2020

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

90a0d60use sum

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Dec 13, 2020

Changed commit from a2d1fc5 to 90a0d60

@kliem
Copy link
Contributor Author

kliem commented Dec 13, 2020

comment:5

Yes, much easier.

@fchapoton
Copy link
Contributor

comment:6

ok, looks good.

@fchapoton
Copy link
Contributor

Changed reviewer from Jonathan Kliem to Jonathan Kliem, Frédéric Chapoton

@jplab
Copy link

jplab commented Dec 14, 2020

comment:7

Replying to @fchapoton:

hmm, reduce is not very pythonic. Why not use sum ?

Ah oui? I once discovered it in a python magazine about "tricks" that go unnoticed. Perhaps it is made for more technical things than +?

@vbraun
Copy link
Member

vbraun commented Dec 21, 2020

Changed branch from u/gh-kliem/improve_zonotope to 90a0d60

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

4 participants