![]() |
aGrUM 3.0.0
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. | |
| const Bijection< const DiscreteVariable *, const DiscreteVariable * > & | mapMainPrime () const |
| Returns the map binding main variables and prime variables. | |
Action Handling Methods. | |
| void | addAction (Idx actionId, std::string_view 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_ELEMENT > *transition) |
| Adds a variable transition table to specified action. | |
| void | addTransition (const DiscreteVariable *var, const MultiDimImplementation< GUM_ELEMENT > *transition) |
| Adds a default variable transition. | |
| const MultiDimImplementation< GUM_ELEMENT > * | 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_ELEMENT > *cost) |
| Adds a cost table to specified action. | |
| void | addCost (const MultiDimImplementation< GUM_ELEMENT > *cost) |
| Adds a default variable cost. | |
| const MultiDimImplementation< GUM_ELEMENT > * | cost (Idx actionId=0) const |
| Returns the reward table of mdp. | |
Reward methods. | |
| void | addRewardForAction (Idx actionId, const MultiDimImplementation< GUM_ELEMENT > *reward) |
| Adds a default variable reward. | |
| void | addReward (const MultiDimImplementation< GUM_ELEMENT > *reward) |
| Adds a default variable reward. | |
| const MultiDimImplementation< GUM_ELEMENT > * | 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 (std::string_view) 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. | |
| void | setDeleteVariablesOnDestruction (bool b) |
| Transfers ownership of variables to this FMDP (they will be deleted on destruction). | |
| void | setDiscount (GUM_ELEMENT discount) |
| Sets the discount factor. | |
| GUM_ELEMENT | discount () const |
| Returns the discount factor. | |
Private Types | |
| template<typename GUM_ELEMENT_O> | |
| using | VarTransitionTable = HashTable< const DiscreteVariable*, const MultiDimImplementation< GUM_ELEMENT_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_ELEMENT > * > | _actionTransitionTable_ |
| Table which give for each action a table containing variables transition cpt. | |
| HashTable< Idx, const MultiDimImplementation< GUM_ELEMENT > * > | _actionCostTable_ |
| Table which give for each action cost table. | |
| HashTable< Idx, const MultiDimImplementation< GUM_ELEMENT > * > | _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. | |
| GUM_ELEMENT | _discount_ {GUM_ELEMENT(1)} |
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 |
| gum::FMDP< GUM_ELEMENT >::FMDP | ( | bool | onDestructionDeleteVar = false | ) |
Default constructor.
Definition at line 75 of file fmdp_tpl.h.
References FMDP(), _actionCostTable_, _actionMap_, _actionRewardTable_, _actionTransitionTable_, and _onDestructionDeleteVars_.
Referenced by FMDP(), and cost().
Default destructor.
Definition at line 90 of file fmdp_tpl.h.
References _actionTransitionTable_.
| Idx gum::FMDP< GUM_ELEMENT >::actionId | ( | std::string_view | action | ) | const |
Returns action id.
Definition at line 336 of file fmdp_tpl.h.
References _actionMap_, and GUM_ERROR.
Referenced by actionName(), addAction(), addCostForAction(), addRewardForAction(), addTransitionForAction(), cost(), reward(), and transition().
| const std::string & gum::FMDP< GUM_ELEMENT >::actionName | ( | Idx | actionId | ) | const |
Returns name of action given in parameter.
Definition at line 325 of file fmdp_tpl.h.
References _actionMap_, actionId(), and GUM_ERROR.
Referenced by addRewardForAction(), reward(), and transition().
| void gum::FMDP< GUM_ELEMENT >::addAction | ( | Idx | actionId, |
| std::string_view | action ) |
Adds an action to FMDP description.
| DuplicateElement | if an action with same name already exists |
Definition at line 164 of file fmdp_tpl.h.
References _actionMap_, actionId(), and GUM_ERROR.
| void gum::FMDP< GUM_ELEMENT >::addCost | ( | const MultiDimImplementation< GUM_ELEMENT > * | cost | ) |
Adds a default variable cost.
| DuplicateElement | if a default cost exists already |
Definition at line 430 of file fmdp_tpl.h.
References addCostForAction(), and cost().
| void gum::FMDP< GUM_ELEMENT >::addCostForAction | ( | Idx | actionId, |
| const MultiDimImplementation< GUM_ELEMENT > * | cost ) |
Adds a cost table to specified action.
| NotFound | if action does not exists |
Definition at line 250 of file fmdp_tpl.h.
References actionId().
Referenced by addCost().
| void gum::FMDP< GUM_ELEMENT >::addReward | ( | const MultiDimImplementation< GUM_ELEMENT > * | reward | ) |
Adds a default variable reward.
| DuplicateElement | if a default reward exists already |
Definition at line 435 of file fmdp_tpl.h.
References addRewardForAction(), and reward().
| void gum::FMDP< GUM_ELEMENT >::addRewardForAction | ( | Idx | actionId, |
| const MultiDimImplementation< GUM_ELEMENT > * | 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().
| void gum::FMDP< GUM_ELEMENT >::addTransition | ( | const DiscreteVariable * | var, |
| const MultiDimImplementation< GUM_ELEMENT > * | transition ) |
Adds a default variable transition.
| NotFound | if var does not exists |
| DuplicateElement | if variable already has a default transition |
Definition at line 424 of file fmdp_tpl.h.
References addTransitionForAction(), and transition().
| void gum::FMDP< GUM_ELEMENT >::addTransitionForAction | ( | Idx | actionId, |
| const DiscreteVariable * | var, | ||
| const MultiDimImplementation< GUM_ELEMENT > * | 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 202 of file fmdp_tpl.h.
References actionId().
Referenced by addTransition().
| void gum::FMDP< GUM_ELEMENT >::addVariable | ( | const DiscreteVariable * | var | ) |
Adds a variable to FMDP description.
| DuplicateElement | if a similar variable already exists |
Definition at line 137 of file fmdp_tpl.h.
References _varSeq_.
| SequenceIteratorSafe< Idx > gum::FMDP< GUM_ELEMENT >::beginActions | ( | ) | const |
Returns an iterator reference to he beginning of the list of actions.
Definition at line 414 of file fmdp_tpl.h.
References _actionSeq_.
Referenced by gum::IDecisionStrategy::initialize(), size(), and toString().
| SequenceIteratorSafe< const DiscreteVariable * > gum::FMDP< GUM_ELEMENT >::beginVariables | ( | ) | const |
Returns an iterator reference to he beginning of the list of variables.
Definition at line 393 of file fmdp_tpl.h.
References _varSeq_.
Referenced by gum::E_GreedyDecider::initialize(), size(), and toString().
| const MultiDimImplementation< GUM_ELEMENT > * gum::FMDP< GUM_ELEMENT >::cost | ( | Idx | actionId = 0 | ) | const |
Returns the reward table of mdp.
Definition at line 266 of file fmdp_tpl.h.
References FMDP(), actionId(), and cost().
Referenced by addCost(), and cost().
| GUM_ELEMENT gum::FMDP< GUM_ELEMENT >::discount | ( | ) | const |
Returns the discount factor.
Definition at line 450 of file fmdp_tpl.h.
References _discount_.
Referenced by setDiscount().
| SequenceIteratorSafe< Idx > gum::FMDP< GUM_ELEMENT >::endActions | ( | ) | const |
Returns an iterator reference to the end of the list of actions.
Definition at line 419 of file fmdp_tpl.h.
References _actionSeq_.
Referenced by gum::AdaptiveRMaxPlaner::_clearTables_(), gum::AdaptiveRMaxPlaner::_makeRMaxFunctionGraphs_(), gum::IDecisionStrategy::initialize(), size(), and toString().
| SequenceIteratorSafe< const DiscreteVariable * > gum::FMDP< GUM_ELEMENT >::endVariables | ( | ) | const |
Returns an iterator reference to the end of the list of variables.
Definition at line 398 of file fmdp_tpl.h.
References _varSeq_.
Referenced by gum::AdaptiveRMaxPlaner::_makeRMaxFunctionGraphs_(), gum::E_GreedyDecider::initialize(), size(), and toString().
| const DiscreteVariable * gum::FMDP< GUM_ELEMENT >::main2prime | ( | const DiscreteVariable * | mainVar | ) | const |
Returns the primed variable associate to the given main variable.
Definition at line 403 of file fmdp_tpl.h.
References _main2primed_.
| const Bijection< const DiscreteVariable *, const DiscreteVariable * > & gum::FMDP< GUM_ELEMENT >::mapMainPrime | ( | ) | const |
Returns the map binding main variables and prime variables.
Definition at line 409 of file fmdp_tpl.h.
References _main2primed_.
Referenced by gum::MDDOperatorStrategy< GUM_ELEMENT >::regress(), gum::TreeOperatorStrategy< GUM_ELEMENT >::regress(), and gum::MDDOperatorStrategy< GUM_ELEMENT >::shouldEleminateVar_().
| const MultiDimImplementation< GUM_ELEMENT > * gum::FMDP< GUM_ELEMENT >::reward | ( | Idx | actionId = 0 | ) | const |
Returns the reward table of mdp.
Definition at line 305 of file fmdp_tpl.h.
References _actionRewardTable_, actionId(), actionName(), and GUM_ERROR.
Referenced by addReward(), addRewardForAction(), size(), and toString().
| void gum::FMDP< GUM_ELEMENT >::setDeleteVariablesOnDestruction | ( | bool | b | ) |
Transfers ownership of variables to this FMDP (they will be deleted on destruction).
Call this when the FMDP has been populated via FMDPFactory.
Definition at line 440 of file fmdp_tpl.h.
References _onDestructionDeleteVars_.
| void gum::FMDP< GUM_ELEMENT >::setDiscount | ( | GUM_ELEMENT | discount | ) |
Sets the discount factor.
Definition at line 445 of file fmdp_tpl.h.
References _discount_, and discount().
Returns the map binding main variables and prime variables.
Definition at line 377 of file fmdp_tpl.h.
References beginActions(), beginVariables(), endActions(), endVariables(), reward(), and transition().
| std::string gum::FMDP< GUM_ELEMENT >::toString | ( | ) | const |
Displays the FMDP in a Dot format.
Definition at line 346 of file fmdp_tpl.h.
References beginActions(), beginVariables(), endActions(), endVariables(), reward(), and transition().
| const MultiDimImplementation< GUM_ELEMENT > * gum::FMDP< GUM_ELEMENT >::transition | ( | Idx | actionId, |
| const DiscreteVariable * | v ) const |
Returns transition associated to given in parameter variable and the given action.
Definition at line 226 of file fmdp_tpl.h.
References _actionTransitionTable_, actionId(), actionName(), and GUM_ERROR.
Referenced by addTransition(), gum::MDDOperatorStrategy< GUM_ELEMENT >::regress(), gum::TreeOperatorStrategy< GUM_ELEMENT >::regress(), size(), and toString().
|
private |
|
private |
Bijection mapping an action name to its id.
Definition at line 286 of file fmdp.h.
Referenced by FMDP(), actionId(), actionName(), and addAction().
|
private |
Table which give for each action reward table.
Definition at line 296 of file fmdp.h.
Referenced by FMDP(), addRewardForAction(), and reward().
Definition at line 280 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 290 of file fmdp.h.
Referenced by FMDP(), ~FMDP(), and transition().
|
private |
Definition at line 303 of file fmdp.h.
Referenced by discount(), and setDiscount().
|
private |
Mapping from a main variable to its associated primed version.
Definition at line 283 of file fmdp.h.
Referenced by main2prime(), and mapMainPrime().
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.
Definition at line 301 of file fmdp.h.
Referenced by FMDP(), and setDeleteVariablesOnDestruction().
|
private |
Sequence de variables and its iterator.
Definition at line 278 of file fmdp.h.
Referenced by addVariable(), beginVariables(), and endVariables().