6 A base class for the various bandit implementations.
8 This class defines several abstract methods and properties that must be
9 implemented by any k-armed bandit implementation. This ensures consistent
10 APIs across all of them.
15 Initialize the object with a set number of arms.
17 @param k The number of arms this bandit should have. This must be an
18 integer greater than zero.
19 @exception ValueError if k is not an integer greater than zero.
21 if not isinstance(k, int)
or k <= 0:
22 raise ValueError(
'k must be an integer greater than 0.')
28 Return the number of arms this bandit has.
29 @return An int greater than or equal to one.
36 The method to select one of the arms of the bandit.
38 When implemented, this method should return the reward obtained when
39 selecting the given arm index.
40 @param index Some sort of index representation to select which arms to
41 get rewards from. Typically, this will be a single integer or some
42 sort of list, array, etc. of integers.
44 raise NotImplementedError(
"Subclass does not implement select method.")
49 Return the true reward values of the bandit.
51 When implemented, this should provide the user with the complete truth
52 of the bandit's state at the moment called. It is up to the
53 implementation what exact information this is.
55 raise NotImplementedError(
56 'Subclass does not implement trueValues method.')
A base class for the various bandit implementations.
int k(self)
Return the number of arms this bandit has.
select(self, index)
The method to select one of the arms of the bandit.
None __init__(self, int k)
Initialize the object with a set number of arms.
trueValues(self)
Return the true reward values of the bandit.