64 template <
TESTNAME VariableAttributeSelection,
68 FMDPLearner(
double lT,
bool actionReward,
double sT) :
77 template <
TESTNAME VariableAttributeSelection,
84 for (
auto learnerIter = actionIter.val()->beginSafe();
85 learnerIter != actionIter.val()->endSafe();
87 delete learnerIter.val();
88 delete actionIter.val();
105 template <
TESTNAME VariableAttributeSelection,
116 for (
auto varIter =
_fmdp_->beginVariables(); varIter !=
_fmdp_->endVariables(); ++varIter) {
117 mainVariables.
insert(*varIter);
121 for (
auto actionIter =
_fmdp_->beginActions(); actionIter !=
_fmdp_->endActions();
127 for (
auto varIter =
_fmdp_->beginVariables(); varIter !=
_fmdp_->endVariables(); ++varIter) {
130 +
" - VARIABLE : " + (*varIter)->name());
131 _fmdp_->addTransitionForAction(*actionIter, *varIter, varTrans);
140 _fmdp_->addRewardForAction(*actionIter, reward);
149 _fmdp_->addReward(reward);
157 template <
TESTNAME VariableAttributeSelection,
163 varIter !=
_fmdp_->endVariables();
165 _actionLearners_[actionId]->getWithDefault(*varIter,
nullptr)->addObservation(newObs);
166 _actionLearners_[actionId]->getWithDefault(*varIter,
nullptr)->updateGraph();
185 template <
TESTNAME VariableAttributeSelection,
192 actionIter !=
_fmdp_->endActions();
195 varIter !=
_fmdp_->endVariables();
197 s +=
_actionLearners_[*actionIter]->getWithDefault(*varIter,
nullptr)->size();
209 template <
TESTNAME VariableAttributeSelection,
215 actionIter !=
_fmdp_->endActions();
218 varIter !=
_fmdp_->endVariables();
220 _actionLearners_[*actionIter]->getWithDefault(*varIter,
nullptr)->updateFunctionGraph();
HashTable< Idx, RewardLearnerType * > _actionRewardLearners_
const double _similarityThreshold_
RewardLearnerType * _instantiateRewardLearner_(MultiDimFunctionGraph< double > *target, gum::VariableSet &mainVariables)
Initializes the learner.
~FMDPLearner()
Default destructor.
MultiDimFunctionGraph< double > * _instantiateFunctionGraph_()
Initializes the learner.
double _modaMax_
learnerSize
void updateFMDP()
Starts an update of datastructure in the associated FMDP.
FMDP< double > * _fmdp_
The FMDP to store the learned model.
HashTable< const DiscreteVariable *, VariableLearnerType * > VarLearnerTable
const double _learningThreshold_
RewardLearnerType * _rewardLearner_
FMDPLearner(double learningThreshold, bool actionReward, double similarityThreshold=0.05)
Default constructor.
void initialize(FMDP< double > *fmdp)
Initializes the learner.
HashTable< Idx, VarLearnerTable * > _actionLearners_
VariableLearnerType * _instantiateVarLearner_(MultiDimFunctionGraph< double > *target, gum::VariableSet &mainVariables, const DiscreteVariable *learnedVar)
Initializes the learner.
bool addObservation(Idx actionId, const Observation *obs)
Gives to the learner a new transition.
void setTableName(const std::string &name)
Sets the name of the table represented by this structure.
double reward() const
Returns the modality assumed by the given variable in this observation.
Safe iterators for Sequence.
void insert(const Key &k)
Inserts a new element into the set.
Headers of the FMDPLearner class.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Size Idx
Type for indexes.
gum is the global namespace for all aGrUM entities
Set< const DiscreteVariable * > VariableSet