set_functions
This module gathers classes defining set functions.
- class ISetFunction(values, ensemble=None, validate=True)
Bases:
ABC
This class represents a set function.
- Parameters
values (Union[List, Dict, ISetFunction]) –
- values of the function as either:
a list ordered as a binary mask on the ensemble
a dictionary with
HashableSet
as keysanother
SetFunction
object (used for casting)
ensemble (Union[List, None]) – ensemble from which to build the set (its default value is \(\mathbf{Z}^+\))
validate (bool) – if
True
, raises an error when building an invalid instance
- __call__(*args, **kwargs)
Call this set function on the set composed of all provided arguments
- Returns
value
- property as_capacity: Self
Return the instance if it respects its properties.
- The properties are the following:
the set function is defined on a power set
the set function is a game
the set function is monotonous
the set function is normal
- Raises
KeyError –
if set function is not defined on a power set
ValueError –
if set function is not a game
if set function is not monotonous
if set function is not normal
- property ensemble: List
Return a copy of the ensemble of this set function.
- Returns
- property interaction_index: DataFrame
Return interaction index matrix.
- Returns
Note
Formula is based on [GKM08].
- property is_additive: bool
Check if the set function is additive or not.
Check that \(\forall S, T \subseteq N, S \cap T = \emptyset, \mu(S \cup T) = \mu(S) + \mu(T)\)
- Returns
Note
use
math.isclose()
to add tolerance
- property is_capacity: bool
Check if the instance is a capacity.
- The properties are the following:
the set function is defined on a power set
the set function is a game
the set function is monotonous
the set function is normal
- Returns
True
if instance is a capacity,False
otherwise
- property is_cardinality_based: bool
Check if the set function is cardinality-based.
Check that \(\forall T \subseteq N, \mu(T)\) only depends on T cardinality.
- Returns
Note
use
math.isclose()
to add tolerance
- property is_game: bool
Check if the set function is a game.
Check \(\nu(\emptyset) = 0\)
- Returns
- property is_monotonous: bool
Check if the set function is monotonous.
Check that \(\forall S, T \subseteq N, S \subseteq T \Rightarrow \nu(S) \leq \nu(T)\)
- Returns
Note
use
math.isclose()
to add tolerance
- property is_normal: bool
Check if the set function is normalized.
Check set_function is a capacity, and that \(\nu(N) = 1\)
- Returns
Note
use
math.isclose()
to add tolerance
- property is_powerset_function: bool
Check if the set function is defined on a power set.
Check length of set_function is a power of 2.
- Returns
- property size: int
Return the size of the ensemble of this set function.
- Returns
- property values: Dict
Return a copy of the dictionary defining this set function.
- Returns