#include <PrioritizedSweeping.hh>
Classes | |
struct | saqPair |
struct | state_info |
Public Types | |
typedef const std::vector < float > * | state_t |
Public Member Functions | |
virtual int | getBestAction (const std::vector< float > &s) |
virtual void | planOnNewModel () |
PrioritizedSweeping (int numactions, float gamma, float MAX_TIME, bool onlyAddLastSA, int modelType, const std::vector< float > &featmax, const std::vector< float > &featmin, Random rng=Random()) | |
PrioritizedSweeping (const PrioritizedSweeping &) | |
virtual void | setModel (MDPModel *model) |
virtual bool | updateModelWithExperience (const std::vector< float > &last, int act, const std::vector< float > &curr, float reward, bool term) |
virtual | ~PrioritizedSweeping () |
Public Attributes | |
bool | ACTDEBUG |
bool | LISTDEBUG |
MDPModel * | model |
bool | MODELDEBUG |
bool | PLANNERDEBUG |
bool | POLICYDEBUG |
Protected Member Functions | |
void | addSAToList (const std::vector< float > &s, int act, float q) |
state_t | canonicalize (const std::vector< float > &s) |
void | createPolicy () |
void | deleteInfo (state_info *info) |
double | getSeconds () |
void | initNewState (state_t s) |
void | initStateInfo (state_info *info) |
void | printStates () |
bool | saqPairMatch (saqPair a, saqPair b) |
void | updatePriorityList (state_info *info, const std::vector< float > &next) |
float | updateQValues (const std::vector< float > &state, int act) |
void | updateStateActionFromModel (const std::vector< float > &state, int a) |
void | updateStatesFromModel () |
Private Attributes | |
std::vector< float > | featmax |
std::vector< float > | featmin |
const float | gamma |
int | lastModelUpdate |
int | MAX_STEPS |
const float | MAX_TIME |
const int | modelType |
int | nactions |
int | nstates |
const int | numactions |
const bool | onlyAddLastSA |
double | planTime |
int | prevact |
std::vector< float > | prevstate |
std::list< saqPair > | priorityList |
std::map< state_t, state_info > | statedata |
std::set< std::vector< float > > | statespace |
bool | timingType |
Definition at line 12 of file PrioritizedSweeping.hh.
typedef const std::vector<float>* PrioritizedSweeping::state_t |
The implementation maps all sensations to a set of canonical pointers, which serve as the internal representation of environment state.
Definition at line 18 of file PrioritizedSweeping.hh.
PrioritizedSweeping::PrioritizedSweeping | ( | int | numactions, |
float | gamma, | ||
float | MAX_TIME, | ||
bool | onlyAddLastSA, | ||
int | modelType, | ||
const std::vector< float > & | featmax, | ||
const std::vector< float > & | featmin, | ||
Random | rng = Random() |
||
) |
Standard constructor
numactions,numactions | in the domain |
gamma | discount factor |
rng | random |
Definition at line 8 of file PrioritizedSweeping.cc.
Unimplemented copy constructor: internal state cannot be simply copied.
PrioritizedSweeping::~PrioritizedSweeping | ( | ) | [virtual] |
Definition at line 41 of file PrioritizedSweeping.cc.
void PrioritizedSweeping::addSAToList | ( | const std::vector< float > & | s, |
int | act, | ||
float | q | ||
) | [protected] |
Definition at line 692 of file PrioritizedSweeping.cc.
PrioritizedSweeping::state_t PrioritizedSweeping::canonicalize | ( | const std::vector< float > & | s | ) | [protected] |
Produces a canonical representation of the given sensation.
s | The current sensation from the environment. |
Definition at line 235 of file PrioritizedSweeping.cc.
void PrioritizedSweeping::createPolicy | ( | ) | [protected] |
Create policy through prioritized sweeping.
Definition at line 359 of file PrioritizedSweeping.cc.
void PrioritizedSweeping::deleteInfo | ( | state_info * | info | ) | [protected] |
Definition at line 343 of file PrioritizedSweeping.cc.
int PrioritizedSweeping::getBestAction | ( | const std::vector< float > & | state | ) | [virtual] |
double PrioritizedSweeping::getSeconds | ( | ) | [protected] |
Definition at line 350 of file PrioritizedSweeping.cc.
void PrioritizedSweeping::initNewState | ( | state_t | s | ) | [protected] |
Definition at line 55 of file PrioritizedSweeping.cc.
void PrioritizedSweeping::initStateInfo | ( | state_info * | info | ) | [protected] |
Definition at line 258 of file PrioritizedSweeping.cc.
void PrioritizedSweeping::planOnNewModel | ( | ) | [virtual] |
Implements Planner.
Definition at line 195 of file PrioritizedSweeping.cc.
void PrioritizedSweeping::printStates | ( | ) | [protected] |
Print state info for debugging.
Definition at line 284 of file PrioritizedSweeping.cc.
bool PrioritizedSweeping::saqPairMatch | ( | saqPair | a, |
saqPair | b | ||
) | [protected] |
Definition at line 532 of file PrioritizedSweeping.cc.
void PrioritizedSweeping::setModel | ( | MDPModel * | model | ) | [virtual] |
Implements Planner.
Definition at line 43 of file PrioritizedSweeping.cc.
bool PrioritizedSweeping::updateModelWithExperience | ( | const std::vector< float > & | laststate, |
int | lastact, | ||
const std::vector< float > & | currstate, | ||
float | reward, | ||
bool | term | ||
) | [virtual] |
Use the latest experience to update state info and the model.
Implements Planner.
Definition at line 83 of file PrioritizedSweeping.cc.
void PrioritizedSweeping::updatePriorityList | ( | state_info * | info, |
const std::vector< float > & | next | ||
) | [protected] |
Definition at line 435 of file PrioritizedSweeping.cc.
float PrioritizedSweeping::updateQValues | ( | const std::vector< float > & | state, |
int | act | ||
) | [protected] |
Definition at line 546 of file PrioritizedSweeping.cc.
void PrioritizedSweeping::updateStateActionFromModel | ( | const std::vector< float > & | state, |
int | a | ||
) | [protected] |
Update a single state-action from the model
Definition at line 715 of file PrioritizedSweeping.cc.
void PrioritizedSweeping::updateStatesFromModel | ( | ) | [protected] |
Update our state info's from the model by calling the model function
Definition at line 138 of file PrioritizedSweeping.cc.
Definition at line 49 of file PrioritizedSweeping.hh.
std::vector<float> PrioritizedSweeping::featmax [private] |
Definition at line 135 of file PrioritizedSweeping.hh.
std::vector<float> PrioritizedSweeping::featmin [private] |
Definition at line 136 of file PrioritizedSweeping.hh.
const float PrioritizedSweeping::gamma [private] |
Definition at line 150 of file PrioritizedSweeping.hh.
int PrioritizedSweeping::lastModelUpdate [private] |
Definition at line 144 of file PrioritizedSweeping.hh.
Definition at line 50 of file PrioritizedSweeping.hh.
int PrioritizedSweeping::MAX_STEPS [private] |
Definition at line 146 of file PrioritizedSweeping.hh.
const float PrioritizedSweeping::MAX_TIME [private] |
Definition at line 151 of file PrioritizedSweeping.hh.
Model that we're using
Definition at line 53 of file PrioritizedSweeping.hh.
Definition at line 48 of file PrioritizedSweeping.hh.
const int PrioritizedSweeping::modelType [private] |
Definition at line 153 of file PrioritizedSweeping.hh.
int PrioritizedSweeping::nactions [private] |
Definition at line 143 of file PrioritizedSweeping.hh.
int PrioritizedSweeping::nstates [private] |
Definition at line 142 of file PrioritizedSweeping.hh.
const int PrioritizedSweeping::numactions [private] |
Definition at line 149 of file PrioritizedSweeping.hh.
const bool PrioritizedSweeping::onlyAddLastSA [private] |
Definition at line 152 of file PrioritizedSweeping.hh.
Definition at line 46 of file PrioritizedSweeping.hh.
double PrioritizedSweeping::planTime [private] |
Definition at line 141 of file PrioritizedSweeping.hh.
Definition at line 47 of file PrioritizedSweeping.hh.
int PrioritizedSweeping::prevact [private] |
Definition at line 139 of file PrioritizedSweeping.hh.
std::vector<float> PrioritizedSweeping::prevstate [private] |
Definition at line 138 of file PrioritizedSweeping.hh.
std::list< saqPair> PrioritizedSweeping::priorityList [private] |
priority list for prioritized sweeping
Definition at line 133 of file PrioritizedSweeping.hh.
std::map<state_t, state_info> PrioritizedSweeping::statedata [private] |
Hashmap mapping state vectors to their state_info structs.
Definition at line 130 of file PrioritizedSweeping.hh.
std::set<std::vector<float> > PrioritizedSweeping::statespace [private] |
Set of all distinct sensations seen. Pointers to elements of this set serve as the internal representation of the environment state.
Definition at line 127 of file PrioritizedSweeping.hh.
bool PrioritizedSweeping::timingType [private] |
Definition at line 147 of file PrioritizedSweeping.hh.