PoliciesMultiPlayers.OracleFair module

OracleFair: a multi-player policy which uses a centralized intelligence to affect users an offset, each one take an orthogonal arm based on (offset + t) % nbBestArms, among the best arms.

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

  • And it is perfectly fair on every run: each chosen arm is played successively by each player.

  • Note that it IS affecting players on the best arms: it requires full knowledge of the means of the arms, not simply the number of arms.

  • Note that they need a perfect knowledge on the arms, even this is not physically plausible.

class PoliciesMultiPlayers.OracleFair.CyclingBest(nbArms, offset, bestArms=None)[source]

Bases: PoliciesMultiPlayers.BaseCentralizedPolicy.BaseCentralizedPolicy

CyclingBest: select an arm in the best ones (bestArms) as (offset + t) % (len(bestArms)), with offset being decided by the OracleFair multi-player policy.

__init__(nbArms, offset, bestArms=None)[source]

Cycling with an offset.

nbArms = None

Number of arms

offset = None

Offset

bestArms = None

List of index of the best arms to play

nb_bestArms = None

Number of best arms

t = None

Internal time

__str__()[source]

Return str(self).

startGame()[source]

Nothing to do.

getReward(arm, reward)[source]

Nothing to do.

choice()[source]

Chose cycling arm.

__module__ = 'PoliciesMultiPlayers.OracleFair'
class PoliciesMultiPlayers.OracleFair.OracleFair(nbPlayers, armsMAB, lower=0.0, amplitude=1.0)[source]

Bases: PoliciesMultiPlayers.BaseMPPolicy.BaseMPPolicy

OracleFair: a multi-player policy which uses a centralize intelligence to affect users an offset, each one take an orthogonal arm based on (offset + t) % nbArms.

__init__(nbPlayers, armsMAB, lower=0.0, amplitude=1.0)[source]
  • nbPlayers: number of players to create (in self._players).

  • armsMAB: MAB object that represents the arms.

Examples:

>>> import sys; sys.path.insert(0, '..'); from Environment import MAB; from Arms import Bernoulli
>>> import random; random.seed(0); import numpy as np; np.random.seed(0)
>>> problem = MAB({'arm_type': Bernoulli, 'params': [0.1, 0.5, 0.9]})  
...
>>> s = OracleFair(2, problem)
>>> [ child.choice() for child in s.children ]
[1, 2]
>>> [ child.choice() for child in s.children ]
[2, 1]
  • 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).

__module__ = 'PoliciesMultiPlayers.OracleFair'
_printNbCollisions()[source]

Print number of collisions.