Package dsc_suite :: Package tools :: Module combinatorics :: Class EnumerativeCombinatorics
[hide private]
[frames] | no frames]

Class EnumerativeCombinatorics

source code

object --+
         |
        EnumerativeCombinatorics

class EnumerativeCombinatorics() - basic EC functionality

This class implements basic enumerative combinatorics functionality, such as permutations, combinations and partitions, since they are necessary for my optimization investigations of data structures.

Most methods are static (class) methods. Basically, this class is used to encapsulated conjoined functions.

Instance Methods [hide private]

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __init__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Static Methods [hide private]
permutation_list
permute_old(element_list)
element_list ...
source code
permutation_list
permute(element_list)
element_list -- list of elements which are used permutation_list -- all possible permutations of elements
source code
permutation
get_permutation(element_list, number)
element_list -- list of elements which are used number -- number of permutation (implementation inherent order) permutation -- resulting permutation of elements
source code
 
get_num_permutations(element_list)
Calculate number of possible permutations.
source code
 
get_num_variations(element_list, variation_length)
Calculate number of possible variations.
source code
variation_list
vary(element_list, variation_length)
element_list ...
source code
 
get_variation(element_list, variation_length, number)
Generate variation and return the specified element.
source code
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

permute_old(element_list)
Static Method

source code 

element_list ... list of elements which are used permutation_list ... all possible permutations of elements

Generates the PERMUTATION WITHOUT REPETITION of all elements given in the element_list, which are used once. The resulting permutation_list is a list including the n = len(element_list)! different sequences.

ATTENTION: This permutation implementation delivers a different order than permute and get_permutation!

Returns: permutation_list

permute(element_list)
Static Method

source code 

element_list -- list of elements which are used permutation_list -- all possible permutations of elements

Generates the PERMUTATION WITHOUT REPETITION of all elements given in the element_list, which are used once. The resulting permutation_list is a list including the n = len(element_list)! different sequences. Obtains the same ordering of permutations as the get_permutation method.

Returns: permutation_list

get_permutation(element_list, number)
Static Method

source code 

element_list -- list of elements which are used number -- number of permutation (implementation inherent order) permutation -- resulting permutation of elements

Generates the PERMUTATION WITHOUT REPETITION of the elements given in the element_list, which are used once. The number of all possible permutations is fak(len(element_list)), thus the range of number should be: 0 <= number < fak(len(element_list)). Validity of number is not tested. This should be done in the calling function (e.g., assert(number) < fak(len(element_list))), otherwise this test would be executed in every recursion step.

Result equal to: permute(element_list)[number]

Returns: permutation

vary(element_list, variation_length)
Static Method

source code 

element_list ... list of elements which are used variation_length ... length of resulting variation variation_list ... result of variation

Generates the VARIATION WITH REPETITION of the given length. Therefore on every place every given element can be used. The order is important. Finaly, the variation_list contains len(element_list)**variation_length variations.

Returns: variation_list

get_variation(element_list, variation_length, number)
Static Method

source code 

Generate variation and return the specified element.

element_list - list of elements which are used variation_length - length of resulting variation number - number of wanted variation variation - resulting variation

Generates one VARIATION WITH REPETITION of the given length and elements at position number. Result equal to: vary(element_list, variation_length)[number].