AIToolbox
A library that offers tools for AI problem solving.
AIToolbox::Bandit::Model< Dist > Class Template Reference

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...
 

Detailed Description

template<typename Dist>
class AIToolbox::Bandit::Model< Dist >

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().

Template Parameters
DistThe distribution family to use for all arms.

Constructor & Destructor Documentation

◆ Model() [1/2]

template<typename Dist >
template<typename... TupleArgs>
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.

Parameters
tupleArgsA set tuples, each containing the parameters to initialize an arm.

◆ Model() [2/2]

template<typename Dist >
template<typename... Args>
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.

Parameters
argsThe arguments with which to initialize the bandit arms.

Member Function Documentation

◆ getA()

template<typename Dist >
size_t AIToolbox::Bandit::Model< Dist >::getA

This function returns the number of arms of the bandit.

Returns
The number of arms of the bandit.

◆ getArms()

template<typename Dist >
const std::vector< Dist > & AIToolbox::Bandit::Model< Dist >::getArms

This function returns a reference to the underlying arms.

Returns
A vector containing the arms of the bandit.

◆ sampleR()

template<typename Dist >
decltype(auto) AIToolbox::Bandit::Model< Dist >::sampleR ( size_t  a) const

This function samples the specified bandit arm.

Parameters
aThe arm to sample.
Returns
A return sampled from the arm's underlying distribution.

The documentation for this class was generated from the following file: