#18241: Great speedup in polytopes construction with generic backend
-------------------------------------+-------------------------------------
Reporter: vdelecroix | Owner:
Type: enhancement | Status: needs_review
Priority: major | Milestone: sage-6.7
Component: geometry | Resolution:
Keywords: | Merged in:
Authors: Vincent Delecroix | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
u/vdelecroix/18241 | 99c670831a4064246d2cdb2aec32a3e51fd4fd7c
Dependencies: #18215 | Stopgaps:
-------------------------------------+-------------------------------------
Old description:
> Construction of polytopes with number field coordinates are very slow.
> There are several reasons for that:
> - quadratic number field element hash is slow (already solved in
> #18215)
> - `NumberField.__cmp__` is slow
> - we can avoid many useless copies and recomputations in the algorithm
> `Vrep2Hrep` and `Hrep2Vrep`
>
> After applying the branch the speedup is really cool. Using
> [http://trac.sagemath.org/attachment/ticket/18241/polyhedron_test.py
> polyhedron_test.py] I got
>
> Before
> {{{
> sage: %runfile polyhedron_test.py
> sage: %time gr = great_rhombicuboctahedron()
> CPU times: user 4.66 s, sys: 24 ms, total: 4.68 s
> Wall time: 4.66 s
> }}}
> After
> {{{
> sage: %runfile polyhedron_test.py
> sage: %time gr = great_rhombicuboctahedron()
> CPU times: user 292 ms, sys: 28 ms, total: 320 ms
> Wall time: 306 ms
> }}}
>
> (But I am still not able to build the
> [http://en.wikipedia.org/wiki/600-cell 600-cell])
New description:
Construction of polytopes with number field coordinates are very slow.
There are several reasons for that:
- quadratic number field element hash is slow (already solved in #18215)
- `NumberField.__cmp__` is slow
- we can avoid many useless copies and recomputations in the algorithm
`Vrep2Hrep` and `Hrep2Vrep`
After applying the branch the speedup is really cool. Using
[http://trac.sagemath.org/attachment/ticket/18241/polyhedron_test.py
polyhedron_test.py] I got
Before
{{{
sage: %runfile polyhedron_test.py
sage: %time gr = great_rhombicuboctahedron()
CPU times: user 4.66 s, sys: 24 ms, total: 4.68 s
Wall time: 4.66 s
}}}
After
{{{
sage: %runfile polyhedron_test.py
sage: %time gr = great_rhombicuboctahedron()
CPU times: user 292 ms, sys: 28 ms, total: 320 ms
Wall time: 306 ms
}}}
(But I am still not able to build the
[http://en.wikipedia.org/wiki/600-cell 600-cell])
Modifications with the branch:
1. In the double description file
- use `itertools` instead of whatever `sage/combinat/*`
- use `base_ring.zero()` and `base_ring.one()` instead of the Python
integer `0` and `1`. That prevents many coercions.
- make the method `add_inequality` so that the object is changed
'''inplace''' instead of returning a new instance. I had to change the
type of the attribute from `tuples` to `lists`.
- add a cache for matrix spaces (see #18231). These are the methods
`_matrix_space` and `_matrix`
- implement a cache for the method `.zero_set` (note that this was
needed because the object is no more immutable, `self.A` will grow in
`add_inequality`)
2. Start with a trivial case in `NumberField.__cmp__`.
--
Comment (by vdelecroix):
Replying to [comment:3 ncohen]:
> Could you say in the ticket's description what the branch does?
>
> Every single thing that you do without explanation, the reviewer has to
figure out from the diff file.
done!
--
Ticket URL: <http://trac.sagemath.org/ticket/18241#comment:4>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.