aGrUM  0.16.0
gum::FMDPFactory< GUM_SCALAR > Class Template Reference

A factory class to ease Factored Markov Decision Process construction. More...

#include <agrum/FMDP/fmdpFactory.h>

+ Inheritance diagram for gum::FMDPFactory< GUM_SCALAR >:
+ Collaboration diagram for gum::FMDPFactory< GUM_SCALAR >:

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 DiscreteVariablevariable (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...
 

Detailed Description

template<typename GUM_SCALAR>
class gum::FMDPFactory< GUM_SCALAR >

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.

Constructor & Destructor Documentation

◆ FMDPFactory()

template<typename GUM_SCALAR >
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.

Parameters
fmdpA pointer over the FMDP filled by this factory.

Definition at line 57 of file fmdpFactory_tpl.h.

References gum::FMDPFactory< GUM_SCALAR >::__actionIdcpt, gum::FMDPFactory< GUM_SCALAR >::__states, gum::NONE, and gum::AbstractFMDPFactory::resetVerbose().

57  :
58  __fmdp(fmdp) {
59  GUM_CONSTRUCTOR(FMDPFactory);
60 
62  resetVerbose();
63  __actionIdcpt = 1;
64  }
FMDP< GUM_SCALAR > * fmdp() const
Returns the Factored Markov Decision Process created by this factory.
Idx __actionIdcpt
Action Id counter.
Definition: fmdpFactory.h:307
std::vector< FMDPfactory_state > __states
State stack.
Definition: fmdpFactory.h:295
FMDP< GUM_SCALAR > * __fmdp
The constructed FMDP.
Definition: fmdpFactory.h:298
FMDPFactory(FMDP< GUM_SCALAR > *fmdp)
Use this constructor if you want to use an already created factored markov decision process...
+ Here is the call graph for this function:

◆ ~FMDPFactory()

template<typename GUM_SCALAR >
INLINE gum::FMDPFactory< GUM_SCALAR >::~FMDPFactory ( )

Destructor.

To prevent strange behaviour you should always destroy a FMDPFactory when it's state equals NONE.

Exceptions
FatalErrorRaised if the state of the factory prevents it to die peacefully.

Definition at line 70 of file fmdpFactory_tpl.h.

70  {
71  GUM_DESTRUCTOR(FMDPFactory);
72  }
FMDPFactory(FMDP< GUM_SCALAR > *fmdp)
Use this constructor if you want to use an already created factored markov decision process...

Member Function Documentation

◆ __checkModalityInBag()

template<typename GUM_SCALAR >
INLINE void gum::FMDPFactory< GUM_SCALAR >::__checkModalityInBag ( const std::string &  mod)
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::FMDPFactory< GUM_SCALAR >::__stringBag, and GUM_ERROR.

Referenced by gum::FMDPFactory< GUM_SCALAR >::addModality().

199  {
200  for (size_t i = 2; i < __stringBag.size(); ++i)
201  if (mod == __stringBag[i])
202  GUM_ERROR(DuplicateElement, "Modality" << mod << " already exists.");
203  }
std::vector< std::string > __stringBag
Just to keep track of strings between two start/end calls.
Definition: fmdpFactory.h:274
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
+ Here is the caller graph for this function:

◆ __finalizeFunctionGraph()

template<typename GUM_SCALAR >
INLINE void gum::FMDPFactory< GUM_SCALAR >::__finalizeFunctionGraph ( )
private

Insert every variables in the function graph.

Definition at line 739 of file fmdpFactory_tpl.h.

References gum::FMDPFactory< GUM_SCALAR >::__FunctionGraph, gum::MultiDimFunctionGraphManager< GUM_SCALAR, TerminalNodePolicy >::clean(), gum::MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy >::manager(), gum::FMDPFactory< GUM_SCALAR >::operator=(), and gum::MultiDimFunctionGraphManager< GUM_SCALAR, TerminalNodePolicy >::reduce().

Referenced by gum::FMDPFactory< GUM_SCALAR >::addCost(), gum::FMDPFactory< GUM_SCALAR >::addReward(), and gum::FMDPFactory< GUM_SCALAR >::addTransition().

739  {
740  this->__FunctionGraph->manager()->reduce();
741  this->__FunctionGraph->manager()->clean();
742  }
void clean()
Removes var without nodes in the diagram.
MultiDimFunctionGraph< GUM_SCALAR > * __FunctionGraph
The FunctionGraph we&#39;re building at a given time.
Definition: fmdpFactory.h:301
MultiDimFunctionGraphManager< GUM_SCALAR, TerminalNodePolicy > * manager()
Returns a const reference to the manager of this diagram.
virtual void reduce()=0
Ensures that every isomorphic subgraphs are merged together.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __illegalStateError()

template<typename GUM_SCALAR >
INLINE void gum::FMDPFactory< GUM_SCALAR >::__illegalStateError ( const std::string &  s)
private

Raise an OperationNotAllowed with the message "Illegal state.".

Definition at line 674 of file fmdpFactory_tpl.h.

References gum::ACTION, gum::COST, gum::DISCOUNT, GUM_ERROR, gum::NONE, gum::REWARD, gum::FMDPFactory< GUM_SCALAR >::state(), gum::TRANSITION, and gum::VARIABLE.

Referenced by gum::FMDPFactory< GUM_SCALAR >::addAction(), gum::FMDPFactory< GUM_SCALAR >::addCost(), gum::FMDPFactory< GUM_SCALAR >::addDiscount(), gum::FMDPFactory< GUM_SCALAR >::addModality(), gum::FMDPFactory< GUM_SCALAR >::addReward(), gum::FMDPFactory< GUM_SCALAR >::addTransition(), gum::FMDPFactory< GUM_SCALAR >::endActionDeclaration(), gum::FMDPFactory< GUM_SCALAR >::endCostDeclaration(), gum::FMDPFactory< GUM_SCALAR >::endDiscountDeclaration(), gum::FMDPFactory< GUM_SCALAR >::endRewardDeclaration(), gum::FMDPFactory< GUM_SCALAR >::endTransitionDeclaration(), gum::FMDPFactory< GUM_SCALAR >::endVariableDeclaration(), gum::FMDPFactory< GUM_SCALAR >::startActionDeclaration(), gum::FMDPFactory< GUM_SCALAR >::startCostDeclaration(), gum::FMDPFactory< GUM_SCALAR >::startDiscountDeclaration(), gum::FMDPFactory< GUM_SCALAR >::startRewardDeclaration(), gum::FMDPFactory< GUM_SCALAR >::startTransitionDeclaration(), gum::FMDPFactory< GUM_SCALAR >::startVariableDeclaration(), gum::FMDPFactory< GUM_SCALAR >::variableDescription(), and gum::FMDPFactory< GUM_SCALAR >::variableName().

674  {
675  std::string msg = "Illegal state call (";
676  msg += s;
677  msg += ") in state ";
678 
679  switch (state()) {
680  case FMDPfactory_state::NONE: msg += "FMDPfactory_state::NONE"; break;
681 
683  msg += "FMDPfactory_state::VARIABLE";
684  break;
685 
686  case FMDPfactory_state::ACTION: msg += "FMDPfactory_state::ACTION"; break;
687 
689  msg += "FMDPfactory_state::TRANSITION";
690  break;
691 
692  case FMDPfactory_state::COST: msg += "FMDPfactory_state::COST"; break;
693 
694  case FMDPfactory_state::REWARD: msg += "FMDPfactory_state::REWARD"; break;
695 
697  msg += "FMDPfactory_state::DISCOUNT";
698  break;
699 
700  default: msg += "Unknown state";
701  }
702 
703  GUM_ERROR(OperationNotAllowed, msg);
704  }
FMDPfactory_state state() const
Returns the current state of the factory.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __initializeFunctionGraph()

template<typename GUM_SCALAR >
INLINE void gum::FMDPFactory< GUM_SCALAR >::__initializeFunctionGraph ( )
private

Insert every variables in the function graph.

Definition at line 719 of file fmdpFactory_tpl.h.

References gum::FMDPFactory< GUM_SCALAR >::__fmdp, gum::FMDPFactory< GUM_SCALAR >::__FunctionGraph, gum::MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy >::add(), and gum::MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy >::getReducedAndOrderedInstance().

Referenced by gum::FMDPFactory< GUM_SCALAR >::startCostDeclaration(), gum::FMDPFactory< GUM_SCALAR >::startRewardDeclaration(), and gum::FMDPFactory< GUM_SCALAR >::startTransitionDeclaration().

719  {
720  this->__FunctionGraph =
722  // Recopie des variables principales dans le graphe de décision
723  for (auto varIter = __fmdp->beginVariables();
724  varIter != __fmdp->endVariables();
725  ++varIter) {
726  __FunctionGraph->add(**varIter);
727  }
728 
729  // Recopie des version primes des variables dans le graphe de décision
730  for (auto varIter = __fmdp->beginVariables();
731  varIter != __fmdp->endVariables();
732  ++varIter) {
733  __FunctionGraph->add(*(__fmdp->main2prime(*varIter)));
734  }
735  }
MultiDimFunctionGraph< GUM_SCALAR > * __FunctionGraph
The FunctionGraph we&#39;re building at a given time.
Definition: fmdpFactory.h:301
virtual void add(const DiscreteVariable &v)
Adds a new var to the variables of the multidimensional matrix.
FMDP< GUM_SCALAR > * __fmdp
The constructed FMDP.
Definition: fmdpFactory.h:298
static MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy > * getReducedAndOrderedInstance()
Returns a reduced and ordered instance.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __resetParts()

template<typename GUM_SCALAR >
INLINE void gum::FMDPFactory< GUM_SCALAR >::__resetParts ( )
private

Reset the different parts used to constructed the FMDP.

Definition at line 710 of file fmdpFactory_tpl.h.

References gum::FMDPFactory< GUM_SCALAR >::__bar_flag, gum::FMDPFactory< GUM_SCALAR >::__ddBag, gum::FMDPFactory< GUM_SCALAR >::__foo_flag, and gum::FMDPFactory< GUM_SCALAR >::__stringBag.

Referenced by gum::FMDPFactory< GUM_SCALAR >::endActionDeclaration(), gum::FMDPFactory< GUM_SCALAR >::endRewardDeclaration(), and gum::FMDPFactory< GUM_SCALAR >::endVariableDeclaration().

710  {
711  __foo_flag = false;
712  __bar_flag = false;
713  __stringBag.clear();
714  __ddBag.clear();
715  }
std::vector< std::string > __stringBag
Just to keep track of strings between two start/end calls.
Definition: fmdpFactory.h:274
bool __bar_flag
Depending on the context this flag is used for some VERY important reasons.
Definition: fmdpFactory.h:271
bool __foo_flag
Depending on the context this flag is used for some VERY important reasons.
Definition: fmdpFactory.h:267
std::vector< const MultiDimImplementation< GUM_SCALAR > *> __ddBag
Just to keep track of multidim between two start/end calls.
Definition: fmdpFactory.h:277
+ Here is the caller graph for this function:

◆ addAction()

template<typename GUM_SCALAR >
INLINE void gum::FMDPFactory< GUM_SCALAR >::addAction ( const std::string &  action)
virtual

Tells the factory to add an action to the current fmdp.

Implements gum::AbstractFMDPFactory.

Definition at line 282 of file fmdpFactory_tpl.h.

References gum::FMDPFactory< GUM_SCALAR >::__actionIdcpt, gum::FMDPFactory< GUM_SCALAR >::__fmdp, gum::FMDPFactory< GUM_SCALAR >::__illegalStateError(), gum::FMDPFactory< GUM_SCALAR >::__stringBag, gum::ACTION, and gum::FMDPFactory< GUM_SCALAR >::state().

282  {
284  __illegalStateError("addAction");
285  else {
286  __stringBag.push_back(action);
287  __fmdp->addAction(__actionIdcpt++, action);
288  }
289  }
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.
Definition: fmdpFactory.h:274
FMDPfactory_state state() const
Returns the current state of the factory.
Idx __actionIdcpt
Action Id counter.
Definition: fmdpFactory.h:307
FMDP< GUM_SCALAR > * __fmdp
The constructed FMDP.
Definition: fmdpFactory.h:298
+ Here is the call graph for this function:

◆ addArc()

template<typename GUM_SCALAR >
INLINE void gum::FMDPFactory< GUM_SCALAR >::addArc ( NodeId  from,
NodeId  to,
Idx  modality 
)
virtual

Insert in diagram a non terminal node.

Implements gum::AbstractFMDPFactory.

Definition at line 651 of file fmdpFactory_tpl.h.

References gum::FMDPFactory< GUM_SCALAR >::__FunctionGraph, gum::MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy >::manager(), and gum::MultiDimFunctionGraphManager< GUM_SCALAR, TerminalNodePolicy >::setSon().

651  {
652  __FunctionGraph->manager()->setSon(from, modality, to);
653  }
void setSon(const NodeId &node, const Idx &modality, const NodeId &sonNode)
Sets nodes son for given modality to designated son node.
MultiDimFunctionGraph< GUM_SCALAR > * __FunctionGraph
The FunctionGraph we&#39;re building at a given time.
Definition: fmdpFactory.h:301
MultiDimFunctionGraphManager< GUM_SCALAR, TerminalNodePolicy > * manager()
Returns a const reference to the manager of this diagram.
+ Here is the call graph for this function:

◆ addCost() [1/2]

template<typename GUM_SCALAR >
INLINE void gum::FMDPFactory< GUM_SCALAR >::addCost ( const MultiDimAdressable cost)
virtual

Tells the factory to add a cost table to the current fmdp.

Implements gum::AbstractFMDPFactory.

Definition at line 415 of file fmdpFactory_tpl.h.

References gum::FMDPFactory< GUM_SCALAR >::__fmdp, gum::FMDPFactory< GUM_SCALAR >::__foo_flag, gum::FMDPFactory< GUM_SCALAR >::__illegalStateError(), gum::FMDPFactory< GUM_SCALAR >::__stringBag, gum::COST, and gum::FMDPFactory< GUM_SCALAR >::state().

415  {
416  const MultiDimImplementation< GUM_SCALAR >* c =
417  reinterpret_cast< const MultiDimImplementation< GUM_SCALAR >* >(cost);
418 
420  __illegalStateError("addCost");
421  else if (__foo_flag)
422  __fmdp->addCostForAction(__fmdp->actionId(__stringBag[0]), c);
423  else
424  __fmdp->addCost(c);
425  }
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.
Definition: fmdpFactory.h:274
FMDPfactory_state state() const
Returns the current state of the factory.
bool __foo_flag
Depending on the context this flag is used for some VERY important reasons.
Definition: fmdpFactory.h:267
FMDP< GUM_SCALAR > * __fmdp
The constructed FMDP.
Definition: fmdpFactory.h:298
+ Here is the call graph for this function:

◆ addCost() [2/2]

template<typename GUM_SCALAR >
INLINE void gum::FMDPFactory< GUM_SCALAR >::addCost ( )
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 432 of file fmdpFactory_tpl.h.

References gum::FMDPFactory< GUM_SCALAR >::__finalizeFunctionGraph(), gum::FMDPFactory< GUM_SCALAR >::__fmdp, gum::FMDPFactory< GUM_SCALAR >::__foo_flag, gum::FMDPFactory< GUM_SCALAR >::__FunctionGraph, gum::FMDPFactory< GUM_SCALAR >::__illegalStateError(), gum::FMDPFactory< GUM_SCALAR >::__stringBag, gum::COST, and gum::FMDPFactory< GUM_SCALAR >::state().

432  {
434  __illegalStateError("addCost");
435  else {
436  this->__finalizeFunctionGraph();
437 
438  if (__foo_flag)
439  __fmdp->addCostForAction(__fmdp->actionId(__stringBag[0]),
440  this->__FunctionGraph);
441  else
442  __fmdp->addCost(this->__FunctionGraph);
443  }
444  }
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.
Definition: fmdpFactory.h:274
FMDPfactory_state state() const
Returns the current state of the factory.
MultiDimFunctionGraph< GUM_SCALAR > * __FunctionGraph
The FunctionGraph we&#39;re building at a given time.
Definition: fmdpFactory.h:301
bool __foo_flag
Depending on the context this flag is used for some VERY important reasons.
Definition: fmdpFactory.h:267
FMDP< GUM_SCALAR > * __fmdp
The constructed FMDP.
Definition: fmdpFactory.h:298
void __finalizeFunctionGraph()
Insert every variables in the function graph.
+ Here is the call graph for this function:

◆ addDiscount()

template<typename GUM_SCALAR >
INLINE void gum::FMDPFactory< GUM_SCALAR >::addDiscount ( float  discount)
virtual

Tells the factory to add a cost table to the current fmdp.

Implements gum::AbstractFMDPFactory.

Definition at line 600 of file fmdpFactory_tpl.h.

References gum::FMDPFactory< GUM_SCALAR >::__illegalStateError(), gum::DISCOUNT, and gum::FMDPFactory< GUM_SCALAR >::state().

600  {
601  if (state() != FMDPfactory_state::DISCOUNT) __illegalStateError("addDiscount");
602  // else
603  // __fmdp->setDiscount ( ( GUM_SCALAR ) discount );
604  }
void __illegalStateError(const std::string &s)
Raise an OperationNotAllowed with the message "Illegal state.".
FMDPfactory_state state() const
Returns the current state of the factory.
+ Here is the call graph for this function:

◆ addInternalNode()

template<typename GUM_SCALAR >
INLINE NodeId gum::FMDPFactory< GUM_SCALAR >::addInternalNode ( std::string  name_of_var)
virtual

Insert in diagram a non terminal node.

Implements gum::AbstractFMDPFactory.

Definition at line 635 of file fmdpFactory_tpl.h.

References gum::FMDPFactory< GUM_SCALAR >::__FunctionGraph, gum::MultiDimFunctionGraphManager< GUM_SCALAR, TerminalNodePolicy >::addInternalNode(), gum::MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy >::manager(), and gum::FMDPFactory< GUM_SCALAR >::variable().

635  {
636  return __FunctionGraph->manager()->addInternalNode(variable(name_of_var));
637  }
MultiDimFunctionGraph< GUM_SCALAR > * __FunctionGraph
The FunctionGraph we&#39;re building at a given time.
Definition: fmdpFactory.h:301
const DiscreteVariable * variable(const std::string &name) const
Returns a constant reference on a variable given it&#39;s name.
NodeId addInternalNode(const DiscreteVariable *var)
Inserts a new non terminal node in graph.
MultiDimFunctionGraphManager< GUM_SCALAR, TerminalNodePolicy > * manager()
Returns a const reference to the manager of this diagram.
+ Here is the call graph for this function:

◆ addModality()

template<typename GUM_SCALAR >
INLINE void gum::FMDPFactory< GUM_SCALAR >::addModality ( const std::string &  name)
virtual

Adds a modality to the current variable.

Implements gum::AbstractFMDPFactory.

Definition at line 185 of file fmdpFactory_tpl.h.

References gum::FMDPFactory< GUM_SCALAR >::__checkModalityInBag(), gum::FMDPFactory< GUM_SCALAR >::__illegalStateError(), gum::FMDPFactory< GUM_SCALAR >::__stringBag, gum::FMDPFactory< GUM_SCALAR >::state(), and gum::VARIABLE.

185  {
187  __illegalStateError("addModality");
188  else {
189  __checkModalityInBag(name);
190  __stringBag.push_back(name);
191  }
192  }
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.
Definition: fmdpFactory.h:274
FMDPfactory_state state() const
Returns the current state of the factory.
void __checkModalityInBag(const std::string &mod)
Used in VARIABLE mode Checks if in __stringBag there is no other modality with the same name...
+ Here is the call graph for this function:

◆ addReward() [1/2]

template<typename GUM_SCALAR >
INLINE void gum::FMDPFactory< GUM_SCALAR >::addReward ( const MultiDimAdressable reward)
virtual

Tells the factory to add a reward table to the current fmdp.

Implements gum::AbstractFMDPFactory.

Definition at line 501 of file fmdpFactory_tpl.h.

References gum::FMDPFactory< GUM_SCALAR >::__fmdp, gum::FMDPFactory< GUM_SCALAR >::__illegalStateError(), gum::REWARD, and gum::FMDPFactory< GUM_SCALAR >::state().

501  {
502  const MultiDimImplementation< GUM_SCALAR >* r =
503  reinterpret_cast< const MultiDimImplementation< GUM_SCALAR >* >(reward);
504 
506  __illegalStateError("addReward");
507  else
508  __fmdp->addReward(r);
509  }
void __illegalStateError(const std::string &s)
Raise an OperationNotAllowed with the message "Illegal state.".
FMDPfactory_state state() const
Returns the current state of the factory.
FMDP< GUM_SCALAR > * __fmdp
The constructed FMDP.
Definition: fmdpFactory.h:298
+ Here is the call graph for this function:

◆ addReward() [2/2]

template<typename GUM_SCALAR >
INLINE void gum::FMDPFactory< GUM_SCALAR >::addReward ( )
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 517 of file fmdpFactory_tpl.h.

References gum::FMDPFactory< GUM_SCALAR >::__ddBag, gum::FMDPFactory< GUM_SCALAR >::__finalizeFunctionGraph(), gum::FMDPFactory< GUM_SCALAR >::__fmdp, gum::FMDPFactory< GUM_SCALAR >::__foo_flag, gum::FMDPFactory< GUM_SCALAR >::__FunctionGraph, gum::FMDPFactory< GUM_SCALAR >::__illegalStateError(), gum::REWARD, gum::MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy >::setTableName(), and gum::FMDPFactory< GUM_SCALAR >::state().

517  {
519  __illegalStateError("addReward");
520  else {
521  this->__finalizeFunctionGraph();
522  __FunctionGraph->setTableName("Reward");
523 
524  if (__foo_flag)
525  __ddBag.push_back(this->__FunctionGraph);
526  else
527  __fmdp->addReward(this->__FunctionGraph);
528  }
529  }
void __illegalStateError(const std::string &s)
Raise an OperationNotAllowed with the message "Illegal state.".
FMDPfactory_state state() const
Returns the current state of the factory.
MultiDimFunctionGraph< GUM_SCALAR > * __FunctionGraph
The FunctionGraph we&#39;re building at a given time.
Definition: fmdpFactory.h:301
bool __foo_flag
Depending on the context this flag is used for some VERY important reasons.
Definition: fmdpFactory.h:267
FMDP< GUM_SCALAR > * __fmdp
The constructed FMDP.
Definition: fmdpFactory.h:298
std::vector< const MultiDimImplementation< GUM_SCALAR > *> __ddBag
Just to keep track of multidim between two start/end calls.
Definition: fmdpFactory.h:277
void __finalizeFunctionGraph()
Insert every variables in the function graph.
void setTableName(const std::string &name)
Sets the name of the table represented by this structure.
+ Here is the call graph for this function:

◆ addTerminalNode()

template<typename GUM_SCALAR >
INLINE NodeId gum::FMDPFactory< GUM_SCALAR >::addTerminalNode ( float  value)
virtual

Insert in diagram a terminal node.

Implements gum::AbstractFMDPFactory.

Definition at line 643 of file fmdpFactory_tpl.h.

References gum::FMDPFactory< GUM_SCALAR >::__FunctionGraph, gum::MultiDimFunctionGraphManager< GUM_SCALAR, TerminalNodePolicy >::addTerminalNode(), and gum::MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy >::manager().

643  {
644  return __FunctionGraph->manager()->addTerminalNode((GUM_SCALAR)value);
645  }
MultiDimFunctionGraph< GUM_SCALAR > * __FunctionGraph
The FunctionGraph we&#39;re building at a given time.
Definition: fmdpFactory.h:301
NodeId addTerminalNode(const GUM_SCALAR &value)
Adds a value to the MultiDimFunctionGraph.
MultiDimFunctionGraphManager< GUM_SCALAR, TerminalNodePolicy > * manager()
Returns a const reference to the manager of this diagram.
+ Here is the call graph for this function:

◆ addTransition() [1/2]

template<typename GUM_SCALAR >
INLINE void gum::FMDPFactory< GUM_SCALAR >::addTransition ( const std::string &  var,
const MultiDimAdressable transition 
)
virtual

Tells the factory to add a transition table to the current fmdp.

Implements gum::AbstractFMDPFactory.

Definition at line 335 of file fmdpFactory_tpl.h.

References gum::FMDPFactory< GUM_SCALAR >::__fmdp, gum::FMDPFactory< GUM_SCALAR >::__foo_flag, gum::FMDPFactory< GUM_SCALAR >::__illegalStateError(), gum::FMDPFactory< GUM_SCALAR >::__stringBag, gum::FMDPFactory< GUM_SCALAR >::__varNameMap, gum::FMDPFactory< GUM_SCALAR >::state(), and gum::TRANSITION.

336  {
337  const MultiDimImplementation< GUM_SCALAR >* t =
338  reinterpret_cast< const MultiDimImplementation< GUM_SCALAR >* >(transition);
339 
341  __illegalStateError("addTransition");
342  else if (__foo_flag)
343  __fmdp->addTransitionForAction(
344  __fmdp->actionId(__stringBag[0]), __varNameMap[var], t);
345  else
346  __fmdp->addTransition(__varNameMap[var], t);
347  }
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.
Definition: fmdpFactory.h:274
FMDPfactory_state state() const
Returns the current state of the factory.
HashTable< std::string, const DiscreteVariable *> __varNameMap
Mapping between a declared variable&#39;s name and itself.
Definition: fmdpFactory.h:304
bool __foo_flag
Depending on the context this flag is used for some VERY important reasons.
Definition: fmdpFactory.h:267
FMDP< GUM_SCALAR > * __fmdp
The constructed FMDP.
Definition: fmdpFactory.h:298
+ Here is the call graph for this function:

◆ addTransition() [2/2]

template<typename GUM_SCALAR >
INLINE void gum::FMDPFactory< GUM_SCALAR >::addTransition ( const std::string &  var)
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 355 of file fmdpFactory_tpl.h.

References gum::FMDPFactory< GUM_SCALAR >::__finalizeFunctionGraph(), gum::FMDPFactory< GUM_SCALAR >::__fmdp, gum::FMDPFactory< GUM_SCALAR >::__foo_flag, gum::FMDPFactory< GUM_SCALAR >::__FunctionGraph, gum::FMDPFactory< GUM_SCALAR >::__illegalStateError(), gum::FMDPFactory< GUM_SCALAR >::__stringBag, gum::FMDPFactory< GUM_SCALAR >::__varNameMap, gum::MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy >::setTableName(), gum::FMDPFactory< GUM_SCALAR >::state(), and gum::TRANSITION.

355  {
357  __illegalStateError("addTransition");
358  else {
359  this->__finalizeFunctionGraph();
360 
361  if (__foo_flag) {
362  this->__FunctionGraph->setTableName("ACTION :" + __stringBag[0]
363  + " - VARIABLE : " + var);
364  __fmdp->addTransitionForAction(__fmdp->actionId(__stringBag[0]),
365  __varNameMap[var],
366  this->__FunctionGraph);
367  } else {
368  __fmdp->addTransition(__varNameMap[var], this->__FunctionGraph);
369  }
370  }
371  }
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.
Definition: fmdpFactory.h:274
FMDPfactory_state state() const
Returns the current state of the factory.
MultiDimFunctionGraph< GUM_SCALAR > * __FunctionGraph
The FunctionGraph we&#39;re building at a given time.
Definition: fmdpFactory.h:301
HashTable< std::string, const DiscreteVariable *> __varNameMap
Mapping between a declared variable&#39;s name and itself.
Definition: fmdpFactory.h:304
bool __foo_flag
Depending on the context this flag is used for some VERY important reasons.
Definition: fmdpFactory.h:267
FMDP< GUM_SCALAR > * __fmdp
The constructed FMDP.
Definition: fmdpFactory.h:298
void __finalizeFunctionGraph()
Insert every variables in the function graph.
void setTableName(const std::string &name)
Sets the name of the table represented by this structure.
+ Here is the call graph for this function:

◆ endActionDeclaration()

template<typename GUM_SCALAR >
INLINE void gum::FMDPFactory< GUM_SCALAR >::endActionDeclaration ( )
virtual

Tells the factory that we're out of an action declaration.

Implements gum::AbstractFMDPFactory.

Definition at line 295 of file fmdpFactory_tpl.h.

References gum::FMDPFactory< GUM_SCALAR >::__illegalStateError(), gum::FMDPFactory< GUM_SCALAR >::__resetParts(), gum::FMDPFactory< GUM_SCALAR >::__states, gum::ACTION, and gum::FMDPFactory< GUM_SCALAR >::state().

295  {
297  __illegalStateError("endActionDeclaration");
298  else {
299  __states.pop_back();
300  __resetParts();
301  }
302 
303  // VERBOSITY ( "action OK" );
304  }
void __illegalStateError(const std::string &s)
Raise an OperationNotAllowed with the message "Illegal state.".
FMDPfactory_state state() const
Returns the current state of the factory.
void __resetParts()
Reset the different parts used to constructed the FMDP.
std::vector< FMDPfactory_state > __states
State stack.
Definition: fmdpFactory.h:295
+ Here is the call graph for this function:

◆ endCostDeclaration()

template<typename GUM_SCALAR >
INLINE void gum::FMDPFactory< GUM_SCALAR >::endCostDeclaration ( )
virtual

Tells the factory that we're out of a cost declaration.

Implements gum::AbstractFMDPFactory.

Definition at line 450 of file fmdpFactory_tpl.h.

References gum::FMDPFactory< GUM_SCALAR >::__illegalStateError(), gum::FMDPFactory< GUM_SCALAR >::__states, gum::COST, and gum::FMDPFactory< GUM_SCALAR >::state().

450  {
452  __illegalStateError("endCostDeclaration");
453  else
454  __states.pop_back();
455 
456  // VERBOSITY ( "Cost OK" );
457  }
void __illegalStateError(const std::string &s)
Raise an OperationNotAllowed with the message "Illegal state.".
FMDPfactory_state state() const
Returns the current state of the factory.
std::vector< FMDPfactory_state > __states
State stack.
Definition: fmdpFactory.h:295
+ Here is the call graph for this function:

◆ endDiscountDeclaration()

template<typename GUM_SCALAR >
INLINE void gum::FMDPFactory< GUM_SCALAR >::endDiscountDeclaration ( )
virtual

Tells the factory that we're out of a cost declaration.

Implements gum::AbstractFMDPFactory.

Definition at line 610 of file fmdpFactory_tpl.h.

References gum::FMDPFactory< GUM_SCALAR >::__illegalStateError(), gum::FMDPFactory< GUM_SCALAR >::__states, gum::DISCOUNT, and gum::FMDPFactory< GUM_SCALAR >::state().

610  {
612  __illegalStateError("endDiscountDeclaration");
613  else
614  __states.pop_back();
615 
616  // VERBOSITY ( "discount OK" );
617  }
void __illegalStateError(const std::string &s)
Raise an OperationNotAllowed with the message "Illegal state.".
FMDPfactory_state state() const
Returns the current state of the factory.
std::vector< FMDPfactory_state > __states
State stack.
Definition: fmdpFactory.h:295
+ Here is the call graph for this function:

◆ endRewardDeclaration()

template<typename GUM_SCALAR >
INLINE void gum::FMDPFactory< GUM_SCALAR >::endRewardDeclaration ( )
virtual

Tells the factory that we're out of a cost declaration.

Implements gum::AbstractFMDPFactory.

Definition at line 535 of file fmdpFactory_tpl.h.

References gum::FMDPFactory< GUM_SCALAR >::__ddBag, gum::FMDPFactory< GUM_SCALAR >::__fmdp, gum::FMDPFactory< GUM_SCALAR >::__foo_flag, gum::FMDPFactory< GUM_SCALAR >::__illegalStateError(), gum::FMDPFactory< GUM_SCALAR >::__resetParts(), gum::FMDPFactory< GUM_SCALAR >::__states, gum::FMDPFactory< GUM_SCALAR >::__stringBag, gum::add2MultiDimFunctionGraphs(), gum::divide2MultiDimFunctionGraphs(), gum::multiply2MultiDimFunctionGraphs(), gum::REWARD, gum::FMDPFactory< GUM_SCALAR >::state(), and gum::subtract2MultiDimFunctionGraphs().

535  {
537  __illegalStateError("endRewardDeclaration");
538  else {
539  if (__foo_flag) {
540  MultiDimImplementation< GUM_SCALAR >* res = nullptr;
541  MultiDimImplementation< GUM_SCALAR >* temp;
542 
543  for (const auto elt : __ddBag) {
544  temp = res;
545 
546  switch (__stringBag[0][0]) {
547  case '+': res = add2MultiDimFunctionGraphs(res, elt); break;
548 
549  case '-': res = subtract2MultiDimFunctionGraphs(res, elt); break;
550 
551  case '*': res = multiply2MultiDimFunctionGraphs(res, elt); break;
552 
553  case '/': res = divide2MultiDimFunctionGraphs(res, elt); break;
554 
555  default: break;
556  }
557 
558  delete elt;
559 
560  if (temp != nullptr) delete temp;
561  }
562  reinterpret_cast< MultiDimFunctionGraph< GUM_SCALAR >* >(res)
563  ->setTableName("Reward");
564  __fmdp->addReward(res);
565  }
566 
567  __resetParts();
568  __states.pop_back();
569  }
570  // VERBOSITY ( "reward OK" );
571  }
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.
Definition: fmdpFactory.h:274
FMDPfactory_state state() const
Returns the current state of the factory.
void __resetParts()
Reset the different parts used to constructed the FMDP.
MultiDimFunctionGraph< T > * subtract2MultiDimFunctionGraphs(const MultiDimFunctionGraph< T > *t1, const MultiDimFunctionGraph< T > *t2)
a specialized function for subtracting two multiDimArraysThe function produces a tensorial subtractio...
MultiDimFunctionGraph< T > * multiply2MultiDimFunctionGraphs(const MultiDimFunctionGraph< T > *t1, const MultiDimFunctionGraph< T > *t2)
a specialized function for multiplying two multiDimArraysThe function produces a tensorial product of...
std::vector< FMDPfactory_state > __states
State stack.
Definition: fmdpFactory.h:295
bool __foo_flag
Depending on the context this flag is used for some VERY important reasons.
Definition: fmdpFactory.h:267
FMDP< GUM_SCALAR > * __fmdp
The constructed FMDP.
Definition: fmdpFactory.h:298
std::vector< const MultiDimImplementation< GUM_SCALAR > *> __ddBag
Just to keep track of multidim between two start/end calls.
Definition: fmdpFactory.h:277
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...
+ Here is the call graph for this function:

◆ endTransitionDeclaration()

template<typename GUM_SCALAR >
INLINE void gum::FMDPFactory< GUM_SCALAR >::endTransitionDeclaration ( )
virtual

Tells the factory that we're out of a transition declaration.

Implements gum::AbstractFMDPFactory.

Definition at line 377 of file fmdpFactory_tpl.h.

References gum::FMDPFactory< GUM_SCALAR >::__illegalStateError(), gum::FMDPFactory< GUM_SCALAR >::__states, gum::FMDPFactory< GUM_SCALAR >::state(), and gum::TRANSITION.

377  {
379  __illegalStateError("endTransitionDeclaration");
380  else
381  __states.pop_back();
382 
383  // VERBOSITY ( "transition OK" );
384  }
void __illegalStateError(const std::string &s)
Raise an OperationNotAllowed with the message "Illegal state.".
FMDPfactory_state state() const
Returns the current state of the factory.
std::vector< FMDPfactory_state > __states
State stack.
Definition: fmdpFactory.h:295
+ Here is the call graph for this function:

◆ endVariableDeclaration()

template<typename GUM_SCALAR >
INLINE void gum::FMDPFactory< GUM_SCALAR >::endVariableDeclaration ( )
virtual

Tells the factory that we're out of a variable declaration.

Exceptions
UndefinedElementRaised if the variable isn't defined (or not enough defined).

Implements gum::AbstractFMDPFactory.

Definition at line 209 of file fmdpFactory_tpl.h.

References gum::FMDPFactory< GUM_SCALAR >::__bar_flag, gum::FMDPFactory< GUM_SCALAR >::__fmdp, gum::FMDPFactory< GUM_SCALAR >::__foo_flag, gum::FMDPFactory< GUM_SCALAR >::__illegalStateError(), gum::FMDPFactory< GUM_SCALAR >::__resetParts(), gum::FMDPFactory< GUM_SCALAR >::__states, gum::FMDPFactory< GUM_SCALAR >::__stringBag, gum::FMDPFactory< GUM_SCALAR >::__varNameMap, gum::LabelizedVariable::addLabel(), GUM_ERROR, gum::Variable::name(), gum::FMDPFactory< GUM_SCALAR >::state(), and gum::VARIABLE.

209  {
211  __illegalStateError("endVariableDeclaration");
212  else if (__foo_flag && (__stringBag.size() > 3)) {
213  LabelizedVariable* var = new LabelizedVariable(
214  __stringBag[0], (__bar_flag) ? __stringBag[1] : "", 0);
215 
216  for (size_t i = 2; i < __stringBag.size(); ++i) {
217  var->addLabel(__stringBag[i]);
218  }
219 
220  __fmdp->addVariable(var);
221  __varNameMap.insert(var->name(), var);
222  __varNameMap.insert(__fmdp->main2prime(var)->name(),
223  __fmdp->main2prime(var));
224 
225  __resetParts();
226  __states.pop_back();
227 
228  // VERBOSITY ( " variable " << var->name() << " OK" );
229 
230  } else {
231  std::stringstream msg;
232  msg << "Not enough modalities (";
233 
234  if (__stringBag.size() > 2)
235  msg << __stringBag.size() - 2;
236  else
237  msg << 0;
238 
239  msg << ") declared for variable ";
240 
241  if (__foo_flag)
242  msg << __stringBag[0];
243  else
244  msg << "unknown";
245 
246  __resetParts();
247  __states.pop_back();
248 
249  GUM_ERROR(OperationNotAllowed, msg.str());
250  }
251  }
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.
Definition: fmdpFactory.h:274
FMDPfactory_state state() const
Returns the current state of the factory.
void __resetParts()
Reset the different parts used to constructed the FMDP.
bool __bar_flag
Depending on the context this flag is used for some VERY important reasons.
Definition: fmdpFactory.h:271
HashTable< std::string, const DiscreteVariable *> __varNameMap
Mapping between a declared variable&#39;s name and itself.
Definition: fmdpFactory.h:304
std::vector< FMDPfactory_state > __states
State stack.
Definition: fmdpFactory.h:295
bool __foo_flag
Depending on the context this flag is used for some VERY important reasons.
Definition: fmdpFactory.h:267
FMDP< GUM_SCALAR > * __fmdp
The constructed FMDP.
Definition: fmdpFactory.h:298
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
+ Here is the call graph for this function:

◆ fmdp()

template<typename GUM_SCALAR >
INLINE FMDP< GUM_SCALAR > * gum::FMDPFactory< GUM_SCALAR >::fmdp ( ) const

Returns the Factored Markov Decision Process created by this factory.

Exceptions
OperationNotAllowedRaise if the state of the factory is different than NONE.

Definition at line 87 of file fmdpFactory_tpl.h.

References gum::FMDPFactory< GUM_SCALAR >::__fmdp, GUM_ERROR, gum::NONE, and gum::FMDPFactory< GUM_SCALAR >::state().

87  {
89  GUM_ERROR(OperationNotAllowed,
90  "Illegal state to return the factored "
91  "markov decision process: it is not yet "
92  "finished.");
93 
94  return __fmdp;
95  }
FMDPfactory_state state() const
Returns the current state of the factory.
FMDP< GUM_SCALAR > * __fmdp
The constructed FMDP.
Definition: fmdpFactory.h:298
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
+ Here is the call graph for this function:

◆ isVerbose()

bool gum::AbstractFMDPFactory::isVerbose ( )
inlineinherited

Definition at line 276 of file IfmdpFactory.h.

276 { return __verbose; }

◆ operator=()

template<typename GUM_SCALAR >
INLINE FMDPFactory< GUM_SCALAR > & gum::FMDPFactory< GUM_SCALAR >::operator= ( const FMDPFactory< GUM_SCALAR > &  source)
private

Copy operator is illegal, use only copy constructor.

Definition at line 761 of file fmdpFactory_tpl.h.

References GUM_ERROR.

Referenced by gum::FMDPFactory< GUM_SCALAR >::__finalizeFunctionGraph().

761  {
762  GUM_ERROR(FatalError, "Illegal!");
763  // For noisy compilers
764  return *this;
765  }
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
+ Here is the caller graph for this function:

◆ resetVerbose()

void gum::AbstractFMDPFactory::resetVerbose ( )
inlineinherited

Definition at line 274 of file IfmdpFactory.h.

Referenced by gum::FMDPFactory< GUM_SCALAR >::FMDPFactory().

274 { __verbose = false; }
+ Here is the caller graph for this function:

◆ setOperationModeOn()

template<typename GUM_SCALAR >
INLINE void gum::FMDPFactory< GUM_SCALAR >::setOperationModeOn ( std::string  operationType)
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 490 of file fmdpFactory_tpl.h.

References gum::FMDPFactory< GUM_SCALAR >::__foo_flag, and gum::FMDPFactory< GUM_SCALAR >::__stringBag.

490  {
491  __foo_flag = true;
492  std::string ot(operationType);
493  __stringBag.push_back(ot);
494  }
std::vector< std::string > __stringBag
Just to keep track of strings between two start/end calls.
Definition: fmdpFactory.h:274
bool __foo_flag
Depending on the context this flag is used for some VERY important reasons.
Definition: fmdpFactory.h:267

◆ setRoot()

template<typename GUM_SCALAR >
INLINE void gum::FMDPFactory< GUM_SCALAR >::setRoot ( NodeId  rootId)
virtual

add an arc in diagram

Implements gum::AbstractFMDPFactory.

Definition at line 657 of file fmdpFactory_tpl.h.

References gum::FMDPFactory< GUM_SCALAR >::__FunctionGraph, gum::MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy >::manager(), and gum::MultiDimFunctionGraphManager< GUM_SCALAR, TerminalNodePolicy >::setRootNode().

657  {
658  __FunctionGraph->manager()->setRootNode(rootId);
659  }
void setRootNode(const NodeId &root)
Sets root node of decision diagram.
MultiDimFunctionGraph< GUM_SCALAR > * __FunctionGraph
The FunctionGraph we&#39;re building at a given time.
Definition: fmdpFactory.h:301
MultiDimFunctionGraphManager< GUM_SCALAR, TerminalNodePolicy > * manager()
Returns a const reference to the manager of this diagram.
+ Here is the call graph for this function:

◆ setVerbose()

void gum::AbstractFMDPFactory::setVerbose ( )
inlineinherited

Definition at line 272 of file IfmdpFactory.h.

272 { __verbose = true; }

◆ startActionDeclaration()

template<typename GUM_SCALAR >
INLINE void gum::FMDPFactory< GUM_SCALAR >::startActionDeclaration ( )
virtual

Tells the factory that we're in an action declaration.

Implements gum::AbstractFMDPFactory.

Definition at line 267 of file fmdpFactory_tpl.h.

References gum::FMDPFactory< GUM_SCALAR >::__foo_flag, gum::FMDPFactory< GUM_SCALAR >::__illegalStateError(), gum::FMDPFactory< GUM_SCALAR >::__states, gum::ACTION, gum::NONE, and gum::FMDPFactory< GUM_SCALAR >::state().

267  {
269  __illegalStateError("startActionDeclaration");
270  else {
271  __foo_flag = true;
273  }
274 
275  // VERBOSITY ( "starting action declaration" );
276  }
void __illegalStateError(const std::string &s)
Raise an OperationNotAllowed with the message "Illegal state.".
FMDPfactory_state state() const
Returns the current state of the factory.
std::vector< FMDPfactory_state > __states
State stack.
Definition: fmdpFactory.h:295
bool __foo_flag
Depending on the context this flag is used for some VERY important reasons.
Definition: fmdpFactory.h:267
+ Here is the call graph for this function:

◆ startCostDeclaration()

template<typename GUM_SCALAR >
INLINE void gum::FMDPFactory< GUM_SCALAR >::startCostDeclaration ( )
virtual

Tells the factory that we're in a cost declaration.

Implements gum::AbstractFMDPFactory.

Definition at line 401 of file fmdpFactory_tpl.h.

References gum::FMDPFactory< GUM_SCALAR >::__illegalStateError(), gum::FMDPFactory< GUM_SCALAR >::__initializeFunctionGraph(), gum::FMDPFactory< GUM_SCALAR >::__states, gum::ACTION, gum::COST, gum::NONE, and gum::FMDPFactory< GUM_SCALAR >::state().

401  {
403  __illegalStateError("startTransitionDeclaration");
404  else
406 
407  // VERBOSITY ( "starting Cost declaration" );
409  }
void __illegalStateError(const std::string &s)
Raise an OperationNotAllowed with the message "Illegal state.".
FMDPfactory_state state() const
Returns the current state of the factory.
void __initializeFunctionGraph()
Insert every variables in the function graph.
std::vector< FMDPfactory_state > __states
State stack.
Definition: fmdpFactory.h:295
+ Here is the call graph for this function:

◆ startDiscountDeclaration()

template<typename GUM_SCALAR >
INLINE void gum::FMDPFactory< GUM_SCALAR >::startDiscountDeclaration ( )
virtual

Tells the factory that we're in a cost declaration.

Implements gum::AbstractFMDPFactory.

Definition at line 587 of file fmdpFactory_tpl.h.

References gum::FMDPFactory< GUM_SCALAR >::__illegalStateError(), gum::FMDPFactory< GUM_SCALAR >::__states, gum::DISCOUNT, gum::NONE, and gum::FMDPFactory< GUM_SCALAR >::state().

587  {
589  __illegalStateError("startDiscountDeclaration");
590  else
592 
593  // VERBOSITY ( "starting discount declaration" );
594  }
void __illegalStateError(const std::string &s)
Raise an OperationNotAllowed with the message "Illegal state.".
FMDPfactory_state state() const
Returns the current state of the factory.
std::vector< FMDPfactory_state > __states
State stack.
Definition: fmdpFactory.h:295
+ Here is the call graph for this function:

◆ startRewardDeclaration()

template<typename GUM_SCALAR >
INLINE void gum::FMDPFactory< GUM_SCALAR >::startRewardDeclaration ( )
virtual

Tells the factory that we're in a reward declaration.

Implements gum::AbstractFMDPFactory.

Definition at line 474 of file fmdpFactory_tpl.h.

References gum::FMDPFactory< GUM_SCALAR >::__illegalStateError(), gum::FMDPFactory< GUM_SCALAR >::__initializeFunctionGraph(), gum::FMDPFactory< GUM_SCALAR >::__states, gum::ACTION, gum::NONE, gum::REWARD, and gum::FMDPFactory< GUM_SCALAR >::state().

474  {
476  __illegalStateError("startRewardDeclaration");
477  else
479 
480  // VERBOSITY ( "starting reward declaration" );
482  }
void __illegalStateError(const std::string &s)
Raise an OperationNotAllowed with the message "Illegal state.".
FMDPfactory_state state() const
Returns the current state of the factory.
void __initializeFunctionGraph()
Insert every variables in the function graph.
std::vector< FMDPfactory_state > __states
State stack.
Definition: fmdpFactory.h:295
+ Here is the call graph for this function:

◆ startTransitionDeclaration()

template<typename GUM_SCALAR >
INLINE void gum::FMDPFactory< GUM_SCALAR >::startTransitionDeclaration ( )
virtual

Tells the factory that we're in a transition declaration.

Implements gum::AbstractFMDPFactory.

Definition at line 321 of file fmdpFactory_tpl.h.

References gum::FMDPFactory< GUM_SCALAR >::__illegalStateError(), gum::FMDPFactory< GUM_SCALAR >::__initializeFunctionGraph(), gum::FMDPFactory< GUM_SCALAR >::__states, gum::ACTION, gum::NONE, gum::FMDPFactory< GUM_SCALAR >::state(), and gum::TRANSITION.

321  {
323  __illegalStateError("startTransitionDeclaration");
324  else
326 
327  // VERBOSITY ( "starting transition declaration" );
329  }
void __illegalStateError(const std::string &s)
Raise an OperationNotAllowed with the message "Illegal state.".
FMDPfactory_state state() const
Returns the current state of the factory.
void __initializeFunctionGraph()
Insert every variables in the function graph.
std::vector< FMDPfactory_state > __states
State stack.
Definition: fmdpFactory.h:295
+ Here is the call graph for this function:

◆ startVariableDeclaration()

template<typename GUM_SCALAR >
INLINE void gum::FMDPFactory< GUM_SCALAR >::startVariableDeclaration ( )
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::FMDPFactory< GUM_SCALAR >::__illegalStateError(), gum::FMDPFactory< GUM_SCALAR >::__states, gum::FMDPFactory< GUM_SCALAR >::__stringBag, gum::NONE, gum::FMDPFactory< GUM_SCALAR >::state(), and gum::VARIABLE.

136  {
138  __illegalStateError("startVariableDeclaration");
139  else {
141  __stringBag.push_back("name");
142  __stringBag.push_back("desc");
143  }
144 
145  // VERBOSITY ( " starting variable" );
146  }
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.
Definition: fmdpFactory.h:274
FMDPfactory_state state() const
Returns the current state of the factory.
std::vector< FMDPfactory_state > __states
State stack.
Definition: fmdpFactory.h:295
+ Here is the call graph for this function:

◆ state()

template<typename GUM_SCALAR >
INLINE FMDPfactory_state gum::FMDPFactory< GUM_SCALAR >::state ( ) const
virtual

Returns the current state of the factory.

Implements gum::AbstractFMDPFactory.

Definition at line 101 of file fmdpFactory_tpl.h.

References gum::FMDPFactory< GUM_SCALAR >::__states.

Referenced by gum::FMDPFactory< GUM_SCALAR >::__illegalStateError(), gum::FMDPFactory< GUM_SCALAR >::addAction(), gum::FMDPFactory< GUM_SCALAR >::addCost(), gum::FMDPFactory< GUM_SCALAR >::addDiscount(), gum::FMDPFactory< GUM_SCALAR >::addModality(), gum::FMDPFactory< GUM_SCALAR >::addReward(), gum::FMDPFactory< GUM_SCALAR >::addTransition(), gum::FMDPFactory< GUM_SCALAR >::endActionDeclaration(), gum::FMDPFactory< GUM_SCALAR >::endCostDeclaration(), gum::FMDPFactory< GUM_SCALAR >::endDiscountDeclaration(), gum::FMDPFactory< GUM_SCALAR >::endRewardDeclaration(), gum::FMDPFactory< GUM_SCALAR >::endTransitionDeclaration(), gum::FMDPFactory< GUM_SCALAR >::endVariableDeclaration(), gum::FMDPFactory< GUM_SCALAR >::fmdp(), gum::FMDPFactory< GUM_SCALAR >::startActionDeclaration(), gum::FMDPFactory< GUM_SCALAR >::startCostDeclaration(), gum::FMDPFactory< GUM_SCALAR >::startDiscountDeclaration(), gum::FMDPFactory< GUM_SCALAR >::startRewardDeclaration(), gum::FMDPFactory< GUM_SCALAR >::startTransitionDeclaration(), gum::FMDPFactory< GUM_SCALAR >::startVariableDeclaration(), gum::FMDPFactory< GUM_SCALAR >::variableDescription(), and gum::FMDPFactory< GUM_SCALAR >::variableName().

101  {
102  // This is ok because there is alway at least the state
103  // FMDPfactory_state::NONE in the stack.
104  return __states.back();
105  }
std::vector< FMDPfactory_state > __states
State stack.
Definition: fmdpFactory.h:295
+ Here is the caller graph for this function:

◆ variable()

template<typename GUM_SCALAR >
INLINE const DiscreteVariable * gum::FMDPFactory< GUM_SCALAR >::variable ( const std::string &  name) const
virtual

Returns a constant reference on a variable given it's name.

Exceptions
NotFoundRaised if no variable matches the name.

Implements gum::AbstractFMDPFactory.

Definition at line 113 of file fmdpFactory_tpl.h.

References gum::FMDPFactory< GUM_SCALAR >::__varNameMap, and GUM_ERROR.

Referenced by gum::FMDPFactory< GUM_SCALAR >::addInternalNode().

113  {
114  for (const auto& elt : __varNameMap)
115  if (elt.first.compare(name) == 0) return elt.second;
116 
117  GUM_ERROR(NotFound, name);
118 
119  return nullptr;
120  }
HashTable< std::string, const DiscreteVariable *> __varNameMap
Mapping between a declared variable&#39;s name and itself.
Definition: fmdpFactory.h:304
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
+ Here is the caller graph for this function:

◆ variableDescription()

template<typename GUM_SCALAR >
INLINE void gum::FMDPFactory< GUM_SCALAR >::variableDescription ( const std::string &  desc)
virtual

Tells the factory the current variable's description.

Implements gum::AbstractFMDPFactory.

Definition at line 170 of file fmdpFactory_tpl.h.

References gum::FMDPFactory< GUM_SCALAR >::__bar_flag, gum::FMDPFactory< GUM_SCALAR >::__illegalStateError(), gum::FMDPFactory< GUM_SCALAR >::__stringBag, gum::FMDPFactory< GUM_SCALAR >::state(), and gum::VARIABLE.

170  {
172  __illegalStateError("variableDescription");
173  else {
174  __bar_flag = true;
175  __stringBag[1] = desc;
176  }
177  }
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.
Definition: fmdpFactory.h:274
FMDPfactory_state state() const
Returns the current state of the factory.
bool __bar_flag
Depending on the context this flag is used for some VERY important reasons.
Definition: fmdpFactory.h:271
+ Here is the call graph for this function:

◆ variableName()

template<typename GUM_SCALAR >
INLINE void gum::FMDPFactory< GUM_SCALAR >::variableName ( const std::string &  name)
virtual

Tells the factory the current variable's name.

Exceptions
DuplicateElementRaised if a variable with the same name already exist.

Implements gum::AbstractFMDPFactory.

Definition at line 152 of file fmdpFactory_tpl.h.

References gum::FMDPFactory< GUM_SCALAR >::__foo_flag, gum::FMDPFactory< GUM_SCALAR >::__illegalStateError(), gum::FMDPFactory< GUM_SCALAR >::__stringBag, gum::FMDPFactory< GUM_SCALAR >::__varNameMap, GUM_ERROR, gum::FMDPFactory< GUM_SCALAR >::state(), and gum::VARIABLE.

152  {
154  __illegalStateError("variableName");
155  else {
156  if (__varNameMap.exists(name))
157  GUM_ERROR(DuplicateElement, "Name already used: " + name);
158 
159  __foo_flag = true;
160  __stringBag[0] = name;
161  // VERBOSITY ( " -- variable " << name );
162  }
163  }
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.
Definition: fmdpFactory.h:274
FMDPfactory_state state() const
Returns the current state of the factory.
HashTable< std::string, const DiscreteVariable *> __varNameMap
Mapping between a declared variable&#39;s name and itself.
Definition: fmdpFactory.h:304
bool __foo_flag
Depending on the context this flag is used for some VERY important reasons.
Definition: fmdpFactory.h:267
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
+ Here is the call graph for this function:

Member Data Documentation

◆ __actionIdcpt

template<typename GUM_SCALAR>
Idx gum::FMDPFactory< GUM_SCALAR >::__actionIdcpt
private

Action Id counter.

Definition at line 307 of file fmdpFactory.h.

Referenced by gum::FMDPFactory< GUM_SCALAR >::addAction(), and gum::FMDPFactory< GUM_SCALAR >::FMDPFactory().

◆ __bar_flag

template<typename GUM_SCALAR>
bool gum::FMDPFactory< GUM_SCALAR >::__bar_flag
private

Depending on the context this flag is used for some VERY important reasons.

Definition at line 271 of file fmdpFactory.h.

Referenced by gum::FMDPFactory< GUM_SCALAR >::__resetParts(), gum::FMDPFactory< GUM_SCALAR >::endVariableDeclaration(), and gum::FMDPFactory< GUM_SCALAR >::variableDescription().

◆ __ddBag

template<typename GUM_SCALAR>
std::vector< const MultiDimImplementation< GUM_SCALAR >* > gum::FMDPFactory< GUM_SCALAR >::__ddBag
private

Just to keep track of multidim between two start/end calls.

Definition at line 277 of file fmdpFactory.h.

Referenced by gum::FMDPFactory< GUM_SCALAR >::__resetParts(), gum::FMDPFactory< GUM_SCALAR >::addReward(), and gum::FMDPFactory< GUM_SCALAR >::endRewardDeclaration().

◆ __fmdp

◆ __foo_flag

◆ __FunctionGraph

◆ __states

◆ __stringBag

◆ __varNameMap

template<typename GUM_SCALAR>
HashTable< std::string, const DiscreteVariable* > gum::FMDPFactory< GUM_SCALAR >::__varNameMap
private

The documentation for this class was generated from the following files: