12#ifndef MCRL2_LPS_STOCHASTIC_STATE_H
13#define MCRL2_LPS_STOCHASTIC_STATE_H
15#include "mcrl2/data/print.h"
16#include "mcrl2/data/rewriter.h"
17#include "mcrl2/data/real_utilities.h"
18#include "mcrl2/lps/state.h"
41 probabilities.push_back(probability);
47 probabilities.clear();
53 assert(states.size()==probabilities.size());
61 const auto& x_ = atermpp::down_cast<data::application>(x);
62 return data::pp(x_[0]) +
'/' + data::pp(x_[1]);
68 const auto& x_ = atermpp::down_cast<data::application>(x);
69 if (x_.head().size() != 3)
71 throw mcrl2::runtime_error(
"The probability " + data::pp(x) +
" is not a proper rational number.");
73 if (x_.head() != data::sort_real::creal())
75 throw mcrl2::runtime_error(
"Probability is not a closed expression with a proper enumerator and denominator: " + data::pp(x) +
".");
79 throw mcrl2::runtime_error(
"Probability is smaller than zero: " + data::pp(x) +
".");
83 throw mcrl2::runtime_error(
"Probability is greater than one: " + data::pp(x) +
".");
91 for (
const data::data_expression& prob: s.probabilities)
93 check_probability(prob, rewr);
94 probability = data::sort_real::plus(probability, prob);
96 probability
= rewr
(probability
);
99 std::vector<std::string> v;
100 for (
const data::data_expression& prob: s.probabilities)
102 v.push_back(print_probability(prob));
104 throw mcrl2::runtime_error(
"The probabilities " + core::detail::print_list(v) +
" do not add up to one, but to " + pp(probability) +
"." );
data_expression & operator=(data_expression &&) noexcept=default
Rewriter that operates on data expressions.
data_expression operator()(const data_expression &d) const
Rewrites a data expression.
void randomly_select_state()
Randomly choose one state among a sequence of probabilistic states.
bool m_auto_select_probabilistic_state
void select_state(std::size_t state_number)
Choose one state among a sequence of probabilistic states.
simulation(const stochastic_specification &specification, data::rewrite_strategy strategy=data::rewrite_strategy())
Constructor.
std::vector< transition_type > transitions(const lps::state &source_state)
void truncate(std::size_t state_number, bool probabilistic)
Remove states from the end of the simulation, making state_number the last state.
Linear process specification.
#define mCRL2log(LEVEL)
mCRL2log(LEVEL) provides the stream used to log.
Namespace for system defined sort bool_.
const function_symbol & true_()
Constructor for function symbol true.
Namespace for system defined sort real_.
data_expression & real_one()
data_expression & real_zero()
application greater_equal(const data_expression &arg0, const data_expression &arg1)
Application of function symbol >=.
The main namespace for the LPS library.
void check_stochastic_state(const stochastic_state &s, const data::rewriter &rewr)
void check_probability(const data::data_expression &x, const data::rewriter &rewr)
std::string print_probability(const data::data_expression &x)
stochastic_state(const state &s)
stochastic_state()=default
void push_back(const data::data_expression &probability, const state &s)
std::vector< data::data_expression > probabilities
std::vector< state > states