Produces the complement space of the combination space, useful for debugging
and the multiprocessing function.
Args:
combination_space (OrderedSet):
ordered set of target combinations (coalitions).
elements (list):
list of players.
lesioned (Optional[any]):
leseioned element that will not be present in any combination but every complement
Returns:
Type |
Description |
OrderedSet
|
complements to be passed for lesioning.
|
Source code in msapy/msa.py
| @typechecked
def make_complement_space(*,
combination_space: OrderedSet,
elements: list,
lesioned: Optional[any] = None) -> OrderedSet:
"""
Produces the complement space of the combination space, useful for debugging
and the multiprocessing function.
Args:
combination_space (OrderedSet):
ordered set of target combinations (coalitions).
elements (list):
list of players.
lesioned (Optional[any]):
leseioned element that will not be present in any combination but every complement
Returns:
(OrderedSet): complements to be passed for lesioning.
"""
_check_valid_elements(elements)
elements = frozenset(elements)
_check_valid_combination_space(combination_space, elements, lesioned)
complement_space = OrderedSet()
# iterate over all combinations and take their difference from set elements to find complements
for combination in combination_space:
complement_space.add(tuple(elements.difference(combination)))
return complement_space
|