aGrUM  0.14.2
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 68 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 54 of file fmdpFactory_tpl.h.

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

54  :
55  __fmdp(fmdp) {
56  GUM_CONSTRUCTOR(FMDPFactory);
57 
59  resetVerbose();
60  __actionIdcpt = 1;
61  }
FMDP< GUM_SCALAR > * fmdp() const
Returns the Factored Markov Decision Process created by this factory.
Idx __actionIdcpt
Action Id counter.
Definition: fmdpFactory.h:304
std::vector< FMDPfactory_state > __states
State stack.
Definition: fmdpFactory.h:292
FMDP< GUM_SCALAR > * __fmdp
The constructed FMDP.
Definition: fmdpFactory.h:295
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 67 of file fmdpFactory_tpl.h.

67  {
68  GUM_DESTRUCTOR(FMDPFactory);
69  }
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 196 of file fmdpFactory_tpl.h.

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

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

196  {
197  for (size_t i = 2; i < __stringBag.size(); ++i)
198  if (mod == __stringBag[i])
199  GUM_ERROR(DuplicateElement, "Modality" << mod << " already exists.");
200  }
std::vector< std::string > __stringBag
Just to keep track of strings between two start/end calls.
Definition: fmdpFactory.h:271
#define GUM_ERROR(type, msg)
Definition: exceptions.h:52
+ 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 736 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().

736  {
737  this->__FunctionGraph->manager()->reduce();
738  this->__FunctionGraph->manager()->clean();
739  }
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:298
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 671 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().

671  {
672  std::string msg = "Illegal state call (";
673  msg += s;
674  msg += ") in state ";
675 
676  switch (state()) {
677  case FMDPfactory_state::NONE: msg += "FMDPfactory_state::NONE"; break;
678 
680  msg += "FMDPfactory_state::VARIABLE";
681  break;
682 
683  case FMDPfactory_state::ACTION: msg += "FMDPfactory_state::ACTION"; break;
684 
686  msg += "FMDPfactory_state::TRANSITION";
687  break;
688 
689  case FMDPfactory_state::COST: msg += "FMDPfactory_state::COST"; break;
690 
691  case FMDPfactory_state::REWARD: msg += "FMDPfactory_state::REWARD"; break;
692 
694  msg += "FMDPfactory_state::DISCOUNT";
695  break;
696 
697  default: msg += "Unknown state";
698  }
699 
700  GUM_ERROR(OperationNotAllowed, msg);
701  }
FMDPfactory_state state() const
Returns the current state of the factory.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:52
+ 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 716 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().

716  {
717  this->__FunctionGraph =
719  // Recopie des variables principales dans le graphe de décision
720  for (auto varIter = __fmdp->beginVariables();
721  varIter != __fmdp->endVariables();
722  ++varIter) {
723  __FunctionGraph->add(**varIter);
724  }
725 
726  // Recopie des version primes des variables dans le graphe de décision
727  for (auto varIter = __fmdp->beginVariables();
728  varIter != __fmdp->endVariables();
729  ++varIter) {
730  __FunctionGraph->add(*(__fmdp->main2prime(*varIter)));
731  }
732  }
MultiDimFunctionGraph< GUM_SCALAR > * __FunctionGraph
The FunctionGraph we&#39;re building at a given time.
Definition: fmdpFactory.h:298
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:295
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 707 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().

707  {
708  __foo_flag = false;
709  __bar_flag = false;
710  __stringBag.clear();
711  __ddBag.clear();
712  }
std::vector< std::string > __stringBag
Just to keep track of strings between two start/end calls.
Definition: fmdpFactory.h:271
bool __bar_flag
Depending on the context this flag is used for some VERY important reasons.
Definition: fmdpFactory.h:268
bool __foo_flag
Depending on the context this flag is used for some VERY important reasons.
Definition: fmdpFactory.h:264
std::vector< const MultiDimImplementation< GUM_SCALAR > *> __ddBag
Just to keep track of multidim between two start/end calls.
Definition: fmdpFactory.h:274
+ 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 279 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().

279  {
281  __illegalStateError("addAction");
282  else {
283  __stringBag.push_back(action);
284  __fmdp->addAction(__actionIdcpt++, action);
285  }
286  }
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:271
FMDPfactory_state state() const
Returns the current state of the factory.
Idx __actionIdcpt
Action Id counter.
Definition: fmdpFactory.h:304
FMDP< GUM_SCALAR > * __fmdp
The constructed FMDP.
Definition: fmdpFactory.h:295
+ 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 648 of file fmdpFactory_tpl.h.

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

648  {
649  __FunctionGraph->manager()->setSon(from, modality, to);
650  }
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:298
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 412 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().

412  {
413  const MultiDimImplementation< GUM_SCALAR >* c =
414  reinterpret_cast< const MultiDimImplementation< GUM_SCALAR >* >(cost);
415 
417  __illegalStateError("addCost");
418  else if (__foo_flag)
419  __fmdp->addCostForAction(__fmdp->actionId(__stringBag[0]), c);
420  else
421  __fmdp->addCost(c);
422  }
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:271
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:264
FMDP< GUM_SCALAR > * __fmdp
The constructed FMDP.
Definition: fmdpFactory.h:295
+ 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 429 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().

429  {
431  __illegalStateError("addCost");
432  else {
433  this->__finalizeFunctionGraph();
434 
435  if (__foo_flag)
436  __fmdp->addCostForAction(__fmdp->actionId(__stringBag[0]),
437  this->__FunctionGraph);
438  else
439  __fmdp->addCost(this->__FunctionGraph);
440  }
441  }
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:271
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:298
bool __foo_flag
Depending on the context this flag is used for some VERY important reasons.
Definition: fmdpFactory.h:264
FMDP< GUM_SCALAR > * __fmdp
The constructed FMDP.
Definition: fmdpFactory.h:295
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 597 of file fmdpFactory_tpl.h.

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

597  {
598  if (state() != FMDPfactory_state::DISCOUNT) __illegalStateError("addDiscount");
599  // else
600  // __fmdp->setDiscount ( ( GUM_SCALAR ) discount );
601  }
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 632 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().

632  {
633  return __FunctionGraph->manager()->addInternalNode(variable(name_of_var));
634  }
MultiDimFunctionGraph< GUM_SCALAR > * __FunctionGraph
The FunctionGraph we&#39;re building at a given time.
Definition: fmdpFactory.h:298
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 182 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.

182  {
184  __illegalStateError("addModality");
185  else {
186  __checkModalityInBag(name);
187  __stringBag.push_back(name);
188  }
189  }
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:271
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 498 of file fmdpFactory_tpl.h.

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

498  {
499  const MultiDimImplementation< GUM_SCALAR >* r =
500  reinterpret_cast< const MultiDimImplementation< GUM_SCALAR >* >(reward);
501 
503  __illegalStateError("addReward");
504  else
505  __fmdp->addReward(r);
506  }
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:295
+ 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 514 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().

514  {
516  __illegalStateError("addReward");
517  else {
518  this->__finalizeFunctionGraph();
519  __FunctionGraph->setTableName("Reward");
520 
521  if (__foo_flag)
522  __ddBag.push_back(this->__FunctionGraph);
523  else
524  __fmdp->addReward(this->__FunctionGraph);
525  }
526  }
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:298
bool __foo_flag
Depending on the context this flag is used for some VERY important reasons.
Definition: fmdpFactory.h:264
FMDP< GUM_SCALAR > * __fmdp
The constructed FMDP.
Definition: fmdpFactory.h:295
std::vector< const MultiDimImplementation< GUM_SCALAR > *> __ddBag
Just to keep track of multidim between two start/end calls.
Definition: fmdpFactory.h:274
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 640 of file fmdpFactory_tpl.h.

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

640  {
641  return __FunctionGraph->manager()->addTerminalNode((GUM_SCALAR)value);
642  }
MultiDimFunctionGraph< GUM_SCALAR > * __FunctionGraph
The FunctionGraph we&#39;re building at a given time.
Definition: fmdpFactory.h:298
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 332 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.

333  {
334  const MultiDimImplementation< GUM_SCALAR >* t =
335  reinterpret_cast< const MultiDimImplementation< GUM_SCALAR >* >(transition);
336 
338  __illegalStateError("addTransition");
339  else if (__foo_flag)
340  __fmdp->addTransitionForAction(
341  __fmdp->actionId(__stringBag[0]), __varNameMap[var], t);
342  else
343  __fmdp->addTransition(__varNameMap[var], t);
344  }
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:271
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:301
bool __foo_flag
Depending on the context this flag is used for some VERY important reasons.
Definition: fmdpFactory.h:264
FMDP< GUM_SCALAR > * __fmdp
The constructed FMDP.
Definition: fmdpFactory.h:295
+ 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 352 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.

352  {
354  __illegalStateError("addTransition");
355  else {
356  this->__finalizeFunctionGraph();
357 
358  if (__foo_flag) {
359  this->__FunctionGraph->setTableName("ACTION :" + __stringBag[0]
360  + " - VARIABLE : " + var);
361  __fmdp->addTransitionForAction(__fmdp->actionId(__stringBag[0]),
362  __varNameMap[var],
363  this->__FunctionGraph);
364  } else {
365  __fmdp->addTransition(__varNameMap[var], this->__FunctionGraph);
366  }
367  }
368  }
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:271
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:298
HashTable< std::string, const DiscreteVariable *> __varNameMap
Mapping between a declared variable&#39;s name and itself.
Definition: fmdpFactory.h:301
bool __foo_flag
Depending on the context this flag is used for some VERY important reasons.
Definition: fmdpFactory.h:264
FMDP< GUM_SCALAR > * __fmdp
The constructed FMDP.
Definition: fmdpFactory.h:295
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 292 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().

292  {
294  __illegalStateError("endActionDeclaration");
295  else {
296  __states.pop_back();
297  __resetParts();
298  }
299 
300  // VERBOSITY ( "action OK" );
301  }
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:292
+ 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 447 of file fmdpFactory_tpl.h.

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

447  {
449  __illegalStateError("endCostDeclaration");
450  else
451  __states.pop_back();
452 
453  // VERBOSITY ( "Cost OK" );
454  }
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:292
+ 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 607 of file fmdpFactory_tpl.h.

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

607  {
609  __illegalStateError("endDiscountDeclaration");
610  else
611  __states.pop_back();
612 
613  // VERBOSITY ( "discount OK" );
614  }
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:292
+ 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 532 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().

532  {
534  __illegalStateError("endRewardDeclaration");
535  else {
536  if (__foo_flag) {
537  MultiDimImplementation< GUM_SCALAR >* res = nullptr;
538  MultiDimImplementation< GUM_SCALAR >* temp;
539 
540  for (const auto elt : __ddBag) {
541  temp = res;
542 
543  switch (__stringBag[0][0]) {
544  case '+': res = add2MultiDimFunctionGraphs(res, elt); break;
545 
546  case '-': res = subtract2MultiDimFunctionGraphs(res, elt); break;
547 
548  case '*': res = multiply2MultiDimFunctionGraphs(res, elt); break;
549 
550  case '/': res = divide2MultiDimFunctionGraphs(res, elt); break;
551 
552  default: break;
553  }
554 
555  delete elt;
556 
557  if (temp != nullptr) delete temp;
558  }
559  reinterpret_cast< MultiDimFunctionGraph< GUM_SCALAR >* >(res)
560  ->setTableName("Reward");
561  __fmdp->addReward(res);
562  }
563 
564  __resetParts();
565  __states.pop_back();
566  }
567  // VERBOSITY ( "reward OK" );
568  }
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:271
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:292
bool __foo_flag
Depending on the context this flag is used for some VERY important reasons.
Definition: fmdpFactory.h:264
FMDP< GUM_SCALAR > * __fmdp
The constructed FMDP.
Definition: fmdpFactory.h:295
std::vector< const MultiDimImplementation< GUM_SCALAR > *> __ddBag
Just to keep track of multidim between two start/end calls.
Definition: fmdpFactory.h:274
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 374 of file fmdpFactory_tpl.h.

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

374  {
376  __illegalStateError("endTransitionDeclaration");
377  else
378  __states.pop_back();
379 
380  // VERBOSITY ( "transition OK" );
381  }
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:292
+ 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 206 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.

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

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

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

◆ isVerbose()

bool gum::AbstractFMDPFactory::isVerbose ( )
inlineinherited

Definition at line 273 of file IfmdpFactory.h.

273 { 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 758 of file fmdpFactory_tpl.h.

References GUM_ERROR.

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

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

◆ resetVerbose()

void gum::AbstractFMDPFactory::resetVerbose ( )
inlineinherited

Definition at line 271 of file IfmdpFactory.h.

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

271 { __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 487 of file fmdpFactory_tpl.h.

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

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

◆ 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 654 of file fmdpFactory_tpl.h.

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

654  {
655  __FunctionGraph->manager()->setRootNode(rootId);
656  }
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:298
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 269 of file IfmdpFactory.h.

269 { __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 264 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().

264  {
266  __illegalStateError("startActionDeclaration");
267  else {
268  __foo_flag = true;
270  }
271 
272  // VERBOSITY ( "starting action declaration" );
273  }
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:292
bool __foo_flag
Depending on the context this flag is used for some VERY important reasons.
Definition: fmdpFactory.h:264
+ 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 398 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().

398  {
400  __illegalStateError("startTransitionDeclaration");
401  else
403 
404  // VERBOSITY ( "starting Cost declaration" );
406  }
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:292
+ 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 584 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().

584  {
586  __illegalStateError("startDiscountDeclaration");
587  else
589 
590  // VERBOSITY ( "starting discount declaration" );
591  }
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:292
+ 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 471 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().

471  {
473  __illegalStateError("startRewardDeclaration");
474  else
476 
477  // VERBOSITY ( "starting reward declaration" );
479  }
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:292
+ 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 318 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.

318  {
320  __illegalStateError("startTransitionDeclaration");
321  else
323 
324  // VERBOSITY ( "starting transition declaration" );
326  }
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:292
+ 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 133 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.

133  {
135  __illegalStateError("startVariableDeclaration");
136  else {
138  __stringBag.push_back("name");
139  __stringBag.push_back("desc");
140  }
141 
142  // VERBOSITY ( " starting variable" );
143  }
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:271
FMDPfactory_state state() const
Returns the current state of the factory.
std::vector< FMDPfactory_state > __states
State stack.
Definition: fmdpFactory.h:292
+ 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 98 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().

98  {
99  // This is ok because there is alway at least the state
100  // FMDPfactory_state::NONE in the stack.
101  return __states.back();
102  }
std::vector< FMDPfactory_state > __states
State stack.
Definition: fmdpFactory.h:292
+ 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 110 of file fmdpFactory_tpl.h.

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

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

110  {
111  for (const auto& elt : __varNameMap)
112  if (elt.first.compare(name) == 0) return elt.second;
113 
114  GUM_ERROR(NotFound, name);
115 
116  return nullptr;
117  }
HashTable< std::string, const DiscreteVariable *> __varNameMap
Mapping between a declared variable&#39;s name and itself.
Definition: fmdpFactory.h:301
#define GUM_ERROR(type, msg)
Definition: exceptions.h:52
+ 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 167 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.

167  {
169  __illegalStateError("variableDescription");
170  else {
171  __bar_flag = true;
172  __stringBag[1] = desc;
173  }
174  }
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:271
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:268
+ 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 149 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.

149  {
151  __illegalStateError("variableName");
152  else {
153  if (__varNameMap.exists(name))
154  GUM_ERROR(DuplicateElement, "Name already used: " + name);
155 
156  __foo_flag = true;
157  __stringBag[0] = name;
158  // VERBOSITY ( " -- variable " << name );
159  }
160  }
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:271
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:301
bool __foo_flag
Depending on the context this flag is used for some VERY important reasons.
Definition: fmdpFactory.h:264
#define GUM_ERROR(type, msg)
Definition: exceptions.h:52
+ 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 304 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 268 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 274 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: