AIToolbox
A library that offers tools for AI problem solving.
FlattenedModel.hpp
Go to the documentation of this file.
1 #ifndef AI_TOOLBOX_FACTORED_BANDIT_FLATTENED_MODEL_HEADER_FILE
2 #define AI_TOOLBOX_FACTORED_BANDIT_FLATTENED_MODEL_HEADER_FILE
3 
5 
23  template <typename Dist>
25  public:
31  FlattenedModel(const Model<Dist> & model);
32 
44  double sampleR(size_t a) const;
45 
53  Action convertA(size_t a) const;
54 
63  size_t getA() const;
64 
70  const Model<Dist> & getModel() const;
71 
72  private:
73  const Model<Dist> & model_;
74 
75  size_t A;
76  mutable Action helper_;
77  };
78 
79  template <typename Dist>
81  model_(model), A(factorSpace(model.getA())), helper_(model.getA().size())
82  {}
83 
84  template <typename Dist>
85  double FlattenedModel<Dist>::sampleR(size_t a) const {
86  toFactors(model_.getA(), a, &helper_);
87  return model_.sampleR(helper_).sum();
88  }
89 
90  template <typename Dist>
91  size_t FlattenedModel<Dist>::getA() const { return A; }
92  template <typename Dist>
93  const Model<Dist> & FlattenedModel<Dist>::getModel() const { return model_; }
94 }
95 
96 #endif
AIToolbox::Factored::Bandit::FlattenedModel
This class flattens a factored bandit model.
Definition: FlattenedModel.hpp:24
AIToolbox::Factored::Bandit::FlattenedModel::FlattenedModel
FlattenedModel(const Model< Dist > &model)
Basic constructor.
Definition: FlattenedModel.hpp:80
AIToolbox::Factored::Bandit::Model
This class represents a factored multi-armed bandit.
Definition: Model.hpp:29
AIToolbox::Factored::Bandit::FlattenedModel::sampleR
double sampleR(size_t a) const
This function samples the specified bandit arm.
Definition: FlattenedModel.hpp:85
AIToolbox::Factored::Bandit::FlattenedModel::convertA
Action convertA(size_t a) const
This function converts the input action to its equivalent joint-action.
AIToolbox::Factored::factorSpace
size_t factorSpace(const Factors &space)
This function returns the multiplication of all elements of the input factor.
AIToolbox::Factored::toFactors
Factors toFactors(size_t F, const PartialFactors &pf)
This function converts PartialFactors into the equivalent Factors structure.
AIToolbox::Factored::Bandit::FlattenedModel::getA
size_t getA() const
This function returns the number of arms of the bandit.
Definition: FlattenedModel.hpp:91
Model.hpp
AIToolbox::Factored::Action
Factors Action
Definition: Types.hpp:69
AIToolbox::Factored::Bandit::FlattenedModel::getModel
const Model< Dist > & getModel() const
This function returns a reference to the wrapped factored bandit.
Definition: FlattenedModel.hpp:93
AIToolbox::Factored::Bandit
Definition: GraphUtils.hpp:12