55 virtual void init(
unsigned int stateDim,
unsigned int actionDim,
RandGen*
randGen = 0);
61 virtual unsigned int select (
unsigned int state);
78 virtual double learn (
unsigned int state,
81 double learnRateFactor = 1);
105 static int valInCrossProd(
const std::list<std::pair<int,int> >& vals);
108 static std::list<int>
ConfInCrossProd(
const std::list<int>& ranges,
int val);
113 virtual bool store(FILE* f)
const;
Matrix type.
Definition: matrix.h:65
int ringbuffersize
Definition: qlearning.h:134
bool random_initQ
Definition: qlearning.h:123
Interface for objects, that can be stored and restored to/from a file stream (binary).
Definition: storeable.h:33
int * actions
< Q table (mxn) == (states x actions)
Definition: qlearning.h:131
virtual void init(unsigned int stateDim, unsigned int actionDim, RandGen *randGen=0)
initialisation with the given number of action and states
Definition: qlearning.cpp:61
virtual ~QLearning()
Definition: qlearning.cpp:54
implements QLearning
Definition: qlearning.h:33
int tau
time horizont for averaging the reward
Definition: qlearning.h:127
int t
Definition: qlearning.h:136
virtual unsigned int select_sample(unsigned int state)
selection of action given current state.
Definition: qlearning.cpp:87
double exploration
Definition: qlearning.h:121
virtual unsigned int select_keepold(unsigned int state)
select with preference to old (90% if good) and 30% second best
Definition: qlearning.cpp:111
RandGen * randGen
Definition: qlearning.h:140
virtual double getCollectedReward() const
returns the collectedReward reward
Definition: qlearning.cpp:197
random generator with 48bit integer arithmentic
Definition: randomgenerator.h:34
virtual unsigned int getActionDim() const
returns the number of actions
Definition: qlearning.cpp:192
double discount
Definition: qlearning.h:120
virtual bool restore(FILE *f)
loads the object from the given file stream (ASCII preferred).
Definition: qlearning.cpp:232
matrix::Matrix Q
Definition: qlearning.h:128
virtual bool store(FILE *f) const
stores the object to the given file stream (ASCII preferred).
Definition: qlearning.cpp:226
static std::list< int > ConfInCrossProd(const std::list< int > &ranges, int val)
expects a list of ranges and a state/action and return the configuration
Definition: qlearning.cpp:214
bool useSARSA
if true, use SARSA strategy otherwise qlearning
Definition: qlearning.h:125
matrix::Matrix getActionValues(unsigned int state)
returns the vector of values for all actions given the current state
Definition: qlearning.cpp:147
double eligibility
Definition: qlearning.h:122
virtual const matrix::Matrix & getQ() const
returns q table (mxn) == (states x actions)
Definition: qlearning.h:111
double * rewards
Definition: qlearning.h:133
virtual double learn(unsigned int state, unsigned int action, double reward, double learnRateFactor=1)
Definition: qlearning.cpp:152
double eps
Definition: qlearning.h:119
virtual void reset()
tells the q learning that the agent was reset, so that it forgets it memory.
Definition: qlearning.cpp:184
bool initialised
Definition: qlearning.h:137
Abstact class for configurable objects.
Definition: configurable.h:81
QLearning(double eps, double discount, double exploration, int eligibility, bool random_initQ=false, bool useSARSA=false, int tau=1000)
Definition: qlearning.cpp:29
static int valInCrossProd(const std::list< std::pair< int, int > > &vals)
expects a list of value,range and returns the associated state
Definition: qlearning.cpp:202
virtual unsigned int select(unsigned int state)
selection of action given current state.
Definition: qlearning.cpp:71
int * states
Definition: qlearning.h:132
double * longrewards
Definition: qlearning.h:135
virtual unsigned int getStateDim() const
returns the number of states
Definition: qlearning.cpp:188
double collectedReward
Definition: qlearning.h:138