Connect++ 0.5.0
A fast, readable connection prover for first-order logic.
Loading...
Searching...
No Matches
UCB.cpp
1/*
2
3Copyright © 2023-24 Sean Holden. All rights reserved.
4
5*/
6/*
7
8This file is part of Connect++.
9
10Connect++ is free software: you can redistribute it and/or modify it
11under the terms of the GNU General Public License as published by the
12Free Software Foundation, either version 3 of the License, or (at your
13option) any later version.
14
15Connect++ is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18more details.
19
20You should have received a copy of the GNU General Public License along
21with Connect++. If not, see <https://www.gnu.org/licenses/>.
22
23*/
24
25#include "UCB.hpp"
26
27boost::random::mt19937 UCB::random_generator(params::boost_random_seed);
28
29//------------------------------------------------------------------
30//------------------------------------------------------------------
31//------------------------------------------------------------------
32// UCB
33//------------------------------------------------------------------
34//------------------------------------------------------------------
35//------------------------------------------------------------------
36
37//------------------------------------------------------------------
38size_t UCB::get_choice() {
39 return choice;
40}
41//------------------------------------------------------------------
42size_t UCB::choose() {
43 if (!choose_next) {
44 cerr << "STOP IT!! EXP3 should be receiving reward..." << endl;
45 }
46 choose_next = false;
47
48 return choice;
49}
50//------------------------------------------------------------------
51void UCB::reward(double r) {
52 if (choose_next) {
53 cerr << "STOP IT!! EXP3 should be choosing..." << endl;
54 }
55 choose_next = true;
56
57}
58//------------------------------------------------------------------
59ostream& operator<<(ostream& out, const UCB& ucb) {
60
61 return out;
62}
Implementation of the UCB algorithm for multiarmed bandits.
Definition UCB.hpp:50
void reward(double)
Provide reward for the most recent choice.
Definition UCB.cpp:51
size_t choice
Store the last choice made.
Definition UCB.hpp:68
static boost::random::mt19937 random_generator
Random source.
Definition UCB.hpp:58
bool choose_next
Belt-and braces: warn if choose/reward happens in the wrong order.
Definition UCB.hpp:64
size_t choose()
Choose using the current state.
Definition UCB.cpp:42