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
Faster Poyhedron.graph() #18860
Comments
Branch: public/18860 |
Commit: |
comment:4
well, you have 26 facets on each edge - none are more useless than the others. You can do the
or just
which makes sense, as General code for adjacency of two vertices (There could be special cases when one of the vertices is the origin, or some inequalities are homogeneous). |
comment:5
Would you know how to adapt this code for that? Hoping that it will remain faster than what we currently have? Nathann |
comment:6
Replying to @nathanncohen:
My understanding is that hacking |
comment:7
I do not know how to do that. If you know how to fix this implementation, at least it will be done. Otherwise chances are that nothing will happen. Nathann |
comment:8
Replying to @nathanncohen:
the whole Polyhedron code does a potentially very slow thing: enumerating the inequalities at construction time, instead of doing it optionally or/and lazily. Indeed, e.g. the problem at hand, deciding if two vertices are adjacent, does not need pre-computed inequalities. Namely, checking that v_1 and v_2 are adjacent can be done by solving the following LP:
if the optimum exists and is strictly positive, they form an edge, and otherwise they don't. So we are trying to find an inequality that is valid for the convex hull of v_k's and turns (The LP above will not work if there are more v_j's on the line joining v_1 and v_2 --- but this case can be taken care of trivially.) |
comment:9
Oh. That's a nice formulation of the problem, thanks. I will not forget it. Would you know a combinatorial way to compute it? It seems that we can already rely on cddlib (see #18861) in order to build the graph over RDF. Nathann |
comment:10
Here is a new 'combinatorial' version. It uses an 'idea', which I am not sure is a proper definition of the object, but well... You tell me
Works for Gosset (at least) Nathann |
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
|
comment:12
A bit cleaner: I moved the code to the With this, all tests pass in the Nathann [1] You can see what goes wrong by adding |
This comment has been minimized.
This comment has been minimized.
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
|
comment:15
The adjacency matrix for unbound polyhedra is essentially the projectvization; See also the adjacency matrix docs for a more down-to-earth definition. |
comment:16
I was not talking about the Nathann |
comment:17
Again its really the V-representation adjacency matrix; The non-compact case is just the projectivization. So in a sense its really the vertex adjacency matrix; I know its somewhat confusing but most people are interested in the compact case so being overly nitpicky about wording is going to be confusing too. |
comment:18
So was this line incorrect I expect the Nathann |
comment:19
Replying to @nathanncohen:
yes, that's correct for the polytopes - provided there is no redundancy.
|
comment:20
Excellent news! Then we have a very nice speedup ahead As for redundancy, it is true that this algorithm will not behave very well if there are several vertices at the same place which are actually the same. Redundancy of inequalities, however, is not a problem.
Yeah but in terms of sets it produces the very same one. So it's cool. Nathann |
comment:21
Replying to @nathanncohen:
Aren't we changing the behaviour of some functions for the non-compact case? |
comment:22
This patch only touches the function Nathann |
comment:23
also note that not a single doctest changed. But to be honest, I still believe that the Nathann |
comment:24
Replying to @nathanncohen:
presently we have
in And then set |
comment:25
Seems reasonable. Though I would very much like to see the definition of a Nathann |
comment:26
Replying to @nathanncohen:
well, check out
How these general adjacencies are used, I don't know. |
comment:27
Oh. Then it seems that it will be possible to rewrite that method using the algorithm implemented here, then. And everything will be faster. Nathann |
comment:28
Are we still in |
comment:29
I do not think that there was any. We had discussions on the name of other functions, but this new implementation only touches the "vertex graph" and clearly improves the running time. Nathann |
Reviewer: Dima Pasechnik |
comment:30
OK. Merges in 6.8, no problem... |
comment:31
Thanks! |
comment:32
Would have been easy to catch if you had checked the patchbot output... |
comment:35
Replying to @nathanncohen: Could you explain what happens in the last commit? |
comment:36
Oh, no problem: there is a difference between the previous output or I adapted the code, for it expected the keys of the position dictionary (the vertices) to be integers, instead of the new points. Actually, it convinced me that the previous version of this function was incorrect in theory. It was assumed that the vertices of the polyhedron appeared in the very same order as how they were first given to the polyhedron constructor. I don't know if it is true in practice, but for sure there is no reason to assume that a priori. So you can see this as a bugfix Nathann |
comment:37
Vertices are definitely reordered in |
comment:38
OK, looks good. |
Changed branch from public/18860 to |
With this branch,
polytopes.Gosset_3_21().graph()
takes 300ms, against 16s before.The 'definition' used to compute adjacent vertices can be found in [comment:10]
And of course the following works:
Depends on #18779
CC: @videlec @dimpase @vbraun @novoselt
Component: geometry
Author: Nathann Cohen
Branch/Commit:
5223cda
Reviewer: Dima Pasechnik
Issue created by migration from https://trac.sagemath.org/ticket/18860
The text was updated successfully, but these errors were encountered: