MachineIntelligenceCore:ReinforcementLearning
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator
GridworldDRLExperienceReplay.hpp
Go to the documentation of this file.
1 
23 #ifndef SRC_APPLICATION_GRIDWORLDDRLEXPERIENCEREPLAY_HPP_
24 #define SRC_APPLICATION_GRIDWORLDDRLEXPERIENCEREPLAY_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>
40 
41 namespace mic {
42 namespace application {
43 
44 
49 class GridworldDRLExperienceReplay: public mic::opengl::application::OpenGLEpisodicApplication {
50 public:
55  GridworldDRLExperienceReplay(std::string node_name_ = "application");
56 
61 
62 protected:
63 
69  virtual void initialize(int argc, char* argv[]);
70 
74  virtual void initializePropertyDependentVariables();
75 
79  virtual bool performSingleStep();
80 
84  virtual void startNewEpisode();
85 
89  virtual void finishCurrentEpisode();
90 
91 
92 private:
93 
95  WindowCollectorChart<float>* w_chart;
96 
98  mic::utils::DataCollectorPtr<std::string, float> collector_ptr;
99 
102 
104  size_t batch_size;
105 
109  mic::configuration::Property<float> step_reward;
110 
114  mic::configuration::Property<float> discount_rate;
115 
119  mic::configuration::Property<float> learning_rate;
120 
125  mic::configuration::Property<double> epsilon;
126 
128  mic::configuration::Property<std::string> statistics_filename;
129 
131  mic::configuration::Property<std::string> mlnn_filename;
132 
134  mic::configuration::Property<bool> mlnn_save;
135 
137  mic::configuration::Property<bool> mlnn_load;
138 
140  BackpropagationNeuralNetwork<float> neural_net;
141 
148  float computeBestValueForGivenStateAndPredictions(mic::types::Position2D player_position_, float* predictions_);
149 
155  mic::types::MatrixXfPtr getPredictedRewardsForGivenState(mic::types::Position2D player_position_);
156 
162  mic::types::NESWAction selectBestActionForGivenState(mic::types::Position2D player_position_);
163 
168  std::string streamNetworkResponseTable();
169 
173  long long sum_of_iterations;
174 
178  long long sum_of_rewards;
179 
184 
189 };
190 
191 } /* namespace application */
192 } /* namespace mic */
193 
194 
195 #endif /* SRC_APPLICATION_GRIDWORLDDRLEXPERIENCEREPLAY_HPP_ */
mic::environments::Gridworld grid_env
The gridworld environment.
Class emulating the gridworld environment.
Definition: Gridworld.hpp:50
size_t batch_size
Size of the batch in experience replay - set to the size of maze (width*height).
mic::configuration::Property< bool > mlnn_save
Property: flad denoting thether the nn should be saved to a file (after every episode end)...
Class responsible for solving the gridworld problem with Q-learning, neural network used for approxim...
mic::configuration::Property< std::string > statistics_filename
Property: name of the file to which the statistics will be exported.
BackpropagationNeuralNetwork< float > neural_net
Multi-layer neural network used for approximation of the Qstate rewards.
mic::utils::DataCollectorPtr< std::string, float > collector_ptr
Data collector.
WindowCollectorChart< float > * w_chart
Window for displaying statistics.
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::configuration::Property< std::string > mlnn_filename
Property: name of the file to which the neural network will be serialized (or deserialized from)...
Class representing the spatial experience memory - used in memory replay. Derived from the Batch clas...