#include <Sarsa.hh>

Public Member Functions | |
| virtual int | first_action (const std::vector< float > &s) |
| float | getValue (std::vector< float > state) |
| virtual void | last_action (float r) |
| void | logValues (ofstream *of, int xmin, int xmax, int ymin, int ymax) |
| virtual int | next_action (float r, const std::vector< float > &s) |
| void | printState (const std::vector< float > &s) |
| std::vector< float >::iterator | random_max_element (std::vector< float >::iterator start, std::vector< float >::iterator end) |
| Sarsa (int numactions, float gamma, float initialvalue, float alpha, float epsilon, float lambda, Random rng=Random()) | |
| Sarsa (const Sarsa &) | |
| virtual void | savePolicy (const char *filename) |
| virtual void | seedExp (std::vector< experience >) |
| virtual void | setDebug (bool d) |
| virtual | ~Sarsa () |
Protected Types | |
| typedef const std::vector < float > * | state_t |
Protected Member Functions | |
| state_t | canonicalize (const std::vector< float > &s) |
Private Attributes | |
| bool | ACTDEBUG |
| const float | alpha |
| float * | currentq |
| bool | ELIGDEBUG |
| std::map< state_t, std::vector < float > > | eligibility |
| const float | epsilon |
| const float | gamma |
| const float | initialvalue |
| const float | lambda |
| const int | numactions |
| std::map< state_t, std::vector < float > > | Q |
| Random | rng |
| std::set< std::vector< float > > | statespace |
Interface for an implementation of the canonical Sarsa lambda algorithm. Agent that uses straight Sarsa Lambda, with no generalization and epsilon-greedy exploration.
typedef const std::vector<float>* Sarsa::state_t [protected] |
| Sarsa::Sarsa | ( | int | numactions, |
| float | gamma, | ||
| float | initialvalue, | ||
| float | alpha, | ||
| float | epsilon, | ||
| float | lambda, | ||
| Random | rng = Random() |
||
| ) |
Standard constructor
| numactions | The number of possible actions |
| gamma | The discount factor |
| initialvalue | The initial value of each Q(s,a) |
| alpha | The learning rate |
| epsilon | The probability of taking a random action |
| rng | Initial state of the random number generator to use |
| Sarsa::Sarsa | ( | const Sarsa & | ) |
Unimplemented copy constructor: internal state cannot be simply copied.
| Sarsa::~Sarsa | ( | ) | [virtual] |
| Sarsa::state_t Sarsa::canonicalize | ( | const std::vector< float > & | s | ) | [protected] |
| int Sarsa::first_action | ( | const std::vector< float > & | s | ) | [virtual] |
| float Sarsa::getValue | ( | std::vector< float > | state | ) |
| void Sarsa::last_action | ( | float | r | ) | [virtual] |
| void Sarsa::logValues | ( | ofstream * | of, |
| int | xmin, | ||
| int | xmax, | ||
| int | ymin, | ||
| int | ymax | ||
| ) |
| int Sarsa::next_action | ( | float | r, |
| const std::vector< float > & | s | ||
| ) | [virtual] |
| void Sarsa::printState | ( | const std::vector< float > & | s | ) |
| std::vector< float >::iterator Sarsa::random_max_element | ( | std::vector< float >::iterator | start, |
| std::vector< float >::iterator | end | ||
| ) |
| void Sarsa::savePolicy | ( | const char * | filename | ) | [virtual] |
| void Sarsa::seedExp | ( | std::vector< experience > | seeds | ) | [virtual] |
| void Sarsa::setDebug | ( | bool | d | ) | [virtual] |
bool Sarsa::ACTDEBUG [private] |
const float Sarsa::alpha [private] |
float* Sarsa::currentq [private] |
bool Sarsa::ELIGDEBUG [private] |
std::map<state_t, std::vector<float> > Sarsa::eligibility [private] |
const float Sarsa::epsilon [private] |
const float Sarsa::gamma [private] |
const float Sarsa::initialvalue [private] |
const float Sarsa::lambda [private] |
const int Sarsa::numactions [private] |
Random Sarsa::rng [private] |
std::set<std::vector<float> > Sarsa::statespace [private] |