MultiAgentDecisionProcess
MADPComponentFactoredStates Class Reference

MADPComponentFactoredStates is a class that represents a factored states space. More...

#include <MADPComponentFactoredStates.h>

Public Member Functions

Index AddStateFactor (const std::string &n="undef. name", const std::string &d="undef. descr.")
 Adds a factor to the statespace. More...
 
Index AddStateFactorValue (Index sf, const std::string &v="undef")
 Adds a state factor value to the sf -th state factor. More...
 
Index FactorValueIndicesToStateIndex (const std::vector< Index > &fv) const
 convert std::vector of (indices of) factor values to (flat) state index. More...
 
Index FactorValueIndicesToStateIndex (const std::vector< Index > &s_e_vec, const Scope &sfSC) const
 
const ScopeGetAllStateFactorScope () const
 
virtual const
FactoredStateDistribution
GetFactoredISD () const
 
virtual FactoredStateDistributionGetFactoredISD ()
 
double GetInitialStateProbability (Index sI) const
 
virtual StateDistributionGetISD () const
 
size_t GetNrStateFactors () const
 return the number of state factors More...
 
size_t GetNrStates () const
 Return the number of states. More...
 
const size_t GetNrValuesForFactor (Index sf) const
 return the std::vector with the number of values per factor More...
 
const std::vector< size_t > & GetNrValuesPerFactor () const
 return the std::vector with the number of values per factor More...
 
const StateGetState (Index i) const
 Returns a pointer to state i. More...
 
const StateFactorDiscreteGetStateFactorDiscrete (Index sfacI) const
 
 MADPComponentFactoredStates ()
 (default) Constructor More...
 
 MADPComponentFactoredStates (const MADPComponentFactoredStates &a)
 Copy constructor. More...
 
MADPComponentFactoredStatesoperator= (const MADPComponentFactoredStates &o)
 Copy assignment operator. More...
 
void PrintDebugStuff () const
 
void RemoveStateFactor (Index sf)
 Removes state factor sf from the problem description, and fixes indices accordingly. More...
 
Index SampleInitialState () const
 
void SampleInitialState (std::vector< Index > &sIs) const
 
bool SetInitialized (bool b)
 Initializes the states space. More...
 
void SetISD (FactoredStateDistribution *p)
 
void SetUniformISD ()
 Sets the initial state distribution to a uniform one. More...
 
std::string SoftPrint () const
 SoftPrints the factored state space and ISD. More...
 
std::string SoftPrintInitialStateDistribution () const
 SoftPrints the ISD. More...
 
std::string SoftPrintPartialState (const Scope &sfSc, const std::vector< Index > &sfValues) const
 
std::string SoftPrintState (Index sI) const
 SoftPrints a particular state. More...
 
std::string SoftPrintStates () const
 SoftPrints the factored state space. More...
 
Index StateIndexToFactorValueIndex (Index fI, Index s) const
 returns the index of the value of factor fI More...
 
std::vector< IndexStateIndexToFactorValueIndices (Index stateI) const
 convert a state index to the std::vector of factor value indices. More...
 
std::vector< IndexStateIndexToFactorValueIndices (Index s_e, const Scope &sfSC) const
 
virtual ~MADPComponentFactoredStates ()
 Destructor. More...
 

Private Member Functions

void AssureInitialized (std::string caller="unspecified caller") const
 Assure that this is inititialed. (throw E otherwise) More...
 

Private Attributes

Scope _m_allStateFactorScope
 
bool _m_initialized
 Is the state space initialized? (is it completely specified?) More...
 
FactoredStateDistribution_m_initialStateDistribution
 
std::map< std::vector< Index >
, State * > * 
_m_jointStatesMap
 
size_t _m_nrStateFactors
 The number of state factors. More...
 
size_t _m_nrStates
 Var that keeps track of the nr. of 'flat' states. More...
 
std::vector< size_t > _m_sfacDomainSizes
 Vector with size of the domain of each state factor (the nr. values) More...
 
std::vector
< StateFactorDiscrete * > 
_m_stateFactors
 A std::vector with a pointers to the different state factors. More...
 
size_t * _m_stepSize
 Array caching the stepsize - used for computing indices. More...
 

Detailed Description

MADPComponentFactoredStates is a class that represents a factored states space.

It implements part of the MultiAgentDecisionProcessDiscreteInterface (at the moment it implements the same part as MADPComponentDiscreteStates, although this class offers more functions. Eventually a MultiAgentDecisionProcessFactoredStatesInterface might be made.)

A factored state is one that is defined as an assignment to a set of state variables, or factors. A factored state space is defined as the cross-product of the set of state factors. This is in contrast to a 'flat' state space that explicitly enumarates all possible states.

Constructor & Destructor Documentation

MADPComponentFactoredStates::MADPComponentFactoredStates ( )

(default) Constructor

References _m_jointStatesMap.

MADPComponentFactoredStates::MADPComponentFactoredStates ( const MADPComponentFactoredStates a)

Copy constructor.

MADPComponentFactoredStates::~MADPComponentFactoredStates ( )
virtual

Member Function Documentation

Index MADPComponentFactoredStates::AddStateFactor ( const std::string &  n = "undef. name",
const std::string &  d = "undef. descr." 
)

Adds a factor to the statespace.

Can only be used when not this is initialized yet. returns the index of the state factor.

References _m_allStateFactorScope, _m_initialized, _m_nrStateFactors, _m_sfacDomainSizes, _m_stateFactors, and Scope::Insert().

Referenced by MultiAgentDecisionProcessDiscreteFactoredStates::AddStateFactor().

Index MADPComponentFactoredStates::AddStateFactorValue ( Index  sf,
const std::string &  v = "undef" 
)

Adds a state factor value to the sf -th state factor.

Can only be used when not this is initialized yet. returns the index of the state factor value. *

References _m_sfacDomainSizes, and _m_stateFactors.

Referenced by MultiAgentDecisionProcessDiscreteFactoredStates::AddStateFactorValue().

void MADPComponentFactoredStates::AssureInitialized ( std::string  caller = "unspecified caller") const
private

Assure that this is inititialed. (throw E otherwise)

References _m_initialized.

Referenced by GetInitialStateProbability(), SetUniformISD(), SoftPrint(), SoftPrintInitialStateDistribution(), and SoftPrintStates().

Index MADPComponentFactoredStates::FactorValueIndicesToStateIndex ( const std::vector< Index > &  fv) const
inline

convert std::vector of (indices of) factor values to (flat) state index.

References IndexTools::IndividualToJointIndicesStepSize().

Referenced by MultiAgentDecisionProcessDiscreteFactoredStates::FactorValueIndicesToStateIndex(), and SampleInitialState().

Index MADPComponentFactoredStates::FactorValueIndicesToStateIndex ( const std::vector< Index > &  s_e_vec,
const Scope sfSC 
) const
const Scope& MADPComponentFactoredStates::GetAllStateFactorScope ( ) const
inline
virtual const FactoredStateDistribution* MADPComponentFactoredStates::GetFactoredISD ( ) const
inlinevirtual
virtual FactoredStateDistribution* MADPComponentFactoredStates::GetFactoredISD ( )
inlinevirtual
virtual StateDistribution* MADPComponentFactoredStates::GetISD ( ) const
inlinevirtual
size_t MADPComponentFactoredStates::GetNrStateFactors ( ) const
inline
size_t MADPComponentFactoredStates::GetNrStates ( ) const
inline

Return the number of states.

References _m_nrStates.

Referenced by MultiAgentDecisionProcessDiscreteFactoredStates::GetNrStates(), and SoftPrint().

const size_t MADPComponentFactoredStates::GetNrValuesForFactor ( Index  sf) const
inline

return the std::vector with the number of values per factor

Referenced by FSDist_COF::FSDist_COF(), and MultiAgentDecisionProcessDiscreteFactoredStates::GetNrValuesForFactor().

const std::vector< size_t >& MADPComponentFactoredStates::GetNrValuesPerFactor ( ) const
inline

return the std::vector with the number of values per factor

References _m_sfacDomainSizes.

Referenced by MultiAgentDecisionProcessDiscreteFactoredStates::GetNrValuesPerFactor().

const StateFactorDiscrete* MADPComponentFactoredStates::GetStateFactorDiscrete ( Index  sfacI) const
inline
MADPComponentFactoredStates & MADPComponentFactoredStates::operator= ( const MADPComponentFactoredStates o)

Copy assignment operator.

void MADPComponentFactoredStates::PrintDebugStuff ( ) const
void MADPComponentFactoredStates::RemoveStateFactor ( Index  sf)

Removes state factor sf from the problem description, and fixes indices accordingly.

References _m_allStateFactorScope, _m_nrStateFactors, _m_sfacDomainSizes, _m_stateFactors, and Scope::Remove().

Referenced by MultiAgentDecisionProcessDiscreteFactoredStates::RemoveStateFactor().

Index MADPComponentFactoredStates::SampleInitialState ( ) const
void MADPComponentFactoredStates::SampleInitialState ( std::vector< Index > &  sIs) const
bool MADPComponentFactoredStates::SetInitialized ( bool  b)
void MADPComponentFactoredStates::SetISD ( FactoredStateDistribution p)
inline
void MADPComponentFactoredStates::SetUniformISD ( )
string MADPComponentFactoredStates::SoftPrintInitialStateDistribution ( ) const
string MADPComponentFactoredStates::SoftPrintPartialState ( const Scope sfSc,
const std::vector< Index > &  sfValues 
) const
string MADPComponentFactoredStates::SoftPrintState ( Index  sI) const
string MADPComponentFactoredStates::SoftPrintStates ( ) const

SoftPrints the factored state space.

References _m_nrStateFactors, _m_stateFactors, and AssureInitialized().

Referenced by SoftPrint().

Index MADPComponentFactoredStates::StateIndexToFactorValueIndex ( Index  fI,
Index  s 
) const
inline

returns the index of the value of factor fI

References StateIndexToFactorValueIndices().

Referenced by MultiAgentDecisionProcessDiscreteFactoredStates::StateIndexToFactorValueIndex().

std::vector<Index> MADPComponentFactoredStates::StateIndexToFactorValueIndices ( Index  stateI) const
inline
vector< Index > MADPComponentFactoredStates::StateIndexToFactorValueIndices ( Index  s_e,
const Scope sfSC 
) const

Member Data Documentation

Scope MADPComponentFactoredStates::_m_allStateFactorScope
private
bool MADPComponentFactoredStates::_m_initialized
private

Is the state space initialized? (is it completely specified?)

Referenced by AddStateFactor(), AssureInitialized(), PrintDebugStuff(), SampleInitialState(), and SetInitialized().

std::map<std::vector<Index>, State*>* MADPComponentFactoredStates::_m_jointStatesMap
private
size_t MADPComponentFactoredStates::_m_nrStateFactors
private
size_t MADPComponentFactoredStates::_m_nrStates
private

Var that keeps track of the nr. of 'flat' states.

Referenced by GetNrStates(), PrintDebugStuff(), and SetInitialized().

std::vector<size_t> MADPComponentFactoredStates::_m_sfacDomainSizes
private

Vector with size of the domain of each state factor (the nr. values)

This is used to compute state indices.

Referenced by AddStateFactor(), AddStateFactorValue(), FactorValueIndicesToStateIndex(), GetNrValuesPerFactor(), PrintDebugStuff(), RemoveStateFactor(), SetInitialized(), and StateIndexToFactorValueIndices().

std::vector<StateFactorDiscrete*> MADPComponentFactoredStates::_m_stateFactors
private

A std::vector with a pointers to the different state factors.

The state factors themself specify their name, description, (size of) their domain, etc.

Referenced by AddStateFactor(), AddStateFactorValue(), RemoveStateFactor(), SoftPrintPartialState(), SoftPrintStates(), and ~MADPComponentFactoredStates().

size_t* MADPComponentFactoredStates::_m_stepSize
private

Array caching the stepsize - used for computing indices.

Computed during initialization.

Referenced by SetInitialized(), and ~MADPComponentFactoredStates().