Package schrodinger :: Package application :: Package desmond :: Module autopartition
[hide private]
[frames] | no frames]

Module autopartition

A module to provide multiset partition, combination and processor topology decomposition.

Copyright Schrodinger, LLC. All rights reserved.

Functions [hide private]
 
_next_multiset_comb(m, state)
 
_multicomb(m, k)
@type m: list of integer @param m: multiset.
 
_list2array(m, n)
 
_array2list(m)
 
all_multicomb(m)
Return all combinations for multiset m
 
get_next_partition(factors)
A partition generator
 
next_prime(n)
A prmie number generator that generates prime number less than or equal to n
 
get_prime_factors(n)
A function to generate all factorizations of a given integer n.
 
auto_partition(dims, nproc)
A function to calculate best cpu partition based on dimension and number of processor.
Variables [hide private]
  __package__ = 'schrodinger.application.desmond'
Function Details [hide private]

_next_multiset_comb(m, state)

 

To Do: convert it to a generator.

_multicomb(m, k)

 

@type m: list of integer 
@param m: multiset.

@type k: int
@param k: the total number of element that will show up in the combination.

@return the combination in an integer number array. 


for i in _multicomb([0, 0, 0, 1, 1, 2, 2, 2, 2, 2], 7):
    print i 
Above statement will generate below combinations:

[0, 0, 0, 1, 1, 2, 2]
[0, 0, 0, 1, 2, 2, 2]
[0, 0, 0, 2, 2, 2, 2]
[0, 0, 1, 1, 2, 2, 2]
[0, 0, 1, 2, 2, 2, 2]
[0, 0, 2, 2, 2, 2, 2]
[0, 1, 1, 2, 2, 2, 2]
[0, 1, 2, 2, 2, 2, 2]
[1, 1, 2, 2, 2, 2, 2]

@todo: provide a mapping function  

all_multicomb(m)

 

Return all combinations for multiset m

Parameters:
  • m (list of integer) - the array contains the maximum number of individual unique element in the multiset.

get_next_partition(factors)

 

A partition generator

Parameters:
  • factors (list of integer) - a list of prime numbers @return a three element tuple that represent the partition

To Do: this algorithm is still not very efficient due to the generation of duplicate combination. A vector partition function with restricted growth order will be a better option.

next_prime(n)

 

A prmie number generator that generates prime number less than or equal to n

Parameters:
  • n (int) - @return prime number

get_prime_factors(n)

 

A function to generate all factorizations of a given integer n.

Parameters:
  • n (int) - an integer to be factorized

    @return a list of prime factors.

auto_partition(dims, nproc)

 

A function to calculate best cpu partition based on dimension and number of processor. The object function to optimize:

Parameters:
  • dims (list of integer) - simulation box
  • nproc (int) - number of cores

    @return an three element integer array that represents the best partition.