tucoopy.games.unanimity¶
Unanimity games.¶
The unanimity game \(u_T\) assigns a positive value to coalitions that contain a fixed coalition \(T\):
\[ u_T(S) = \begin{cases} v, & \text{if } T \subseteq S, \\ 0, & \text{otherwise}. \end{cases} \]
Unanimity games form a convenient basis for TU games (via Harsanyi dividends).
See Also
tucoopy.games.glove.glove_game tucoopy.transforms.harsanyi.harsanyi_dividends
Examples:
>>> from tucoopy.games.unanimity import unanimity_game
>>> g = unanimity_game([0, 1], value=2.0, n_players=3)
>>> g.value(0b111)
2.0
unanimity_game ¶
unanimity_game(
coalition,
*,
value=1.0,
n_players=None,
player_labels=None,
)
Construct a unanimity game \(u_T\) (TU).
Let \(v\) denote the value. Given a coalition \(S\) define:
\[ u_T(S) = \begin{cases} v & \text{ if } T \subseteq S \\ 0 & \text{ otherwise } \end{cases} \]
Provide either:
- coalition as bitmask and n_players, or
- coalition as iterable of players and n_players inferred from labels/explicit arg.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coalition | int or Iterable[int] | Coalition as bitmask or iterable of player indices. | required |
value | float | Value assigned if T is a subset of S (default 1.0). | 1.0 |
n_players | int | Number of players (required if coalition is bitmask or no labels provided). | None |
player_labels | list of str | Optional labels for players. | None |
Returns:
| Type | Description |
|---|---|
Game | Cooperative game instance representing the unanimity game. |
Raises:
| Type | Description |
|---|---|
InvalidParameterError | If n_players is missing or fewer than 1 player. |
Examples:
>>> from tucoopy.games.unanimity import unanimity_game
>>> g = unanimity_game([0, 1], value=2.0, n_players=3)
>>> g.n_players
3
>>> g.value(3)
2.0
>>> g.value(7)
2.0