MultiAgentDecisionProcess
Release 0.2.1
|
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. | |
Index | ActionObservation_to_ActionIndex (Index aoI, size_t nrA, size_t nrO) |
Convert (joint) ActionObservation indices to (joint) Action indices. | |
Index | ActionObservation_to_ObservationIndex (Index aoI, size_t nrA, size_t nrO) |
Convert (joint) ActionObservation indices to (joint) Observation indices. | |
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. | |
size_t * | CalculateStepSize (const std::vector< size_t > &nrElems) |
Calculates the step size array for nrElems. | |
size_t * | CalculateStepSize (const std::vector< size_t > &nrElems, size_t n) |
Calculates the step size array from the first n entries of nrElems. | |
LIndex * | CalculateStepSize (const std::vector< LIndex > &nrElems) |
LIndex equivalent function. | |
bool | Increment (Index &index, size_t nrElems) |
Increments index which ranges over nrElems. | |
bool | Increment (std::vector< Index > &indexVec, const std::vector< size_t > &nrElems) |
Increments vector of indices that range over nrElems. | |
bool | Increment (LIndex &index, LIndex &nrElems) |
LIndex equivalent function. | |
bool | Increment (std::vector< LIndex > &indexVec, std::vector< LIndex > &nrElems) |
LIndex equivalent function. | |
Index | IndividualToJointIndices (const std::vector< Index > &indices, const std::vector< size_t > &nrElems) |
Convert individual to joint indices. | |
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. | |
LIndex | IndividualToJointIndices (const std::vector< LIndex > &indices, const std::vector< LIndex > &nrElems) |
LIndex equivalent function. | |
Index | IndividualToJointIndicesArray (const Index *indices, const std::vector< size_t > &nrElems) |
A variant that takes an array instead of a vector for extra speed. | |
LIndex | IndividualToJointIndicesArray (LIndex *indices, const std::vector< LIndex > &nrElems) |
LIndex equivalent function. | |
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. | |
Index | IndividualToJointIndicesArrayStepSize (const Index *indices, const std::vector< size_t > &step_size, size_t vec_size) |
A variant with a step_size vector. | |
LIndex | IndividualToJointIndicesArrayStepSize (LIndex *indices, const LIndex *step_size, LIndex vec_size) |
LIndex equivalent function. | |
LIndex | IndividualToJointIndicesArrayStepSize (LIndex *indices, const std::vector< LIndex > &step_size, LIndex vec_size) |
LIndex equivalent function. | |
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. | |
Index | IndividualToJointIndicesStepSize (const std::vector< Index > &indices, const size_t *step_size) |
A variant that takes a cached step_size array for extra speed. | |
LIndex | IndividualToJointIndicesStepSize (const std::vector< LIndex > &indices, const std::vector< LIndex > &step_size) |
LIndex equivalent function. | |
LIndex | IndividualToJointIndicesStepSize (const std::vector< LIndex > &indices, const LIndex *step_size) |
LIndex equivalent function. | |
std::vector< Index > | JointToIndividualIndices (Index jointI, const std::vector< size_t > &nrElems) |
The reverse of IndividualToJointIndices. | |
std::vector< LIndex > | JointToIndividualIndices (LIndex jointI, const std::vector< LIndex > &nrElems) |
LIndex equivalent function. | |
const Index * | JointToIndividualIndicesArrayStepSize (Index jointI, const size_t *stepSize, size_t vec_size) |
The reverse of IndividualToJointIndices - taking the stepSize array as an argument and returning a pointer to a array. | |
const LIndex * | JointToIndividualIndicesArrayStepSize (LIndex jointI, const LIndex *stepSize, LIndex vec_size) |
LIndex equivalent function. | |
std::vector< Index > | JointToIndividualIndicesStepSize (Index jointI, const size_t *stepSize, size_t vec_size) |
The reverse of IndividualToJointIndices - taking the stepSize array as an argument. | |
std::vector< Index > | JointToIndividualIndicesStepSize (Index jointI, const std::vector< size_t > &stepSize, size_t vec_size) |
The reverse of IndividualToJointIndices - taking the stepSize array as an argument. | |
std::vector< Index > | JointToIndividualIndicesStepSize (Index jointI, const std::vector< size_t > &stepSize) |
std::vector< LIndex > | JointToIndividualIndicesStepSize (LIndex jointI, const LIndex *stepSize, LIndex vec_size) |
LIndex equivalent function. | |
std::vector< LIndex > | JointToIndividualIndicesStepSize (LIndex jointI, const std::vector< LIndex > &stepSize, LIndex vec_size) |
LIndex equivalent function. | |
std::vector< LIndex > | JointToIndividualIndicesStepSize (LIndex jointI, const std::vector< LIndex > &stepSize) |
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 .
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.
Definition at line 559 of file IndexTools.cpp.
Referenced by PlanningUnitMADPDiscrete::GetActionObservationHistoryIndex(), PlanningUnitMADPDiscrete::GetJointActionObservationHistoryIndex(), and JointActionObservationHistory::SoftPrintJointIndices().
Index IndexTools::ActionObservation_to_ActionIndex | ( | Index | aoI, |
size_t | nrA, | ||
size_t | nrO | ||
) |
Convert (joint) ActionObservation indices to (joint) Action indices.
Definition at line 565 of file IndexTools.cpp.
Referenced by PlanningUnitMADPDiscrete::GetActionObservationHistoryArrays(), and PlanningUnitMADPDiscrete::GetJointActionObservationHistoryArrays().
Index IndexTools::ActionObservation_to_ObservationIndex | ( | Index | aoI, |
size_t | nrA, | ||
size_t | nrO | ||
) |
Convert (joint) ActionObservation indices to (joint) Observation indices.
Definition at line 570 of file IndexTools.cpp.
Referenced by PlanningUnitMADPDiscrete::GetActionObservationHistoryArrays(), and PlanningUnitMADPDiscrete::GetJointActionObservationHistoryArrays().
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). *
Definition at line 342 of file IndexTools.cpp.
Referenced by PlanningUnitMADPDiscrete::CreateActionHistoryTree(), and PlanningUnitMADPDiscrete::CreateObservationHistoryTree().
size_t * IndexTools::CalculateStepSize | ( | const std::vector< size_t > & | nrElems | ) |
Calculates the step size array for nrElems.
(so is of the same size as nrElems).
Definition at line 286 of file IndexTools.cpp.
Referenced by BayesianGameBase::BayesianGameBase(), IndividualBeliefJESP::IndividualBeliefJESP(), IndividualToJointIndices(), IndividualToJointIndicesArray(), JointToIndividualIndices(), MADPComponentDiscreteObservations::SetInitialized(), MADPComponentDiscreteActions::SetInitialized(), and TransitionObservationIndependentMADPDiscrete::SetInitialized().
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).
Definition at line 314 of file IndexTools.cpp.
LIndex * IndexTools::CalculateStepSize | ( | const std::vector< LIndex > & | nrElems | ) |
LIndex equivalent function.
Definition at line 530 of file IndexTools.cpp.
bool IndexTools::Increment | ( | Index & | index, |
size_t | nrElems | ||
) |
Increments index which ranges over nrElems.
Definition at line 32 of file IndexTools.cpp.
Referenced by TransitionObservationIndependentMADPDiscrete::CreateJointStates(), TOICompactRewardDecPOMDPDiscrete::GetReward(), and Increment().
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 >
Stating with this example, Incrementing < 1, 3, 1> will yield < 1, 4, 0>
returns a bool indicating carryover signal (true = on)
Definition at line 52 of file IndexTools.cpp.
References Increment().
bool IndexTools::Increment | ( | LIndex & | index, |
LIndex & | nrElems | ||
) |
LIndex equivalent function.
Definition at line 364 of file IndexTools.cpp.
bool IndexTools::Increment | ( | std::vector< LIndex > & | indexVec, |
std::vector< LIndex > & | nrElems | ||
) |
Index IndexTools::IndividualToJointIndices | ( | const std::vector< Index > & | indices, |
const std::vector< size_t > & | nrElems | ||
) |
Convert individual to joint indices.
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).
Definition at line 96 of file IndexTools.cpp.
References CalculateStepSize().
Referenced by ProblemFireFighting::FillTransitionModel(), PolicyPureVector::GetIndex(), JPolComponent_VectorImplementation::GetIndex(), TOICompactRewardDecPOMDPDiscrete::GetTwoAgentReward(), TransitionObservationIndependentMADPDiscrete::IndividualToJointActionIndices(), TransitionObservationIndependentMADPDiscrete::IndividualToJointObservationIndices(), and TransitionObservationIndependentMADPDiscrete::IndividualToJointStateIndices().
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).
Definition at line 122 of file IndexTools.cpp.
References CalculateStepSize().
LIndex IndexTools::IndividualToJointIndices | ( | const std::vector< LIndex > & | indices, |
const std::vector< LIndex > & | nrElems | ||
) |
LIndex equivalent function.
Definition at line 402 of file IndexTools.cpp.
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.
Definition at line 139 of file IndexTools.cpp.
References CalculateStepSize().
Referenced by TransitionObservationIndependentMADPDiscrete::IndividualToJointActionIndices().
LIndex IndexTools::IndividualToJointIndicesArray | ( | LIndex * | indices, |
const std::vector< LIndex > & | nrElems | ||
) |
LIndex equivalent function.
Definition at line 417 of file IndexTools.cpp.
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.
Definition at line 176 of file IndexTools.cpp.
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.
Definition at line 186 of file IndexTools.cpp.
LIndex IndexTools::IndividualToJointIndicesArrayStepSize | ( | LIndex * | indices, |
const LIndex * | step_size, | ||
LIndex | vec_size | ||
) |
LIndex equivalent function.
Definition at line 454 of file IndexTools.cpp.
LIndex IndexTools::IndividualToJointIndicesArrayStepSize | ( | LIndex * | indices, |
const std::vector< LIndex > & | step_size, | ||
LIndex | vec_size | ||
) |
LIndex equivalent function.
Definition at line 463 of file IndexTools.cpp.
Index IndexTools::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.
Definition at line 153 of file IndexTools.cpp.
Referenced by IndividualBeliefJESP::GetAugmentedStateIndex(), MADPComponentDiscreteActions::IndividualToJointActionIndices(), BayesianGameBase::IndividualToJointActionIndices(), MADPComponentDiscreteObservations::IndividualToJointObservationIndices(), and BayesianGameBase::IndividualToJointTypeIndices().
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.
Definition at line 165 of file IndexTools.cpp.
LIndex IndexTools::IndividualToJointIndicesStepSize | ( | const std::vector< LIndex > & | indices, |
const std::vector< LIndex > & | step_size | ||
) |
LIndex equivalent function.
Definition at line 431 of file IndexTools.cpp.
LIndex IndexTools::IndividualToJointIndicesStepSize | ( | const std::vector< LIndex > & | indices, |
const LIndex * | step_size | ||
) |
LIndex equivalent function.
Definition at line 443 of file IndexTools.cpp.
vector< Index > IndexTools::JointToIndividualIndices | ( | Index | jointI, |
const std::vector< size_t > & | nrElems | ||
) |
The reverse of IndividualToJointIndices.
Definition at line 197 of file IndexTools.cpp.
References CalculateStepSize().
Referenced by ProblemFireFighting::FillTransitionModel(), TransitionObservationIndependentMADPDiscrete::GetJointActionDiscrete(), TransitionObservationIndependentMADPDiscrete::GetJointObservation(), ProblemFireFighting::GetStateVector(), MADPComponentDiscreteActions::JointToIndividualActionIndices(), TransitionObservationIndependentMADPDiscrete::JointToIndividualActionIndicesNoCache(), MADPComponentDiscreteObservations::JointToIndividualObservationIndices(), TransitionObservationIndependentMADPDiscrete::JointToIndividualObservationIndicesNoCache(), TransitionObservationIndependentMADPDiscrete::JointToIndividualStateIndices(), BayesianGameBase::JointToIndividualTypeIndices(), PolicyPureVector::SetIndex(), JPolComponent_VectorImplementation::SetIndex(), and IndividualBeliefJESP::Update().
vector< LIndex > IndexTools::JointToIndividualIndices | ( | LIndex | jointI, |
const std::vector< LIndex > & | nrElems | ||
) |
LIndex equivalent function.
Definition at line 471 of file IndexTools.cpp.
References CalculateStepSize().
const Index * IndexTools::JointToIndividualIndicesArrayStepSize | ( | Index | jointI, |
const size_t * | stepSize, | ||
size_t | vec_size | ||
) |
The reverse of IndividualToJointIndices - 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.
Definition at line 271 of file IndexTools.cpp.
const LIndex* IndexTools::JointToIndividualIndicesArrayStepSize | ( | LIndex | jointI, |
const LIndex * | stepSize, | ||
LIndex | vec_size | ||
) |
LIndex equivalent function.
vector< Index > IndexTools::JointToIndividualIndicesStepSize | ( | Index | jointI, |
const size_t * | stepSize, | ||
size_t | vec_size | ||
) |
The reverse of IndividualToJointIndices - taking the stepSize array as an argument.
Definition at line 225 of file IndexTools.cpp.
Referenced by IndividualBeliefJESP::GetOthersObservationHistIndex(), IndividualBeliefJESP::GetStateIndex(), BayesianGameBase::JointToIndividualActionIndices(), and JointToIndividualIndicesStepSize().
vector< Index > IndexTools::JointToIndividualIndicesStepSize | ( | Index | jointI, |
const std::vector< size_t > & | stepSize, | ||
size_t | vec_size | ||
) |
The reverse of IndividualToJointIndices - taking the stepSize array as an argument.
Definition at line 242 of file IndexTools.cpp.
std::vector< Index > IndexTools::JointToIndividualIndicesStepSize | ( | Index | jointI, |
const std::vector< size_t > & | stepSize | ||
) |
Definition at line 261 of file IndexTools.cpp.
References JointToIndividualIndicesStepSize().
vector< LIndex > IndexTools::JointToIndividualIndicesStepSize | ( | LIndex | jointI, |
const LIndex * | stepSize, | ||
LIndex | vec_size | ||
) |
LIndex equivalent function.
Definition at line 491 of file IndexTools.cpp.
vector< LIndex > IndexTools::JointToIndividualIndicesStepSize | ( | LIndex | jointI, |
const std::vector< LIndex > & | stepSize, | ||
LIndex | vec_size | ||
) |
LIndex equivalent function.
Definition at line 507 of file IndexTools.cpp.
std::vector< LIndex > IndexTools::JointToIndividualIndicesStepSize | ( | LIndex | jointI, |
const std::vector< LIndex > & | stepSize | ||
) |
Definition at line 524 of file IndexTools.cpp.
References JointToIndividualIndicesStepSize().