75 template <
typename GUM_SCALAR >
86 template <
typename GUM_SCALAR >
103 template <
typename GUM_SCALAR >
107 "Illegal state to return the factored "
108 "markov decision process: it is not yet "
116 template <
typename GUM_SCALAR >
126 template <
typename GUM_SCALAR >
130 if (elt.first.compare(name) == 0)
return elt.second;
149 template <
typename GUM_SCALAR >
163 template <
typename GUM_SCALAR >
177 template <
typename GUM_SCALAR >
190 template <
typename GUM_SCALAR >
201 template <
typename GUM_SCALAR >
210 template <
typename GUM_SCALAR >
231 std::stringstream msg;
232 msg <<
"Not enough modalities (";
237 msg <<
") declared for variable ";
240 else msg <<
"unknown";
261 template <
typename GUM_SCALAR >
274 template <
typename GUM_SCALAR >
285 template <
typename GUM_SCALAR >
309 template <
typename GUM_SCALAR >
321 template <
typename GUM_SCALAR >
337 template <
typename GUM_SCALAR >
347 this->_FunctionGraph_);
356 template <
typename GUM_SCALAR >
377 template <
typename GUM_SCALAR >
389 template <
typename GUM_SCALAR >
402 template <
typename GUM_SCALAR >
416 template <
typename GUM_SCALAR >
437 template <
typename GUM_SCALAR >
450 template <
typename GUM_SCALAR >
453 std::string ot(operationType);
459 template <
typename GUM_SCALAR >
465 else _fmdp_->addReward(r);
472 template <
typename GUM_SCALAR >
486 template <
typename GUM_SCALAR >
494 for (
const auto elt:
_ddBag_) {
511 if (temp !=
nullptr)
delete temp;
535 template <
typename GUM_SCALAR >
545 template <
typename GUM_SCALAR >
554 template <
typename GUM_SCALAR >
575 template <
typename GUM_SCALAR >
582 template <
typename GUM_SCALAR >
588 template <
typename GUM_SCALAR >
593 template <
typename GUM_SCALAR >
609 template <
typename GUM_SCALAR >
611 std::string msg =
"Illegal state call (";
613 msg +=
") in state ";
630 default : msg +=
"Unknown state";
638 template <
typename GUM_SCALAR >
646 template <
typename GUM_SCALAR >
650 for (
auto varIter =
_fmdp_->beginVariables(); varIter !=
_fmdp_->endVariables(); ++varIter) {
655 for (
auto varIter =
_fmdp_->beginVariables(); varIter !=
_fmdp_->endVariables(); ++varIter) {
660 template <
typename GUM_SCALAR >
681 template <
typename GUM_SCALAR >
Base class for discrete random variable.
Exception : a similar element already exists.
A factory class to ease Factored Markov Decision Process construction.
void addCost()
Tells the factory to add a cost table to the current fmdp. This cost table will be extracted from inc...
NodeId addTerminalNode(float value)
Insert in diagram a terminal node.
void setOperationModeOn(std::string operationType)
Tells the factory that we're in a reward declaration mode where the global reward diagram is an opera...
FMDP< GUM_SCALAR > * _fmdp_
The constructed FMDP.
void addArc(NodeId from, NodeId to, Idx modality)
Insert in diagram a non terminal node.
FMDPFactory(FMDP< GUM_SCALAR > *fmdp)
Use this constructor if you want to use an already created factored markov decision process.
FMDPFactory< GUM_SCALAR > & operator=(const FMDPFactory< GUM_SCALAR > &source)
Copy operator is illegal, use only copy constructor.
void endTransitionDeclaration()
Tells the factory that we're out of a transition declaration.
void addTransition(const std::string &var, const MultiDimAdressable *transition)
Tells the factory to add a transition table to the current fmdp.
void addAction(const std::string &action)
Tells the factory to add an action to the current fmdp.
void startVariableDeclaration()
Tells the factory that we're in a variable declaration.
void startDiscountDeclaration()
Tells the factory that we're in a cost declaration.
void _resetParts_()
Reset the different parts used to constructed the FMDP.
~FMDPFactory()
Destructor.
void _initializeFunctionGraph_()
Insert every variables in the function graph.
void variableName(const std::string &name)
Tells the factory the current variable's name.
HashTable< std::string, const DiscreteVariable * > _varNameMap_
Mapping between a declared variable's name and itself.
void addModality(const std::string &name)
Adds a modality to the current variable.
void addReward()
Tells the factory to add a reward table to the current fmdp. This reward table will be extracted from...
void startTransitionDeclaration()
Tells the factory that we're in a transition declaration.
void endVariableDeclaration()
Tells the factory that we're out of a variable declaration.
void startActionDeclaration()
Tells the factory that we're in an action declaration.
bool _bar_flag_
Depending on the context this flag is used for some VERY important reasons.
bool _foo_flag_
Depending on the context this flag is used for some VERY important reasons.
void _checkModalityInBag_(const std::string &mod)
Used in VARIABLE mode Checks if in stringBag there is no other modality with the same name.
void endCostDeclaration()
Tells the factory that we're out of a cost declaration.
void startRewardDeclaration()
Tells the factory that we're in a reward declaration.
void endRewardDeclaration()
Tells the factory that we're out of a cost declaration.
std::vector< const MultiDimImplementation< GUM_SCALAR > * > _ddBag_
Just to keep track of multidim between two start/end calls.
void startCostDeclaration()
Tells the factory that we're in a cost declaration.
void endActionDeclaration()
Tells the factory that we're out of an action declaration.
void endDiscountDeclaration()
Tells the factory that we're out of a cost declaration.
FMDPfactory_state state() const
Returns the current state of the factory.
FMDP< GUM_SCALAR > * fmdp() const
Returns the Factored Markov Decision Process created by this factory.
std::vector< FMDPfactory_state > _states_
State stack.
void variableDescription(const std::string &desc)
Tells the factory the current variable's description.
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.
void addDiscount(float discount)
Tells the factory to add a cost table to the current fmdp.
NodeId addInternalNode(std::string name_of_var)
Insert in diagram a non terminal node.
MultiDimFunctionGraph< GUM_SCALAR > * _FunctionGraph_
The FunctionGraph we're building at a given time.
std::vector< std::string > _stringBag_
Just to keep track of strings between two start/end calls.
void _finalizeFunctionGraph_()
Insert every variables in the function graph.
void _illegalStateError_(const std::string &s)
Raise an OperationNotAllowed with the message "Illegal state.".
Idx _actionIdcpt_
Action Id counter.
This class is used to implement factored decision process.
Exception : fatal (unknown ?) error.
LabelizedVariable & addLabel(const std::string &aLabel)
add a label with a new index (we assume that we will NEVER remove a label)
Abstract base class for all multi dimensionnal addressable.
Class implementingting a function graph.
static MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy > * getReducedAndOrderedInstance()
Returns a reduced and ordered instance.
<agrum/base/multidim/multiDimImplementation.h>
Exception : the element we looked for cannot be found.
Exception : operation not allowed.
const std::string & name() const
returns the name of the variable
#define GUM_ERROR(type, msg)
Headers of the FMDPFactory class.
Size Idx
Type for indexes.
Size NodeId
Type for node ids.
MultiDimFunctionGraph< T > * divide2MultiDimFunctionGraphs(const MultiDimFunctionGraph< T > *t1, const MultiDimFunctionGraph< T > *t2)
a specialized function for dividing two multiDimArrays
MultiDimFunctionGraph< T > * multiply2MultiDimFunctionGraphs(const MultiDimFunctionGraph< T > *t1, const MultiDimFunctionGraph< T > *t2)
a specialized function for multiplying two multiDimArrays
MultiDimFunctionGraph< T > * subtract2MultiDimFunctionGraphs(const MultiDimFunctionGraph< T > *t1, const MultiDimFunctionGraph< T > *t2)
a specialized function for subtracting two multiDimArrays
MultiDimFunctionGraph< T > * add2MultiDimFunctionGraphs(const MultiDimFunctionGraph< T > *t1, const MultiDimFunctionGraph< T > *t2)
a specialized function for summing two multiDimArrays
Headers of gum::MultiDimImplementation.
gum is the global namespace for all aGrUM entities
FMDPfactory_state
The enumeration of states in which the factory can be in.
Header of the Tensor class.