Analysis of Games

About This Package

This package deals with analysis of games, equilibrium-wises or otherwise.

PoA calculation for Congestion Games

Module for calculating price of anarchy for a general class of congestion games, where U_i(a) = sum over resources ( value of resource * C_i(players that cover resource r))

class games.analysis.congestion_poa.CongestionPoA

PoA Calculation for a general class of congestion games. Results in an LP with 4^n constraints, with n being the number of players.

TOL

Significant figure for rounding to 0.

Type

int

classmethod primal_poa(n: int, w: Callable[[List[int]], float], flist: List[Callable[[List[int]], float]]) → Tuple[numpy.ndarray, ...]

Primal program for calculating the price of anarcy in a congestion game.

Parameters
  • n (int) – Number of players in game.

  • w (Callable[[List[int]], float]) – What players are covering resource -> utility for the system.

  • flist (List[Callable[[List[int]], float]]) – What players are covering resource -> Utility for player i, for i in the list.

Returns

LP Parameters for getting PoA calculations.

Return type

Tuple[np.ndarray, ..]

classmethod worst_case(theta: List[float], N: int) → Tuple[List[float], List[List[tuple]]]

Gives list of player actions and values of the worst case congestion game that attains PoA.

Parameters
  • theta (List[float]) – values associated with each allocation type - given by the primal program for PoA.

  • N (int) – Number of players.

Returns

(actions: list of possible actions for each player, values: value of each resource in list)

Return type

Tuple[List[float], List[List[tuple]]]

Brute Force Search Algorithms

class games.analysis.search_nash.BruteNash

Collection of methods for brute force calculation of Nash equilibrium in noncooperative games.

TOLERANCE

Numerical tolerance for float point comparisons.

Type

float

classmethod find_NCnash(game: games.types.game.Game, add=True) → List[games.types.equilibrium.PureEq]

Find nash equilibrium of a specified noncooperative game through brute force search.

Parameters
  • game (Game) – Noncooperative Game with finite action sets.

  • add (bool, optional) – Whether to add the calculated equilibrium to Game.eq member.

Returns

List of calculated Nash equilibrium.

Return type

List[PureEq]

classmethod find_nash(payoffs: List[numpy.ndarray]) → List[games.types.equilibrium.PureEq]

Find nash equilibrium of specified list of payoff matrices through brute force search.

Parameters

payoffs (List[np.ndarray]) – List of payoff arrays defining the utilities of the game.

Returns

List of calculated Nash equilibrium.

Return type

List[PureEq]

static game_to_payoffs(game: games.types.game.Game) → List[numpy.ndarray]

Turn a noncooperative game into strategic form through calculation of payoff arrays.

Parameters

game (Game) – Noncooperative game, all players must have a finite number of actioms.

Returns

List of payoff arrays defining the game.

Return type

List[np.ndarray]

class games.analysis.search_nash.BrutePoA

Collection of methods used for calculating price of anarchy/stability. We use the designation PoA = min (welfare of pne / welfare of optimal) over all pne and PoS = max (welfare of pne / welfare of optimal) over all pne.

static game_to_welfare(game: games.types.misc.WelfareGame) → numpy.ndarray

Retrieve the Welfare matrix from a Welfare Game.

Parameters

game (WelfareGame) – Welfare Game, all players must have a finite action set.

Returns

Welfare matrix.

Return type

np.ndarray

static get_argopt(welfare: numpy.ndarray) → Tuple[int, ...]

get index of where maximum is attained for a welfare matrix.

Parameters

welfare (np.ndarray) – Welfare matrix.

Returns

An index where maximum is attained (may not be unique though).

Return type

Tuple[int, ..]

static set_poas(list_pureeq: List[games.types.equilibrium.PureEq], welfare: numpy.ndarray) → Tuple[float, float]

Get price of anarchy and prince of stability based on the list of pure equilibrium of the game.

Parameters
  • list_pureeq (List[PureEq]) – List of pure equilibria of the given game

  • welfare (np.ndarray) – Welfare matrix of the game.

Returns

PoA, PoS

Return type

Tuple[float, float]

Zero Sum Game Calculations

games.analysis.zerosum.set_msec(self)

set mixed security values and policies

games.analysis.zerosum.set_sec(self)

set pure security values and policies

Indices and tables