Brush C++ API
A flexible interpretable machine learning framework
Toggle main menu visibility
Loading...
Searching...
No Matches
thompson.h
Go to the documentation of this file.
1
#include "
bandit_operator.h
"
2
3
#include "
../util/utils.h
"
// to use random generator
4
5
#ifndef THOMPSON_H
6
#define THOMPSON_H
7
8
namespace
Brush
{
9
namespace
MAB
{
10
11
class
ThompsonSamplingBandit
:
public
BanditOperator
12
{
13
public
:
14
ThompsonSamplingBandit
(vector<string> arms,
bool
dynamic=
false
);
15
ThompsonSamplingBandit
(map<string, float> arms_probs,
bool
dynamic=
false
);
16
~ThompsonSamplingBandit
(){};
17
18
std::map<string, float>
sample_probs
(
bool
update
);
19
string
choose
();
20
void
update
(
string
arm,
float
reward);
21
private
:
22
bool
dynamic_update
;
23
float
C
= 250;
24
25
std::map<string, float>
alphas
;
26
std::map<string, float>
betas
;
27
};
28
29
}
// MAB
30
}
// Brush
31
32
#endif
// THOMPSON_H
bandit_operator.h
Brush::MAB::BanditOperator::BanditOperator
BanditOperator(vector< string > arms)
Constructs a BanditOperator object with a vector of arms.
Definition
bandit_operator.cpp:6
Brush::MAB::ThompsonSamplingBandit::dynamic_update
bool dynamic_update
Definition
thompson.h:22
Brush::MAB::ThompsonSamplingBandit::choose
string choose()
Chooses an arm based on the given tree and fitness. Should call sample_probs internally.
Definition
thompson.cpp:54
Brush::MAB::ThompsonSamplingBandit::sample_probs
std::map< string, float > sample_probs(bool update)
Samples the probabilities of the arms.
Definition
thompson.cpp:27
Brush::MAB::ThompsonSamplingBandit::~ThompsonSamplingBandit
~ThompsonSamplingBandit()
Definition
thompson.h:16
Brush::MAB::ThompsonSamplingBandit::update
void update(string arm, float reward)
Updates the reward for a specific arm.
Definition
thompson.cpp:60
Brush::MAB::ThompsonSamplingBandit::alphas
std::map< string, float > alphas
Definition
thompson.h:25
Brush::MAB::ThompsonSamplingBandit::ThompsonSamplingBandit
ThompsonSamplingBandit(vector< string > arms, bool dynamic=false)
Definition
thompson.cpp:6
Brush::MAB::ThompsonSamplingBandit::C
float C
Definition
thompson.h:23
Brush::MAB::ThompsonSamplingBandit::betas
std::map< string, float > betas
Definition
thompson.h:26
Brush::MAB
Definition
bandit.cpp:4
Brush
< nsga2 selection operator for getting the front
Definition
bandit.cpp:3
utils.h
src
bandit
thompson.h
Generated by
1.17.0