MachineIntelligenceCore:ReinforcementLearning
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator
GridworldDeepQLearning.hpp
Go to the documentation of this file.
1 
23 #ifndef SRC_APPLICATION_GRIDWORLDDEEPQLEARNING_HPP_
24 #define SRC_APPLICATION_GRIDWORLDDEEPQLEARNING_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 <mlnn/BackpropagationNeuralNetwork.hpp>
34 // Using multi layer neural networks
35 using namespace mic::mlnn;
36 using namespace mic::types;
37 
38 #include <types/Gridworld.hpp>
39 
40 namespace mic {
41 namespace application {
42 
43 
48 class GridworldDeepQLearning: public mic::opengl::application::OpenGLEpisodicApplication {
49 public:
54  GridworldDeepQLearning(std::string node_name_ = "application");
55 
59  virtual ~GridworldDeepQLearning();
60 
61 protected:
62 
68  virtual void initialize(int argc, char* argv[]);
69 
73  virtual void initializePropertyDependentVariables();
74 
78  virtual bool performSingleStep();
79 
83  virtual void startNewEpisode();
84 
88  virtual void finishCurrentEpisode();
89 
90 
91 private:
92 
94  WindowCollectorChart<float>* w_chart;
95 
97  mic::utils::DataCollectorPtr<std::string, float> collector_ptr;
98 
101 
105  mic::configuration::Property<float> step_reward;
106 
110  mic::configuration::Property<float> discount_rate;
111 
115  mic::configuration::Property<float> learning_rate;
116 
121  mic::configuration::Property<double> epsilon;
122 
124  mic::configuration::Property<std::string> statistics_filename;
125 
127  mic::configuration::Property<std::string> mlnn_filename;
128 
130  mic::configuration::Property<bool> mlnn_save;
131 
133  mic::configuration::Property<bool> mlnn_load;
134 
136  BackpropagationNeuralNetwork<float> neural_net;
137 
142  float computeBestValueForCurrentState();
143 
148  mic::types::MatrixXfPtr getPredictedRewardsForCurrentState();
149 
154  mic::types::NESWAction selectBestActionForCurrentState();
155 
160  std::string streamNetworkResponseTable();
161 
165  mic::types::Position2D player_pos_t_minus_prim;
166 
170  long long sum_of_iterations;
171 
175  long long sum_of_rewards;
176 
177 };
178 
179 } /* namespace application */
180 } /* namespace mic */
181 
182 #endif /* SRC_APPLICATION_GRIDWORLDDEEPQLEARNING_HPP_ */
mic::configuration::Property< std::string > mlnn_filename
Property: name of the file to which the neural network will be serialized (or deserialized from)...
Class emulating the gridworld environment.
Definition: Gridworld.hpp:50
mic::configuration::Property< float > discount_rate
mic::configuration::Property< std::string > statistics_filename
Property: name of the file to which the statistics will be exported.
mic::configuration::Property< double > epsilon
mic::configuration::Property< bool > mlnn_load
Property: flad denoting thether the nn should be loaded from a file (at the initialization of the tas...
mic::environments::Gridworld grid_env
The gridworld environment.
mic::configuration::Property< float > learning_rate
BackpropagationNeuralNetwork< float > neural_net
Multi-layer neural network used for approximation of the Qstate rewards.
WindowCollectorChart< float > * w_chart
Window for displaying statistics.
mic::configuration::Property< bool > mlnn_save
Property: flad denoting thether the nn should be saved to a file (after every episode end)...
mic::configuration::Property< float > step_reward
Class responsible for solving the gridworld problem with Q-learning and (not that) deep neural networ...
mic::utils::DataCollectorPtr< std::string, float > collector_ptr
Data collector.