=============== CoalitionalGame =============== Constructor ------------ Creating a CoalitionalGame object takes a dictionary where the key is a tuple (or frozenset) whose members are the members of a coalition and whose values are the values of that coalition. Additionally there is an optional boolean value isCost (default False) indicating this is a cost game. The constructor will "fill in" dictionary values not given according to the rule that the value of a coalition is the highest value of any subcoaltions where there is an explicit value. The empty coalition is assumed to have value zero. from coalitions.coalitionalgame import CoalitionalGame vals = {('L1', 'R'):1,('L2', 'R'):1} cgg = CoalitionalGame(vals) Methods --------- get_is_core(self, imputation) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Return a boolean indicating whether the passed in imputation is part of the core. Because of the perils of checking floating point equlities, this method may return the wrong answer. This module comes with no guarentees in any case. get_is_additive(self) ~~~~~~~~~~~~~~~~~~~~~~ Returns a boolean. get_is_simple(self) ~~~~~~~~~~~~~~~~~~~~ Returns a boolean get_banzhaf_values(self) ~~~~~~~~~~~~~~~~~~~~~~~~~~ Returns a dict where the key is the player label and the value is the Banzhaf value. get_shapley_values(self) ~~~~~~~~~~~~~~~~~~~~~~~~~ Returns a dict where the key is the player label and the value is the Shapley value. simulate_shapley_values(self, perms) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ For large player sets it may not be feasible to calculate the Shapley values precisely, since this requires checking the values of all subcoalitions. This method calculates an approximate Shapley value using a fixed number of permutations. Returns a dict where the key is th player label and the value is the Shapley value. zero_normalize(self) ~~~~~~~~~~~~~~~~~~~~~ return a pair theGame, newgrand where game is the zero-mormalized new game and newgrand is the value of the grand coalition in the new game ( 1, 0 or -1). is_equivaluent(self, game): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Check whether the the passed game is stratgeically equivalent to this game. returns a boolean. get_is_monotonic(self) ~~~~~~~~~~~~~~~~~~~~~~~~ returns a boolean get_is_superadditive(self) ~~~~~~~~~~~~~~~~~~~~~~~~~~ Returns a boolean create_voting_game(player_strengths, crit) ------------------------------------------- This consruction method takes a dictionary with key player_type and value voting strength, plus the critival value form the vote to carry. So long as the sums of the voting strengths of the players of a coalition is greater than or equal to the critical value, the coalition value is 1. Otherwise it is zero.