19 map<T, float> arms_probs;
20 float prob = 1.0 /
arms.size();
21 for (
const auto& arm :
arms) {
22 arms_probs[arm] = prob;
33 for (
const auto& pair : arms_probs) {
34 arms_names.push_back(pair.first);
44 if (
type ==
"thompson") {
46 }
else if (
type ==
"dynamic_thompson") {
48 }
else if (
type ==
"linear_thompson") {
50 }
else if (type ==
"dummy") {
51 pbandit = make_unique<DummyBandit<T>>(probabilities);
99 this->
pbandit->update(arm, reward, context);
102template <
typename T>
template <ProgramType PT>
118 ArrayXf out = (*program.
Tree.begin().node).template predict<ArrayXf>(d);
129 ArrayXf out = (*program.
Tree.begin().node).template predict<ArrayXf>(d);
130 context = ArrayXf(out.template cast<float>());
142 ArrayXXf out = (*program.
Tree.begin().node).template predict<ArrayXXf>(d);
144 context = ArrayXf(argmax(out).
template cast<float>());
150 cout <<
"MulticlassClassifierProgram detected, not implemented\n" << endl;
holds variable type data.
#define HANDLE_ERROR_THROW(err)
< nsga2 selection operator for getting the front
tree< Node >::pre_order_iterator Iter
VectorXf get_context(const Program< PT > &program, Iter spot, const SearchSpace &ss, const Dataset &d)
T choose(const VectorXf &context)
Selects an arm using the tree and fitness as context.
std::shared_ptr< BanditOperator< T > > pbandit
A shared pointer to the bandit operator (policy).
void set_arms(vector< T > arms)
Sets 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.
vector< T > get_arms()
Gets the arms of the bandit.
map< T, float > get_probs()
Gets the probabilities associated with each arm.
void update(T arm, float reward, VectorXf &context)
Updates the bandit's state based on the chosen arm and the received reward.
std::map< T, float > probabilities
void set_probs(map< T, float > arms_probs)
Sets the probabilities associated with each arm.
void set_bandit()
Sets the bandit operator (policy).
map< T, float > sample_probs(bool update=false)
Samples the probabilities associated with each arm using the policy.
An individual program, a.k.a. model.
Holds a search space, consisting of operations and terminals and functions, and methods to sample tha...