aGrUM  0.14.2
fmdpFactory_tpl.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Christophe GONZALES and Pierre-Henri WUILLEMIN *
3  * {prenom.nom}_at_lip6.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by*
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
27 #include <agrum/FMDP/fmdpFactory.h>
28 
31 
32 
33 // #define FMDP_VERBOSITY(x) { if (isVerbose()) std::cerr << "[FMDP factory]
34 // "<< x << std::endl; }
35 
36 
37 namespace gum {
38 
39  /* ****************************************************************************************************
40  * **/
41  /* ** **/
42  /* ** Constructor &
43  * Destructor **/
44  /* ** **/
45  /* ****************************************************************************************************
46  * **/
47 
48 
49  // Default constructor.
50  // @param fmdp A pointer over the Factored Markov Decision Process filled by
51  // this factory.
52 
53  template < typename GUM_SCALAR >
55  __fmdp(fmdp) {
56  GUM_CONSTRUCTOR(FMDPFactory);
57 
59  resetVerbose();
60  __actionIdcpt = 1;
61  }
62 
63 
64  // Destructor
65 
66  template < typename GUM_SCALAR >
68  GUM_DESTRUCTOR(FMDPFactory);
69  }
70 
71  /* ****************************************************************************************************
72  * **/
73  /* ** **/
74  /* ** Getter and
75  * setters **/
76  /* ** **/
77  /* ****************************************************************************************************
78  * **/
79 
80 
81  // Returns the IBayesNet created by this factory.
82 
83  template < typename GUM_SCALAR >
87  "Illegal state to return the factored "
88  "markov decision process: it is not yet "
89  "finished.");
90 
91  return __fmdp;
92  }
93 
94 
95  // Returns the current state of the factory.
96 
97  template < typename GUM_SCALAR >
99  // This is ok because there is alway at least the state
100  // FMDPfactory_state::NONE in the stack.
101  return __states.back();
102  }
103 
104 
105  // Returns a constant reference on a variable given it's name.
106  // @throw NotFound Raised if no variable matches the name.
107 
108  template < typename GUM_SCALAR >
109  INLINE const DiscreteVariable*
110  FMDPFactory< GUM_SCALAR >::variable(const std::string& name) const {
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  }
118 
119 
120  /* ****************************************************************************************************
121  * **/
122  /* ** **/
123  /* ** Variable declaration methods (FMDPfactory_state::NONE <->
124  * FMDPfactory_state::VARIABLE) **/
125  /* ** **/
126  /* ****************************************************************************************************
127  * **/
128 
129 
130  // Tells the factory that we're in a variable declaration.
131 
132  template < typename GUM_SCALAR >
135  __illegalStateError("startVariableDeclaration");
136  else {
138  __stringBag.push_back("name");
139  __stringBag.push_back("desc");
140  }
141 
142  // VERBOSITY ( " starting variable" );
143  }
144 
145 
146  // Tells the factory the current variable's name.
147 
148  template < typename GUM_SCALAR >
149  INLINE void FMDPFactory< GUM_SCALAR >::variableName(const std::string& name) {
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  }
161 
162 
163  // Tells the factory the current variable's description.
164 
165  template < typename GUM_SCALAR >
166  INLINE void
169  __illegalStateError("variableDescription");
170  else {
171  __bar_flag = true;
172  __stringBag[1] = desc;
173  }
174  }
175 
176 
177  // Adds a modality to the current variable.
178  // @throw DuplicateElement If the current variable already has a modality
179  // with the same name.
180 
181  template < typename GUM_SCALAR >
182  INLINE void FMDPFactory< GUM_SCALAR >::addModality(const std::string& name) {
184  __illegalStateError("addModality");
185  else {
186  __checkModalityInBag(name);
187  __stringBag.push_back(name);
188  }
189  }
190 
191 
192  // Check if in __stringBag there is no other modality with the same name.
193 
194  template < typename GUM_SCALAR >
195  INLINE void
197  for (size_t i = 2; i < __stringBag.size(); ++i)
198  if (mod == __stringBag[i])
199  GUM_ERROR(DuplicateElement, "Modality" << mod << " already exists.");
200  }
201 
202 
203  // Tells the factory that we're out of a variable declaration.
204 
205  template < typename GUM_SCALAR >
208  __illegalStateError("endVariableDeclaration");
209  else if (__foo_flag && (__stringBag.size() > 3)) {
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  }
249 
250 
251  /* ****************************************************************************************************
252  * **/
253  /* ** **/
254  /* ** Action declaration methods (FMDPfactory_state::NONE <->
255  * FMDPfactory_state::ACTION) **/
256  /* ** **/
257  /* ****************************************************************************************************
258  * **/
259 
260 
261  // Tells the factory that we're declaring action
262 
263  template < typename GUM_SCALAR >
266  __illegalStateError("startActionDeclaration");
267  else {
268  __foo_flag = true;
270  }
271 
272  // VERBOSITY ( "starting action declaration" );
273  }
274 
275 
276  // Tells the factory to add an action
277 
278  template < typename GUM_SCALAR >
279  INLINE void FMDPFactory< GUM_SCALAR >::addAction(const std::string& action) {
281  __illegalStateError("addAction");
282  else {
283  __stringBag.push_back(action);
284  __fmdp->addAction(__actionIdcpt++, action);
285  }
286  }
287 
288 
289  // Tells the factory that we're out of an action declaration.
290 
291  template < typename GUM_SCALAR >
294  __illegalStateError("endActionDeclaration");
295  else {
296  __states.pop_back();
297  __resetParts();
298  }
299 
300  // VERBOSITY ( "action OK" );
301  }
302 
303 
304  /* ****************************************************************************************************
305  * **/
306  /* ** **/
307  /* ** Transition declaration methods **/
308  /* ** (FMDPfactory_state::NONE <-> FMDPfactory_state::TRANSITION <->
309  * FMDPfactory_state::ACTION) **/
310  /* ** **/
311  /* ****************************************************************************************************
312  * **/
313 
314 
315  // Tells the factory that we're declaring transition
316 
317  template < typename GUM_SCALAR >
320  __illegalStateError("startTransitionDeclaration");
321  else
323 
324  // VERBOSITY ( "starting transition declaration" );
326  }
327 
328 
329  // Tells the factory to add an action
330 
331  template < typename GUM_SCALAR >
333  const std::string& var, const MultiDimAdressable* transition) {
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  }
345 
346 
347  // Tells the factory to add a transition table to the current fmdp.
348  // This transition table will be extracted from incorporated
349  // multiDimFunctionGraph.
350 
351  template < typename GUM_SCALAR >
352  INLINE void FMDPFactory< GUM_SCALAR >::addTransition(const std::string& var) {
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  }
369 
370 
371  // Tells the factory that we're out of a transition declaration.
372 
373  template < typename GUM_SCALAR >
376  __illegalStateError("endTransitionDeclaration");
377  else
378  __states.pop_back();
379 
380  // VERBOSITY ( "transition OK" );
381  }
382 
383 
384  /* ****************************************************************************************************
385  * **/
386  /* ** **/
387  /* ** Cost declaration methods **/
388  /* ** (FMDPfactory_state::NONE <-> FMDPfactory_state::COST <->
389  * FMDPfactory_state::ACTION) **/
390  /* ** **/
391  /* ****************************************************************************************************
392  * **/
393 
394 
395  // Tells the factory that we're declaring cost
396 
397  template < typename GUM_SCALAR >
400  __illegalStateError("startTransitionDeclaration");
401  else
403 
404  // VERBOSITY ( "starting Cost declaration" );
406  }
407 
408 
409  // Tells the factory to add a cost
410 
411  template < typename GUM_SCALAR >
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  }
423 
424 
425  // Tells the factory to add a cost
426  // This cost table will be extracted from incorporated multiDimFunctionGraph.
427 
428  template < typename GUM_SCALAR >
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  }
442 
443 
444  // Tells the factory that we're out of a cost declaration.
445 
446  template < typename GUM_SCALAR >
449  __illegalStateError("endCostDeclaration");
450  else
451  __states.pop_back();
452 
453  // VERBOSITY ( "Cost OK" );
454  }
455 
456 
457  /* ****************************************************************************************************
458  * **/
459  /* ** **/
460  /* ** Reward declaration methods **/
461  /* ** (FMDPfactory_state::NONE <-> FMDPfactory_state::REWARD <->
462  * FMDPfactory_state::ACTION) **/
463  /* ** **/
464  /* ****************************************************************************************************
465  * **/
466 
467 
468  // Tells the factory that we're declaring reward
469 
470  template < typename GUM_SCALAR >
473  __illegalStateError("startRewardDeclaration");
474  else
476 
477  // VERBOSITY ( "starting reward declaration" );
479  }
480 
481 
482  // Tells the factory that we're in a reward declaration mode where the global
483  // reward diagram is an operation between simplier dd
484 
485  template < typename GUM_SCALAR >
486  INLINE void
488  __foo_flag = true;
489  std::string ot(operationType);
490  __stringBag.push_back(ot);
491  }
492 
493 
494  // Tells the factory to add a reward
495 
496  template < typename GUM_SCALAR >
497  INLINE void
500  reinterpret_cast< const MultiDimImplementation< GUM_SCALAR >* >(reward);
501 
503  __illegalStateError("addReward");
504  else
505  __fmdp->addReward(r);
506  }
507 
508 
509  // Tells the factory to add a reward
510  // This reward table will be extracted from incorporated
511  // multiDimFunctionGraph.
512 
513  template < typename GUM_SCALAR >
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  }
527 
528 
529  // Tells the factory that we're out of a reward declaration.
530 
531  template < typename GUM_SCALAR >
534  __illegalStateError("endRewardDeclaration");
535  else {
536  if (__foo_flag) {
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  }
569 
570 
571  /* ****************************************************************************************************
572  * **/
573  /* ** **/
574  /* ** Discount declaration methods **/
575  /* ** (FMDPfactory_state::NONE <-> FMDPfactory_state::DISCOUNT <->
576  * FMDPfactory_state::ACTION) **/
577  /* ** **/
578  /* ****************************************************************************************************
579  * **/
580 
581 
582  // Tells the factory that we're declaring discount
583  template < typename GUM_SCALAR >
586  __illegalStateError("startDiscountDeclaration");
587  else
589 
590  // VERBOSITY ( "starting discount declaration" );
591  }
592 
593 
594  // Tells the factory to add a discount
595 
596  template < typename GUM_SCALAR >
597  INLINE void FMDPFactory< GUM_SCALAR >::addDiscount(float discount) {
598  if (state() != FMDPfactory_state::DISCOUNT) __illegalStateError("addDiscount");
599  // else
600  // __fmdp->setDiscount ( ( GUM_SCALAR ) discount );
601  }
602 
603 
604  // Tells the factory that we're out of a discount declaration.
605 
606  template < typename GUM_SCALAR >
609  __illegalStateError("endDiscountDeclaration");
610  else
611  __states.pop_back();
612 
613  // VERBOSITY ( "discount OK" );
614  }
615 
616 
617  /* ****************************************************************************************************
618  * **/
619  /* ** **/
620  /* ** Discount declaration methods **/
621  /* ** (FMDPfactory_state::NONE <-> FMDPfactory_state::DISCOUNT <->
622  * FMDPfactory_state::ACTION) **/
623  /* ** **/
624  /* ****************************************************************************************************
625  * **/
626 
627 
628  // Insert in diagram a non terminal node
629 
630  template < typename GUM_SCALAR >
631  INLINE NodeId
633  return __FunctionGraph->manager()->addInternalNode(variable(name_of_var));
634  }
635 
636 
637  // Insert in diagram a terminal node
638 
639  template < typename GUM_SCALAR >
641  return __FunctionGraph->manager()->addTerminalNode((GUM_SCALAR)value);
642  }
643 
644 
645  // Insert an arc in diagram
646  template < typename GUM_SCALAR >
647  INLINE void
649  __FunctionGraph->manager()->setSon(from, modality, to);
650  }
651 
652 
653  template < typename GUM_SCALAR >
655  __FunctionGraph->manager()->setRootNode(rootId);
656  }
657 
658  /* ****************************************************************************************************
659  * **/
660  /* ** **/
661  /* ** Various Private Methods **/
662  /* ** **/
663  /* ****************************************************************************************************
664  * **/
665 
666 
667  // Raise an OperationNotAllowed with the message "Illegal state."
668 
669  template < typename GUM_SCALAR >
670  INLINE void
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 
701  }
702 
703 
704  // Reset the different parts used to constructed the IBayesNet.
705 
706  template < typename GUM_SCALAR >
708  __foo_flag = false;
709  __bar_flag = false;
710  __stringBag.clear();
711  __ddBag.clear();
712  }
713 
714 
715  template < typename GUM_SCALAR >
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  }
733 
734 
735  template < typename GUM_SCALAR >
737  this->__FunctionGraph->manager()->reduce();
738  this->__FunctionGraph->manager()->clean();
739  }
740 
741  //~ ==============
742  //~ // Check if a variable with the given name exists, if not raise an
743  // NotFound
744  //~ // exception.
745  //~ ==============
746  //~ template<typename GUM_SCALAR> INLINE
747  //~ void
748  //~ FMDPFactory<GUM_SCALAR>::__checkVariableName ( const std::string& name ) {
749  //~ if ( !__varNameMap.exists ( name ) )
750  //~ GUM_ERROR ( NotFound, name );
751  //~ }
752 
753 
754  // Copy operator is illegal, use only copy constructor.
755 
756  template < typename GUM_SCALAR >
759  GUM_ERROR(FatalError, "Illegal!");
760  // For noisy compilers
761  return *this;
762  }
763 } /* namespace gum */
void addReward()
Tells the factory to add a reward table to the current fmdp. This reward table will be extracted from...
void __illegalStateError(const std::string &s)
Raise an OperationNotAllowed with the message "Illegal state.".
std::vector< std::string > __stringBag
Just to keep track of strings between two start/end calls.
Definition: fmdpFactory.h:271
void endTransitionDeclaration()
Tells the factory that we&#39;re out of a transition declaration.
FMDPfactory_state state() const
Returns the current state of the factory.
void __resetParts()
Reset the different parts used to constructed the FMDP.
void endActionDeclaration()
Tells the factory that we&#39;re out of an action declaration.
A factory class to ease Factored Markov Decision Process construction.
Definition: fmdpFactory.h:68
FMDPFactory< GUM_SCALAR > & operator=(const FMDPFactory< GUM_SCALAR > &source)
Copy operator is illegal, use only copy constructor.
void addAction(const std::string &action)
Tells the factory to add an action to the current fmdp.
void setSon(const NodeId &node, const Idx &modality, const NodeId &sonNode)
Sets nodes son for given modality to designated son node.
void __initializeFunctionGraph()
Insert every variables in the function graph.
void clean()
Removes var without nodes in the diagram.
void setRootNode(const NodeId &root)
Sets root node of decision diagram.
class LabelizedVariable
MultiDimFunctionGraph< GUM_SCALAR > * __FunctionGraph
The FunctionGraph we&#39;re building at a given time.
Definition: fmdpFactory.h:298
void startDiscountDeclaration()
Tells the factory that we&#39;re in a cost declaration.
FMDPfactory_state
The enumeration of states in which the factory can be in.
Definition: IfmdpFactory.h:50
void startActionDeclaration()
Tells the factory that we&#39;re in an action declaration.
void addDiscount(float discount)
Tells the factory to add a cost table to the current fmdp.
void startVariableDeclaration()
Tells the factory that we&#39;re in a variable declaration.
void endCostDeclaration()
Tells the factory that we&#39;re out of a cost declaration.
void addArc(NodeId from, NodeId to, Idx modality)
Insert in diagram a non terminal node.
void setRoot(NodeId rootId)
add an arc in diagram
const DiscreteVariable * variable(const std::string &name) const
Returns a constant reference on a variable given it&#39;s name.
MultiDimFunctionGraph< T > * subtract2MultiDimFunctionGraphs(const MultiDimFunctionGraph< T > *t1, const MultiDimFunctionGraph< T > *t2)
a specialized function for subtracting two multiDimArraysThe function produces a tensorial subtractio...
NodeId addInternalNode(const DiscreteVariable *var)
Inserts a new non terminal node in graph.
This class is used to implement factored decision process.
Definition: fmdp.h:54
void addModality(const std::string &name)
Adds a modality to the current variable.
Base class for discrete random variable.
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
void __checkModalityInBag(const std::string &mod)
Used in VARIABLE mode Checks if in __stringBag there is no other modality with the same name...
Headers of gum::MultiDimImplementation.
bool __bar_flag
Depending on the context this flag is used for some VERY important reasons.
Definition: fmdpFactory.h:268
FMDP< GUM_SCALAR > * fmdp() const
Returns the Factored Markov Decision Process created by this factory.
void endDiscountDeclaration()
Tells the factory that we&#39;re out of a cost declaration.
~FMDPFactory()
Destructor.
virtual void add(const DiscreteVariable &v)
Adds a new var to the variables of the multidimensional matrix.
Header of the Potential class.
void addTransition(const std::string &var, const MultiDimAdressable *transition)
Tells the factory to add a transition table to the current fmdp.
void addCost()
Tells the factory to add a cost table to the current fmdp. This cost table will be extracted from inc...
MultiDimFunctionGraph< T > * multiply2MultiDimFunctionGraphs(const MultiDimFunctionGraph< T > *t1, const MultiDimFunctionGraph< T > *t2)
a specialized function for multiplying two multiDimArraysThe function produces a tensorial product of...
Idx __actionIdcpt
Action Id counter.
Definition: fmdpFactory.h:304
void endRewardDeclaration()
Tells the factory that we&#39;re out of a cost declaration.
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
void endVariableDeclaration()
Tells the factory that we&#39;re out of a variable declaration.
NodeId addInternalNode(std::string name_of_var)
Insert in diagram a non terminal node.
void startCostDeclaration()
Tells the factory that we&#39;re in a cost declaration.
NodeId addTerminalNode(float value)
Insert in diagram a terminal node.
void variableName(const std::string &name)
Tells the factory the current variable&#39;s name.
Headers of the FMDPFactory class.
bool __foo_flag
Depending on the context this flag is used for some VERY important reasons.
Definition: fmdpFactory.h:264
Abstract base class for all multi dimensionnal addressable.
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...
void variableDescription(const std::string &desc)
Tells the factory the current variable&#39;s description.
NodeId addTerminalNode(const GUM_SCALAR &value)
Adds a value to the MultiDimFunctionGraph.
<agrum/multidim/multiDimImplementation.h>
Size Idx
Type for indexes.
Definition: types.h:50
void setOperationModeOn(std::string operationType)
Tells the factory that we&#39;re in a reward declaration mode where the global reward diagram is an opera...
MultiDimFunctionGraphManager< GUM_SCALAR, TerminalNodePolicy > * manager()
Returns a const reference to the manager of this diagram.
void __finalizeFunctionGraph()
Insert every variables in the function graph.
void startRewardDeclaration()
Tells the factory that we&#39;re in a reward declaration.
void setTableName(const std::string &name)
Sets the name of the table represented by this structure.
FMDPFactory(FMDP< GUM_SCALAR > *fmdp)
Use this constructor if you want to use an already created factored markov decision process...
const std::string & name() const
returns the name of the variable
LabelizedVariable & addLabel(const std::string &aLabel)
add a label with a new index (we assume that we will NEVER remove a label)
virtual void reduce()=0
Ensures that every isomorphic subgraphs are merged together.
Size NodeId
Type for node ids.
Definition: graphElements.h:97
void startTransitionDeclaration()
Tells the factory that we&#39;re in a transition declaration.
static MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy > * getReducedAndOrderedInstance()
Returns a reduced and ordered instance.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:52