Gambling pool

gambling_pool.pspace = ('W', 'D', 'L')

The set of possible football match outcomes (Win, Draw, or Lose)

class gambling_pool.Gamble(W, D, L)

Gamble on the outcome of a football match

With each possible match outcome, the gamble assigns a payoff (a Real); it corresponds to winnings if it is positive, to losses if it is negative.

D

Alias for field number 1

L

Alias for field number 2

W

Alias for field number 0

gambling_pool.lp_setup(lp, accdss)[source]

Set up the basic linear feasibility problem defining the gambling pool

A number of players will form a gambling pool:

  • Each player states which gambles he finds acceptable, i.e., which have an expected payoff that is nonnegative
  • If there is a bet between the players, a gamble is assigned to each of them; from the player’s perspective, the assigned gamble should be acceptable, meaning that is a positive linear combination of the gambles that that player has stated to be acceptable
  • The stake is assumed to be one, i.e., the assigned gamble’s lowest payoff is -1.
  • There is a bet between the players if the gambles assigned to the players sum up to one for each possible match outcome and the assigned gambles do not all have identically zero payoff
  • An important quantity for each player is the ‘lower prevision’ of the gamble assigned to him: the greatest lower bound on the player’s expected payoff for the assigned gamble that can be deduced from the player’s stated acceptable gambles
  • The objective is to maximize the sum of the lower previsions, possibly under additional constraints
Parameters:
Returns:

the set up problem object

Return type:

ecyglpki.Problem

gambling_pool.lp_assign(accdss)[source]

Assign gambles to all players that maximize the sum of lower previsions

Parameters:accdss (dict of str (player id) to list of Gamble) – the gambles accepted by the players
Returns:the gamble assigned to the players and the corresponding lower prevision value
Return type:dict of str (player id) to {'gamble': Gamble, 'lpr': float}
>>> Agambles = [Gamble(.5, .25, -1), Gamble(1, -1, -1)]
>>> Bgambles = [Gamble(-1, -1, 2), Gamble(1, .5, -.25)]
>>> Cgambles = [Gamble(-1, 0, -1)]
>>> accdss = {'Alice': Agambles, 'Bob': Bgambles, 'Cthulhu': Cgambles}
>>> solution = lp_assign(accdss)
>>> assert solution == (
...     {'Alice': {'gamble': Gamble(W=2.0, D=-1.0, L=-1.0), 'lpr': 0.5},
...      'Bob': {'gamble': Gamble(W=-1.0, D=-1.0, L=2.0), 'lpr': 0.0},
...      'Cthulhu': {'gamble': Gamble(W=-1.0, D=2.0, L=-1.0), 'lpr': 2.0}}
... )
gambling_pool.milp_assign(accdss)[source]

Assign gambles to some players that maximize the sum of lower previsions

As compared to lp_assign, we now try to make the bet fair in the sense that for each player the lower prevision for the assigned gamble is equal to the other player’s lower prevision, or the gamble assigned to the player is zero for all outcomes.

Parameters:accdss (dict of str (player id) to list of Gamble) – the gambles accepted by the players
Returns:the gamble assigned to the players and the corresponding lower prevision value
Return type:dict of str (player id) to {'gamble': Gamble, 'lpr': float}
>>> Agambles = [Gamble(.5, .25, -1), Gamble(1, -1, -1)]
>>> Bgambles = [Gamble(-1, -1, 2), Gamble(1, .5, -.25)]
>>> Cgambles = [Gamble(-1, 0, -1)]
>>> accdss = {'Alice': Agambles, 'Bob': Bgambles, 'Cthulhu': Cgambles}
>>> solution = milp_assign(accdss)
>>> for player, data in solution.items():  # round floats for doctest
...     solution[player]['lpr'] = round(data['lpr'], 2)
...     solution[player]['gamble'] = Gamble(round(data['gamble'].W, 2),
...                                         round(data['gamble'].D, 2),
...                                         round(data['gamble'].L, 2))
>>> assert solution == (
...     {'Alice': {'gamble': Gamble(W=1.4, D=0.0, L=-1.0), 'lpr': 0.4},
...      'Bob': {'gamble': Gamble(W=-0.4, D=-0.4, L=2.0), 'lpr': 0.4},
...      'Cthulhu': {'gamble': Gamble(W=-1.0, D=0.4, L=-1.0), 'lpr': 0.4}}
... )