76 template <
typename GUM_ELEMENT >
87 template <
typename GUM_ELEMENT >
104 template <
typename GUM_ELEMENT >
108 "Illegal state to return the factored "
109 "markov decision process: it is not yet "
117 template <
typename GUM_ELEMENT >
127 template <
typename GUM_ELEMENT >
130 if (elt.first.compare(name) == 0)
return elt.second;
149 template <
typename GUM_ELEMENT >
163 template <
typename GUM_ELEMENT >
177 template <
typename GUM_ELEMENT >
190 template <
typename GUM_ELEMENT >
201 template <
typename GUM_ELEMENT >
210 template <
typename GUM_ELEMENT >
222 _fmdp_->setDeleteVariablesOnDestruction(
true);
239 std::format(
"Not enough modalities ({}) declared for variable {}", nModa, varName))
255 template <
typename GUM_ELEMENT >
268 template <
typename GUM_ELEMENT >
279 template <
typename GUM_ELEMENT >
303 template <
typename GUM_ELEMENT >
315 template <
typename GUM_ELEMENT >
331 template <
typename GUM_ELEMENT >
339 +
" - VARIABLE : " + std::string(var));
351 template <
typename GUM_ELEMENT >
372 template <
typename GUM_ELEMENT >
384 template <
typename GUM_ELEMENT >
397 template <
typename GUM_ELEMENT >
411 template <
typename GUM_ELEMENT >
432 template <
typename GUM_ELEMENT >
445 template <
typename GUM_ELEMENT >
453 template <
typename GUM_ELEMENT >
459 else _fmdp_->addReward(r);
466 template <
typename GUM_ELEMENT >
480 template <
typename GUM_ELEMENT >
487 for (
const auto elt:
_ddBag_) {
488 if (res ==
nullptr) {
510 if (res !=
nullptr) {
534 template <
typename GUM_ELEMENT >
544 template <
typename GUM_ELEMENT >
547 else _fmdp_->setDiscount((GUM_ELEMENT)discount);
552 template <
typename GUM_ELEMENT >
573 template <
typename GUM_ELEMENT >
580 template <
typename GUM_ELEMENT >
582 return _FunctionGraph_->manager()->addTerminalNode((GUM_ELEMENT)value);
586 template <
typename GUM_ELEMENT >
591 template <
typename GUM_ELEMENT >
607 template <
typename GUM_ELEMENT >
609 std::string msg =
"Illegal state call (";
611 msg +=
") in state ";
628 default : msg +=
"Unknown state";
636 template <
typename GUM_ELEMENT >
644 template <
typename GUM_ELEMENT >
648 for (
auto varIter =
_fmdp_->beginVariables(); varIter !=
_fmdp_->endVariables(); ++varIter) {
653 for (
auto varIter =
_fmdp_->beginVariables(); varIter !=
_fmdp_->endVariables(); ++varIter) {
658 template <
typename GUM_ELEMENT >
679 template <
typename GUM_ELEMENT >
Base class for discrete random variable.
Exception : a similar element already exists.
A factory class to ease Factored Markov Decision Process construction.
void variableName(std::string_view name) override
Tells the factory the current variable's name.
void addModality(std::string_view name) override
Adds a modality to the current variable.
void endVariableDeclaration() override
Tells the factory that we're out of a variable declaration.
NodeId addInternalNode(std::string_view name_of_var) override
Insert in diagram a non terminal node.
const DiscreteVariable * variable(std::string_view name) const override
Returns a constant reference on a variable given it's name.
void endTransitionDeclaration() override
Tells the factory that we're out of a transition declaration.
void endDiscountDeclaration() override
Tells the factory that we're out of a cost declaration.
~FMDPFactory() override
Destructor.
std::vector< FMDPfactory_state > _states_
State stack.
FMDPFactory< GUM_ELEMENT > & operator=(const FMDPFactory< GUM_ELEMENT > &source)
Copy operator is illegal, use only copy constructor.
void startActionDeclaration() override
Tells the factory that we're in an action declaration.
void addCost() override
Tells the factory to add a cost table to the current fmdp. This cost table will be extracted from inc...
void _resetParts_()
Reset the different parts used to constructed the FMDP.
HashTable< std::string, const DiscreteVariable * > _varNameMap_
Mapping between a declared variable's name and itself.
FMDP< GUM_ELEMENT > * _fmdp_
The constructed FMDP.
void addTransition(std::string_view var, const MultiDimAdressable *transition) override
Tells the factory to add a transition table to the current fmdp.
void _finalizeFunctionGraph_()
Insert every variables in the function graph.
void addArc(NodeId from, NodeId to, Idx modality) override
Insert in diagram a non terminal node.
void addReward() override
Tells the factory to add a reward table to the current fmdp. This reward table will be extracted from...
void endActionDeclaration() override
Tells the factory that we're out of an action declaration.
bool _foo_flag_
Depending on the context this flag is used for some VERY important reasons.
void _initializeFunctionGraph_()
Insert every variables in the function graph.
void setRoot(NodeId rootId) override
add an arc in diagram
void addDiscount(float discount) override
Tells the factory to add a cost table to the current fmdp.
MultiDimFunctionGraph< GUM_ELEMENT > * _FunctionGraph_
The FunctionGraph we're building at a given time.
void _checkModalityInBag_(std::string_view mod)
Used in VARIABLE mode Checks if in stringBag there is no other modality with the same name.
void endRewardDeclaration() override
Tells the factory that we're out of a cost declaration.
void startVariableDeclaration() override
Tells the factory that we're in a variable declaration.
FMDP< GUM_ELEMENT > * fmdp() const
Returns the Factored Markov Decision Process created by this factory.
void startDiscountDeclaration() override
Tells the factory that we're in a cost declaration.
void startCostDeclaration() override
Tells the factory that we're in a cost declaration.
FMDPFactory(FMDP< GUM_ELEMENT > *fmdp)
Use this constructor if you want to use an already created factored markov decision process.
FMDPfactory_state state() const override
Returns the current state of the factory.
NodeId addTerminalNode(float value) override
Insert in diagram a terminal node.
bool _bar_flag_
Depending on the context this flag is used for some VERY important reasons.
void endCostDeclaration() override
Tells the factory that we're out of a cost declaration.
std::vector< std::string > _stringBag_
Just to keep track of strings between two start/end calls.
Idx _actionIdcpt_
Action Id counter.
void variableDescription(std::string_view desc) override
Tells the factory the current variable's description.
std::vector< const MultiDimImplementation< GUM_ELEMENT > * > _ddBag_
Just to keep track of multidim between two start/end calls.
void startRewardDeclaration() override
Tells the factory that we're in a reward declaration.
void _illegalStateError_(std::string_view s)
Raise an OperationNotAllowed with the message "Illegal state.".
void startTransitionDeclaration() override
Tells the factory that we're in a transition declaration.
void addAction(std::string_view action) override
Tells the factory to add an action to the current fmdp.
void setOperationModeOn(std::string_view operationType) override
Tells the factory that we're in a reward declaration mode where the global reward diagram is an opera...
This class is used to implement factored decision process.
Exception : fatal (unknown ?) error.
LabelizedVariable & addLabel(std::string_view 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_ELEMENT, 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.