56 template <
typename GUM_SCALAR >
69 template <
typename GUM_SCALAR >
86 template <
typename GUM_SCALAR >
90 "Illegal state to return the factored " 91 "markov decision process: it is not yet " 100 template <
typename GUM_SCALAR >
111 template <
typename GUM_SCALAR >
115 if (elt.first.compare(name) == 0)
return elt.second;
135 template <
typename GUM_SCALAR >
151 template <
typename GUM_SCALAR >
168 template <
typename GUM_SCALAR >
184 template <
typename GUM_SCALAR >
197 template <
typename GUM_SCALAR >
208 template <
typename GUM_SCALAR >
216 for (
size_t i = 2; i < __stringBag.size(); ++i) {
231 std::stringstream msg;
232 msg <<
"Not enough modalities (";
239 msg <<
") declared for variable ";
266 template <
typename GUM_SCALAR >
281 template <
typename GUM_SCALAR >
294 template <
typename GUM_SCALAR >
320 template <
typename GUM_SCALAR >
334 template <
typename GUM_SCALAR >
343 __fmdp->addTransitionForAction(
354 template <
typename GUM_SCALAR >
363 +
" - VARIABLE : " + var);
376 template <
typename GUM_SCALAR >
400 template <
typename GUM_SCALAR >
414 template <
typename GUM_SCALAR >
431 template <
typename GUM_SCALAR >
449 template <
typename GUM_SCALAR >
473 template <
typename GUM_SCALAR >
488 template <
typename GUM_SCALAR >
492 std::string ot(operationType);
499 template <
typename GUM_SCALAR >
516 template <
typename GUM_SCALAR >
534 template <
typename GUM_SCALAR >
543 for (
const auto elt :
__ddBag) {
560 if (temp !=
nullptr)
delete temp;
563 ->setTableName(
"Reward");
586 template <
typename GUM_SCALAR >
599 template <
typename GUM_SCALAR >
609 template <
typename GUM_SCALAR >
633 template <
typename GUM_SCALAR >
642 template <
typename GUM_SCALAR >
649 template <
typename GUM_SCALAR >
656 template <
typename GUM_SCALAR >
672 template <
typename GUM_SCALAR >
675 std::string msg =
"Illegal state call (";
677 msg +=
") in state ";
683 msg +=
"FMDPfactory_state::VARIABLE";
689 msg +=
"FMDPfactory_state::TRANSITION";
697 msg +=
"FMDPfactory_state::DISCOUNT";
700 default: msg +=
"Unknown state";
709 template <
typename GUM_SCALAR >
718 template <
typename GUM_SCALAR >
723 for (
auto varIter =
__fmdp->beginVariables();
724 varIter !=
__fmdp->endVariables();
730 for (
auto varIter =
__fmdp->beginVariables();
731 varIter !=
__fmdp->endVariables();
738 template <
typename GUM_SCALAR >
759 template <
typename GUM_SCALAR >
void addReward()
Tells the factory to add a reward table to the current fmdp. This reward table will be extracted from...
void __illegalStateError(const std::string &s)
Raise an OperationNotAllowed with the message "Illegal state.".
std::vector< std::string > __stringBag
Just to keep track of strings between two start/end calls.
void endTransitionDeclaration()
Tells the factory that we're out of a transition declaration.
FMDPfactory_state state() const
Returns the current state of the factory.
void __resetParts()
Reset the different parts used to constructed the FMDP.
void endActionDeclaration()
Tells the factory that we're out of an action declaration.
A factory class to ease Factored Markov Decision Process construction.
FMDPFactory< GUM_SCALAR > & operator=(const FMDPFactory< GUM_SCALAR > &source)
Copy operator is illegal, use only copy constructor.
void addAction(const std::string &action)
Tells the factory to add an action to the current fmdp.
void setSon(const NodeId &node, const Idx &modality, const NodeId &sonNode)
Sets nodes son for given modality to designated son node.
void __initializeFunctionGraph()
Insert every variables in the function graph.
void clean()
Removes var without nodes in the diagram.
void setRootNode(const NodeId &root)
Sets root node of decision diagram.
MultiDimFunctionGraph< GUM_SCALAR > * __FunctionGraph
The FunctionGraph we're building at a given time.
void startDiscountDeclaration()
Tells the factory that we're in a cost declaration.
FMDPfactory_state
The enumeration of states in which the factory can be in.
void startActionDeclaration()
Tells the factory that we're in an action declaration.
void addDiscount(float discount)
Tells the factory to add a cost table to the current fmdp.
void startVariableDeclaration()
Tells the factory that we're in a variable declaration.
void endCostDeclaration()
Tells the factory that we're out of a cost declaration.
void addArc(NodeId from, NodeId to, Idx modality)
Insert in diagram a non terminal node.
void setRoot(NodeId rootId)
add an arc in diagram
const DiscreteVariable * variable(const std::string &name) const
Returns a constant reference on a variable given it's name.
MultiDimFunctionGraph< T > * subtract2MultiDimFunctionGraphs(const MultiDimFunctionGraph< T > *t1, const MultiDimFunctionGraph< T > *t2)
a specialized function for subtracting two multiDimArraysThe function produces a tensorial subtractio...
NodeId addInternalNode(const DiscreteVariable *var)
Inserts a new non terminal node in graph.
This class is used to implement factored decision process.
void addModality(const std::string &name)
Adds a modality to the current variable.
Base class for discrete random variable.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
void __checkModalityInBag(const std::string &mod)
Used in VARIABLE mode Checks if in __stringBag there is no other modality with the same name...
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
bool __bar_flag
Depending on the context this flag is used for some VERY important reasons.
FMDP< GUM_SCALAR > * fmdp() const
Returns the Factored Markov Decision Process created by this factory.
void endDiscountDeclaration()
Tells the factory that we're out of a cost declaration.
~FMDPFactory()
Destructor.
virtual void add(const DiscreteVariable &v)
Adds a new var to the variables of the multidimensional matrix.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
void addTransition(const std::string &var, const MultiDimAdressable *transition)
Tells the factory to add a transition table to the current fmdp.
void addCost()
Tells the factory to add a cost table to the current fmdp. This cost table will be extracted from inc...
MultiDimFunctionGraph< T > * multiply2MultiDimFunctionGraphs(const MultiDimFunctionGraph< T > *t1, const MultiDimFunctionGraph< T > *t2)
a specialized function for multiplying two multiDimArraysThe function produces a tensorial product of...
Idx __actionIdcpt
Action Id counter.
void endRewardDeclaration()
Tells the factory that we're out of a cost declaration.
HashTable< std::string, const DiscreteVariable *> __varNameMap
Mapping between a declared variable's name and itself.
std::vector< FMDPfactory_state > __states
State stack.
void endVariableDeclaration()
Tells the factory that we're out of a variable declaration.
NodeId addInternalNode(std::string name_of_var)
Insert in diagram a non terminal node.
void startCostDeclaration()
Tells the factory that we're in a cost declaration.
NodeId addTerminalNode(float value)
Insert in diagram a terminal node.
void variableName(const std::string &name)
Tells the factory the current variable's name.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
bool __foo_flag
Depending on the context this flag is used for some VERY important reasons.
Abstract base class for all multi dimensionnal addressable.
FMDP< GUM_SCALAR > * __fmdp
The constructed FMDP.
std::vector< const MultiDimImplementation< GUM_SCALAR > *> __ddBag
Just to keep track of multidim between two start/end calls.
MultiDimFunctionGraph< T > * add2MultiDimFunctionGraphs(const MultiDimFunctionGraph< T > *t1, const MultiDimFunctionGraph< T > *t2)
a specialized function for summing two multiDimArraysThe function produces a tensorial addition of t1...
MultiDimFunctionGraph< T > * divide2MultiDimFunctionGraphs(const MultiDimFunctionGraph< T > *t1, const MultiDimFunctionGraph< T > *t2)
a specialized function for dividing two multiDimArraysThe function produces a tensorial division of t...
void variableDescription(const std::string &desc)
Tells the factory the current variable's description.
NodeId addTerminalNode(const GUM_SCALAR &value)
Adds a value to the MultiDimFunctionGraph.
<agrum/multidim/multiDimImplementation.h>
Size Idx
Type for indexes.
void setOperationModeOn(std::string operationType)
Tells the factory that we're in a reward declaration mode where the global reward diagram is an opera...
MultiDimFunctionGraphManager< GUM_SCALAR, TerminalNodePolicy > * manager()
Returns a const reference to the manager of this diagram.
void __finalizeFunctionGraph()
Insert every variables in the function graph.
void startRewardDeclaration()
Tells the factory that we're in a reward declaration.
void setTableName(const std::string &name)
Sets the name of the table represented by this structure.
FMDPFactory(FMDP< GUM_SCALAR > *fmdp)
Use this constructor if you want to use an already created factored markov decision process...
const std::string & name() const
returns the name of the variable
LabelizedVariable & addLabel(const std::string &aLabel)
add a label with a new index (we assume that we will NEVER remove a label)
virtual void reduce()=0
Ensures that every isomorphic subgraphs are merged together.
Size NodeId
Type for node ids.
void startTransitionDeclaration()
Tells the factory that we're in a transition declaration.
static MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy > * getReducedAndOrderedInstance()
Returns a reduced and ordered instance.
#define GUM_ERROR(type, msg)