Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Private Attributes
ModelBasedAgent Class Reference

#include <ModelBasedAgent.hh>

Inheritance diagram for ModelBasedAgent:
Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual int first_action (const std::vector< float > &s)
void initParams ()
virtual void last_action (float r)
void logValues (ofstream *of, int xmin, int xmax, int ymin, int ymax)
 ModelBasedAgent (int numactions, float gamma, float rmax, float rrange, int modelType, int exploreType, int predType, int nModels, int plannerType, float epsilon, float lambda, float MAX_TIME, float m, const std::vector< float > &featmin, const std::vector< float > &featmax, int statesPerDim, int history, float v, float n, bool depTrans, bool relTrans, float featPct, bool stoch, bool episodic, Random rng=Random())
 ModelBasedAgent (int numactions, float gamma, float rmax, float rrange, int modelType, int exploreType, int predType, int nModels, int plannerType, float epsilon, float lambda, float MAX_TIME, float m, const std::vector< float > &featmin, const std::vector< float > &featmax, std::vector< int > statesPerDim, int history, float v, float n, bool depTrans, bool relTrans, float featPct, bool stoch, bool episodic, Random rng=Random())
 ModelBasedAgent (const ModelBasedAgent &)
virtual int next_action (float r, const std::vector< float > &s)
virtual void savePolicy (const char *filename)
virtual void seedExp (std::vector< experience > seeds)
virtual void setDebug (bool d)
virtual ~ModelBasedAgent ()

Public Attributes

bool ACTDEBUG
float actionTime
bool AGENTDEBUG
std::vector< float > featmax
std::vector< float > featmin
MDPModelmodel
float modelUpdateTime
Plannerplanner
float planningTime
bool POLICYDEBUG
bool seeding
bool SIMPLEDEBUG
bool TIMEDEBUG

Protected Types

typedef const std::vector
< float > * 
state_t

Protected Member Functions

int chooseAction (const std::vector< float > &s)
double getSeconds ()
void initModel (int nfactors)
void initPlanner ()
void saveStateAndAction (const std::vector< float > &s, int act)
void updateWithNewExperience (const std::vector< float > &last, const std::vector< float > &curr, int lastact, float reward, bool term)

Private Attributes

int BATCH_FREQ
const bool depTrans
const bool episodic
const float epsilon
const int exploreType
const float featPct
const float gamma
const int history
const float lambda
int lastUpdate
const float M
const float MAX_TIME
bool modelChanged
bool modelNeedsUpdate
const int modelType
const float n
int nactions
const int nModels
int nstates
const int numactions
const int plannerType
const int predType
int prevact
std::vector< float > prevstate
const float qmax
const bool relTrans
const float rmax
Random rng
const float rrange
const std::vector< int > statesPerDim
const bool stoch
const float v

Detailed Description

Code for a model based agent, that can use any model and planner that meet the interface requirements

Definition at line 17 of file ModelBasedAgent.hh.


Member Typedef Documentation

typedef const std::vector<float>* ModelBasedAgent::state_t [protected]

The implementation maps all sensations to a set of canonical pointers, which serve as the internal representation of environment state.

Definition at line 135 of file ModelBasedAgent.hh.


Constructor & Destructor Documentation

ModelBasedAgent::ModelBasedAgent ( int  numactions,
float  gamma,
float  rmax,
float  rrange,
int  modelType,
int  exploreType,
int  predType,
int  nModels,
int  plannerType,
float  epsilon,
float  lambda,
float  MAX_TIME,
float  m,
const std::vector< float > &  featmin,
const std::vector< float > &  featmax,
int  statesPerDim,
int  history,
float  v,
float  n,
bool  depTrans,
bool  relTrans,
float  featPct,
bool  stoch,
bool  episodic,
Random  rng = Random() 
)

Standard constructor

Parameters:
numactionsThe number of possible actions
gammaThe discount factor
rmaxmax reward value, given out for unknown states
rrangerange between max and min reward in domain
modelTypespecifies model type
exploreTypespecifies exploration type
predTypespecifies how to combine multiple models
nModelsnumber of models in ensemble
plannerTypespecifies planner type
epsilonused for epsilon-greedy action selection
lambdaused for eligibility traces in uct planning
MAX_TIMEamount of time the uct planners are given for planning
m# visits required for a state to become known when doing rmax exploration
featminmin values of each feature
featmaxmax values of each feature
statesPerDim# of values to discretize each feature into
history# of previous actions to use for delayed domains
b\vbonus reward used when models disagree
nbonus reward used for novel states
depTransassume dependent or indep. feature transitions
relTransmodel transitions relatively vs absolutely
featPctpct of feature to remove from set used for each split in tree
stochis the domain stochastic?
episodicis the domain episodic?
rngInitial state of the random number generator to use

Definition at line 57 of file ModelBasedAgent.cc.

ModelBasedAgent::ModelBasedAgent ( int  numactions,
float  gamma,
float  rmax,
float  rrange,
int  modelType,
int  exploreType,
int  predType,
int  nModels,
int  plannerType,
float  epsilon,
float  lambda,
float  MAX_TIME,
float  m,
const std::vector< float > &  featmin,
const std::vector< float > &  featmax,
std::vector< int >  statesPerDim,
int  history,
float  v,
float  n,
bool  depTrans,
bool  relTrans,
float  featPct,
bool  stoch,
bool  episodic,
Random  rng = Random() 
)

Standard constructor

Parameters:
numactionsThe number of possible actions
gammaThe discount factor
rmaxmax reward value, given out for unknown states
rrangerange between max and min reward in domain
modelTypespecifies model type
exploreTypespecifies exploration type
predTypespecifies how to combine multiple models
nModelsnumber of models in ensemble
plannerTypespecifies planner type
epsilonused for epsilon-greedy action selection
lambdaused for eligibility traces in uct planning
MAX_TIMEamount of time the uct planners are given for planning
m# visits required for a state to become known when doing rmax exploration
featminmin values of each feature
featmaxmax values of each feature
statesPerDim# of values to discretize each feature into
history# of previous actions to use for delayed domains
bbonus reward used when models disagree
depTransassume dependent or indep. feature transitions
relTransmodel transitions relatively vs absolutely
featPctpct of feature to remove from set used for each split in tree
stochis the domain stochastic?
episodicis the domain episodic?
rngInitial state of the random number generator to use

Definition at line 26 of file ModelBasedAgent.cc.

Unimplemented copy constructor: internal state cannot be simply copied.

Definition at line 130 of file ModelBasedAgent.cc.


Member Function Documentation

int ModelBasedAgent::chooseAction ( const std::vector< float > &  s) [protected]

Select action from the given state

Definition at line 386 of file ModelBasedAgent.cc.

int ModelBasedAgent::first_action ( const std::vector< float > &  s) [virtual]

Implements Agent.

Definition at line 138 of file ModelBasedAgent.cc.

double ModelBasedAgent::getSeconds ( ) [protected]

Get the current time in seconds

Definition at line 434 of file ModelBasedAgent.cc.

void ModelBasedAgent::initModel ( int  nfactors) [protected]

Initialize the model with the given # of features

Definition at line 217 of file ModelBasedAgent.cc.

Init params for both constructors

Definition at line 87 of file ModelBasedAgent.cc.

void ModelBasedAgent::initPlanner ( ) [protected]

Initialize the planner

Definition at line 284 of file ModelBasedAgent.cc.

void ModelBasedAgent::last_action ( float  r) [virtual]

Implements Agent.

Definition at line 198 of file ModelBasedAgent.cc.

void ModelBasedAgent::logValues ( ofstream *  of,
int  xmin,
int  xmax,
int  ymin,
int  ymax 
)

Output value function to a file

Definition at line 491 of file ModelBasedAgent.cc.

int ModelBasedAgent::next_action ( float  r,
const std::vector< float > &  s 
) [virtual]

Implements Agent.

Definition at line 166 of file ModelBasedAgent.cc.

void ModelBasedAgent::savePolicy ( const char *  filename) [virtual]

Reimplemented from Agent.

Definition at line 485 of file ModelBasedAgent.cc.

void ModelBasedAgent::saveStateAndAction ( const std::vector< float > &  s,
int  act 
) [protected]

Saves state and action to use for update on next action

Definition at line 421 of file ModelBasedAgent.cc.

void ModelBasedAgent::seedExp ( std::vector< experience seeds) [virtual]

Reimplemented from Agent.

Definition at line 442 of file ModelBasedAgent.cc.

void ModelBasedAgent::setDebug ( bool  d) [virtual]

Implements Agent.

Definition at line 481 of file ModelBasedAgent.cc.

void ModelBasedAgent::updateWithNewExperience ( const std::vector< float > &  last,
const std::vector< float > &  curr,
int  lastact,
float  reward,
bool  term 
) [protected]

Update the agent with the new s,a,s',r experience

Definition at line 333 of file ModelBasedAgent.cc.


Member Data Documentation

Definition at line 111 of file ModelBasedAgent.hh.

Definition at line 125 of file ModelBasedAgent.hh.

Definition at line 109 of file ModelBasedAgent.hh.

Definition at line 170 of file ModelBasedAgent.hh.

Definition at line 195 of file ModelBasedAgent.hh.

Definition at line 199 of file ModelBasedAgent.hh.

const float ModelBasedAgent::epsilon [private]

Definition at line 186 of file ModelBasedAgent.hh.

const int ModelBasedAgent::exploreType [private]

Definition at line 181 of file ModelBasedAgent.hh.

std::vector<float> ModelBasedAgent::featmax

Definition at line 128 of file ModelBasedAgent.hh.

std::vector<float> ModelBasedAgent::featmin

Definition at line 127 of file ModelBasedAgent.hh.

const float ModelBasedAgent::featPct [private]

Definition at line 197 of file ModelBasedAgent.hh.

const float ModelBasedAgent::gamma [private]

Definition at line 175 of file ModelBasedAgent.hh.

const int ModelBasedAgent::history [private]

Definition at line 192 of file ModelBasedAgent.hh.

const float ModelBasedAgent::lambda [private]

Definition at line 187 of file ModelBasedAgent.hh.

Definition at line 168 of file ModelBasedAgent.hh.

const float ModelBasedAgent::M [private]

Definition at line 190 of file ModelBasedAgent.hh.

const float ModelBasedAgent::MAX_TIME [private]

Definition at line 188 of file ModelBasedAgent.hh.

Model that we're using

Definition at line 118 of file ModelBasedAgent.hh.

Definition at line 172 of file ModelBasedAgent.hh.

Definition at line 167 of file ModelBasedAgent.hh.

const int ModelBasedAgent::modelType [private]

Definition at line 180 of file ModelBasedAgent.hh.

Definition at line 124 of file ModelBasedAgent.hh.

const float ModelBasedAgent::n [private]

Definition at line 194 of file ModelBasedAgent.hh.

Definition at line 165 of file ModelBasedAgent.hh.

const int ModelBasedAgent::nModels [private]

Definition at line 183 of file ModelBasedAgent.hh.

int ModelBasedAgent::nstates [private]

Definition at line 164 of file ModelBasedAgent.hh.

const int ModelBasedAgent::numactions [private]

Definition at line 174 of file ModelBasedAgent.hh.

Planner that we're using

Definition at line 121 of file ModelBasedAgent.hh.

const int ModelBasedAgent::plannerType [private]

Definition at line 184 of file ModelBasedAgent.hh.

Definition at line 123 of file ModelBasedAgent.hh.

Definition at line 110 of file ModelBasedAgent.hh.

const int ModelBasedAgent::predType [private]

Definition at line 182 of file ModelBasedAgent.hh.

int ModelBasedAgent::prevact [private]

Previous action

Definition at line 162 of file ModelBasedAgent.hh.

std::vector<float> ModelBasedAgent::prevstate [private]

Previous state

Definition at line 160 of file ModelBasedAgent.hh.

const float ModelBasedAgent::qmax [private]

Definition at line 179 of file ModelBasedAgent.hh.

Definition at line 196 of file ModelBasedAgent.hh.

const float ModelBasedAgent::rmax [private]

Definition at line 177 of file ModelBasedAgent.hh.

Definition at line 201 of file ModelBasedAgent.hh.

const float ModelBasedAgent::rrange [private]

Definition at line 178 of file ModelBasedAgent.hh.

Definition at line 115 of file ModelBasedAgent.hh.

Definition at line 112 of file ModelBasedAgent.hh.

const std::vector<int> ModelBasedAgent::statesPerDim [private]

Definition at line 191 of file ModelBasedAgent.hh.

const bool ModelBasedAgent::stoch [private]

Definition at line 198 of file ModelBasedAgent.hh.

Definition at line 113 of file ModelBasedAgent.hh.

const float ModelBasedAgent::v [private]

Definition at line 193 of file ModelBasedAgent.hh.


The documentation for this class was generated from the following files:


rl_agent
Author(s): Todd Hester
autogenerated on Thu Jun 6 2019 22:00:14