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
sizesis[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 ofnelements. 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 ``nelements.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
litems, where there arenchoices for each item, this will compute thejthcombination, out of all \(n^l\) possibilities.