AIToolbox
A library that offers tools for AI problem solving.
|
This class represent a multi-armed bandit. More...
#include <AIToolbox/Bandit/Model.hpp>
Public Member Functions | |
template<typename... TupleArgs> | |
Model (TupleArgs... tupleArgs) | |
Basic constructor. More... | |
template<typename... Args> | |
Model (std::vector< std::tuple< Args... >> args) | |
Basic constructor. More... | |
decltype(auto) | sampleR (size_t a) const |
This function samples the specified bandit arm. More... | |
size_t | getA () const |
This function returns the number of arms of the bandit. More... | |
const std::vector< Dist > & | getArms () const |
This function returns a reference to the underlying arms. More... | |
This class represent a multi-armed bandit.
This class contains a set of distributions, each of which corresponds to a specific bandit arm. The arms are all assumed to be of the same family; we could work with different distributions but it would complicate the code for something that is not really commonly used.
The class is fairly easy to use, as one can only pull a given arm and obtain a sampled reward in return.
The distribution is assumed to be one of the standard C++ distributions. Custom ones may be used, as long as they can be sampled by passing a RandomEngine to their operator().
Dist | The distribution family to use for all arms. |
AIToolbox::Bandit::Model< Dist >::Model | ( | TupleArgs... | tupleArgs | ) |
Basic constructor.
We take as input a variable number of tuples (possibly containing different types). Each tuple is used to initialize a single arm.
The number of arms will be equal to the number of tuples passed as arguments.
tupleArgs | A set tuples, each containing the parameters to initialize an arm. |
AIToolbox::Bandit::Model< Dist >::Model | ( | std::vector< std::tuple< Args... >> | args | ) |
Basic constructor.
This constructor initializes each arm from one of the tuples contained by the parameter.
The number of arms will be equal to the size of the input vector.
args | The arguments with which to initialize the bandit arms. |
size_t AIToolbox::Bandit::Model< Dist >::getA |
This function returns the number of arms of the bandit.
const std::vector< Dist > & AIToolbox::Bandit::Model< Dist >::getArms |
This function returns a reference to the underlying arms.
decltype(auto) AIToolbox::Bandit::Model< Dist >::sampleR | ( | size_t | a | ) | const |
This function samples the specified bandit arm.
a | The arm to sample. |