MultiAgentDecisionProcess
|
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 Scope & | GetAllStateFactorScope () const |
virtual const FactoredStateDistribution * | GetFactoredISD () const |
virtual FactoredStateDistribution * | GetFactoredISD () |
double | GetInitialStateProbability (Index sI) const |
virtual StateDistribution * | GetISD () 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 State * | GetState (Index i) const |
Returns a pointer to state i. More... | |
const StateFactorDiscrete * | GetStateFactorDiscrete (Index sfacI) const |
MADPComponentFactoredStates () | |
(default) Constructor More... | |
MADPComponentFactoredStates (const MADPComponentFactoredStates &a) | |
Copy constructor. More... | |
MADPComponentFactoredStates & | operator= (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< Index > | StateIndexToFactorValueIndices (Index stateI) const |
convert a state index to the std::vector of factor value indices. More... | |
std::vector< Index > | StateIndexToFactorValueIndices (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... | |
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.
MADPComponentFactoredStates::MADPComponentFactoredStates | ( | ) |
(default) Constructor
References _m_jointStatesMap.
MADPComponentFactoredStates::MADPComponentFactoredStates | ( | const MADPComponentFactoredStates & | a | ) |
Copy constructor.
|
virtual |
Destructor.
References _m_initialStateDistribution, _m_jointStatesMap, _m_stateFactors, and _m_stepSize.
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().
|
private |
Assure that this is inititialed. (throw E otherwise)
References _m_initialized.
Referenced by GetInitialStateProbability(), SetUniformISD(), SoftPrint(), SoftPrintInitialStateDistribution(), and SoftPrintStates().
|
inline |
convert std::vector of (indices of) factor values to (flat) state index.
References IndexTools::IndividualToJointIndicesStepSize().
Referenced by MultiAgentDecisionProcessDiscreteFactoredStates::FactorValueIndicesToStateIndex(), and SampleInitialState().
|
inline |
References _m_allStateFactorScope.
Referenced by MultiAgentDecisionProcessDiscreteFactoredStates::GetAllStateFactorScope().
|
inlinevirtual |
References _m_initialStateDistribution.
Referenced by MultiAgentDecisionProcessDiscreteFactoredStates::GetFactoredISD().
|
inlinevirtual |
References _m_initialStateDistribution.
double MADPComponentFactoredStates::GetInitialStateProbability | ( | Index | sI | ) | const |
|
inlinevirtual |
References _m_initialStateDistribution.
Referenced by MultiAgentDecisionProcessDiscreteFactoredStates::GetISD().
|
inline |
return the number of state factors
References _m_nrStateFactors.
Referenced by FSDist_COF::FSDist_COF(), and MultiAgentDecisionProcessDiscreteFactoredStates::GetNrStateFactors().
|
inline |
Return the number of states.
References _m_nrStates.
Referenced by MultiAgentDecisionProcessDiscreteFactoredStates::GetNrStates(), and SoftPrint().
|
inline |
return the std::vector with the number of values per factor
Referenced by FSDist_COF::FSDist_COF(), and MultiAgentDecisionProcessDiscreteFactoredStates::GetNrValuesForFactor().
|
inline |
return the std::vector with the number of values per factor
References _m_sfacDomainSizes.
Referenced by MultiAgentDecisionProcessDiscreteFactoredStates::GetNrValuesPerFactor().
Returns a pointer to state i.
This function is defined in MultiAgentDecisionProcessDiscreteInterface. We cache any requests made on the fly.
References _m_jointStatesMap, _m_nrStateFactors, GetStateFactorDiscrete(), StateFactorDiscrete::GetStateFactorValue(), NamedDescribedEntity::SetDescription(), NamedDescribedEntity::SetName(), and StateIndexToFactorValueIndices().
Referenced by MultiAgentDecisionProcessDiscreteFactoredStates::GetState().
|
inline |
Referenced by GetState(), and MultiAgentDecisionProcessDiscreteFactoredStates::GetStateFactorDiscrete().
MADPComponentFactoredStates & MADPComponentFactoredStates::operator= | ( | const MADPComponentFactoredStates & | o | ) |
Copy assignment operator.
void MADPComponentFactoredStates::PrintDebugStuff | ( | ) | const |
References _m_initialized, _m_nrStateFactors, _m_nrStates, _m_sfacDomainSizes, and PrintTools::SoftPrintVector().
Referenced by SetInitialized(), and SetUniformISD().
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 |
References _m_initialized, and FactorValueIndicesToStateIndex().
Referenced by MultiAgentDecisionProcessDiscreteFactoredStates::SampleInitialState().
void MADPComponentFactoredStates::SampleInitialState | ( | std::vector< Index > & | sIs | ) | const |
References _m_initialStateDistribution, and FactoredStateDistribution::SampleState().
bool MADPComponentFactoredStates::SetInitialized | ( | bool | b | ) |
Initializes the states space.
Should be called when all factors are added.
From _m_stateFactors, this function initializes all the other member variables.
References _m_initialized, _m_initialStateDistribution, _m_nrStateFactors, _m_nrStates, _m_sfacDomainSizes, _m_stepSize, IndexTools::CalculateStepSize(), and PrintDebugStuff().
Referenced by MultiAgentDecisionProcessDiscreteFactoredStates::RemoveStateFactor(), MultiAgentDecisionProcessDiscreteFactoredStates::SetInitialized(), and MultiAgentDecisionProcessDiscreteFactoredStates::SetStatesInitialized().
|
inline |
Referenced by MultiAgentDecisionProcessDiscreteFactoredStates::SetISD().
void MADPComponentFactoredStates::SetUniformISD | ( | ) |
Sets the initial state distribution to a uniform one.
References _m_initialStateDistribution, AssureInitialized(), PrintDebugStuff(), and FactoredStateDistribution::SetUniform().
Referenced by MultiAgentDecisionProcessDiscreteFactoredStates::SetUniformISD().
string MADPComponentFactoredStates::SoftPrint | ( | ) | const |
SoftPrints the factored state space and ISD.
References AssureInitialized(), GetNrStates(), SoftPrintInitialStateDistribution(), and SoftPrintStates().
Referenced by ProblemFOBSFireFightingFactored::InitializePFFF(), ProblemFireFightingFactored::InitializePFFF(), and MultiAgentDecisionProcessDiscreteFactoredStates::SoftPrint().
string MADPComponentFactoredStates::SoftPrintInitialStateDistribution | ( | ) | const |
SoftPrints the ISD.
References _m_initialStateDistribution, AssureInitialized(), and FactoredStateDistribution::SoftPrint().
Referenced by SoftPrint().
string MADPComponentFactoredStates::SoftPrintState | ( | Index | sI | ) | const |
SoftPrints a particular state.
References PrintTools::SoftPrintVector(), and StateIndexToFactorValueIndices().
Referenced by MultiAgentDecisionProcessDiscreteFactoredStates::SoftPrintState().
string MADPComponentFactoredStates::SoftPrintStates | ( | ) | const |
SoftPrints the factored state space.
References _m_nrStateFactors, _m_stateFactors, and AssureInitialized().
Referenced by SoftPrint().
returns the index of the value of factor fI
References StateIndexToFactorValueIndices().
Referenced by MultiAgentDecisionProcessDiscreteFactoredStates::StateIndexToFactorValueIndex().
|
inline |
convert a state index to the std::vector of factor value indices.
References IndexTools::JointToIndividualIndicesStepSize().
Referenced by GetInitialStateProbability(), GetState(), SoftPrintState(), StateIndexToFactorValueIndex(), and MultiAgentDecisionProcessDiscreteFactoredStates::StateIndexToFactorValueIndices().
|
private |
Referenced by AddStateFactor(), GetAllStateFactorScope(), and RemoveStateFactor().
|
private |
Is the state space initialized? (is it completely specified?)
Referenced by AddStateFactor(), AssureInitialized(), PrintDebugStuff(), SampleInitialState(), and SetInitialized().
|
private |
Referenced by GetState(), MADPComponentFactoredStates(), and ~MADPComponentFactoredStates().
|
private |
The number of state factors.
Referenced by AddStateFactor(), GetNrStateFactors(), GetState(), PrintDebugStuff(), RemoveStateFactor(), SetInitialized(), and SoftPrintStates().
|
private |
Var that keeps track of the nr. of 'flat' states.
Referenced by GetNrStates(), PrintDebugStuff(), and SetInitialized().
|
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().
|
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().
|
private |
Array caching the stepsize - used for computing indices.
Computed during initialization.
Referenced by SetInitialized(), and ~MADPComponentFactoredStates().