Skip to content

tucoopy.properties.cost_games

Cost game recognizers.

This module provides simple heuristics for recognizing and validating cost-style games, where costs are represented as negative worths (so \(v(S) \leq 0\)).

Examples:

>>> from tucoopy.base.game import Game
>>> from tucoopy.properties.cost_games import is_cost_game
>>> g = Game.from_coalitions(n_players=2, values={(): 0.0, (0,): -1.0, (1,): -2.0, (0, 1): -3.0})
>>> is_cost_game(g)
True

is_cost_game

is_cost_game(game, *, eps=1e-12, max_players=12)

Heuristic recognizer for "cost games" represented as negative values.

Convention used in this library:

  • TU games always have \(v(\varnothing)=0\).
  • Many cost-style models store costs as negative worths (\(v(S) \leq 0\)).

This recognizer checks:

  • \(v(S) \leq \epsilon\) for all \(S\) (non-positive, up to tolerance)
  • monotone non-increasing: if \(S \subseteq T\) then \(v(S) \geq v(T) - \epsilon\)

validate_cost_game

validate_cost_game(game, *, eps=1e-12, max_players=12)

Validate that a game matches the library's "cost-game" convention.

Parameters:

Name Type Description Default
game GameProtocol

TU game.

required
eps float

Numerical tolerance.

1e-12
max_players int | None

Fail fast if game.n_players exceeds this bound (check is exponential).

12

Raises:

Type Description
InvalidGameError

If the game fails :func:is_cost_game.