#10534: Generation of subwords, subsets and set partitions
---------------------------------------------------------------------+------
Reporter: vdelecroix |
Owner: vdelecroix
Type: enhancement |
Status: needs_info
Priority: major |
Milestone: sage-5.0
Component: combinatorics |
Resolution:
Keywords: generation, combinatorics, set, subset, partition | Work
issues:
Report Upstream: N/A |
Reviewers: Florent Hivert
Authors: Vincent Delecroix |
Merged in:
Dependencies: |
Stopgaps:
---------------------------------------------------------------------+------
Old description:
> This ticket stands for a faster method of exhaustive generation of
>
> * subwords
> * subsets
> * set partitions (ordered and non orderered)
>
> Moreover, the patch provides
> * bugs and typos corrections (doctest coverage is now 100%)
> * random generation capabilities
> * modified cardinality method which always return a Sage Integer (and
> no more Python int or Sage Rational)
>
> Some timings (on Intel(R) Core(TM)2 Duo CPU T8100 @ 2.10GHz)
>
> Old version
>
> {{{
> sage: S = SetPartitions(8,[3,3,2])
> sage: timeit('for p in S: pass')
> 5 loops, best of 3: 401 ms per loop
>
> sage: S = SetPartitions(9,[3,3,2,1])
> sage: timeit('for p in S: pass')
> 5 loops, best of 3: 4 s per loop
>
> sage: S = Subsets([1]*1+[2]*2+[3]*3+[4]*4+[5]*5, submultiset=True)
> sage: timeit('S.cardinality()')
> 5 loops, best of 3: 712 ms per loop
> }}}
> New version
>
> {{{
> sage: S = SetPartitions(8,[3,3,2])
> sage: timeit('for p in S: pass')
> 5 loops, best of 3: 130 ms per loop
> sage: timeit('for p in S._fast_iterator(): pass')
> 25 loops, best of 3: 10.4 ms per loop
>
> sage: S = SetPartitions(9,[3,3,2,1])
> sage: timeit('for p in S: pass')
> 5 loops, best of 3: 1.43 s per loop
> sage: timeit('for p in S._fast_iterator(): pass')
> 5 loops, best of 3: 91.3 ms per loop
>
> sage: S = Subsets([1]*1+[2]*2+[3]*3+[4]*4+[5]*5,submultiset=True)
> sage: timeit('S.cardinality()')
> 625 loops, best of 3: 33.9 µs per loop
> }}}
New description:
This ticket stands for a faster method of exhaustive generation of
combinatorial object that may be found in sage.combinat.* and more
precisely
* subwords (sage.combinat.subword)
* subsets (sage.combinat.subset)
* set partitions (sage.combinat.set_partitions and
sage.combinat.set_partition_ordered)
Most of the time, the improvment just consists in calling the python
library itertools. For other, it consists in creating a lower level Python
iterator which does not use the heavy mechanism of Parent/Element (which
is not intended for the frontend user).
Moreover, the patch provides
* bugs and typos corrections (doctest coverage is now 100%)
* random generation capabilities
* modified cardinality method which always return a Sage Integer (and no
more Python int or Sage Rational)
Some timings (on Intel(R) Core(TM)2 Duo CPU T8100 @ 2.10GHz)
Old version
{{{
sage: S = SetPartitions(8,[3,3,2])
sage: timeit('for p in S: pass')
5 loops, best of 3: 401 ms per loop
sage: S = SetPartitions(9,[3,3,2,1])
sage: timeit('for p in S: pass')
5 loops, best of 3: 4 s per loop
sage: S = Subsets([1]*1+[2]*2+[3]*3+[4]*4+[5]*5, submultiset=True)
sage: timeit('S.cardinality()')
5 loops, best of 3: 712 ms per loop
}}}
New version
{{{
sage: S = SetPartitions(8,[3,3,2])
sage: timeit('for p in S: pass')
5 loops, best of 3: 130 ms per loop
sage: timeit('for p in S._fast_iterator(): pass')
25 loops, best of 3: 10.4 ms per loop
sage: S = SetPartitions(9,[3,3,2,1])
sage: timeit('for p in S: pass')
5 loops, best of 3: 1.43 s per loop
sage: timeit('for p in S._fast_iterator(): pass')
5 loops, best of 3: 91.3 ms per loop
sage: S = Subsets([1]*1+[2]*2+[3]*3+[4]*4+[5]*5,submultiset=True)
sage: timeit('S.cardinality()')
625 loops, best of 3: 33.9 µs per loop
}}}
--
Comment (by vdelecroix):
Nathan, you should be more explicit when asking for more info...
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/10534#comment:14>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.