#10534: Generation of subwords, subsets and set partitions
-----------------------------+----------------------------------------------
Reporter: vdelecroix | Owner: vdelecroix
Type: enhancement | Status: needs_work
Priority: major | Milestone: sage-4.7.1
Component: combinatorics | Keywords: generation, combinatorics, set,
subset, partition
Work_issues: | Upstream: N/A
Reviewer: | Author: vdelecroix
Merged: | Dependencies:
-----------------------------+----------------------------------------------
Description changed by vdelecroix:
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
> }}}
> 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
> }}}
New 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
}}}
--
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/10534#comment:7>
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.