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

A virtual class representing a bandit operator. More...

#include <bandit_operator.h>

Inheritance diagram for Brush::MAB::BanditOperator:
Collaboration diagram for Brush::MAB::BanditOperator:

Public Member Functions

 BanditOperator (vector< string > arms)
 Constructs a BanditOperator object with a vector of arms.
 
 BanditOperator (map< string, float > arms_probs)
 Constructs a BanditOperator object with a map of arms and their probabilities.
 
 ~BanditOperator ()
 
virtual std::map< string, float > sample_probs (bool update)
 Samples the probabilities of the arms.
 
virtual string choose ()
 Chooses an arm based on the given tree and fitness. Should call sample_probs internally.
 
virtual void update (string arm, float reward)
 Updates the reward for a specific arm.
 

Protected Attributes

std::map< string, float > probabilities
 

Private Types

using Iter = tree<Node>::pre_order_iterator
 

Detailed Description

A virtual class representing a bandit operator.

This class provides functionality for sampling probabilities and updating rewards for different arms. The bandit should somehow behave stocasticaly when called twice in a row without being rewarded, because some mutations may require multiple sampling from the search space. Also, the bandit should have a functionality to return smapling probabilities, instead of just the chosen arm.

Template Parameters
TThe type of the arms.

Definition at line 21 of file bandit_operator.h.

Member Typedef Documentation

◆ Iter

using Brush::MAB::BanditOperator::Iter = tree<Node>::pre_order_iterator
private

Definition at line 23 of file bandit_operator.h.

Constructor & Destructor Documentation

◆ BanditOperator() [1/2]

Brush::MAB::BanditOperator::BanditOperator ( vector< string > arms)

Constructs a BanditOperator object with a vector of arms.

Parameters
armsThe vector of arms.

Definition at line 6 of file bandit_operator.cpp.

Here is the caller graph for this function:

◆ BanditOperator() [2/2]

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

Constructs a BanditOperator object with a map of arms and their probabilities.

Parameters
arms_probsThe map of arms and their probabilities.

Definition at line 17 of file bandit_operator.cpp.

◆ ~BanditOperator()

Brush::MAB::BanditOperator::~BanditOperator ( )
inline

Definition at line 39 of file bandit_operator.h.

Member Function Documentation

◆ choose()

string Brush::MAB::BanditOperator::choose ( )
virtual

Chooses an arm based on the given tree and fitness. Should call sample_probs internally.

Parameters
treeThe tree structure used to choose the arm.
fThe fitness value used to influence the choice.
Returns
The arm with highest probability.

Reimplemented in Brush::MAB::DummyBandit, and Brush::MAB::ThompsonSamplingBandit.

Definition at line 37 of file bandit_operator.cpp.

◆ sample_probs()

std::map< string, float > Brush::MAB::BanditOperator::sample_probs ( bool update)
virtual

Samples the probabilities of the arms.

Parameters
updateA boolean indicating whether to update the probabilities.
Returns
A map of arms and their probabilities.

Reimplemented in Brush::MAB::DummyBandit, and Brush::MAB::ThompsonSamplingBandit.

Definition at line 25 of file bandit_operator.cpp.

Here is the call graph for this function:

◆ update()

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

Updates the reward for a specific arm.

Parameters
armThe arm for which to update the reward.
rewardThe reward value.

Reimplemented in Brush::MAB::DummyBandit, and Brush::MAB::ThompsonSamplingBandit.

Definition at line 49 of file bandit_operator.cpp.

Here is the caller graph for this function:

Member Data Documentation

◆ probabilities

std::map<string, float> Brush::MAB::BanditOperator::probabilities
protected

Definition at line 66 of file bandit_operator.h.


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