53 template <
typename GUM_SCALAR >
66 template <
typename GUM_SCALAR >
83 template <
typename GUM_SCALAR >
87 "Illegal state to return the factored " 88 "markov decision process: it is not yet " 97 template <
typename GUM_SCALAR >
108 template <
typename GUM_SCALAR >
112 if (elt.first.compare(name) == 0)
return elt.second;
132 template <
typename GUM_SCALAR >
148 template <
typename GUM_SCALAR >
165 template <
typename GUM_SCALAR >
181 template <
typename GUM_SCALAR >
194 template <
typename GUM_SCALAR >
205 template <
typename GUM_SCALAR >
213 for (
size_t i = 2; i < __stringBag.size(); ++i) {
228 std::stringstream msg;
229 msg <<
"Not enough modalities (";
236 msg <<
") declared for variable ";
263 template <
typename GUM_SCALAR >
278 template <
typename GUM_SCALAR >
291 template <
typename GUM_SCALAR >
317 template <
typename GUM_SCALAR >
331 template <
typename GUM_SCALAR >
340 __fmdp->addTransitionForAction(
351 template <
typename GUM_SCALAR >
360 +
" - VARIABLE : " + var);
373 template <
typename GUM_SCALAR >
397 template <
typename GUM_SCALAR >
411 template <
typename GUM_SCALAR >
428 template <
typename GUM_SCALAR >
446 template <
typename GUM_SCALAR >
470 template <
typename GUM_SCALAR >
485 template <
typename GUM_SCALAR >
489 std::string ot(operationType);
496 template <
typename GUM_SCALAR >
513 template <
typename GUM_SCALAR >
531 template <
typename GUM_SCALAR >
540 for (
const auto elt :
__ddBag) {
557 if (temp !=
nullptr)
delete temp;
560 ->setTableName(
"Reward");
583 template <
typename GUM_SCALAR >
596 template <
typename GUM_SCALAR >
606 template <
typename GUM_SCALAR >
630 template <
typename GUM_SCALAR >
639 template <
typename GUM_SCALAR >
646 template <
typename GUM_SCALAR >
653 template <
typename GUM_SCALAR >
669 template <
typename GUM_SCALAR >
672 std::string msg =
"Illegal state call (";
674 msg +=
") in state ";
680 msg +=
"FMDPfactory_state::VARIABLE";
686 msg +=
"FMDPfactory_state::TRANSITION";
694 msg +=
"FMDPfactory_state::DISCOUNT";
697 default: msg +=
"Unknown state";
706 template <
typename GUM_SCALAR >
715 template <
typename GUM_SCALAR >
720 for (
auto varIter =
__fmdp->beginVariables();
721 varIter !=
__fmdp->endVariables();
727 for (
auto varIter =
__fmdp->beginVariables();
728 varIter !=
__fmdp->endVariables();
735 template <
typename GUM_SCALAR >
756 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.
gum is the global namespace for all aGrUM entities
void __checkModalityInBag(const std::string &mod)
Used in VARIABLE mode Checks if in __stringBag there is no other modality with the same name...
Headers of gum::MultiDimImplementation.
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.
Header of the Potential class.
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.
Headers of the FMDPFactory class.
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)