Skip to content

tucoopy.games.cost_sharing

Cost-sharing games (via savings).

This module constructs a TU worth game from stand-alone costs \(c_i\) and a dense table of coalition costs \(C(S)\) (length \(2^n\)) using the standard savings transformation:

\[ v(S) = \sum_{i \in S} c_i - C(S). \]
See Also

tucoopy.games.savings.savings_game

Examples:

>>> from tucoopy.games.cost_sharing import cost_sharing_game
>>> g = cost_sharing_game([2, 3], [0, 2, 3, 4])
>>> g.value(0b11)
1.0

cost_sharing_game

cost_sharing_game(
    individual_costs, coalition_costs, *, player_labels=None
)

Construct a cost-sharing game as a TU worth game (via savings).

Given:

  • individual (stand-alone) costs \(c_i\)
  • coalition costs \(C(S)\) for every coalition mask \(S\) (dense, length \(2^n\))

Define the savings game:

\[v(S) = \sum_{i \in S} c_i - C(S)\]

Parameters:

Name Type Description Default
individual_costs Sequence[float]

Stand-alone costs for each player.

required
coalition_costs Sequence[float]

Costs for each coalition (length \(2^n\)).

required
player_labels list of str

Optional labels for players.

None

Returns:

Type Description
Game

Cooperative game instance representing the cost-sharing game.

Raises:

Type Description
InvalidParameterError

If coalition_costs does not have length \(2^n\).

Examples:

>>> from tucoopy.games.cost_sharing import cost_sharing_game
>>> g = cost_sharing_game([2, 3], [0, 2, 3, 4])
>>> g.n_players
2
>>> g.value(1)
0.0
>>> g.value(3)
1.0