IntegerPartitioner2D

Provides a tree-based approach to obtain the different integer partitions possible when n balls are divided into different numbers of boxes

partition_data: dict

 

@classmethod
iter_partitions(cls, boxes, balls, *, allowed=None): 

Yield multiplicity tables without caching or collecting their tree.

Rows sum to boxes and columns to balls. allowed can forbid individual cells. Small margins are assigned first; the final row and column are determined by the remaining capacities.

 

@classmethod
get_partitions(cls, boxes, balls): 

LLM Docstring

Enumerate all ways to distribute balls into boxes (a 2-D integer partition / contingency-table enumeration), sorting both descending and undoing the sort on the result.

  • boxes: np.ndarray

    the box capacities

  • balls: np.ndarray

    the ball counts

  • :returns: np.ndarray

    the enumerated distributions


Feedback

Examples

Templates

Documentation