19template<
typename ValueType,
typename RewardModelType>
23 std::unordered_map<std::string, RewardModelType>
const& rewardModels)
29template<
typename ValueType,
typename RewardModelType>
32 std::unordered_map<std::string, RewardModelType>&& rewardModels)
34 std::move(transitionMatrix),
std::move(stateLabeling),
std::move(rewardModels), true,
std::move(markovianStates))) {
38template<
typename ValueType,
typename RewardModelType>
42 exitRates = components.exitRates.get();
46 this->turnRatesToProbabilities();
48 closed = this->checkIsClosed();
51template<
typename ValueType,
typename RewardModelType>
55 markovianStates(
std::move(components.markovianStates.get())) {
56 if (components.exitRates) {
57 exitRates = std::move(components.exitRates.get());
60 if (components.rateTransitions) {
61 this->turnRatesToProbabilities();
64 closed = this->checkIsClosed();
67template<
typename ValueType,
typename RewardModelType>
72template<
typename ValueType,
typename RewardModelType>
74 if (!this->hasZenoCycle.is_initialized()) {
75 this->hasZenoCycle = this->checkContainsZenoCycle();
77 return this->hasZenoCycle.get();
80template<
typename ValueType,
typename RewardModelType>
85template<
typename ValueType,
typename RewardModelType>
87 return this->markovianStates.get(state);
90template<
typename ValueType,
typename RewardModelType>
92 return !this->markovianStates.get(state);
95template<
typename ValueType,
typename RewardModelType>
97 return this->exitRates;
100template<
typename ValueType,
typename RewardModelType>
102 return this->exitRates;
105template<
typename ValueType,
typename RewardModelType>
107 return this->exitRates[state];
110template<
typename ValueType,
typename RewardModelType>
115template<
typename ValueType,
typename RewardModelType>
117 return this->markovianStates;
120template<
typename ValueType,
typename RewardModelType>
130 this->markovianStates.set(state,
false);
135 if (!keptChoices.
full()) {
145template<
typename ValueType,
typename RewardModelType>
146void MarkovAutomaton<ValueType, RewardModelType>::turnRatesToProbabilities() {
147 bool assertRates = (this->exitRates.size() == this->getNumberOfStates());
149 STORM_LOG_THROW(this->exitRates.empty(), storm::exceptions::InvalidArgumentException,
"The specified exit rate vector has an unexpected size.");
150 this->exitRates.reserve(this->getNumberOfStates());
153 for (uint_fast64_t state = 0; state < this->getNumberOfStates(); ++state) {
154 uint_fast64_t row = this->getTransitionMatrix().getRowGroupIndices()[state];
155 if (this->markovianStates.get(state)) {
157 STORM_LOG_THROW(this->exitRates[state] == this->getTransitionMatrix().getRowSum(row), storm::exceptions::InvalidArgumentException,
158 "The specified exit rate is inconsistent with the rate matrix. Difference is "
159 << (this->exitRates[state] - this->getTransitionMatrix().getRowSum(row)) <<
".");
161 this->exitRates.push_back(this->getTransitionMatrix().getRowSum(row));
163 for (
auto& transition : this->getTransitionMatrix().getRow(row)) {
164 transition.setValue(transition.getValue() / this->exitRates[state]);
170 "The specified exit rate for (non-Markovian) choice should be 0.");
178template<
typename ValueType,
typename RewardModelType>
180 return isClosed() && markovianStates.full();
183template<
typename ValueType,
typename RewardModelType>
197template<
typename ValueType,
typename RewardModelType>
198bool MarkovAutomaton<ValueType, RewardModelType>::checkIsClosed()
const {
199 for (uint64_t state : markovianStates) {
200 if (this->getTransitionMatrix().getRowGroupSize(state) > 1) {
207template<
typename ValueType,
typename RewardModelType>
224 return std::make_shared<storm::models::sparse::Ctmc<ValueType, RewardModelType>>(std::move(components));
227template<
typename ValueType,
typename RewardModelType>
228bool MarkovAutomaton<ValueType, RewardModelType>::checkContainsZenoCycle()
const {
229 if (isClosed() && markovianStates.empty()) {
234 return !statesWithZenoCycle.
empty();
237template<
typename ValueType,
typename RewardModelType>
241 out <<
"Markovian St.: \t" << this->
getMarkovianStates().getNumberOfSetBits() <<
'\n';
242 out <<
"Max. Rate: \t";
std::shared_ptr< ModelType > as()
Casts the model into the model type given by the template parameter.
This class represents a Markov automaton.
void close()
Closes the Markov automaton.
MarkovAutomaton(storm::storage::SparseMatrix< ValueType > const &transitionMatrix, storm::models::sparse::StateLabeling const &stateLabeling, storm::storage::BitVector const &markovianStates, std::unordered_map< std::string, RewardModelType > const &rewardModels=std::unordered_map< std::string, RewardModelType >())
Constructs a model from the given data.
bool containsZenoCycle() const
Retrieves whether the Markov automaton contains Zeno cycles.
bool isClosed() const
Retrieves whether the Markov automaton is closed.
std::shared_ptr< storm::models::sparse::Ctmc< ValueType, RewardModelType > > convertToCtmc() const
Convert the MA to a CTMC.
bool isProbabilisticState(storm::storage::sparse::state_type state) const
Retrieves whether the given state is a probabilistic state.
bool isMarkovianState(storm::storage::sparse::state_type state) const
Retrieves whether the given state is a Markovian state.
bool hasOnlyTrivialNondeterminism() const
bool isConvertibleToCtmc() const
Determines whether the Markov automaton can be converted to a CTMC without changing any measures.
virtual void printModelInformationToStream(std::ostream &out) const override
Prints information about the model to the specified stream.
std::vector< ValueType > const & getExitRates() const
Retrieves the vector representing the exit rates of the states.
storm::storage::BitVector const & getMarkovianStates() const
Retrieves the set of Markovian states of the model.
ValueType const & getExitRate(storm::storage::sparse::state_type state) const
Retrieves the exit rate of the given state.
ValueType getMaximalExitRate() const
Retrieves the maximal exit rate over all states of the model.
bool isHybridState(storm::storage::sparse::state_type state) const
Retrieves whether the given state is a hybrid state, i.e.
storm::models::sparse::ChoiceLabeling const & getChoiceLabeling() const
Retrieves the labels for the choices of the model.
storm::storage::SparseMatrix< ValueType > const & getTransitionMatrix() const
Retrieves the matrix representing the transitions of the model.
void printModelInformationFooterToStream(std::ostream &out) const
Prints the information footer (reward models, labels and size in memory) of the model to the specifie...
std::unordered_map< std::string, RewardModelType > const & getRewardModels() const
Retrieves the reward models.
bool hasStateValuations() const
Retrieves whether this model was build with state valuations.
storm::storage::sparse::Valuations const & getStateValuations() const
Retrieves the valuations of the states of the model.
std::shared_ptr< storm::storage::sparse::ChoiceOrigins > const & getChoiceOrigins() const
Retrieves the origins of the choices of the model.
bool hasChoiceLabeling() const
Retrieves whether this model has a labeling of the choices.
storm::models::sparse::StateLabeling const & getStateLabeling() const
Returns the state labeling associated with this model.
void printModelInformationHeaderToStream(std::ostream &out) const
Prints the information header (number of states and transitions) of the model to the specified stream...
CRewardModelType RewardModelType
bool hasChoiceOrigins() const
Retrieves whether this model was build with choice origins.
virtual uint_fast64_t getNumberOfStates() const override
Returns the number of states of the model.
NondeterministicModel(ModelType modelType, storm::storage::sparse::ModelComponents< ValueType, RewardModelType > const &components)
Constructs a model from the given data.
uint_fast64_t getNumberOfChoices(uint_fast64_t state) const
This class manages the labeling of the state space with a number of (atomic) labels.
A bit vector that is internally represented as a vector of 64-bit values.
bool full() const
Retrieves whether all bits are set in this bit vector.
bool empty() const
Retrieves whether no bits are set to true in this bit vector.
void set(uint64_t index, bool value=true)
Sets the given truth value at the given index.
A class that holds a possibly non-square matrix in the compressed row storage format.
#define STORM_LOG_ASSERT(cond, message)
#define STORM_LOG_THROW(cond, exception, message)
storm::storage::BitVector performProb0E(storm::models::sparse::NondeterministicModel< T, RM > const &model, storm::storage::SparseMatrix< T > const &backwardTransitions, storm::storage::BitVector const &phiStates, storm::storage::BitVector const &psiStates)
Computes the sets of states that have probability 0 of satisfying phi until psi under at least one po...
VT max_if(std::vector< VT > const &values, storm::storage::BitVector const &filter)
Computes the maximum of the entries from the values that are selected by the (non-empty) filter.
bool isZero(ValueType const &a)
storm::storage::SparseMatrix< ValueType > transitionMatrix
std::optional< std::shared_ptr< storm::storage::sparse::ChoiceOrigins > > choiceOrigins
std::optional< storm::models::sparse::ChoiceLabeling > choiceLabeling
std::optional< storm::storage::sparse::Valuations > stateValuations
boost::optional< std::vector< ValueType > > exitRates