aGrUM  0.16.0
fmdpSimulator.h
Go to the documentation of this file.
1 
29 #ifndef GUM_FMDP_SIMULATOR_H
30 #define GUM_FMDP_SIMULATOR_H
31 //======================================================================
33 //======================================================================
34 #include <agrum/FMDP/fmdp.h>
36 //======================================================================
37 
38 namespace gum {
49  public:
50  // ===========================================================================
52  // ===========================================================================
54 
58  FMDPSimulator(const FMDP< double >* fmdp);
59  FMDPSimulator(const std::string& resource);
60 
65 
67 
68  // ===========================================================================
70  // ===========================================================================
72 
74  double reward() { return __fmdp->reward()->get(this->_currentState); }
75 
76  void perform(Idx);
77 
79 
80  // ===========================================================================
82  // ===========================================================================
84 
85  const DiscreteVariable* primeVar(const DiscreteVariable* mainVar) {
86  return __fmdp->main2prime(mainVar);
87  }
88 
91  return __fmdp->beginVariables();
92  }
94  return __fmdp->endVariables();
95  }
96 
98 
99  // ===========================================================================
101  // ===========================================================================
103 
104  virtual const std::string& actionName(Idx actionId) {
105  return __fmdp->actionName(actionId);
106  }
107 
112 
113  protected:
114  virtual double _transitionProbability(const DiscreteVariable* var,
115  const Instantiation& transit,
116  Idx actionId) {
117  return reinterpret_cast< const MultiDimFunctionGraph< double >* >(
118  __fmdp->transition(actionId, var))
119  ->get(transit);
120  }
121 
122  private:
126 
128  const bool __loaded;
129  };
130 
131 } /* namespace gum */
132 
133 
134 #endif // GUM_FMDP_SIMULATOR_H
Safe iterators for Sequence.
Definition: sequence.h:1206
void perform(Idx)
Sets the intial statefrom which we begun the simulation.
<agrum/FMDP/simulation/abstractSimulator.h>
SequenceIteratorSafe< Idx > beginActions() const
Returns an iterator reference to he beginning of the list of actions.
Definition: fmdp.h:137
const DiscreteVariable * primeVar(const DiscreteVariable *mainVar)
Iteration over the variables of the simulated probleme.
Definition: fmdpSimulator.h:85
virtual double _transitionProbability(const DiscreteVariable *var, const Instantiation &transit, Idx actionId)
const std::string & actionName(Idx actionId) const
Returns name of action given in parameter.
Definition: fmdp_tpl.h:347
SequenceIteratorSafe< const DiscreteVariable *> beginVariables() const
Returns an iterator reference to he beginning of the list of variables.
Definition: fmdp.h:95
Base class for discrete random variable.
<agrum/FMDP/simulation/fmdpSimulator.h>
Definition: fmdpSimulator.h:48
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
const bool __loaded
Just to know if it should be deleted in the end.
Instantiation _currentState
Tha state in which the system currently is.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
const MultiDimImplementation< GUM_SCALAR > * transition(Idx actionId, const DiscreteVariable *v) const
Returns transition associated to given in parameter variable and the given action.
Definition: fmdp_tpl.h:227
const MultiDimImplementation< GUM_SCALAR > * reward(Idx actionId=0) const
Returns the reward table of mdp.
Definition: fmdp_tpl.h:324
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
const DiscreteVariable * main2prime(const DiscreteVariable *mainVar) const
Returns the primed variable associate to the given main variable.
Definition: fmdp.h:109
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
SequenceIteratorSafe< const DiscreteVariable *> endVariables()
Iteration over the variables of the simulated probleme.
Definition: fmdpSimulator.h:93
FMDPSimulator(const FMDP< double > *fmdp)
Default constructor.
SequenceIteratorSafe< const DiscreteVariable *> beginVariables()
Iteration over the variables of the simulated probleme.
Definition: fmdpSimulator.h:90
Class for assigning/browsing values to tuples of discrete variables.
Definition: instantiation.h:83
FMDP< double > * __fmdp
The Factored Markov Decision Process that describes how the system evolves.
SequenceIteratorSafe< Idx > endActions() const
Returns an iterator reference to the end of the list of actions.
Definition: fmdp.h:144
virtual const std::string & actionName(Idx actionId)
Iteration over the variables of the simulated probleme.
double reward()
Sets the intial statefrom which we begun the simulation.
Definition: fmdpSimulator.h:74
Size Idx
Type for indexes.
Definition: types.h:53
SequenceIteratorSafe< const DiscreteVariable *> endVariables() const
Returns an iterator reference to the end of the list of variables.
Definition: fmdp.h:102
SequenceIteratorSafe< Idx > endActions()
Iteration over the variables of the simulated probleme.
SequenceIteratorSafe< Idx > beginActions()
Iteration over the variables of the simulated probleme.
~FMDPSimulator()
Default destructor.