MultiAgentDecisionProcess
MADPComponentDiscreteStates Class Reference

MADPComponentDiscreteStates is a class that represents a discrete state space. More...

#include <MADPComponentDiscreteStates.h>

Public Member Functions

void AddState (const std::string &StateName)
 Adds a new state. More...
 
double GetInitialStateProbability (Index sI) const
 Return the initial state distribution. More...
 
virtual StateDistributionGetISD ()
 Returns the complete initial state distribution. More...
 
virtual StateDistributionGetISD () const
 
size_t GetNrStates () const
 Return the number of states. More...
 
const StateGetState (Index i) const
 Returns a pointer to state i. */. More...
 
Index GetStateIndex (StateDiscrete s) const
 Returns the state index of state s. More...
 
Index GetStateIndexByName (const std::string &s) const
 Returns the state index of state s. More...
 
std::string GetStateName (Index i) const
 Returns the name of a particular state i. More...
 
 MADPComponentDiscreteStates ()
 (default) Constructor More...
 
 MADPComponentDiscreteStates (size_t nrS)
 Constructor that sets the number of states. More...
 
 MADPComponentDiscreteStates (const MADPComponentDiscreteStates &a)
 Copy constructor. More...
 
void Print () const
 
Index SampleInitialState () const
 Sample a state according to the initial state PDF. More...
 
bool SetInitialized (bool b)
 Sets _m_initialized to b. More...
 
void SetISD (StateDistribution *p)
 Sets the initial state distribution to v. More...
 
void SetISD (StateDistributionVector *p)
 
void SetISD (std::vector< double > v)
 
void SetNrStates (size_t nrS)
 Sets the number of states to nrS. More...
 
void SetUniformISD ()
 Sets the initial state distribution to a uniform one. More...
 
std::string SoftPrint () const
 
virtual std::string SoftPrintState (Index sI) const
 
virtual ~MADPComponentDiscreteStates ()
 Destructor. More...
 

Private Member Functions

std::string SoftPrintInitialStateDistribution () const
 Returns a string with the initial state distribution. More...
 
std::string SoftPrintStates () const
 Returns a string with the states. More...
 

Private Attributes

bool _m_initialized
 
StateDistributionVector_m_initialStateDistribution
 A StateDistributionVector that represents the initial state distribution. More...
 
size_t _m_nrStates
 
std::vector< StateDiscrete_m_stateVec
 A vector that contains all the states. More...
 

Detailed Description

MADPComponentDiscreteStates is a class that represents a discrete state space.

It implements a part of the MultiAgentDecisionProcessDiscreteInterface.

Constructor & Destructor Documentation

MADPComponentDiscreteStates::MADPComponentDiscreteStates ( )

(default) Constructor

MADPComponentDiscreteStates::MADPComponentDiscreteStates ( size_t  nrS)

Constructor that sets the number of states.

References _m_initialized, and SetNrStates().

MADPComponentDiscreteStates::MADPComponentDiscreteStates ( const MADPComponentDiscreteStates a)

Copy constructor.

References _m_initialized, _m_initialStateDistribution, _m_nrStates, and _m_stateVec.

MADPComponentDiscreteStates::~MADPComponentDiscreteStates ( )
virtual

Destructor.

References _m_initialStateDistribution.

Member Function Documentation

void MADPComponentDiscreteStates::AddState ( const std::string &  StateName)
double MADPComponentDiscreteStates::GetInitialStateProbability ( Index  sI) const
virtual StateDistribution* MADPComponentDiscreteStates::GetISD ( )
inlinevirtual

Returns the complete initial state distribution.

Referenced by MultiAgentDecisionProcessDiscrete::GetISD().

virtual StateDistribution* MADPComponentDiscreteStates::GetISD ( ) const
inlinevirtual
size_t MADPComponentDiscreteStates::GetNrStates ( ) const
inline

Return the number of states.

References _m_nrStates.

Referenced by MultiAgentDecisionProcessDiscrete::GetNrStates(), SetUniformISD(), and SoftPrint().

const State* MADPComponentDiscreteStates::GetState ( Index  i) const
inline

Returns a pointer to state i. */.

Referenced by MultiAgentDecisionProcessDiscrete::GetState().

Index MADPComponentDiscreteStates::GetStateIndex ( StateDiscrete  s) const

Returns the state index of state s.

References DiscreteEntity::GetIndex().

Index MADPComponentDiscreteStates::GetStateIndexByName ( const std::string &  s) const

Returns the state index of state s.

Throws an exception if there is no state with name s.

References _m_initialized, and _m_stateVec.

Referenced by MultiAgentDecisionProcessDiscrete::GetStateIndexByName().

std::string MADPComponentDiscreteStates::GetStateName ( Index  i) const
inline

Returns the name of a particular state i.

Referenced by MultiAgentDecisionProcessDiscrete::SanityCheck(), and SoftPrintState().

void MADPComponentDiscreteStates::Print ( ) const
inline

References SoftPrint().

Index MADPComponentDiscreteStates::SampleInitialState ( ) const

Sample a state according to the initial state PDF.

References _m_initialized, and _m_initialStateDistribution.

Referenced by MultiAgentDecisionProcessDiscrete::SampleInitialState().

bool MADPComponentDiscreteStates::SetInitialized ( bool  b)

Sets _m_initialized to b.

If no initial state distribution had been set, this function will call SetUniformISD(). (To accomodate .pomdp files where specification of ISD is optional.)

References _m_initialized, _m_initialStateDistribution, _m_nrStates, Globals::PROB_PRECISION, and SetUniformISD().

Referenced by MultiAgentDecisionProcessDiscrete::SetInitialized(), and MultiAgentDecisionProcessDiscrete::SetStatesInitialized().

void MADPComponentDiscreteStates::SetISD ( StateDistribution p)

Sets the initial state distribution to v.

Referenced by MultiAgentDecisionProcessDiscrete::SetISD().

void MADPComponentDiscreteStates::SetISD ( StateDistributionVector p)
inline
void MADPComponentDiscreteStates::SetISD ( std::vector< double >  v)
void MADPComponentDiscreteStates::SetNrStates ( size_t  nrS)
void MADPComponentDiscreteStates::SetUniformISD ( )

Sets the initial state distribution to a uniform one.

References _m_initialized, _m_initialStateDistribution, and GetNrStates().

Referenced by SetInitialized(), and MultiAgentDecisionProcessDiscrete::SetUniformISD().

string MADPComponentDiscreteStates::SoftPrint ( ) const
string MADPComponentDiscreteStates::SoftPrintInitialStateDistribution ( ) const
private

Returns a string with the initial state distribution.

References _m_initialized, _m_initialStateDistribution, and StateDistributionVector::SoftPrint().

Referenced by SoftPrint().

virtual std::string MADPComponentDiscreteStates::SoftPrintState ( Index  sI) const
inlinevirtual
string MADPComponentDiscreteStates::SoftPrintStates ( ) const
private

Returns a string with the states.

References _m_stateVec.

Referenced by SoftPrint().

Member Data Documentation

size_t MADPComponentDiscreteStates::_m_nrStates
private
std::vector<StateDiscrete> MADPComponentDiscreteStates::_m_stateVec
private

A vector that contains all the states.

Referenced by AddState(), GetStateIndexByName(), MADPComponentDiscreteStates(), SetNrStates(), and SoftPrintStates().