Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Trac #33611: Improve edges/ridges for simple/simplicial polytopes
In #30040 we have improved the face iterator for simple/simplicial polytopes, but have not applied this to our heuristic, whether we should find edges/ridges in dual/non-dual mode. This is noticeable for edges of the permutahedron (and theoretically also for other edges of simple polytopes) and does not make a difference otherwise. Before: {{{ sage: C = polytopes.hypercube(12).combinatorial_polyhedron() sage: %time _ = C.edges() CPU times: user 86.1 ms, sys: 9 µs, total: 86.1 ms Wall time: 86 ms sage: %time _ = C.ridges() CPU times: user 617 µs, sys: 3 µs, total: 620 µs Wall time: 622 µs sage: C = polytopes.cyclic_polytope(6, 20).combinatorial_polyhedron() sage: %time _ = C.edges() CPU times: user 114 µs, sys: 0 ns, total: 114 µs Wall time: 117 µs sage: %time _ = C.ridges() CPU times: user 1.09 ms, sys: 5 µs, total: 1.09 ms Wall time: 1.1 ms sage: C = polytopes.permutahedron(7).combinatorial_polyhedron() sage: %time _ = C.edges() CPU times: user 16.1 s, sys: 0 ns, total: 16.1 s Wall time: 16.1 s sage: %time _ = C.ridges() CPU times: user 2.35 ms, sys: 0 ns, total: 2.35 ms Wall time: 2.36 ms }}} After: {{{ sage: C = polytopes.hypercube(12).combinatorial_polyhedron() sage: %time _ = C.edges() CPU times: user 39.5 ms, sys: 0 ns, total: 39.5 ms Wall time: 39.4 ms sage: %time _ = C.ridges() CPU times: user 725 µs, sys: 60 µs, total: 785 µs Wall time: 791 µs sage: C = polytopes.cyclic_polytope(6, 20).combinatorial_polyhedron() sage: %time _ = C.edges() CPU times: user 154 µs, sys: 12 µs, total: 166 µs Wall time: 168 µs sage: %time _ = C.ridges() CPU times: user 1.16 ms, sys: 95 µs, total: 1.25 ms Wall time: 1.26 ms sage: C = polytopes.permutahedron(7).combinatorial_polyhedron() sage: %time _ = C.edges() CPU times: user 63.2 ms, sys: 0 ns, total: 63.2 ms Wall time: 63.2 ms sage: %time _ = C.ridges() CPU times: user 4.56 ms, sys: 0 ns, total: 4.56 ms Wall time: 4.57 ms }}} The heuristic isn't perfect, but if it fails, you can now select a better algorithm: {{{ sage: P = polytopes.permutahedron(7) sage: P1 = P.stack(next(P.face_generator(1))) sage: %time P1.vertex_adjacency_matrix() CPU times: user 20.6 s, sys: 7.96 ms, total: 20.6 s Wall time: 20.6 s 5041 x 5041 dense matrix over Integer Ring (use the '.str()' method to see the entries) sage: P1 = P.stack(next(P.face_generator(1))) sage: %time P1.vertex_adjacency_matrix(algorithm='primal') CPU times: user 206 ms, sys: 16 ms, total: 222 ms Wall time: 222 ms 5041 x 5041 dense matrix over Integer Ring (use the '.str()' method to see the entries) }}} URL: https://trac.sagemath.org/33611 Reported by: gh-kliem Ticket author(s): Jonathan Kliem Reviewer(s): Travis Scrimshaw, Yuan Zhou
- Loading branch information