20 std::list<transition> outgoing_transitions =
out_edges(source_state);
21 std::vector<simulation::transition_t> output(outgoing_transitions.begin(), outgoing_transitions.end());
26 mCRL2log(
mcrl2::log::error) <<
"an error occurred while calculating the transitions from this state;\n" << e.what() << std::endl;
27 return std::vector<simulation::transition_t>();
35 m_distrib(0,
std::numeric_limits<
std::size_t>::max())
54 if (probabilistic &&
m_full_trace[state_number].source_state.size()>1)
65 assert(state_number<
state.source_state.states.
size());
66 state.state_number=state_number;
73 std::size_t state_number=0;
78 double random_value=
static_cast<double>(
m_distrib(
m_gen))/
static_cast<double>(std::numeric_limits<std::size_t>::max());
79 random_value=random_value-data::sort_real::value<double>(
state.source_state.probabilities[state_number]);
80 while (random_value>0)
83 assert(state_number<
state.source_state.states.
size());
84 random_value=random_value-data::sort_real::value<double>(
state.source_state.probabilities[state_number]);
87 state.state_number=state_number;
93 assert(transition_number <
m_full_trace.back().transitions.size());
94 m_full_trace.back().transition_number = transition_number;
126 for (std::size_t i = 0; i + 1 <
m_full_trace.size(); i++)
139 std::cout <<
"the last state in the saved trace is the first concrete state from the last probabilistic state." << std::endl;
143 trace.save(filename);
150 trace.reset_position();
160 if (
trace.current_state_exists())
165 "of this specification");
173 + std::to_string(
m_full_trace.size() - 1) +
" from the trace loaded from " + filename +
".");
182 state.source_state = s;
184 state.transition_number = 0;
190 if (!
trace.current_state_exists())
194 assert(
trace.current_state_exists());
212 if (!
trace.current_action_exists())
218 trace.increase_position();
219 for (std::size_t i = 0; i < current.
transitions.size(); ++i)
Read-only balanced binary tree of terms.
size_type size() const
Returns the size of the term_balanced_tree.
size_type size() const
Returns the size of the term_list.
const_iterator end() const
Returns a const_iterator pointing to the end of the term_list.
const_iterator begin() const
Returns a const_iterator pointing to the beginning of the term_list.
data::enumerator_algorithm m_global_enumerator
const data::data_expression_list & initial_state() const
void compute_stochastic_state(stochastic_state &result, const stochastic_distribution &distribution, const DataExpressionSequence &next_state, data::mutable_indexed_substitution<> &sigma, data::rewriter &rewr, data::enumerator_algorithm<> &enumerator) const
data::data_expression_list m_initial_state
data::mutable_indexed_substitution m_global_sigma
lps::stochastic_distribution m_initial_distribution
data::rewriter m_global_rewr
typename std::conditional< Stochastic, stochastic_state, state >::type state_type
std::list< transition > out_edges(const state &s, const SummandSequence ®ular_summands, const SummandSequence &confluent_summands, data::mutable_indexed_substitution<> &sigma, data::rewriter &rewr, data::enumerator_algorithm<> &enumerator, data::enumerator_identifier_generator &id_generator)
\brief A timed multi-action
void enable_auto_select_probability(bool enable)
If enabled, automatically a probabilistic state is chosen using its intrinsic probability.
void select_transition(std::size_t transition_number)
Choose outgoing transition indexed by transition_number and add its state to the state vector.
void add_new_state(const lps::stochastic_state &s)
std::uniform_int_distribution< std::size_t > m_distrib
std::deque< simulator_state_t > m_full_trace
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.
void randomly_select_transition()
Randomly choose an outgoing transition and add its state to the state vector.
bool match_trace_transition(lts::trace &trace)
bool match_trace_probabilistic_state(lts::trace &trace)
void save(const std::string &filename) const
Save the trace to a file.
const std::deque< simulator_state_t > & trace() const
Returns the current annotated state vector.
stochastic_specification m_specification
void truncate(std::size_t state_number, bool probabilistic)
Remove states from the end of the simulation, making state_number the last state.
std::vector< transition_t > transitions(const lps::state &source_state)
void load(const std::string &filename)
Load a trace from a file.
const process::action_label_list & action_labels() const
Returns a sequence of action labels. This sequence contains all action labels occurring in the specif...
const data::data_specification & data() const
Returns the data specification.
Linear process specification.
Linear process specification.
This class contains a trace consisting of a sequence of (timed) actions possibly with intermediate st...
Standard exception class for reporting runtime errors.
#define mCRL2log(LEVEL)
mCRL2log(LEVEL) provides the stream used to log.
rewrite_strategy
The strategy of the rewriter.
The main namespace for the LPS library.
atermpp::term_balanced_tree< data::data_expression > state
std::string pp(const action_summand &x)
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
Provides utilities for working with data expressions of standard sorts.
std::vector< transition_t > transitions
std::size_t transition_number
lps::stochastic_state source_state
std::vector< state > states