Source code for Policies.TakeFixedArm

# -*- coding: utf-8 -*-
""" TakeFixedArm: always select a fixed arm.
This is the perfect static policy if armIndex = bestArmIndex (not realistic, for test only).
"""
from __future__ import division, print_function  # Python 2 compatibility

__author__ = "Lilian Besson"
__version__ = "0.9"

try:
    from .BasePolicy import BasePolicy
except ImportError:
    from BasePolicy import BasePolicy


[docs]class TakeFixedArm(BasePolicy): """ TakeFixedArm: always select a fixed arm. This is the perfect static policy if armIndex = bestArmIndex (not realistic, for test only). """
[docs] def __init__(self, nbArms, armIndex=None, lower=0., amplitude=1.): self.nbArms = nbArms #: Number of arms if armIndex is None: armIndex = 0 self.armIndex = armIndex #: Fixed arm
[docs] def __str__(self): return "TakeFixedArm({})".format(self.armIndex)
[docs] def startGame(self): """Nothing to do.""" pass
[docs] def getReward(self, arm, reward): """Nothing to do.""" pass
[docs] def choice(self): """Always the same choice.""" return self.armIndex
[docs] def choiceWithRank(self, rank=1): """ Ignore the rank.""" return self.choice()