Brush C++ API
A flexible interpretable machine learning framework
Loading...
Searching...
No Matches
Brush::MAB::Bandit Struct Reference

The Bandit struct represents a multi-armed bandit. More...

#include <bandit.h>

Collaboration diagram for Brush::MAB::Bandit:

Public Types

using Iter = tree<Node>::pre_order_iterator
 

Public Member Functions

 Bandit ()
 
 ~Bandit ()
 
 Bandit (string type, vector< string > arms)
 Constructor for the Bandit struct.
 
 Bandit (string type, map< string, float > arms_probs)
 Constructor for the Bandit struct.
 
void set_bandit ()
 Sets the bandit operator (policy).
 
void set_arms (vector< string > arms)
 Sets the arms of the bandit.
 
vector< stringget_arms ()
 Gets the arms of the bandit.
 
string get_type ()
 Gets the type of the bandit.
 
void set_type (string type)
 Sets the type of the bandit.
 
map< string, float > get_probs ()
 Gets the probabilities associated with each arm.
 
void set_probs (map< string, float > arms_probs)
 Sets the probabilities associated with each arm.
 
map< string, float > sample_probs (bool update=false)
 Samples the probabilities associated with each arm using the policy.
 
string choose ()
 Selects an arm.
 
void update (string arm, float reward)
 Updates the bandit's state based on the chosen arm and the received reward.
 

Public Attributes

std::shared_ptr< BanditOperatorpbandit
 A shared pointer to the bandit operator (policy).
 
std::string type
 
vector< stringarms
 
std::map< string, float > probabilities
 

Detailed Description

The Bandit struct represents a multi-armed bandit.

The Bandit struct encapsulates the bandit operator (policy) and provides\ methods to set and get the arms, type, and probabilities of the bandit. It also provides a method to update the bandit's state based on the chosen arm and the received reward.

Definition at line 31 of file bandit.h.

Member Typedef Documentation

◆ Iter

using Brush::MAB::Bandit::Iter = tree<Node>::pre_order_iterator

Definition at line 33 of file bandit.h.

Constructor & Destructor Documentation

◆ Bandit() [1/3]

Brush::MAB::Bandit::Bandit ( )

Definition at line 7 of file bandit.cpp.

Here is the call graph for this function:

◆ ~Bandit()

Brush::MAB::Bandit::~Bandit ( )
inline

Definition at line 48 of file bandit.h.

◆ Bandit() [2/3]

Brush::MAB::Bandit::Bandit ( string type,
vector< string > arms )

Constructor for the Bandit struct.

Parameters
typeThe type of the bandit.
armsThe arms of the bandit.

Definition at line 14 of file bandit.cpp.

Here is the call graph for this function:

◆ Bandit() [3/3]

Brush::MAB::Bandit::Bandit ( string type,
map< string, float > arms_probs )

Constructor for the Bandit struct.

Parameters
typeThe type of the bandit.
arms_probsThe arms and their associated probabilities.

Definition at line 26 of file bandit.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ choose()

string Brush::MAB::Bandit::choose ( )

Selects an arm.

Returns
T The selected arm from the tree.

Definition at line 90 of file bandit.cpp.

◆ get_arms()

vector< string > Brush::MAB::Bandit::get_arms ( )

Gets the arms of the bandit.

Definition at line 59 of file bandit.cpp.

◆ get_probs()

map< string, float > Brush::MAB::Bandit::get_probs ( )

Gets the probabilities associated with each arm.

Definition at line 67 of file bandit.cpp.

◆ get_type()

string Brush::MAB::Bandit::get_type ( )

Gets the type of the bandit.

Definition at line 51 of file bandit.cpp.

◆ sample_probs()

map< string, float > Brush::MAB::Bandit::sample_probs ( bool update = false)

Samples the probabilities associated with each arm using the policy.

Parameters
updateFlag indicating whether to update the bandit's state, or just return the current probabilities.
Returns
The sampled probabilities associated with each arm.

Definition at line 75 of file bandit.cpp.

Here is the call graph for this function:

◆ set_arms()

void Brush::MAB::Bandit::set_arms ( vector< string > arms)

Sets the arms of the bandit.

Definition at line 63 of file bandit.cpp.

Here is the caller graph for this function:

◆ set_bandit()

void Brush::MAB::Bandit::set_bandit ( )

Sets the bandit operator (policy).

Definition at line 37 of file bandit.cpp.

Here is the caller graph for this function:

◆ set_probs()

void Brush::MAB::Bandit::set_probs ( map< string, float > arms_probs)

Sets the probabilities associated with each arm.

Parameters
arms_probsThe arms and their associated probabilities.

Definition at line 71 of file bandit.cpp.

Here is the caller graph for this function:

◆ set_type()

void Brush::MAB::Bandit::set_type ( string type)

Sets the type of the bandit.

Definition at line 55 of file bandit.cpp.

Here is the caller graph for this function:

◆ update()

void Brush::MAB::Bandit::update ( string arm,
float reward )

Updates the bandit's state based on the chosen arm and the received reward.

Parameters
armThe chosen arm.
rewardThe received reward.

Definition at line 94 of file bandit.cpp.

Here is the caller graph for this function:

Member Data Documentation

◆ arms

vector<string> Brush::MAB::Bandit::arms

The arms of the bandit.

Definition at line 43 of file bandit.h.

◆ pbandit

std::shared_ptr<BanditOperator> Brush::MAB::Bandit::pbandit

A shared pointer to the bandit operator (policy).

Definition at line 39 of file bandit.h.

◆ probabilities

std::map<string, float> Brush::MAB::Bandit::probabilities

The probabilities associated with each arm.

Definition at line 45 of file bandit.h.

◆ type

std::string Brush::MAB::Bandit::type

The type of the bandit.

Definition at line 42 of file bandit.h.


The documentation for this struct was generated from the following files: