aGrUM  0.14.2
fmdpSimulator.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  ***************************************************************************/
26 #ifndef GUM_FMDP_SIMULATOR_H
27 #define GUM_FMDP_SIMULATOR_H
28 //======================================================================
30 //======================================================================
31 #include <agrum/FMDP/fmdp.h>
33 //======================================================================
34 
35 namespace gum {
46  public:
47  // ===========================================================================
49  // ===========================================================================
51 
55  FMDPSimulator(const FMDP< double >* fmdp);
56  FMDPSimulator(const std::string& resource);
57 
62 
64 
65  // ===========================================================================
67  // ===========================================================================
69 
71  double reward() { return __fmdp->reward()->get(this->_currentState); }
72 
73  void perform(Idx);
74 
76 
77  // ===========================================================================
79  // ===========================================================================
81 
82  const DiscreteVariable* primeVar(const DiscreteVariable* mainVar) {
83  return __fmdp->main2prime(mainVar);
84  }
85 
88  return __fmdp->beginVariables();
89  }
91  return __fmdp->endVariables();
92  }
93 
95 
96  // ===========================================================================
98  // ===========================================================================
100 
101  virtual const std::string& actionName(Idx actionId) {
102  return __fmdp->actionName(actionId);
103  }
104 
109 
110  protected:
111  virtual double _transitionProbability(const DiscreteVariable* var,
112  const Instantiation& transit,
113  Idx actionId) {
114  return reinterpret_cast< const MultiDimFunctionGraph< double >* >(
115  __fmdp->transition(actionId, var))
116  ->get(transit);
117  }
118 
119  private:
123 
125  const bool __loaded;
126  };
127 
128 } /* namespace gum */
129 
130 
131 #endif // GUM_FMDP_SIMULATOR_H
Safe iterators for Sequence.
Definition: sequence.h:1203
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:134
const DiscreteVariable * primeVar(const DiscreteVariable *mainVar)
Iteration over the variables of the simulated probleme.
Definition: fmdpSimulator.h:82
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:344
SequenceIteratorSafe< const DiscreteVariable *> beginVariables() const
Returns an iterator reference to he beginning of the list of variables.
Definition: fmdp.h:92
Base class for discrete random variable.
<agrum/FMDP/simulation/fmdpSimulator.h>
Definition: fmdpSimulator.h:45
gum is the global namespace for all aGrUM entities
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.
Class for implementation of factored markov decision process.
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:224
const MultiDimImplementation< GUM_SCALAR > * reward(Idx actionId=0) const
Returns the reward table of mdp.
Definition: fmdp_tpl.h:321
Class for simulating a discrete time stochastic process.
const DiscreteVariable * main2prime(const DiscreteVariable *mainVar) const
Returns the primed variable associate to the given main variable.
Definition: fmdp.h:106
Header files of gum::Instantiation.
SequenceIteratorSafe< const DiscreteVariable *> endVariables()
Iteration over the variables of the simulated probleme.
Definition: fmdpSimulator.h:90
FMDPSimulator(const FMDP< double > *fmdp)
Default constructor.
SequenceIteratorSafe< const DiscreteVariable *> beginVariables()
Iteration over the variables of the simulated probleme.
Definition: fmdpSimulator.h:87
Class for assigning/browsing values to tuples of discrete variables.
Definition: instantiation.h:80
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:141
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:71
Size Idx
Type for indexes.
Definition: types.h:50
SequenceIteratorSafe< const DiscreteVariable *> endVariables() const
Returns an iterator reference to the end of the list of variables.
Definition: fmdp.h:99
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.