MachineIntelligenceCore:ReinforcementLearning
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator
GridworldQLearning.hpp
Go to the documentation of this file.
1 
23 #ifndef SRC_APPLICATION_GRIDWORLDQLEARNING_HPP_
24 #define SRC_APPLICATION_GRIDWORLDQLEARNING_HPP_
25 
26 #include <vector>
27 #include <string>
28 
29 #include <opengl/application/OpenGLEpisodicApplication.hpp>
30 #include <opengl/visualization/WindowCollectorChart.hpp>
31 using namespace mic::opengl::visualization;
32 
33 #include <types/Gridworld.hpp>
34 
35 namespace mic {
36 namespace application {
37 
38 
39 
44 class GridworldQLearning: public mic::opengl::application::OpenGLEpisodicApplication {
45 public:
50  GridworldQLearning(std::string node_name_ = "application");
51 
55  virtual ~GridworldQLearning();
56 
57 protected:
58 
64  virtual void initialize(int argc, char* argv[]);
65 
69  virtual void initializePropertyDependentVariables();
70 
74  virtual bool performSingleStep();
75 
79  virtual void startNewEpisode();
80 
84  virtual void finishCurrentEpisode();
85 
86 
87 private:
88 
90  WindowCollectorChart<float>* w_chart;
91 
93  mic::utils::DataCollectorPtr<std::string, float> collector_ptr;
94 
97 
99  mic::types::TensorXf qstate_table;
100 
104  mic::configuration::Property<float> step_reward;
105 
109  mic::configuration::Property<float> discount_rate;
110 
114  mic::configuration::Property<float> learning_rate;
115 
119  mic::configuration::Property<float> move_noise;
120 
125  mic::configuration::Property<double> epsilon;
126 
128  mic::configuration::Property<std::string> statistics_filename;
129 
134  std::string streamQStateTable();
135 
136 
142  float computeBestValue(mic::types::Position2D pos_);
143 
144 
149  mic::types::NESWAction selectBestAction(mic::types::Position2D pos_);
150 
151 
155  long long sum_of_iterations;
156 
160  long long sum_of_rewards;
161 
162 };
163 
164 } /* namespace application */
165 } /* namespace mic */
166 
167 #endif /* SRC_APPLICATION_GRIDWORLDQLEARNING_HPP_ */
WindowCollectorChart< float > * w_chart
Window for displaying ???.
Class emulating the gridworld environment.
Definition: Gridworld.hpp:50
mic::configuration::Property< double > epsilon
mic::types::TensorXf qstate_table
Tensor storing values for all states (gridworld w * h * 4 (number of actions)). COL MAJOR(!)...
mic::configuration::Property< float > move_noise
mic::configuration::Property< float > discount_rate
mic::configuration::Property< float > learning_rate
mic::utils::DataCollectorPtr< std::string, float > collector_ptr
Data collector.
mic::environments::Gridworld grid_env
The gridworld object.
mic::configuration::Property< float > step_reward
Class responsible for solving the gridworld problem with Q-learning.
mic::configuration::Property< std::string > statistics_filename
Property: name of the file to which the statistics will be exported.