MultiAgentDecisionProcess
IndexTools Namespace Reference

IndexTools contains functionality for manipulating indices. More...

Functions

Index ActionAndObservation_to_ActionObservationIndex (Index aI, Index oI, size_t nrA, size_t nrO)
 Computation of a index for (joint) actionObservations. More...
 
Index ActionObservation_to_ActionIndex (Index aoI, size_t nrA, size_t nrO)
 Convert (joint) ActionObservation indices to (joint) Action indices. More...
 
Index ActionObservation_to_ObservationIndex (Index aoI, size_t nrA, size_t nrO)
 Convert (joint) ActionObservation indices to (joint) Observation indices. More...
 
size_t CalculateNumberOfSequences (size_t o, size_t seqLength)
 Calculate the number of sequences of length up to seqLength, for which at every time step o options are available. More...
 
size_t * CalculateStepSize (const std::vector< size_t > &nrElems)
 Calculates the step size array for nrElems. More...
 
size_t * CalculateStepSize (const std::vector< size_t > &nrElems, size_t n)
 Calculates the step size array from the first n entries of nrElems. More...
 
LIndexCalculateStepSize (const std::vector< LIndex > &nrElems)
 LIndex equivalent function. More...
 
std::vector< size_t > CalculateStepSizeVector (const std::vector< size_t > &nrElems)
 Calculates the step size vector for nrElems. More...
 
std::vector< LIndexCalculateStepSizeVector (const std::vector< LIndex > &nrElems)
 LIndex equivalent function. More...
 
bool Increment (Index &index, size_t nrElems)
 Increments index which ranges over nrElems. More...
 
bool Increment (std::vector< Index > &indexVec, const std::vector< size_t > &nrElems)
 Increments vector of indices that range over nrElems. More...
 
bool Increment (LIndex &index, LIndex nrElems)
 LIndex equivalent function. More...
 
bool Increment (std::vector< LIndex > &indexVec, const std::vector< LIndex > &nrElems)
 LIndex equivalent function. More...
 
Index IndividualToJointIndices (const std::vector< Index > &indices, const std::vector< size_t > &nrElems)
 Convert individual to joint indices. More...
 
Index IndividualToJointIndices (const std::vector< Index > &indices, const std::vector< size_t > &nrElems, size_t n)
 Convert individual to joint indices. Only uses first n entries of vecs. More...
 
LIndex IndividualToJointIndices (const std::vector< LIndex > &indices, const std::vector< LIndex > &nrElems)
 LIndex equivalent function. More...
 
Index IndividualToJointIndicesArray (const Index *indices, const std::vector< size_t > &nrElems)
 A variant that takes an array instead of a vector for extra speed. More...
 
LIndex IndividualToJointIndicesArray (LIndex *indices, const std::vector< LIndex > &nrElems)
 LIndex equivalent function. More...
 
Index IndividualToJointIndicesArrayStepSize (const Index *indices, const size_t *step_size, size_t vec_size)
 A variant that 1) takes an array instead of a vector and 2) takes a cached step_size array for extra speed. More...
 
Index IndividualToJointIndicesArrayStepSize (const Index *indices, const std::vector< size_t > &step_size, size_t vec_size)
 A variant with a step_size vector. More...
 
LIndex IndividualToJointIndicesArrayStepSize (LIndex *indices, const LIndex *step_size, size_t vec_size)
 LIndex equivalent function. More...
 
LIndex IndividualToJointIndicesArrayStepSize (LIndex *indices, const std::vector< LIndex > &step_size, size_t vec_size)
 LIndex equivalent function. More...
 
Index IndividualToJointIndicesStepSize (const std::vector< Index > &indices, const std::vector< size_t > &step_size)
 A variant that takes a cached step_size vector for extra speed. More...
 
Index IndividualToJointIndicesStepSize (const std::vector< Index > &indices, const size_t *step_size)
 A variant that takes a cached step_size array for extra speed. More...
 
LIndex IndividualToJointIndicesStepSize (const std::vector< LIndex > &indices, const std::vector< LIndex > &step_size)
 LIndex equivalent function. More...
 
LIndex IndividualToJointIndicesStepSize (const std::vector< LIndex > &indices, const LIndex *step_size)
 LIndex equivalent function. More...
 
std::vector< IndexJointToIndividualIndices (Index jointI, const std::vector< size_t > &nrElems)
 Convert individual to joint indices. More...
 
void JointToIndividualIndices (Index jointI, const std::vector< size_t > &nrElems, std::vector< Index > &result)
 Convert individual to joint indices. More...
 
std::vector< LIndexJointToIndividualIndices (LIndex jointI, const std::vector< LIndex > &nrElems)
 LIndex equivalent function. More...
 
const IndexJointToIndividualIndicesArrayStepSize (Index jointI, const size_t *stepSize, size_t vec_size)
 Convert individual to joint indices - taking the stepSize array as an argument and returning a pointer to a array. More...
 
const LIndexJointToIndividualIndicesArrayStepSize (LIndex jointI, const LIndex *stepSize, size_t vec_size)
 LIndex equivalent function. More...
 
std::vector< IndexJointToIndividualIndicesStepSize (Index jointI, const size_t *stepSize, size_t vec_size)
 Convert individual to joint indices - taking the stepSize array as an argument. More...
 
void JointToIndividualIndicesStepSize (Index jointI, const size_t *stepSize, size_t vec_size, std::vector< Index > &result)
 Convert individual to joint indices, taking the stepSize array as an argument. More...
 
std::vector< IndexJointToIndividualIndicesStepSize (Index jointI, const std::vector< size_t > &stepSize, size_t vec_size)
 Convert individual to joint indices - taking the stepSize array as an argument. More...
 
std::vector< IndexJointToIndividualIndicesStepSize (Index jointI, const std::vector< size_t > &stepSize)
 
std::vector< LIndexJointToIndividualIndicesStepSize (LIndex jointI, const LIndex *stepSize, size_t vec_size)
 LIndex equivalent function. More...
 
std::vector< LIndexJointToIndividualIndicesStepSize (LIndex jointI, const std::vector< LIndex > &stepSize, size_t vec_size)
 LIndex equivalent function. More...
 
std::vector< LIndexJointToIndividualIndicesStepSize (LIndex jointI, const std::vector< LIndex > &stepSize)
 
template<typename T >
void RestrictIndividualIndicesToNarrowerScope (const std::vector< T > &indivIndices, const Scope &old_sc, const Scope &new_sc, std::vector< T > &restrictedIndivIndices)
 Restricts a vector of indices with a current scope to a narrower scope. More...
 
template<typename T >
void RestrictIndividualIndicesToScope (const std::vector< T > &indivIndices, const Scope &sc, std::vector< T > &restrictedIndivIndices)
 Restrict a vector of indices to a scope. More...
 

Detailed Description

IndexTools contains functionality for manipulating indices.

A detailed description of how joint indices etc are constructed, see doc/manually_maintained/MADPToolbox-Histories+indices.ps.gz .

Function Documentation

Index IndexTools::ActionAndObservation_to_ActionObservationIndex ( Index  aI,
Index  oI,
size_t  nrA,
size_t  nrO 
)

Computation of a index for (joint) actionObservations.

ActionObservation indices (aoI's) are used as the basis for indexing (Joint)ActionObservationHistories. This function computes them.

See also
manually maintained documentation

Referenced by PlanningUnitMADPDiscrete::GetActionObservationHistoryIndex(), PlanningUnitMADPDiscrete::GetJointActionObservationHistoryIndex(), and JointActionObservationHistory::SoftPrintJointIndices().

Index IndexTools::ActionObservation_to_ActionIndex ( Index  aoI,
size_t  nrA,
size_t  nrO 
)
Index IndexTools::ActionObservation_to_ObservationIndex ( Index  aoI,
size_t  nrA,
size_t  nrO 
)
size_t IndexTools::CalculateNumberOfSequences ( size_t  o,
size_t  seqLength 
)

Calculate the number of sequences of length up to seqLength, for which at every time step o options are available.

Calculation includes 1 empty sequence (of length 0). *

Referenced by PlanningUnitMADPDiscrete::CreateActionHistoryTree(), and PlanningUnitMADPDiscrete::CreateObservationHistoryTree().

size_t * IndexTools::CalculateStepSize ( const std::vector< size_t > &  nrElems,
size_t  n 
)

Calculates the step size array from the first n entries of nrElems.

(so the array's size is n).

LIndex * IndexTools::CalculateStepSize ( const std::vector< LIndex > &  nrElems)

LIndex equivalent function.

std::vector< size_t > IndexTools::CalculateStepSizeVector ( const std::vector< size_t > &  nrElems)

Calculates the step size vector for nrElems.

(so is of the same size as nrElems).

Referenced by TransitionObservationIndependentMADPDiscrete::SetInitialized().

vector< LIndex > IndexTools::CalculateStepSizeVector ( const std::vector< LIndex > &  nrElems)

LIndex equivalent function.

bool IndexTools::Increment ( std::vector< Index > &  indexVec,
const std::vector< size_t > &  nrElems 
)

Increments vector of indices that range over nrElems.

takes 2 vectors of size vec_size: indexVec gives for each vector index(i) an element index( indexVec[i] ) e.g.

< 2, 4, 0 > nrElems gives for each vector index(i) the number of elements e.g. < 3, 5, 2 > Meaning that (in this example) the highest indexVec vector is < 2, 4, 1 >

Staying with this example, Incrementing < 1, 3, 1> will yield < 1, 4, 0>

returns a bool indicating carryover signal (true = on)

References Increment().

bool IndexTools::Increment ( LIndex index,
LIndex  nrElems 
)

LIndex equivalent function.

bool IndexTools::Increment ( std::vector< LIndex > &  indexVec,
const std::vector< LIndex > &  nrElems 
)

LIndex equivalent function.

References Increment().

Index IndexTools::IndividualToJointIndices ( const std::vector< Index > &  indices,
const std::vector< size_t > &  nrElems 
)
Index IndexTools::IndividualToJointIndices ( const std::vector< Index > &  indices,
const std::vector< size_t > &  nrElems,
size_t  n 
)

Convert individual to joint indices. Only uses first n entries of vecs.

Calculate the joint index from individual indices i each taken from sets with nrElems[i] elems (i.e., index i ranges from 0...nrElems[i]-1.

Note: this only works if all joint indices occur, so you can use this for joint actions, but not joint observation histories (this would assume there is a joint observation history index corresponding to indiv. observation histories of different lengths).

References CalculateStepSize().

LIndex IndexTools::IndividualToJointIndices ( const std::vector< LIndex > &  indices,
const std::vector< LIndex > &  nrElems 
)

LIndex equivalent function.

References CalculateStepSize().

Index IndexTools::IndividualToJointIndicesArray ( const Index indices,
const std::vector< size_t > &  nrElems 
)

A variant that takes an array instead of a vector for extra speed.

References CalculateStepSize().

Referenced by TransitionObservationIndependentMADPDiscrete::IndividualToJointActionIndices().

LIndex IndexTools::IndividualToJointIndicesArray ( LIndex indices,
const std::vector< LIndex > &  nrElems 
)

LIndex equivalent function.

References CalculateStepSize().

Index IndexTools::IndividualToJointIndicesArrayStepSize ( const Index indices,
const size_t *  step_size,
size_t  vec_size 
)

A variant that 1) takes an array instead of a vector and 2) takes a cached step_size array for extra speed.

Referenced by BayesianGameBase::IndividualToJointActionIndices(), MADPComponentDiscreteActions::IndividualToJointActionIndices(), and TransitionObservationIndependentMADPDiscrete::IndividualToJointActionIndices().

Index IndexTools::IndividualToJointIndicesArrayStepSize ( const Index indices,
const std::vector< size_t > &  step_size,
size_t  vec_size 
)

A variant with a step_size vector.

LIndex IndexTools::IndividualToJointIndicesArrayStepSize ( LIndex indices,
const LIndex step_size,
size_t  vec_size 
)

LIndex equivalent function.

LIndex IndexTools::IndividualToJointIndicesArrayStepSize ( LIndex indices,
const std::vector< LIndex > &  step_size,
size_t  vec_size 
)

LIndex equivalent function.

Index IndexTools::IndividualToJointIndicesStepSize ( const std::vector< Index > &  indices,
const size_t *  step_size 
)

A variant that takes a cached step_size array for extra speed.

LIndex IndexTools::IndividualToJointIndicesStepSize ( const std::vector< LIndex > &  indices,
const std::vector< LIndex > &  step_size 
)

LIndex equivalent function.

LIndex IndexTools::IndividualToJointIndicesStepSize ( const std::vector< LIndex > &  indices,
const LIndex step_size 
)

LIndex equivalent function.

void IndexTools::JointToIndividualIndices ( Index  jointI,
const std::vector< size_t > &  nrElems,
std::vector< Index > &  result 
)

Convert individual to joint indices.

References CalculateStepSize().

vector< LIndex > IndexTools::JointToIndividualIndices ( LIndex  jointI,
const std::vector< LIndex > &  nrElems 
)

LIndex equivalent function.

References CalculateStepSize().

const Index * IndexTools::JointToIndividualIndicesArrayStepSize ( Index  jointI,
const size_t *  stepSize,
size_t  vec_size 
)

Convert individual to joint indices - taking the stepSize array as an argument and returning a pointer to a array.

Note: the returned array is allocate with new, so it must be freed.

const LIndex* IndexTools::JointToIndividualIndicesArrayStepSize ( LIndex  jointI,
const LIndex stepSize,
size_t  vec_size 
)

LIndex equivalent function.

void IndexTools::JointToIndividualIndicesStepSize ( Index  jointI,
const size_t *  stepSize,
size_t  vec_size,
std::vector< Index > &  result 
)

Convert individual to joint indices, taking the stepSize array as an argument.

avoids return by value.

vector< Index > IndexTools::JointToIndividualIndicesStepSize ( Index  jointI,
const std::vector< size_t > &  stepSize,
size_t  vec_size 
)

Convert individual to joint indices - taking the stepSize array as an argument.

std::vector< Index > IndexTools::JointToIndividualIndicesStepSize ( Index  jointI,
const std::vector< size_t > &  stepSize 
)
vector< LIndex > IndexTools::JointToIndividualIndicesStepSize ( LIndex  jointI,
const LIndex stepSize,
size_t  vec_size 
)

LIndex equivalent function.

vector< LIndex > IndexTools::JointToIndividualIndicesStepSize ( LIndex  jointI,
const std::vector< LIndex > &  stepSize,
size_t  vec_size 
)

LIndex equivalent function.

std::vector< LIndex > IndexTools::JointToIndividualIndicesStepSize ( LIndex  jointI,
const std::vector< LIndex > &  stepSize 
)
template<typename T >
void IndexTools::RestrictIndividualIndicesToNarrowerScope ( const std::vector< T > &  indivIndices,
const Scope old_sc,
const Scope new_sc,
std::vector< T > &  restrictedIndivIndices 
)
template<typename T >
void IndexTools::RestrictIndividualIndicesToScope ( const std::vector< T > &  indivIndices,
const Scope sc,
std::vector< T > &  restrictedIndivIndices 
)

Restrict a vector of indices to a scope.

sc is a Scope (also a vector of indices), each index i in sc identifies an element of indivIndices: namely indivIndices[i]

this function changes the vector restrictedIndivIndices to contain < indivIndices[i] > for all i in scope

restrictedIndivIndices should already have the correct size: I.e., it should be at least at big as the number of elements in the scope. However, restrictedIndivIndices may be larger than the number of elements in the scope. In this case, the superfluous elements remain untouched. (this is actually used in some places to increase performance).

Referenced by GMAA_MAA_ELSI::CAVNP_quick_n_dirty2(), BayesianGameCollaborativeGraphical::ComputeValueJPol(), FactoredDecPOMDPDiscrete::ExportSpuddFile(), MADPComponentFactoredStates::FactorValueIndicesToStateIndex(), FSAOHDist_NECOF::FSAOHDist_NECOF(), BGCG_SolverNonserialDynamicProgramming::GetJpolIndexForBestResponses(), FactoredDecPOMDPDiscrete::GetLRFRewardFlat(), MADPComponentDiscreteActions::GetNrJointActions(), TransitionObservationIndependentMADPDiscrete::GetNrJointActions(), MultiAgentDecisionProcessDiscreteFactoredStates::GetNrStateFactorInstantiations(), TwoStageDynamicBayesianNetwork::GetOProbability(), FSAOHDist_NECOF::GetXOHProb_relT(), TwoStageDynamicBayesianNetwork::GetYProbability(), MADPComponentDiscreteActions::IndividualToJointActionIndices(), TransitionObservationIndependentMADPDiscrete::IndividualToJointActionIndices(), MADPComponentDiscreteObservations::IndividualToJointObservationIndices(), TwoStageDynamicBayesianNetwork::InitializeIIs(), FactoredDecPOMDPDiscrete::InitializeInstantiationInformation(), MADPComponentDiscreteActions::JointToIndividualActionIndices(), TransitionObservationIndependentMADPDiscrete::JointToIndividualActionIndices(), MADPComponentDiscreteObservations::JointToIndividualObservationIndices(), MADPComponentDiscreteActions::JointToRestrictedJointActionIndex(), TransitionObservationIndependentMADPDiscrete::JointToRestrictedJointActionIndex(), MADPComponentDiscreteObservations::JointToRestrictedJointObservationIndex(), BayesianGameCollaborativeGraphical::RestrictIndividualIndicesToScope(), TwoStageDynamicBayesianNetwork::SampleO(), TwoStageDynamicBayesianNetwork::SampleY(), MADPComponentFactoredStates::StateIndexToFactorValueIndices(), and FSAOHDist_NECOF::Update().