1 #ifndef HOPS_DNEST4ADAPTER_HPP
2 #define HOPS_DNEST4ADAPTER_HPP
4 #include <dnest4/DNest4.h>
11 template<
typename Environment>
28 double perturb(DNest4::RNG &rng);
36 void print(std::ostream &out)
const;
45 Environment environment;
46 typename Environment::StateType state;
49 template<
typename ModelImplType>
51 if(!environment.isRngInitialized()) {
52 int seed = rng.rand_int(std::numeric_limits<int>::max()-1);
53 environment.seedRng(seed);
55 ModelImplType::getSampler()->draw(ModelImplType::getRandomNumberGenerator());
56 this->state = ModelImplType::getSampler()->getState();
59 template<
typename ModelImplType>
61 if(!ModelImplType::isRngInitialized()) {
62 int seed = rng.rand_int(std::numeric_limits<int>::max()-1);
63 ModelImplType::seedRng(seed);
65 ModelImplType::getSampler()->draw(ModelImplType::getRandomNumberGenerator());
66 this->state = ModelImplType::getSampler()->getState();
67 return ModelImplType::getSampler()->computeLogAcceptanceProbability();
70 template<
typename ModelImplType>
72 return -ModelImplType::getModel()->computeNegativeLogLikelihood(this->state);
75 template<
typename ModelImplType>
77 for (
long i = 0; i < this->state.rows(); i++)
78 out << this->state(i) <<
" ";
81 template<
typename ModelImplType>
83 TODO
if implements getParameterNames() then
return those as
string
86 for (
long i = 0; i < state.rows(); ++i) {
87 description +=
"dim " + std::to_string(i) +
" ,";
89 description.pop_back();
92 environment = Environment::getInstance();
93 this->state = environment.getSampler()->getState();
98 #endif //HOPS_DNEST4ADAPTER_HPP