![]() |
aGrUM
0.20.2
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 70 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 284 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 665 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 420 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 437 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 614 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 649 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 185 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 506 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 522 of file fmdpFactory_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
Insert in diagram a terminal node.
Implements gum::AbstractFMDPFactory.
Definition at line 657 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 337 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 360 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 199 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 297 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 455 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 624 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 540 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 382 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 209 of file fmdpFactory_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
private |
Insert every variables in the function graph.
Definition at line 762 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 87 of file fmdpFactory_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
private |
Raise an OperationNotAllowed with the message "Illegal state.".
Definition at line 688 of file fmdpFactory_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
private |
Insert every variables in the function graph.
Definition at line 742 of file fmdpFactory_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
inlineinherited |
|
private |
Copy operator is illegal, use only copy constructor.
Definition at line 783 of file fmdpFactory_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
private |
Reset the different parts used to constructed the FMDP.
Definition at line 733 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 495 of file fmdpFactory_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
add an arc in diagram
Implements gum::AbstractFMDPFactory.
Definition at line 671 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 269 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 406 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 601 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 479 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 323 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 136 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 101 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 113 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 170 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 152 of file fmdpFactory_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
private |
Action Id counter.
Definition at line 307 of file fmdpFactory.h.
|
private |
Depending on the context this flag is used for some VERY important reasons.
Definition at line 271 of file fmdpFactory.h.
|
private |
Just to keep track of multidim between two start/end calls.
Definition at line 277 of file fmdpFactory.h.
|
private |
The constructed FMDP.
Definition at line 298 of file fmdpFactory.h.
|
private |
Depending on the context this flag is used for some VERY important reasons.
Definition at line 267 of file fmdpFactory.h.
|
private |
The FunctionGraph we're building at a given time.
Definition at line 301 of file fmdpFactory.h.
|
private |
State stack.
Definition at line 295 of file fmdpFactory.h.
|
private |
Just to keep track of strings between two start/end calls.
Definition at line 274 of file fmdpFactory.h.
|
private |
Mapping between a declared variable's name and itself.
Definition at line 304 of file fmdpFactory.h.