1 #ifndef SIMPT_MATH_RANDOM_ENGINE_H_INCLUDED
2 #define SIMPT_MATH_RANDOM_ENGINE_H_INCLUDED
23 #include <trng/lcg64_shift.hpp>
24 #include <trng/lcg64.hpp>
25 #include <trng/mrg2.hpp>
26 #include <trng/mrg3.hpp>
27 #include <trng/yarn2.hpp>
28 #include <trng/yarn3.hpp>
29 #include <boost/property_tree/ptree.hpp>
68 std::function<typename D::result_type()>
GetGenerator(
const D& d,
int i = 0)
70 using namespace RandomEngineType;
72 std::function<typename D::result_type()> gen;
75 gen = std::bind(d, std::ref(m_lcg64[i]));
break;
76 case TypeId::lcg64_shift :
77 gen = std::bind(d, std::ref(m_lcg64_shift[i]));
break;
79 gen = std::bind(d, std::ref(m_mrg2[i]));
break;
81 gen = std::bind(d, std::ref(m_mrg3[i]));
break;
83 gen = std::bind(d, std::ref(m_yarn2[i]));
break;
85 gen = std::bind(d, std::ref(m_yarn3[i]));
break;
98 bool Reinitialize(
const boost::property_tree::ptree& ptree);
102 void SetState(
unsigned long);
105 void SetState(
const std::string& state);
107 unsigned long m_seed;
111 std::vector<trng::lcg64> m_lcg64;
112 std::vector<trng::lcg64_shift> m_lcg64_shift;
113 std::vector<trng::mrg2> m_mrg2;
114 std::vector<trng::mrg3> m_mrg3;
115 std::vector<trng::yarn2> m_yarn2;
116 std::vector<trng::yarn3> m_yarn3;
121 #endif // end-of-include-guard
RandomEngine()
Initializes to default engine( trng::mrg2 with seed 1).
Namespace for the core simulator.
bool Reinitialize()
Reset to the default engine (trng::mrg2 with seed 1).
std::function< typename D::result_type()> GetGenerator(const D &d, int i=0)
Produce a random generator out of a distribution bound to sim's random engine.
TypeId
Enumerates type ids.
Interface of RandomEngineType.
Creates a random generator based on a seed.
RandomEngineType::Info GetInfo() const
Return the state of the random engine.