31 const double tol = 1e-9;
71 std::cout << std::endl;
73 std::cout << std::endl;
75 const std::size_t size = mychain.
size1();
78 if (std::fabs(mychain.
get_rate(0,1) - r12.value()) > 1e-10)
80 if (std::fabs(mychain.
get_rate(1,0) - r21.value()) > 1e-10)
82 if (std::fabs(mychain.
get_rate(0,0)) > 1e-10)
84 if (std::fabs(mychain.
get_rate(1,1)) > 1e-10)
91 ssa.set_equilibrium(rnd);
93 std::cout << std::endl;
95 std::cout << std::endl;
103 double dt = ssa.solve(rnd);
104 std::cout << std::endl <<
"dt = " << std::setprecision(10) << dt << std::endl;
115 std::cout << std::endl;
116 std::cout <<
"Test finished successfully!" << std::endl;
118 return (EXIT_SUCCESS);
Implements the concept of a state (in a finite-state diagram) and markov chains.
Exception for the case that an invalid value (depends on the method called) is encountered.
A pseudo-random number generator implementation based on std::rand()
void seed(unsigned int s)
Sets the seed of the pseudo-random number generator (std::srand)
Implementation of Markov-Chains.
void add_rate(state_base const &from, state_base const &to, rate_base const &r)
Adds a rate between to states. Additionally adds the given states if necessary.
void print_occupancies() const
Prints the occupancies of each state in the chain onto screen (log::info). Usefull for debugging.
void print_rate_matrix() const
Prints the rate matrix onto screen (log::info). Usefull for debugging.
state_base & get_state(index_type idx)
double get_rate(state_base const &from, state_base const &to) const
Returns the actual rate (double value!) between to states.
index_type size1() const
Returns the row size of the rate-matrix.
The SSA (Monte Carlo) solver for Markov-Chains The given chain is being referenced and the occupancie...
The basic concept of a state in Markov-Chains.
double occupancy() const
Returns the occupancy f or p of the state. It has to be a number in [0,1].
bool fuzzy_equal(double is, double should, double tol=1e-1)
Performs a fuzzy (up to a tolerance) equal. Returns true if is and should are equal within the tolera...
Implementation of pseudo-random number generators.
Contains the basic reaction rate interface.
Contains an impelemtation of the SSA algorithm for Markov-Chains (cf. viennashe/models/markovchain/ch...
Contains common functions, functors and other classes often needed by the tests.