1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include "PolicyAgent.h"
// PolicyAgent::PolicyAgent(int numFeatures, int numActions, double learningRate, double epsilon, FunctionApproximator *FA, char *loadWeightsFile, char *saveWeightsFile){
PolicyAgent::PolicyAgent(int numFeatures, int numActions, double learningRate, double epsilon, FunctionApproximator *FA1, FunctionApproximator *FA2, char *loadWeightsFile, char *saveWeightsFile){
this->numFeatures = numFeatures;
this->numActions = numActions;
this->learningRate = learningRate;
this->epsilon = epsilon;
this->FA1 = FA1;
this->FA2 = FA2;
this->FA = FA1;
toLoadWeights = strlen(loadWeightsFile) > 0;
if(toLoadWeights){
strcpy(this->loadWeightsFile, loadWeightsFile);
// loadWeights(loadWeightsFile);
}
toSaveWeights = strlen(saveWeightsFile) > 0;
if(toSaveWeights){
strcpy(this->saveWeightsFile, saveWeightsFile);
}
}
PolicyAgent::~PolicyAgent(){
}
void PolicyAgent::switchToSecondFA(){
this->FA = this->FA2;
this->idCurrFA = 1;
}
void PolicyAgent::switchToFirstFA(){
this->FA = this->FA1;
this->idCurrFA = 0;
}
int PolicyAgent::getNumFeatures(){
return numFeatures;
}
int PolicyAgent::getNumActions(){
return numActions;
}
void PolicyAgent::loadWeights(char *fileName){
// std::cout << "Loading Weights from " << fileName << std::endl;
// std::cout << "Doing nothing. Check PolicyAgent.cpp." << std::endl;
// FA->read(fileName);
}
void PolicyAgent::saveWeights(char *fileName){
// std::cout<< "Doing nothing. Check PolicyAgent.cpp." << std::endl;
// FA->write(fileName);
}
int PolicyAgent::argmaxQ(double state[]){
return ((int)(drand48() * getNumActions()) % getNumActions());
}
double PolicyAgent::computeQ(double state[], int action){
std::cout<<"PolicyAgent ComputeQ being called"<<std::endl;
return 0;
}