MUQ  0.4.3
muq::SamplingAlgorithms::SamplingState Class Reference

Each state is one sample generated by a sampling algorithm. More...

#include <SamplingState.h>

Detailed Description

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...
 

Constructor & Destructor Documentation

◆ SamplingState() [1/3]

muq::SamplingAlgorithms::SamplingState::SamplingState ( )
default

◆ SamplingState() [2/3]

SamplingState::SamplingState ( Eigen::VectorXd const &  stateIn,
double  weight = 1.0 
)

Definition at line 8 of file SamplingState.cpp.

◆ SamplingState() [3/3]

SamplingState::SamplingState ( std::vector< Eigen::VectorXd > const &  stateIn,
double  weight = 1.0 
)

Definition at line 9 of file SamplingState.cpp.

◆ ~SamplingState()

virtual muq::SamplingAlgorithms::SamplingState::~SamplingState ( )
virtualdefault

Member Function Documentation

◆ HasMeta()

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.

◆ serialize()

template<class Archive >
void muq::SamplingAlgorithms::SamplingState::serialize ( Archive &  archive)
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.

References meta, state, and weight.

◆ StateValue() [1/2]

double & SamplingState::StateValue ( unsigned int  totalInd)

Definition at line 58 of file SamplingState.cpp.

References state.

◆ StateValue() [2/2]

double SamplingState::StateValue ( unsigned int  totalInd) const

Returns the state value given an index into concatenated state vector.

Parameters
[in]totalIndIndex into the concatenated state. Maximum value is TotalDim()-1.

Definition at line 43 of file SamplingState.cpp.

References state.

◆ TotalDim()

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().

◆ 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().

Member Data Documentation

◆ meta

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().

◆ state

◆ weight

double muq::SamplingAlgorithms::SamplingState::weight

The weight of this state.

Definition at line 51 of file SamplingState.h.

Referenced by serialize().


The documentation for this class was generated from the following files: