![]() |
aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
|
This class is used to implement factored decision process. More...
#include <fmdp.h>
Public Member Functions | |
Constructors, Destructors. | |
| FMDP (bool onDestructionDeleteVar=false) | |
| Default constructor. | |
| ~FMDP () | |
| Default destructor. | |
Variable Handling Methods. | |
| void | addVariable (const DiscreteVariable *var) |
| Adds a variable to FMDP description. | |
| SequenceIteratorSafe< const DiscreteVariable * > | beginVariables () const |
| Returns an iterator reference to he beginning of the list of variables. | |
| SequenceIteratorSafe< const DiscreteVariable * > | endVariables () const |
| Returns an iterator reference to the end of the list of variables. | |
| const DiscreteVariable * | main2prime (const DiscreteVariable *mainVar) const |
| Returns the primed variable associate to the given main variable. | |
| INLINE const Bijection< const DiscreteVariable *, const DiscreteVariable * > & | mapMainPrime () const |
| Returns the map binding main variables and prime variables. | |
Action Handling Methods. | |
| void | addAction (Idx actionId, const std::string &action) |
| Adds an action to FMDP description. | |
| SequenceIteratorSafe< Idx > | beginActions () const |
| Returns an iterator reference to he beginning of the list of actions. | |
| SequenceIteratorSafe< Idx > | endActions () const |
| Returns an iterator reference to the end of the list of actions. | |
Transition methods. | |
| void | addTransitionForAction (Idx actionId, const DiscreteVariable *var, const MultiDimImplementation< GUM_SCALAR > *transition) |
| Adds a variable transition table to specified action. | |
| void | addTransition (const DiscreteVariable *var, const MultiDimImplementation< GUM_SCALAR > *transition) |
| Adds a default variable transition. | |
| const MultiDimImplementation< GUM_SCALAR > * | transition (Idx actionId, const DiscreteVariable *v) const |
| Returns transition associated to given in parameter variable and the given action. | |
Cost methods. | |
| void | addCostForAction (Idx actionId, const MultiDimImplementation< GUM_SCALAR > *cost) |
| Adds a cost table to specified action. | |
| void | addCost (const MultiDimImplementation< GUM_SCALAR > *cost) |
| Adds a default variable cost. | |
| const MultiDimImplementation< GUM_SCALAR > * | cost (Idx actionId=0) const |
| Returns the reward table of mdp. | |
Reward methods. | |
| void | addRewardForAction (Idx actionId, const MultiDimImplementation< GUM_SCALAR > *reward) |
| Adds a default variable reward. | |
| void | addReward (const MultiDimImplementation< GUM_SCALAR > *reward) |
| Adds a default variable reward. | |
| const MultiDimImplementation< GUM_SCALAR > * | reward (Idx actionId=0) const |
| Returns the reward table of mdp. | |
FMPD miscelleanous methods. | |
| const std::string & | actionName (Idx actionId) const |
| Returns name of action given in parameter. | |
| Idx | actionId (const std::string &) const |
| Returns action id. | |
| std::string | toString () const |
| Displays the FMDP in a Dot format. | |
| Size | size () const |
| Returns the map binding main variables and prime variables. | |
Private Types | |
| template<typename GUM_SCALAR_O> | |
| using | VarTransitionTable = HashTable< const DiscreteVariable*, const MultiDimImplementation< GUM_SCALAR_O >* > |
Private Attributes | |
| Sequence< const DiscreteVariable * > | _varSeq_ |
| Sequence de variables and its iterator. | |
| Sequence< Idx > | _actionSeq_ |
| Bijection< const DiscreteVariable *, const DiscreteVariable * > | _main2primed_ |
| Mapping from a main variable to its associated primed version. | |
| Bijection< Idx, const std::string * > | _actionMap_ |
| Bijection mapping an action name to its id. | |
| HashTable< Idx, VarTransitionTable< GUM_SCALAR > * > | _actionTransitionTable_ |
| Table which give for each action a table containing variables transition cpt. | |
| HashTable< Idx, const MultiDimImplementation< GUM_SCALAR > * > | _actionCostTable_ |
| Table which give for each action cost table. | |
| HashTable< Idx, const MultiDimImplementation< GUM_SCALAR > * > | _actionRewardTable_ |
| Table which give for each action reward table. | |
| bool | _onDestructionDeleteVars_ |
| Boolean indicates whether or not main variables should be deleted on destruction of this instance Usually the case when fmdp has been initialized with the factory. | |
This class is used to implement factored decision process.
This class supports a mechanism which allows user to give, for each variable ivolved in the process, a default transition probability table and to describe for specific actions a different table.
|
private |
| INLINE gum::FMDP< GUM_SCALAR >::FMDP | ( | bool | onDestructionDeleteVar = false | ) |
Default constructor.
Definition at line 74 of file fmdp_tpl.h.
References FMDP(), _actionCostTable_, _actionMap_, _actionRewardTable_, _actionTransitionTable_, and _onDestructionDeleteVars_.
Referenced by FMDP(), and cost().
Default destructor.
Definition at line 89 of file fmdp_tpl.h.
| INLINE Idx gum::FMDP< GUM_SCALAR >::actionId | ( | const std::string & | action | ) | const |
Returns action id.
Definition at line 337 of file fmdp_tpl.h.
References _actionMap_, and GUM_ERROR.
Referenced by actionName(), addAction(), addCostForAction(), addRewardForAction(), addTransitionForAction(), cost(), reward(), and transition().
| INLINE const std::string & gum::FMDP< GUM_SCALAR >::actionName | ( | Idx | actionId | ) | const |
Returns name of action given in parameter.
Definition at line 326 of file fmdp_tpl.h.
References _actionMap_, actionId(), and GUM_ERROR.
Referenced by addCostForAction(), addRewardForAction(), cost(), reward(), and transition().
| INLINE void gum::FMDP< GUM_SCALAR >::addAction | ( | Idx | actionId, |
| const std::string & | action ) |
Adds an action to FMDP description.
| DuplicateElement | if an action with same name already exists |
Definition at line 163 of file fmdp_tpl.h.
References _actionMap_, actionId(), and GUM_ERROR.
|
inline |
Adds a default variable cost.
| DuplicateElement | if a default cost exists already |
Definition at line 209 of file fmdp.h.
References addCostForAction(), and cost().
| INLINE void gum::FMDP< GUM_SCALAR >::addCostForAction | ( | Idx | actionId, |
| const MultiDimImplementation< GUM_SCALAR > * | cost ) |
Adds a cost table to specified action.
| NotFound | if action does not exists |
Definition at line 250 of file fmdp_tpl.h.
References _actionCostTable_, actionId(), actionName(), cost(), and GUM_ERROR.
Referenced by addCost().
|
inline |
Adds a default variable reward.
| DuplicateElement | if a default reward exists already |
Definition at line 235 of file fmdp.h.
References addRewardForAction(), and reward().
| INLINE void gum::FMDP< GUM_SCALAR >::addRewardForAction | ( | Idx | actionId, |
| const MultiDimImplementation< GUM_SCALAR > * | reward ) |
Adds a default variable reward.
| DuplicateElement | if a default reward exists already |
Definition at line 288 of file fmdp_tpl.h.
References _actionRewardTable_, actionId(), actionName(), GUM_ERROR, and reward().
Referenced by addReward().
|
inline |
Adds a default variable transition.
| NotFound | if var does not exists |
| DuplicateElement | if variable already has a default transition |
Definition at line 180 of file fmdp.h.
References addTransitionForAction(), and transition().
| INLINE void gum::FMDP< GUM_SCALAR >::addTransitionForAction | ( | Idx | actionId, |
| const DiscreteVariable * | var, | ||
| const MultiDimImplementation< GUM_SCALAR > * | transition ) |
Adds a variable transition table to specified action.
| NotFound | if action or var does not exists |
| DuplicateElement | if variable already has a transition for this action |
Definition at line 201 of file fmdp_tpl.h.
References actionId().
Referenced by addTransition().
| INLINE void gum::FMDP< GUM_SCALAR >::addVariable | ( | const DiscreteVariable * | var | ) |
Adds a variable to FMDP description.
| DuplicateElement | if a similar variable already exists |
Definition at line 136 of file fmdp_tpl.h.
References _varSeq_, gum::DiscreteVariable::clone(), GUM_ERROR, and gum::Variable::name().
|
inline |
Returns an iterator reference to he beginning of the list of actions.
Definition at line 151 of file fmdp.h.
References _actionSeq_.
Referenced by gum::IDecisionStrategy::initialize(), size(), and toString().
|
inline |
Returns an iterator reference to he beginning of the list of variables.
Definition at line 109 of file fmdp.h.
References _varSeq_.
Referenced by gum::E_GreedyDecider::initialize(), size(), and toString().
| INLINE const MultiDimImplementation< GUM_SCALAR > * gum::FMDP< GUM_SCALAR >::cost | ( | Idx | actionId = 0 | ) | const |
Returns the reward table of mdp.
Definition at line 266 of file fmdp_tpl.h.
References FMDP(), _actionCostTable_, actionId(), actionName(), cost(), and GUM_ERROR.
Referenced by addCost(), addCostForAction(), and cost().
|
inline |
Returns an iterator reference to the end of the list of actions.
Definition at line 156 of file fmdp.h.
References _actionSeq_.
Referenced by gum::AdaptiveRMaxPlaner::_clearTables_(), gum::AdaptiveRMaxPlaner::_makeRMaxFunctionGraphs_(), gum::IDecisionStrategy::initialize(), size(), and toString().
|
inline |
Returns an iterator reference to the end of the list of variables.
Definition at line 116 of file fmdp.h.
References _varSeq_.
Referenced by gum::AdaptiveRMaxPlaner::_makeRMaxFunctionGraphs_(), gum::E_GreedyDecider::initialize(), size(), and toString().
|
inline |
Returns the primed variable associate to the given main variable.
Definition at line 123 of file fmdp.h.
References _main2primed_.
|
inline |
Returns the map binding main variables and prime variables.
Definition at line 131 of file fmdp.h.
References _main2primed_.
Referenced by gum::MDDOperatorStrategy< GUM_SCALAR >::regress(), gum::TreeOperatorStrategy< GUM_SCALAR >::regress(), and gum::MDDOperatorStrategy< GUM_SCALAR >::shouldEleminateVar_().
| INLINE const MultiDimImplementation< GUM_SCALAR > * gum::FMDP< GUM_SCALAR >::reward | ( | Idx | actionId = 0 | ) | const |
Returns the reward table of mdp.
Definition at line 306 of file fmdp_tpl.h.
References _actionRewardTable_, actionId(), actionName(), and GUM_ERROR.
Referenced by addReward(), addRewardForAction(), size(), and toString().
Returns the map binding main variables and prime variables.
Definition at line 366 of file fmdp_tpl.h.
References beginActions(), beginVariables(), endActions(), endVariables(), gum::MultiDimImplementation< GUM_SCALAR >::realSize(), and reward().
| INLINE std::string gum::FMDP< GUM_SCALAR >::toString | ( | ) | const |
Displays the FMDP in a Dot format.
Definition at line 347 of file fmdp_tpl.h.
References beginActions(), beginVariables(), endActions(), endVariables(), RECAST, and reward().
| INLINE const MultiDimImplementation< GUM_SCALAR > * gum::FMDP< GUM_SCALAR >::transition | ( | Idx | actionId, |
| const DiscreteVariable * | v ) const |
Returns transition associated to given in parameter variable and the given action.
Definition at line 225 of file fmdp_tpl.h.
References _actionTransitionTable_, actionId(), actionName(), and GUM_ERROR.
Referenced by addTransition(), gum::MDDOperatorStrategy< GUM_SCALAR >::regress(), and gum::TreeOperatorStrategy< GUM_SCALAR >::regress().
|
private |
Table which give for each action cost table.
Definition at line 291 of file fmdp.h.
Referenced by FMDP(), addCostForAction(), and cost().
|
private |
Bijection mapping an action name to its id.
Definition at line 284 of file fmdp.h.
Referenced by FMDP(), actionId(), actionName(), and addAction().
|
private |
Table which give for each action reward table.
Definition at line 294 of file fmdp.h.
Referenced by FMDP(), addRewardForAction(), and reward().
Definition at line 278 of file fmdp.h.
Referenced by beginActions(), and endActions().
|
private |
Table which give for each action a table containing variables transition cpt.
Definition at line 288 of file fmdp.h.
Referenced by FMDP(), and transition().
|
private |
Mapping from a main variable to its associated primed version.
Definition at line 281 of file fmdp.h.
Referenced by main2prime(), and mapMainPrime().
|
private |
Sequence de variables and its iterator.
Definition at line 276 of file fmdp.h.
Referenced by addVariable(), beginVariables(), and endVariables().