aGrUM  0.16.0
fmdpFactory.h
Go to the documentation of this file.
1 
30 #ifndef GUM_FMDP_FACTORY_H
31 #define GUM_FMDP_FACTORY_H
32 //======================================================================
33 #include <string>
34 #include <vector>
35 //======================================================================
36 #include <agrum/core/sequence.h>
37 
39 
41 #include <agrum/FMDP/fmdp.h>
42 
43 
44 namespace gum {
45 
70  template < typename GUM_SCALAR >
72  public:
73  // ==========================================================================
75  // ==========================================================================
77 
84 
94  ~FMDPFactory();
95 
97  // ==========================================================================
99  // ==========================================================================
101 
107  FMDP< GUM_SCALAR >* fmdp() const;
108 
110  FMDPfactory_state state() const;
111 
114  const DiscreteVariable* variable(const std::string& name) const;
115 
117  // ==========================================================================
119  // ==========================================================================
121 
124 
128  void variableName(const std::string& name);
129 
131  void variableDescription(const std::string& desc);
132 
134  void addModality(const std::string& name);
135 
139  void endVariableDeclaration();
140 
142  // ==========================================================================
144  // ==========================================================================
146 
148  void startActionDeclaration();
149 
151  void addAction(const std::string& action);
152 
154  void endActionDeclaration();
155 
157  // ==========================================================================
159  // ==========================================================================
161 
164 
166  void addTransition(const std::string& var,
167  const MultiDimAdressable* transition);
168 
172  void addTransition(const std::string& var);
173 
176 
178  // ==========================================================================
180  // ==========================================================================
182 
184  void startCostDeclaration();
185 
187  void addCost(const MultiDimAdressable* cost);
188 
192  void addCost();
193 
195  void endCostDeclaration();
196 
198  // ==========================================================================
200  // ==========================================================================
202 
204  void startRewardDeclaration();
205 
209  void setOperationModeOn(std::string operationType);
210 
212  void addReward(const MultiDimAdressable* reward);
213 
217  void addReward();
218 
220  void endRewardDeclaration();
221 
223  // ==========================================================================
225  // ==========================================================================
227 
230 
232  void addDiscount(float discount);
233 
235  void endDiscountDeclaration();
236 
238  // ==========================================================================
242  // ==========================================================================
244 
246  NodeId addInternalNode(std::string name_of_var);
247 
249  NodeId addTerminalNode(float value);
250 
252  void addArc(NodeId from, NodeId to, Idx modality);
253 
255  void setRoot(NodeId rootId);
256 
258 
259  private:
260  // ==========================================================================
262  // ==========================================================================
264 
268 
272 
274  std::vector< std::string > __stringBag;
275 
277  std::vector< const MultiDimImplementation< GUM_SCALAR >* > __ddBag;
278 
281  void __checkModalityInBag(const std::string& mod);
282 
284  void __resetParts();
285 
288 
291 
293 
295  std::vector< FMDPfactory_state > __states;
296 
299 
302 
305 
308 
311 
313  void __illegalStateError(const std::string& s);
314  };
315 
316 
317 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
318  extern template class FMDPFactory< double >;
319 #endif
320 
321 } /* namespace gum */
322 
323 
325 
326 #endif // GUM_FMDP_FACTORY_H
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:274
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:71
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 __initializeFunctionGraph()
Insert every variables in the function graph.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
MultiDimFunctionGraph< GUM_SCALAR > * __FunctionGraph
The FunctionGraph we&#39;re building at a given time.
Definition: fmdpFactory.h:301
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:53
void startActionDeclaration()
Tells the factory that we&#39;re in an action declaration.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
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.
This class is used to implement factored decision process.
Definition: fmdp.h:57
void addModality(const std::string &name)
Adds a modality to the current variable.
Base class for discrete random variable.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
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...
bool __bar_flag
Depending on the context this flag is used for some VERY important reasons.
Definition: fmdpFactory.h:271
The class for generic Hash Tables.
Definition: hashTable.h:679
FMDP< GUM_SCALAR > * fmdp() const
Returns the Factored Markov Decision Process created by this factory.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
void endDiscountDeclaration()
Tells the factory that we&#39;re out of a cost declaration.
~FMDPFactory()
Destructor.
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...
Idx __actionIdcpt
Action Id counter.
Definition: fmdpFactory.h:307
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:304
std::vector< FMDPfactory_state > __states
State stack.
Definition: fmdpFactory.h:295
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.
bool __foo_flag
Depending on the context this flag is used for some VERY important reasons.
Definition: fmdpFactory.h:267
Abstract base class for all multi dimensionnal addressable.
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 variableDescription(const std::string &desc)
Tells the factory the current variable&#39;s description.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
A factory class to ease Factored Markov Decision Process construction.
Definition: IfmdpFactory.h:86
Size Idx
Type for indexes.
Definition: types.h:53
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...
void __finalizeFunctionGraph()
Insert every variables in the function graph.
void startRewardDeclaration()
Tells the factory that we&#39;re in a reward declaration.
FMDPFactory(FMDP< GUM_SCALAR > *fmdp)
Use this constructor if you want to use an already created factored markov decision process...
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Size NodeId
Type for node ids.
Definition: graphElements.h:98
void startTransitionDeclaration()
Tells the factory that we&#39;re in a transition declaration.