sweetpea.combinatorics module¶
This module provides combinatoric functionality.
- sweetpea.combinatorics.extract_components(sizes, n)¶
Given a list of dimension sizes, and an integer less than the product of the sizes, this function will extract the component value for each dimension from the total.
For example, if
sizes
is[3, 4, 2]
, there are 24 possible combinations of the three. If0 <= n < 24
, this function will return the selections for each dimension for thatn
.
- sweetpea.combinatorics.compute_jth_inversion_sequence(n, j)¶
The are
n!
permutations ofn
elements. Each permutation can be uniquely identified by and constructed from its “inversion sequence”. This function will compute thej``th inversion sequence for a set of ``n
elements.Information on inversion sequences can be found:
“Introductory Combinatorics” by Richard A. Brualdi, ISBN 978-0136020400.
- sweetpea.combinatorics.construct_permutation(inversion_sequence)¶
Given an inversion sequence, construct the permutation.
- sweetpea.combinatorics.compute_jth_combination(l, n, j)¶
In a sequence of
l
items, where there aren
choices for each item, this will compute thejth
combination, out of all possibilities.