Go to the documentation of this file. 1 #ifndef HOPS_MARKOVCHAINADAPTER_HPP
2 #define HOPS_MARKOVCHAINADAPTER_HPP
5 #include "../Utility/Data.hpp"
17 template<
typename MarkovChainImpl>
20 explicit MarkovChainAdapter(
const MarkovChainImpl &markovChainImpl) : MarkovChainImpl(markovChainImpl) {}
23 assert(numberOfSamples > 0);
24 for (
long i = 0; i < numberOfSamples; ++i) {
25 MarkovChainImpl::draw(randomNumberGenerator);
26 MarkovChainImpl::storeRecord();
31 assert(numberOfSamples > 0);
33 for (
long i = 0; i < numberOfSamples; ++i) {
34 for (
long j = 0; j < thinning; ++j) {
35 MarkovChainImpl::draw(randomNumberGenerator);
37 MarkovChainImpl::storeRecord();
42 MarkovChainImpl::writeRecordsToFile(fileWriter);
46 MarkovChainImpl::installDataObject(chainData);
50 return MarkovChainImpl::getStateRecords();
54 return MarkovChainImpl::reserveStateRecords(numberOfSamples);
58 MarkovChainImpl::clearRecords();
62 return MarkovChainImpl::getName();
66 return MarkovChainImpl::getAcceptanceRate();
70 switch (markovChainAttribute) {
73 MarkovChainImpl::setFisherWeight(value);
76 throw std::runtime_error(
"FISHER_WEIGHT attribute does not exist.");
80 MarkovChainImpl::setStepSize(value);
83 throw std::runtime_error(
"STEP_SIZE attribute does not exist.");
87 MarkovChainImpl::setColdness(value);
90 throw std::runtime_error(
"PARALLEL_TEMPERING_COLDNESS attribute does not exist.");
95 MarkovChainImpl::setExchangeAttemptProbability(value);
98 throw std::runtime_error(
"PARALLEL_TEMPERING_EXCHANGE_PROBABILITY attribute does not exist.");
101 throw std::runtime_error(
"Attribute does not exist.");
106 void setState(Eigen::Matrix<double, -1, 1, 0, -1, 1> state)
override {
107 MarkovChainImpl::setState(state);
111 switch (markovChainAttribute) {
114 return MarkovChainImpl::getColdness();
116 throw std::runtime_error(
"PARALLEL_TEMPERING_COLDNESS attribute does not exist.");
121 return MarkovChainImpl::getExchangeAttemptProbability();
123 throw std::runtime_error(
"PARALLEL_TEMPERING_EXCHANGE_PROBABILITY attribute does not exist.");
126 return MarkovChainImpl::computeLogAcceptanceProbability();
130 return MarkovChainImpl::getStepSize();
132 throw std::runtime_error(
"STEP_SIZE attribute does not exist.");
135 throw std::runtime_error(
"Attribute does not exist.");
142 #endif //HOPS_MARKOVCHAINADAPTER_HPP
Definition: IsGetColdnessAvailable.hpp:9
void setAttribute(MarkovChainAttribute markovChainAttribute, double value) override
Definition: MarkovChainAdapter.hpp:69
Definition: MarkovChainAdapter.hpp:18
@ PREVIOUS_STEP_ACCEPTANCE_PROBABILITY
void setState(Eigen::Matrix< double, -1, 1, 0, -1, 1 > state) override
Definition: MarkovChainAdapter.hpp:106
Definition: pcg_random.hpp:364
void draw(RandomNumberGenerator &randomNumberGenerator, long numberOfSamples) override
Updates internal state of the chain and stores numberOfSamples samples in memory.
Definition: MarkovChainAdapter.hpp:22
void draw(RandomNumberGenerator &randomNumberGenerator, long numberOfSamples, long thinning) override
Updates internal state of the chain and stores numberOfSamples samples in memory.
Definition: MarkovChainAdapter.hpp:30
Definition: IsGetExchangeAttemptProbabilityAvailable.hpp:9
double getAcceptanceRate() override
Definition: MarkovChainAdapter.hpp:65
Definition: IsSetFisherWeightAvailable.hpp:7
void clearHistory() override
Deletes all stored chain history.
Definition: MarkovChainAdapter.hpp:57
std::string getName() override
Definition: MarkovChainAdapter.hpp:61
Definition: ChainData.hpp:12
Definition: IsGetStepSizeAvailable.hpp:9
Definition: IsSetExchangeAttemptProbabilityAvailable.hpp:8
MarkovChainAdapter(const MarkovChainImpl &markovChainImpl)
Definition: MarkovChainAdapter.hpp:20
@ PARALLEL_TEMPERING_EXCHANGE_PROBABILITY
Definition: FileWriter.hpp:9
Definition: CsvReader.hpp:8
Definition: MarkovChain.hpp:17
@ PARALLEL_TEMPERING_COLDNESS
Definition: IsSetStepSizeAvailable.hpp:8
MarkovChainAttribute
Definition: MarkovChainAttribute.hpp:5
NAME string(REPLACE ".cpp" "_bin" example_name ${example_filename}) if($
Definition: hops/Third-party/HighFive/src/examples/CMakeLists.txt:6
Definition: IsSetColdnessAvailable.hpp:8
void reserveStateRecords(long numberOfSamples) override
Definition: MarkovChainAdapter.hpp:53
const std::vector< Eigen::VectorXd > & getStateRecords() override
Definition: MarkovChainAdapter.hpp:49
double getAttribute(MarkovChainAttribute markovChainAttribute) override
Definition: MarkovChainAdapter.hpp:110
void installDataObject(ChainData &chainData) override
Definition: MarkovChainAdapter.hpp:45
void writeHistory(FileWriter *const fileWriter) override
Writes all stored chain history using the fileWriter.
Definition: MarkovChainAdapter.hpp:41