Brush C++ API
A flexible interpretable machine learning framework
Loading...
Searching...
No Matches
thompson.h
Go to the documentation of this file.
1#include "bandit_operator.h"
2
3// #include <boost/random.hpp>
4// #include <boost/random/gamma_distribution.hpp>
5
6#include <boost/math/distributions/gamma.hpp>
7
8// // https://www.boost.org/doc/libs/1_85_0/doc/html/boost/random/beta_distribution.html
9// #include <boost/random/beta_distribution.hpp>
10
11#include "../util/utils.h" // to use random generator
12
13#ifndef THOMPSON_H
14#define THOMPSON_H
15
16namespace Brush {
17namespace MAB {
18
19template <typename T> // TODO: make templates to have a requirement on T (so compilation is faster)
21{
22public:
23 ThompsonSamplingBandit(vector<T> arms, bool dynamic=false);
24 ThompsonSamplingBandit(map<T, float> arms_probs, bool dynamic=false);
26
27 std::map<T, float> sample_probs(bool update);
28 T choose(const VectorXf& context);
29 void update(T arm, float reward, VectorXf& context);
30private:
32 float C = 250;
33
34 std::map<T, float> alphas;
35 std::map<T, float> betas;
36};
37
38} // MAB
39} // Brush
40
41#endif // THOMPSON_H
BanditOperator(vector< T > arms)
Constructs a BanditOperator object with a vector of arms.
std::map< T, float > alphas
Definition thompson.h:34
ThompsonSamplingBandit(vector< T > arms, bool dynamic=false)
Definition thompson.cpp:7
std::map< T, float > sample_probs(bool update)
Samples the probabilities of the arms.
Definition thompson.cpp:30
std::map< T, float > betas
Definition thompson.h:35
void update(T arm, float reward, VectorXf &context)
Updates the reward for a specific arm.
Definition thompson.cpp:88
T choose(const VectorXf &context)
Chooses an arm based on the given tree and fitness. Should call sample_probs internally.
Definition thompson.cpp:81
< nsga2 selection operator for getting the front
Definition bandit.cpp:4