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

Let CombinatorialPolyhedron handle f_vector of polyhedra #28625

Closed
kliem opened this issue Oct 18, 2019 · 15 comments
Closed

Let CombinatorialPolyhedron handle f_vector of polyhedra #28625

kliem opened this issue Oct 18, 2019 · 15 comments

Comments

@kliem
Copy link
Contributor

kliem commented Oct 18, 2019

CombinatorialPolyhedron computes the f_vector much faster than the current algorithm. In addition it is very memory efficient.

The goal of this ticket is to replace the method in Polyhedron_base by the method in CombinatorialPolyedron.

Here is a tiny example of the comparison:

sage: P = polytopes.permutahedron(6)
sage: _ = P.incidence_matrix()
sage: a = get_memory_usage()
sage: %time P.f_vector()
CPU times: user 8.19 s, sys: 4.46 ms, total: 8.19 s
Wall time: 8.19 s
(1, 720, 1800, 1560, 540, 62, 1)
sage: get_memory_usage(a)
22.84765625
sage: a = get_memory_usage()
sage: C = CombinatorialPolyhedron(P)
sage: %time C.f_vector()
CPU times: user 889 µs, sys: 14 µs, total: 903 µs
Wall time: 905 µs
(1, 720, 1800, 1560, 540, 62, 1)
sage: get_memory_usage(a)
0.81640625

Depends on #28621
Depends on #28607

CC: @jplab @LaisRast

Component: geometry

Author: Jonathan Kliem

Branch/Commit: bf85a62

Reviewer: Laith Rastanawi

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

@kliem
Copy link
Contributor Author

kliem commented Oct 18, 2019

Branch: public/28625

@kliem
Copy link
Contributor Author

kliem commented Oct 18, 2019

New commits:

b89610eadded combinatorial polyhedron as an attribute for polyhedra
326602cf_vector of CombinatorialPolyhedron is a vector
dfbe2adMerge branch 'public/28607' of git://trac.sagemath.org/sage into public/28621
ed5518bused CombinatorialPolyhedron to compute f_vector
9bdd005give an error message for polytopes in some cases; removed incorrect example
acd671dnow we get a precice error message for inexact truncated dodecahedron

@kliem
Copy link
Contributor Author

kliem commented Oct 18, 2019

Commit: acd671d

@LaisRast
Copy link
Contributor

comment:4

Running f_vector twice on truncated_dodecahedron will ignore the error and create a wrong f_vector

sage: tr = polytopes.truncated_dodecahedron(exact=False)
  warn("This polyhedron data is numerically complicated; cdd could not convert between the inexact V and H representation without loss of data. The resulting object might show inconsistencies.")
sage: tr.f_vector()
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
...
ValueError: not all vertices are intersections of facets
sage: tr.f_vector()
(1, 36, 57, 22, 1)
sage: tr
A 3-dimensional polyhedron in RDF^3 defined as the convex hull of 60 vertices

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Oct 18, 2019

Changed commit from acd671d to bf85a62

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Oct 18, 2019

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

bf85a62subsequent calls for f_vector fail if first attempt fails

@LaisRast
Copy link
Contributor

comment:7

It looks good now.

@LaisRast
Copy link
Contributor

Reviewer: Laith Rastanawi

@fchapoton
Copy link
Contributor

comment:9

missing author name

@kliem
Copy link
Contributor Author

kliem commented Oct 18, 2019

Author: Jonathan Kliem

@jplab
Copy link
Contributor

jplab commented Oct 19, 2019

comment:11

Just a comment. I have no idea where this was added due to the 1000 tickets:

raise ValueError("not all facets are joins of vertices")

This error message is very misleading. I would change this to something that does not use the word join. Usually, facet are convex hulls of vertices. Is this what fails here? If yes, then I would change it to that.

@kliem
Copy link
Contributor Author

kliem commented Oct 19, 2019

comment:12

Replying to @jplab:

Just a comment. I have no idea where this was added due to the 1000 tickets:

raise ValueError("not all facets are joins of vertices")

This error message is very misleading. I would change this to something that does not use the word join. Usually, facet are convex hulls of vertices. Is this what fails here? If yes, then I would change it to that.

give an error message for polytopes in some cases; removed incorrect example

It's an error message that was generated in CombinatorialPolyhedron. Convex hull isn't really defined there. But I guess people get what it means.

Its a lot better than what we used to get. This was a very cryptic KeyError in hasse diagram and it took me a while to figure out what the error message is supposed to tell us.

If you think it should be changed now, you can put this ticket, #28605, #28606 and #28614 on needs work, because there will be merge conflicts. Otherwise, we can always fix this later.

@jplab
Copy link
Contributor

jplab commented Oct 19, 2019

comment:13

Replying to @kliem:

Replying to @jplab:

Just a comment. I have no idea where this was added due to the 1000 tickets:

raise ValueError("not all facets are joins of vertices")

This error message is very misleading. I would change this to something that does not use the word join. Usually, facet are convex hulls of vertices. Is this what fails here? If yes, then I would change it to that.

give an error message for polytopes in some cases; removed incorrect example

It's an error message that was generated in CombinatorialPolyhedron. Convex hull isn't really defined there. But I guess people get what it means.

Its a lot better than what we used to get. This was a very cryptic KeyError in hasse diagram and it took me a while to figure out what the error message is supposed to tell us.

If you think it should be changed now, you can put this ticket, #28605, #28606 and #28614 on needs work, because there will be merge conflicts. Otherwise, we can always fix this later.

Please let the positively reviewed tickets get into a beta before trying to shove them all at once. It's simply impossible to review otherwise.

@kliem
Copy link
Contributor Author

kliem commented Oct 19, 2019

comment:14

Replying to @jplab:

Replying to @kliem:

Replying to @jplab:

Just a comment. I have no idea where this was added due to the 1000 tickets:

raise ValueError("not all facets are joins of vertices")

This error message is very misleading. I would change this to something that does not use the word join. Usually, facet are convex hulls of vertices. Is this what fails here? If yes, then I would change it to that.

give an error message for polytopes in some cases; removed incorrect example

It's an error message that was generated in CombinatorialPolyhedron. Convex hull isn't really defined there. But I guess people get what it means.

Its a lot better than what we used to get. This was a very cryptic KeyError in hasse diagram and it took me a while to figure out what the error message is supposed to tell us.

If you think it should be changed now, you can put this ticket, #28605, #28606 and #28614 on needs work, because there will be merge conflicts. Otherwise, we can always fix this later.

Please let the positively reviewed tickets get into a beta before trying to shove them all at once. It's simply impossible to review otherwise.

I agree that it is a bit confusing. This ticket here has a total number of 7 commits and three of them belong to #28621 and #28607. I think this is doable.

As this ticket and #28605 conflict, we need to make one depend on the other. I just figured that this here is easier than #28605.

@vbraun
Copy link
Member

vbraun commented Oct 21, 2019

Changed branch from public/28625 to bf85a62

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