74 template <
typename GUM_ELEMENT >
76 GUM_CONSTRUCTOR(
FMDP);
89 template <
typename GUM_ELEMENT >
96 for (
auto iterH = (iterA.val())->beginSafe(); iterH != (iterA.val())->endSafe(); ++iterH)
97 if (iterH.val())
delete iterH.val();
103 for (
auto iterA = _actionCostTable_.beginSafe(); iterA != _actionCostTable_.endSafe(); ++iterA)
104 if (iterA.val())
delete iterA.val();
109 if (iterA.val())
delete iterA.val();
113 delete iterId.second();
117 delete varIter.second();
136 template <
typename GUM_ELEMENT >
140 " Variable " << var->
name() <<
" has already been inserted in FMDP.");
163 template <
typename GUM_ELEMENT >
170 if (*(actIter.second()) == action)
172 " Action " << action <<
" has already been inserted in FMDP with this name.");
176 " An action with same id (" <<
actionId <<
") has already been inserted.");
201 template <
typename GUM_ELEMENT >
214 " Variable " << var->
name() <<
" already has a transition table in " <<
actionId
224 template <
typename GUM_ELEMENT >
249 template <
typename GUM_ELEMENT >
265 template < typename GUM_ELEMENT >
286 template <
typename GUM_ELEMENT >
304 template <
typename GUM_ELEMENT >
324 template <
typename GUM_ELEMENT >
335 template <
typename GUM_ELEMENT >
340 if (*(actIter.second()) == action) {
return actIter.first(); }
345 template <
typename GUM_ELEMENT >
347 std::string fmdpCore;
356 if (this->
reward(*actionIter))
376 template <
typename GUM_ELEMENT >
382 s += this->
transition(*actionIter, *varIter)->realSize();
383 if (this->
reward(*actionIter)) s += this->
reward(*actionIter)->realSize();
392 template <
typename GUM_ELEMENT >
397 template <
typename GUM_ELEMENT >
402 template <
typename GUM_ELEMENT >
407 template <
typename GUM_ELEMENT >
413 template <
typename GUM_ELEMENT >
418 template <
typename GUM_ELEMENT >
423 template <
typename GUM_ELEMENT >
429 template <
typename GUM_ELEMENT >
434 template <
typename GUM_ELEMENT >
439 template <
typename GUM_ELEMENT >
444 template <
typename GUM_ELEMENT >
449 template <
typename GUM_ELEMENT >
Safe iterators for bijectionIterator.
Unsafe iterators for bijection.
Set of pairs of elements with fast search for both elements.
Base class for discrete random variable.
DiscreteVariable * clone() const override=0
Copy Factory.
Exception : a similar element already exists.
Bijection< Idx, const std::string * > _actionMap_
Bijection mapping an action name to its id.
HashTable< Idx, const MultiDimImplementation< GUM_ELEMENT > * > _actionRewardTable_
Table which give for each action reward table.
void addRewardForAction(Idx actionId, const MultiDimImplementation< GUM_ELEMENT > *reward)
Adds a default variable reward.
void addVariable(const DiscreteVariable *var)
Adds a variable to FMDP description.
Size size() const
Returns the map binding main variables and prime variables.
void addCost(const MultiDimImplementation< GUM_ELEMENT > *cost)
Adds a default variable cost.
HashTable< Idx, const MultiDimImplementation< GUM_ELEMENT > * > _actionCostTable_
Table which give for each action cost table.
void setDiscount(GUM_ELEMENT discount)
Sets the discount factor.
void addTransitionForAction(Idx actionId, const DiscreteVariable *var, const MultiDimImplementation< GUM_ELEMENT > *transition)
Adds a variable transition table to specified action.
SequenceIteratorSafe< Idx > beginActions() const
Returns an iterator reference to he beginning of the list of actions.
FMDP(bool onDestructionDeleteVar=false)
Default constructor.
void addAction(Idx actionId, std::string_view action)
Adds an action to FMDP description.
void addCostForAction(Idx actionId, const MultiDimImplementation< GUM_ELEMENT > *cost)
Adds a cost table to specified action.
void setDeleteVariablesOnDestruction(bool b)
Transfers ownership of variables to this FMDP (they will be deleted on destruction).
Sequence< const DiscreteVariable * > _varSeq_
Sequence de variables and its iterator.
const DiscreteVariable * main2prime(const DiscreteVariable *mainVar) const
Returns the primed variable associate to the given main variable.
SequenceIteratorSafe< const DiscreteVariable * > beginVariables() const
Returns an iterator reference to he beginning of the list of variables.
Idx actionId(std::string_view) const
Returns action id.
SequenceIteratorSafe< Idx > endActions() const
Returns an iterator reference to the end of the list of actions.
void addReward(const MultiDimImplementation< GUM_ELEMENT > *reward)
Adds a default variable reward.
bool _onDestructionDeleteVars_
Boolean indicates whether or not main variables should be deleted on destruction of this instance Usu...
const Bijection< const DiscreteVariable *, const DiscreteVariable * > & mapMainPrime() const
Returns the map binding main variables and prime variables.
HashTable< const DiscreteVariable *, const MultiDimImplementation< GUM_ELEMENT_O > * > VarTransitionTable
GUM_ELEMENT discount() const
Returns the discount factor.
Bijection< const DiscreteVariable *, const DiscreteVariable * > _main2primed_
void addTransition(const DiscreteVariable *var, const MultiDimImplementation< GUM_ELEMENT > *transition)
Adds a default variable transition.
~FMDP()
Default destructor.
Sequence< Idx > _actionSeq_
SequenceIteratorSafe< const DiscreteVariable * > endVariables() const
Returns an iterator reference to the end of the list of variables.
HashTable< Idx, VarTransitionTable< GUM_ELEMENT > * > _actionTransitionTable_
Table which give for each action a table containing variables transition cpt.
const MultiDimImplementation< double > * cost(Idx actionId=0) const
const MultiDimImplementation< double > * transition(Idx actionId, const DiscreteVariable *v) const
std::string toString() const
Displays the FMDP in a Dot format.
const std::string & actionName(Idx actionId) const
const MultiDimImplementation< GUM_ELEMENT > * reward(Idx actionId=0) const
Returns the reward table of mdp.
Class implementingting a function graph.
<agrum/base/multidim/multiDimImplementation.h>
Exception : the element we looked for cannot be found.
Safe iterators for Sequence.
const std::string & name() const
returns the name of the variable
void setName(std::string_view theValue)
sets the name of the variable
#define GUM_ERROR(type, msg)
Class for implementation of factored markov decision process.
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