65 template <
TESTNAME VariableAttributeSelection,
69 FMDPLearner(
double lT,
bool actionReward,
double sT) :
78 template <
TESTNAME VariableAttributeSelection,
85 for (
auto learnerIter = actionIter.val()->beginSafe();
86 learnerIter != actionIter.val()->endSafe();
88 delete learnerIter.val();
89 delete actionIter.val();
106 template <
TESTNAME VariableAttributeSelection,
117 for (
auto varIter =
_fmdp_->beginVariables(); varIter !=
_fmdp_->endVariables(); ++varIter) {
118 mainVariables.
insert(*varIter);
122 for (
auto actionIter =
_fmdp_->beginActions(); actionIter !=
_fmdp_->endActions();
128 for (
auto varIter =
_fmdp_->beginVariables(); varIter !=
_fmdp_->endVariables(); ++varIter) {
131 +
" - VARIABLE : " + (*varIter)->name());
132 _fmdp_->addTransitionForAction(*actionIter, *varIter, varTrans);
141 _fmdp_->addRewardForAction(*actionIter, reward);
150 _fmdp_->addReward(reward);
158 template <
TESTNAME VariableAttributeSelection,
164 varIter !=
_fmdp_->endVariables();
166 _actionLearners_[actionId]->getWithDefault(*varIter,
nullptr)->addObservation(newObs);
167 _actionLearners_[actionId]->getWithDefault(*varIter,
nullptr)->updateGraph();
186 template <
TESTNAME VariableAttributeSelection,
193 actionIter !=
_fmdp_->endActions();
196 varIter !=
_fmdp_->endVariables();
198 s +=
_actionLearners_[*actionIter]->getWithDefault(*varIter,
nullptr)->size();
210 template <
TESTNAME VariableAttributeSelection,
216 actionIter !=
_fmdp_->endActions();
219 varIter !=
_fmdp_->endVariables();
221 _actionLearners_[*actionIter]->getWithDefault(*varIter,
nullptr)->updateFunctionGraph();
232 template <
TESTNAME VariableAttributeSelection,
236 RewardAttributeSelection,
241 template <
TESTNAME VariableAttributeSelection,
250 template <
TESTNAME VariableAttributeSelection,
259 template <
TESTNAME VariableAttributeSelection,
272 template <
TESTNAME VariableAttributeSelection,
287 template <
TESTNAME VariableAttributeSelection,
298 template <
TESTNAME VariableAttributeSelection,
307 template <
TESTNAME VariableAttributeSelection,
317 template <
TESTNAME VariableAttributeSelection,
327 template <
TESTNAME VariableAttributeSelection,
336 template <
TESTNAME VariableAttributeSelection,
345 template <
TESTNAME VariableAttributeSelection,
Base class for discrete random variable.
double rMax() const override
learnerSize
RewardLearnerType * _instantiateRewardLearner_(MultiDimFunctionGraph< double > *target, gum::VariableSet &mainVariables)
Initializes the learner.
typename LearnerSelect< LearnerSelection, IMDDI< RewardAttributeSelection, true >, ITI< RewardAttributeSelection, true > >::type RewardLearnerType
HashTable< Idx, RewardLearnerType * > _actionRewardLearners_
const double _similarityThreshold_
void initialize(FMDP< double > *fmdp) override
Initializes the learner.
MultiDimFunctionGraph< double > * _instantiateFunctionGraph_()
Initializes the learner.
double _modaMax_
learnerSize
FMDP< double > * _fmdp_
The FMDP to store the learned model.
bool addObservation(Idx actionId, const Observation *obs) override
Gives to the learner a new transition.
HashTable< const DiscreteVariable *, VariableLearnerType * > VarLearnerTable
~FMDPLearner() override
Default destructor.
const double _learningThreshold_
RewardLearnerType * _rewardLearner_
VariableLearnerType * _instantiateVarLearner_(MultiDimFunctionGraph< double > *target, gum::VariableSet &mainVariables, const DiscreteVariable *learnedVar)
Initializes the learner.
FMDPLearner(double learningThreshold, bool actionReward, double similarityThreshold=0.05)
Default constructor.
void updateFMDP() override
Starts an update of datastructure in the associated FMDP.
HashTable< Idx, VarLearnerTable * > _actionLearners_
typename LearnerSelect< LearnerSelection, IMDDI< VariableAttributeSelection, false >, ITI< VariableAttributeSelection, false > >::type VariableLearnerType
const IVisitableGraphLearner * varLearner(Idx actionId, const DiscreteVariable *var) const override
extractCount
Size size() override
learnerSize
double modaMax() const override
learnerSize
<agrum/FMDP/SDyna/IVisitableGraphLearner.h>
static MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy > * getTreeInstance()
Returns an arborescent instance.
void setTableName(std::string_view name)
Sets the name of the table represented by this structure.
static MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy > * getReducedAndOrderedInstance()
Returns a reduced and ordered instance.
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