PoliciesMultiPlayers.CentralizedFixed module

CentralizedFixed: a multi-player policy which uses a centralized intelligence to affect users to a FIXED arm.

  • It allows to have absolutely no collision, if there is more channels than users (always assumed).

  • But it is NOT fair on ONE run: the best arm is played only by one player.

  • Note that in average, it is fair (who plays the best arm is randomly decided).

  • Note that it is NOT affecting players on the best arms: it has no knowledge of the means of the arms, only of the number of arms nbArms.

class PoliciesMultiPlayers.CentralizedFixed.Fixed(nbArms, armIndex, lower=0.0, amplitude=1.0)[source]

Bases: PoliciesMultiPlayers.BaseCentralizedPolicy.BaseCentralizedPolicy

Fixed: always select a fixed arm, as decided by the CentralizedFixed multi-player policy.

__init__(nbArms, armIndex, lower=0.0, amplitude=1.0)[source]

Fixed on this arm.

nbArms = None

Number of arms

armIndex = None

Index of the fixed arm

__str__()[source]

Return str(self).

startGame()[source]

Nothing to do.

getReward(arm, reward)[source]

Nothing to do.

choice()[source]

Chose fixed arm.

__module__ = 'PoliciesMultiPlayers.CentralizedFixed'
class PoliciesMultiPlayers.CentralizedFixed.CentralizedFixed(nbPlayers, nbArms)[source]

Bases: PoliciesMultiPlayers.BaseMPPolicy.BaseMPPolicy

CentralizedFixed: a multi-player policy which uses a centralized intelligence to affect users to a FIXED arm.

__init__(nbPlayers, nbArms)[source]
  • nbPlayers: number of players to create (in self._players).

  • nbArms: number of arms.

Examples:

>>> import random; random.seed(0); import numpy as np; np.random.seed(0)
>>> s = CentralizedFixed(2, 3)
>>> [ child.choice() for child in s.children ]
[2, 1]
>>> [ child.choice() for child in s.children ]
[2, 1]
>>> import random; random.seed(0); import numpy as np; np.random.seed(0)
>>> s = CentralizedFixed(4, 8)
>>> [ child.choice() for child in s.children ]
[7, 6, 1, 2]
>>> [ child.choice() for child in s.children ]
[7, 6, 1, 2]
>>> s = CentralizedFixed(10, 14)
  • To get a list of usable players, use s.children.

  • Warning: s._players is for internal use

nbPlayers = None

Number of players

nbArms = None

Number of arms

children = None

List of children, fake algorithms

__str__()[source]

Return str(self).

_printNbCollisions()[source]

Print number of collisions.

_startGame_one(playerId)[source]

Pass the call to the player algorithm.

_getReward_one(playerId, arm, reward)[source]

Pass the call to the player algorithm.

__module__ = 'PoliciesMultiPlayers.CentralizedFixed'
_choice_one(playerId)[source]

Pass the call to the player algorithm.