Scheduler
reinforcedLearningTest.cpp
Go to the documentation of this file.
1 
11 #include <gtest/gtest.h>
12 
13 #include <mdp/context.h>
14 #include <mdp/policy.h>
15 #include <mdp/stateSpace.h>
16 #include <mdp/mdpConfiguration.h>
17 #include <utils/randomGenerator.h>
18 
19 using namespace Mdp;
20 
22 {
23 public:
24  RlTester(std::shared_ptr<Context> context) : ReinforcedLearning(context){};
25 };
26 
27 size_t NBOFSTATES = 5;
28 size_t NBOFACTIONS = 4;
29 
31 {
32 public:
34  size_t size() override {return NBOFSTATES;};
35  state_t getState() override {return 0;};
36  void updateCurrentState() override {};
37  double getReward() override {return 1.0;};
38 };
39 
41 {
42 public:
43  size_t size() override {return NBOFACTIONS;};
44 };
45 
46 std::shared_ptr<Context> buildContext()
47 {
48  std::shared_ptr<Context> context = std::make_shared<Context>();
49  std::shared_ptr<Utils::RandomGenerator> gen = std::make_shared<Utils::RandomGenerator>();
50  std::shared_ptr<Policy> policy = std::make_shared<Policy>(NBOFSTATES, NBOFACTIONS, context->randomGenerator);
51 
52  std::shared_ptr<CustomStateSpace> stateSpace = std::make_shared<CustomStateSpace>();
53  std::shared_ptr<CustomActionSpace> actionSpace = std::make_shared<CustomActionSpace>();
54  std::shared_ptr<MdpConfiguration> conf = std::make_shared<MdpConfiguration>("configuration.conf");
55 
56  context->randomGenerator = gen;
57  context->policy = policy;
58  context->stateSpace = stateSpace;
59  context->actionSpace = actionSpace;
60  context->conf = conf;
61  return context;
62 }
63 
64 TEST(ReinforcementLearningTest, testBasic)
65 {
66  std::shared_ptr<Context> context = buildContext();
67  RlTester tester(context);
68  tester.initializeModel();
69  tester.end();
70 }
71 
72 
73 
74 
75 
size_t size() override
TEST(ReinforcementLearningTest, testBasic)
void updateCurrentState() override
RlTester(std::shared_ptr< Context > context)
double getReward() override
state_t getState() override
Definition: action.h:18
std::shared_ptr< Context > buildContext()
size_t NBOFSTATES
size_t state_t
Definition: state.h:19
size_t NBOFACTIONS