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.
-
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
- 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.
-
classmethod
Brute Force Search Algorithms¶
-
class
games.analysis.search_nash.
BruteNash
¶ Collection of methods for brute force calculation of Nash equilibrium in noncooperative games.
-
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.
-
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]
-
classmethod
-
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.
-
static
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