![]() |
aGrUM
0.20.3
a C++ library for (probabilistic) graphical models
|
A factory class to ease Factored Markov Decision Process construction. More...
#include <agrum/FMDP/fmdpFactory.h>
Public Member Functions | |
Constructor & destructor. | |
FMDPFactory (FMDP< GUM_SCALAR > *fmdp) | |
Use this constructor if you want to use an already created factored markov decision process. More... | |
~FMDPFactory () | |
Destructor. More... | |
Getter and setters. | |
FMDP< GUM_SCALAR > * | fmdp () const |
Returns the Factored Markov Decision Process created by this factory. More... | |
FMDPfactory_state | state () const |
Returns the current state of the factory. More... | |
const DiscreteVariable * | variable (const std::string &name) const |
Returns a constant reference on a variable given it's name. More... | |
Variable declaration methods (NONE -> VARIABLE) | |
void | startVariableDeclaration () |
Tells the factory that we're in a variable declaration. More... | |
void | variableName (const std::string &name) |
Tells the factory the current variable's name. More... | |
void | variableDescription (const std::string &desc) |
Tells the factory the current variable's description. More... | |
void | addModality (const std::string &name) |
Adds a modality to the current variable. More... | |
void | endVariableDeclaration () |
Tells the factory that we're out of a variable declaration. More... | |
Action declaration methods (NONE -> ACTION) | |
void | startActionDeclaration () |
Tells the factory that we're in an action declaration. More... | |
void | addAction (const std::string &action) |
Tells the factory to add an action to the current fmdp. More... | |
void | endActionDeclaration () |
Tells the factory that we're out of an action declaration. More... | |
Transition declaration methods (NONE -> TRANSITION <- ACTION) | |
void | startTransitionDeclaration () |
Tells the factory that we're in a transition declaration. More... | |
void | addTransition (const std::string &var, const MultiDimAdressable *transition) |
Tells the factory to add a transition table to the current fmdp. More... | |
void | addTransition (const std::string &var) |
Tells the factory to add a transition table to the current fmdp. This transition table will be extracted from incorporated multiDimFunctionGraph. More... | |
void | endTransitionDeclaration () |
Tells the factory that we're out of a transition declaration. More... | |
Cost declaration methods (NONE -> COST <- ACTION) | |
void | startCostDeclaration () |
Tells the factory that we're in a cost declaration. More... | |
void | addCost (const MultiDimAdressable *cost) |
Tells the factory to add a cost table to the current fmdp. More... | |
void | addCost () |
Tells the factory to add a cost table to the current fmdp. This cost table will be extracted from incorporated multiDimFunctionGraph. More... | |
void | endCostDeclaration () |
Tells the factory that we're out of a cost declaration. More... | |
Reward declaration methods (NONE -> REWARD <- ACTION) | |
void | startRewardDeclaration () |
Tells the factory that we're in a reward declaration. More... | |
void | setOperationModeOn (std::string operationType) |
Tells the factory that we're in a reward declaration mode where the global reward diagram is an operation between simplier decision diagram.. More... | |
void | addReward (const MultiDimAdressable *reward) |
Tells the factory to add a reward table to the current fmdp. More... | |
void | addReward () |
Tells the factory to add a reward table to the current fmdp. This reward table will be extracted from incorporated multiDimFunctionGraph. More... | |
void | endRewardDeclaration () |
Tells the factory that we're out of a cost declaration. More... | |
Discount declaration methods (NONE -> DISCOUNT) | |
void | startDiscountDeclaration () |
Tells the factory that we're in a cost declaration. More... | |
void | addDiscount (float discount) |
Tells the factory to add a cost table to the current fmdp. More... | |
void | endDiscountDeclaration () |
Tells the factory that we're out of a cost declaration. More... | |
FunctionGraph Creation specific methods | |
methods used by internal FunctionGraphfactory to build up a multidimFunctionGraph | |
NodeId | addInternalNode (std::string name_of_var) |
Insert in diagram a non terminal node. More... | |
NodeId | addTerminalNode (float value) |
Insert in diagram a terminal node. More... | |
void | addArc (NodeId from, NodeId to, Idx modality) |
Insert in diagram a non terminal node. More... | |
void | setRoot (NodeId rootId) |
add an arc in diagram More... | |
verbosity control | |
void | setVerbose () |
void | resetVerbose () |
bool | isVerbose () |
Current constructed FMDP's parts. | |
bool | _foo_flag_ |
Depending on the context this flag is used for some VERY important reasons. More... | |
bool | _bar_flag_ |
Depending on the context this flag is used for some VERY important reasons. More... | |
std::vector< std::string > | _stringBag_ |
Just to keep track of strings between two start/end calls. More... | |
std::vector< const MultiDimImplementation< GUM_SCALAR > *> | _ddBag_ |
Just to keep track of multidim between two start/end calls. More... | |
void | _checkModalityInBag_ (const std::string &mod) |
Used in VARIABLE mode Checks if in stringBag there is no other modality with the same name. More... | |
void | _resetParts_ () |
Reset the different parts used to constructed the FMDP. More... | |
void | _initializeFunctionGraph_ () |
Insert every variables in the function graph. More... | |
void | _finalizeFunctionGraph_ () |
Insert every variables in the function graph. More... | |
A factory class to ease Factored Markov Decision Process construction.
A FMDPFactory will never create a Factored Markov Decision Process and works on only one Factored Markov Decision Process.
The only exception of this behaviour is when you create a copy of the factory, it will create a copy of its FMDP. This is useful when you want to create two FMDP sharing a common base. However be very careful because the copy will not delete its FMDP.
Each method will raise an OperationNotAllowed if you call it when the factory is not in a valid state for that call. The error message is "Illegal state.".
Definition at line 71 of file fmdpFactory.h.
INLINE gum::FMDPFactory< GUM_SCALAR >::FMDPFactory | ( | FMDP< GUM_SCALAR > * | fmdp | ) |
Use this constructor if you want to use an already created factored markov decision process.
fmdp | A pointer over the FMDP filled by this factory. |
Definition at line 57 of file fmdpFactory_tpl.h.
References gum::Set< Key, Alloc >::emplace().
INLINE gum::FMDPFactory< GUM_SCALAR >::~FMDPFactory | ( | ) |
Destructor.
To prevent strange behaviour you should always destroy a FMDPFactory when it's state equals NONE.
FatalError | Raised if the state of the factory prevents it to die peacefully. |
Definition at line 69 of file fmdpFactory_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
private |
Used in VARIABLE mode Checks if in stringBag there is no other modality with the same name.
Definition at line 195 of file fmdpFactory_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
private |
Insert every variables in the function graph.
Definition at line 738 of file fmdpFactory_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
private |
Raise an OperationNotAllowed with the message "Illegal state.".
Definition at line 669 of file fmdpFactory_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
private |
Insert every variables in the function graph.
Definition at line 723 of file fmdpFactory_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
private |
Reset the different parts used to constructed the FMDP.
Definition at line 714 of file fmdpFactory_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
Tells the factory to add an action to the current fmdp.
Implements gum::AbstractFMDPFactory.
Definition at line 277 of file fmdpFactory_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
Insert in diagram a non terminal node.
Implements gum::AbstractFMDPFactory.
Definition at line 647 of file fmdpFactory_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
Tells the factory to add a cost table to the current fmdp.
Implements gum::AbstractFMDPFactory.
Definition at line 408 of file fmdpFactory_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
Tells the factory to add a cost table to the current fmdp. This cost table will be extracted from incorporated multiDimFunctionGraph.
Implements gum::AbstractFMDPFactory.
Definition at line 425 of file fmdpFactory_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
Tells the factory to add a cost table to the current fmdp.
Implements gum::AbstractFMDPFactory.
Definition at line 598 of file fmdpFactory_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
Insert in diagram a non terminal node.
Implements gum::AbstractFMDPFactory.
Definition at line 632 of file fmdpFactory_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
Adds a modality to the current variable.
Implements gum::AbstractFMDPFactory.
Definition at line 182 of file fmdpFactory_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
Tells the factory to add a reward table to the current fmdp.
Implements gum::AbstractFMDPFactory.
Definition at line 491 of file fmdpFactory_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
Tells the factory to add a reward table to the current fmdp. This reward table will be extracted from incorporated multiDimFunctionGraph.
Implements gum::AbstractFMDPFactory.
Definition at line 507 of file fmdpFactory_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
Insert in diagram a terminal node.
Implements gum::AbstractFMDPFactory.
Definition at line 640 of file fmdpFactory_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
Tells the factory to add a transition table to the current fmdp.
Implements gum::AbstractFMDPFactory.
Definition at line 330 of file fmdpFactory_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
Tells the factory to add a transition table to the current fmdp. This transition table will be extracted from incorporated multiDimFunctionGraph.
Implements gum::AbstractFMDPFactory.
Definition at line 349 of file fmdpFactory_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
Tells the factory that we're out of an action declaration.
Implements gum::AbstractFMDPFactory.
Definition at line 290 of file fmdpFactory_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
Tells the factory that we're out of a cost declaration.
Implements gum::AbstractFMDPFactory.
Definition at line 442 of file fmdpFactory_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
Tells the factory that we're out of a cost declaration.
Implements gum::AbstractFMDPFactory.
Definition at line 608 of file fmdpFactory_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
Tells the factory that we're out of a cost declaration.
Implements gum::AbstractFMDPFactory.
Definition at line 525 of file fmdpFactory_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
Tells the factory that we're out of a transition declaration.
Implements gum::AbstractFMDPFactory.
Definition at line 370 of file fmdpFactory_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
Tells the factory that we're out of a variable declaration.
UndefinedElement | Raised if the variable isn't defined (or not enough defined). |
Implements gum::AbstractFMDPFactory.
Definition at line 205 of file fmdpFactory_tpl.h.
References gum::Set< Key, Alloc >::emplace().
INLINE FMDP< GUM_SCALAR > * gum::FMDPFactory< GUM_SCALAR >::fmdp | ( | ) | const |
Returns the Factored Markov Decision Process created by this factory.
OperationNotAllowed | Raise if the state of the factory is different than NONE. |
Definition at line 86 of file fmdpFactory_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
inlineinherited |
|
private |
Copy operator is illegal, use only copy constructor.
Definition at line 760 of file fmdpFactory_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
inlineinherited |
|
virtual |
Tells the factory that we're in a reward declaration mode where the global reward diagram is an operation between simplier decision diagram..
Implements gum::AbstractFMDPFactory.
Definition at line 481 of file fmdpFactory_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
add an arc in diagram
Implements gum::AbstractFMDPFactory.
Definition at line 653 of file fmdpFactory_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
inlineinherited |
|
virtual |
Tells the factory that we're in an action declaration.
Implements gum::AbstractFMDPFactory.
Definition at line 262 of file fmdpFactory_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
Tells the factory that we're in a cost declaration.
Implements gum::AbstractFMDPFactory.
Definition at line 394 of file fmdpFactory_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
Tells the factory that we're in a cost declaration.
Implements gum::AbstractFMDPFactory.
Definition at line 585 of file fmdpFactory_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
Tells the factory that we're in a reward declaration.
Implements gum::AbstractFMDPFactory.
Definition at line 466 of file fmdpFactory_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
Tells the factory that we're in a transition declaration.
Implements gum::AbstractFMDPFactory.
Definition at line 316 of file fmdpFactory_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
Tells the factory that we're in a variable declaration.
Implements gum::AbstractFMDPFactory.
Definition at line 135 of file fmdpFactory_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
Returns the current state of the factory.
Implements gum::AbstractFMDPFactory.
Definition at line 100 of file fmdpFactory_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
Returns a constant reference on a variable given it's name.
NotFound | Raised if no variable matches the name. |
Implements gum::AbstractFMDPFactory.
Definition at line 112 of file fmdpFactory_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
Tells the factory the current variable's description.
Implements gum::AbstractFMDPFactory.
Definition at line 167 of file fmdpFactory_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
Tells the factory the current variable's name.
DuplicateElement | Raised if a variable with the same name already exist. |
Implements gum::AbstractFMDPFactory.
Definition at line 151 of file fmdpFactory_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
private |
Action Id counter.
Definition at line 306 of file fmdpFactory.h.
|
private |
Depending on the context this flag is used for some VERY important reasons.
Definition at line 270 of file fmdpFactory.h.
|
private |
Just to keep track of multidim between two start/end calls.
Definition at line 276 of file fmdpFactory.h.
|
private |
The constructed FMDP.
Definition at line 297 of file fmdpFactory.h.
|
private |
Depending on the context this flag is used for some VERY important reasons.
Definition at line 266 of file fmdpFactory.h.
|
private |
The FunctionGraph we're building at a given time.
Definition at line 300 of file fmdpFactory.h.
|
private |
State stack.
Definition at line 294 of file fmdpFactory.h.
|
private |
Just to keep track of strings between two start/end calls.
Definition at line 273 of file fmdpFactory.h.
|
private |
Mapping between a declared variable's name and itself.
Definition at line 303 of file fmdpFactory.h.