Each state is one sample generated by a sampling algorithm. More...
#include <SamplingState.h>
Each state is one sample generated by a sampling algorithm.
A SamplingState includes a vector holding the location of the state as well as a std::map of metadata. The metadata can include density evaluations and other information collected by the sampling algorithm.
Definition at line 31 of file SamplingState.h.
Public Member Functions | |
SamplingState ()=default | |
SamplingState (Eigen::VectorXd const &stateIn, double weight=1.0) | |
SamplingState (std::vector< Eigen::VectorXd > const &stateIn, double weight=1.0) | |
virtual | ~SamplingState ()=default |
bool | HasMeta (std::string const &metaKey) |
Checks to see if the meta map contains a particular key. More... | |
int | TotalDim () const |
The total number of parameters in the state, i.e., the sum of state[i].size() More... | |
Eigen::VectorXd | ToVector (int blockInd=-1) const |
double | StateValue (unsigned int totalInd) const |
double & | StateValue (unsigned int totalInd) |
template<class Archive > | |
void | serialize (Archive &archive) |
Serialization function for use with Cereal. More... | |
Public Attributes | |
std::vector< Eigen::VectorXd > | state |
The state variables. More... | |
double | weight |
The weight of this state. More... | |
std::unordered_map< std::string, boost::any > | meta |
A map containing extra information like the target density, run time, forward model output, etc... More... | |
|
default |
SamplingState::SamplingState | ( | Eigen::VectorXd const & | stateIn, |
double | weight = 1.0 |
||
) |
Definition at line 8 of file SamplingState.cpp.
SamplingState::SamplingState | ( | std::vector< Eigen::VectorXd > const & | stateIn, |
double | weight = 1.0 |
||
) |
Definition at line 9 of file SamplingState.cpp.
|
virtualdefault |
bool SamplingState::HasMeta | ( | std::string const & | metaKey | ) |
Checks to see if the meta map contains a particular key.
Definition at line 11 of file SamplingState.cpp.
References meta.
|
inline |
Serialization function for use with Cereal.
This function provides a way to serialize most of the SamplingState for use with Cereal and ParCer. Due to the intracacies of serializing the boost::any type, this function does not serialize the meta variable.
Definition at line 82 of file SamplingState.h.
double & SamplingState::StateValue | ( | unsigned int | totalInd | ) |
Definition at line 58 of file SamplingState.cpp.
References state.
double SamplingState::StateValue | ( | unsigned int | totalInd | ) | const |
Returns the state value given an index into concatenated state vector.
[in] | totalInd | Index into the concatenated state. Maximum value is TotalDim()-1. |
Definition at line 43 of file SamplingState.cpp.
References state.
int SamplingState::TotalDim | ( | ) | const |
The total number of parameters in the state, i.e., the sum of state[i].size()
Definition at line 16 of file SamplingState.cpp.
References state.
Referenced by muq::SamplingAlgorithms::SamplingStateIdentity::operator()(), muq::SamplingAlgorithms::SamplingStatePartialMoment::operator()(), and ToVector().
Eigen::VectorXd SamplingState::ToVector | ( | int | blockInd = -1 | ) | const |
If blockInd>=0, then this function simply returns the state vector at the specified block. Otherwise, this function concatenates all the blocks into a single Eigen::VectorXd.
Definition at line 24 of file SamplingState.cpp.
References state, and TotalDim().
std::unordered_map<std::string, boost::any> muq::SamplingAlgorithms::SamplingState::meta |
A map containing extra information like the target density, run time, forward model output, etc...
Definition at line 72 of file SamplingState.h.
Referenced by ExpectedValueInputs(), HasMeta(), and serialize().
std::vector<Eigen::VectorXd> muq::SamplingAlgorithms::SamplingState::state |
The state variables.
Definition at line 48 of file SamplingState.h.
Referenced by ExpectedValueInputs(), muq::SamplingAlgorithms::SamplingStateIdentity::operator()(), muq::SamplingAlgorithms::ExpectedModPieceValue::operator()(), muq::SamplingAlgorithms::SamplingStatePartialMoment::operator()(), serialize(), StateValue(), TotalDim(), and ToVector().
double muq::SamplingAlgorithms::SamplingState::weight |