CRAAM  2.0.0
Robust and Approximate Markov Decision Processes
Public Member Functions | Protected Attributes | List of all members
craam::SAState< AType > Class Template Reference

State for sa-rectangular uncertainty (or no uncertainty) in an MDP. More...

#include <State.hpp>

Public Member Functions

 SAState (const vector< AType > &actions)
 Initializes state with actions and sets them all to valid.
 
size_t action_count () const
 Number of actions.
 
size_t size () const
 Number of actions.
 
AType & create_action (long actionid)
 Creates an action given by actionid if it does not exists. More...
 
AType & create_action ()
 Creates an action at the last position of the state.
 
const AType & get_action (long actionid) const
 Returns an existing action.
 
const AType & operator[] (long actionid) const
 Returns an existing action.
 
AType & get_action (long actionid)
 Returns an existing action.
 
AType & operator[] (long actionid)
 Returns an existing action.
 
bool is_valid (long actionid) const
 Returns whether the actions is valid.
 
void set_valid (long actionid, bool value=true)
 Set action validity. More...
 
const vector< AType > & get_actions () const
 Returns set of all actions.
 
bool is_terminal () const
 True if the state is considered terminal (no actions). More...
 
void normalize ()
 Normalizes transition probabilities to sum to one. More...
 
bool is_action_correct (long aid, numvec nataction) const
 Checks whether the prescribed action and outcome are correct.
 
bool is_action_correct (long aid) const
 Checks whether the prescribed action correct.
 
prec_t mean_reward (long actionid, numvec nataction) const
 Returns the mean reward following the action (and outcome). More...
 
prec_t mean_reward (long actionid) const
 Returns the mean reward following the action. More...
 
Transition mean_transition (long action, numvec nataction) const
 Returns the mean transition probabilities following the action and outcome. More...
 
Transition mean_transition (long action) const
 Returns the mean transition probabilities following the action and outcome. More...
 
string to_json (long stateid=-1) const
 Returns json representation of the state. More...
 

Protected Attributes

vector< AType > actions
 list of actions
 
vector< bool > valid
 whether actions can be used in computation. If false, that means that they should not be used in algorithms or in computation.
 

Detailed Description

template<class AType>
class craam::SAState< AType >

State for sa-rectangular uncertainty (or no uncertainty) in an MDP.

Actions within a state are sequentially labeled. That is, adding an action with an id = 3 will also create actions 0,1,2. These additional actions are marked as "invalid" state. This means that they will not be used in computations and algorithms will simply skip over them. Use create_action to make and action valid.

Template Parameters
Typeof action used in the state. This type determines the type of uncertainty set.

Member Function Documentation

◆ create_action()

template<class AType>
AType& craam::SAState< AType >::create_action ( long  actionid)
inline

Creates an action given by actionid if it does not exists.

Otherwise returns the existing one.

All newly created actions with id < actionid are created as invalid (action.get_valid() = false). Action actionid is created as valid.

◆ is_terminal()

template<class AType>
bool craam::SAState< AType >::is_terminal ( ) const
inline

True if the state is considered terminal (no actions).

◆ mean_reward() [1/2]

template<class AType>
prec_t craam::SAState< AType >::mean_reward ( long  actionid,
numvec  nataction 
) const
inline

Returns the mean reward following the action (and outcome).

◆ mean_reward() [2/2]

template<class AType>
prec_t craam::SAState< AType >::mean_reward ( long  actionid) const
inline

Returns the mean reward following the action.

◆ mean_transition() [1/2]

template<class AType>
Transition craam::SAState< AType >::mean_transition ( long  action,
numvec  nataction 
) const
inline

Returns the mean transition probabilities following the action and outcome.

This class assumes a deterministic policy of the decision maker and a randomized policy of nature.

Parameters
actionDeterministic action of the decision maker
natactionRandomized action of nature

◆ mean_transition() [2/2]

template<class AType>
Transition craam::SAState< AType >::mean_transition ( long  action) const
inline

Returns the mean transition probabilities following the action and outcome.

Parameters
actionDeterministic action of decision maker

◆ normalize()

template<class AType>
void craam::SAState< AType >::normalize ( )
inline

Normalizes transition probabilities to sum to one.

◆ set_valid()

template<class AType>
void craam::SAState< AType >::set_valid ( long  actionid,
bool  value = true 
)
inline

Set action validity.

A valid action can be used in computations. An invalid action is just a placeholder.

◆ to_json()

template<class AType>
string craam::SAState< AType >::to_json ( long  stateid = -1) const
inline

Returns json representation of the state.

Parameters
stateidIncludes also state id

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