Connect++ 0.4.0
A fast, readable connection prover for first-order logic.
Loading...
Searching...
No Matches
UCB Class Reference

Implementation of the UCB algorithm for multiarmed bandits. More...

#include <UCB.hpp>

Public Member Functions

size_t get_choice ()
 
size_t choose ()
 Choose using the current state.
 
void reward (double)
 Provide reward for the most recent choice.
 

Private Attributes

bool choose_next
 Belt-and braces: warn if choose/reward happens in the wrong order.
 
size_t choice
 Store the last choice made.
 

Static Private Attributes

static boost::random::mt19937 random_generator
 Random source.
 

Friends

ostream & operator<< (ostream &, const UCB &)
 

Detailed Description

Implementation of the UCB algorithm for multiarmed bandits.

It's easy enough to find a description of this algorithm. The implementation here is pretty much straight from my book.

Definition at line 50 of file UCB.hpp.

Constructor & Destructor Documentation

◆ UCB()

UCB::UCB ( )
inline

Definition at line 70 of file UCB.hpp.

70{};

Member Function Documentation

◆ choose()

size_t UCB::choose ( )

Choose using the current state.

Definition at line 42 of file UCB.cpp.

42 {
43 if (!choose_next) {
44 cerr << "STOP IT!! EXP3 should be receiving reward..." << endl;
45 }
46 choose_next = false;
47
48 return choice;
49}
size_t choice
Store the last choice made.
Definition UCB.hpp:68
bool choose_next
Belt-and braces: warn if choose/reward happens in the wrong order.
Definition UCB.hpp:64

◆ get_choice()

size_t UCB::get_choice ( )

Definition at line 38 of file UCB.cpp.

38 {
39 return choice;
40}

◆ reward()

void UCB::reward ( double r)

Provide reward for the most recent choice.

Definition at line 51 of file UCB.cpp.

51 {
52 if (choose_next) {
53 cerr << "STOP IT!! EXP3 should be choosing..." << endl;
54 }
55 choose_next = true;
56
57}

Friends And Related Symbol Documentation

◆ operator<<

ostream & operator<< ( ostream & out,
const UCB & ucb )
friend

Definition at line 59 of file UCB.cpp.

59 {
60
61 return out;
62}

Member Data Documentation

◆ choice

size_t UCB::choice
private

Store the last choice made.

Definition at line 68 of file UCB.hpp.

◆ choose_next

bool UCB::choose_next
private

Belt-and braces: warn if choose/reward happens in the wrong order.

Definition at line 64 of file UCB.hpp.

◆ random_generator

boost::random::mt19937 UCB::random_generator
staticprivate

Random source.

Underlying random number generator for boost::random::discrete_distribution.

Definition at line 58 of file UCB.hpp.


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