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>
54 markovianStates(
std::move(components.markovianStates.get())) {
55 if (components.exitRates) {
56 exitRates = std::move(components.exitRates.get());
59 if (components.rateTransitions) {
60 this->turnRatesToProbabilities();
62 closed = this->checkIsClosed();
65template<
typename ValueType,
typename RewardModelType>
70template<
typename ValueType,
typename RewardModelType>
72 if (!this->hasZenoCycle.is_initialized()) {
73 this->hasZenoCycle = this->checkContainsZenoCycle();
75 return this->hasZenoCycle.get();
78template<
typename ValueType,
typename RewardModelType>
83template<
typename ValueType,
typename RewardModelType>
85 return this->markovianStates.get(state);
88template<
typename ValueType,
typename RewardModelType>
90 return !this->markovianStates.get(state);
93template<
typename ValueType,
typename RewardModelType>
95 return this->exitRates;
98template<
typename ValueType,
typename RewardModelType>
100 return this->exitRates;
103template<
typename ValueType,
typename RewardModelType>
105 return this->exitRates[state];
108template<
typename ValueType,
typename RewardModelType>
113template<
typename ValueType,
typename RewardModelType>
115 return this->markovianStates;
118template<
typename ValueType,
typename RewardModelType>
128 this->markovianStates.set(state,
false);
133 if (!keptChoices.
full()) {
143template<
typename ValueType,
typename RewardModelType>
144void MarkovAutomaton<ValueType, RewardModelType>::turnRatesToProbabilities() {
145 bool assertRates = (this->exitRates.size() == this->getNumberOfStates());
147 STORM_LOG_THROW(this->exitRates.empty(), storm::exceptions::InvalidArgumentException,
"The specified exit rate vector has an unexpected size.");
148 this->exitRates.reserve(this->getNumberOfStates());
151 for (uint_fast64_t state = 0; state < this->getNumberOfStates(); ++state) {
152 uint_fast64_t row = this->getTransitionMatrix().getRowGroupIndices()[state];
153 if (this->markovianStates.get(state)) {
155 STORM_LOG_THROW(this->exitRates[state] == this->getTransitionMatrix().getRowSum(row), storm::exceptions::InvalidArgumentException,
156 "The specified exit rate is inconsistent with the rate matrix. Difference is "
157 << (this->exitRates[state] - this->getTransitionMatrix().getRowSum(row)) <<
".");
159 this->exitRates.push_back(this->getTransitionMatrix().getRowSum(row));
161 for (
auto& transition : this->getTransitionMatrix().getRow(row)) {
162 transition.setValue(transition.getValue() / this->exitRates[state]);
168 "The specified exit rate for (non-Markovian) choice should be 0.");
176template<
typename ValueType,
typename RewardModelType>
178 return isClosed() && markovianStates.full();
181template<
typename ValueType,
typename RewardModelType>
195template<
typename ValueType,
typename RewardModelType>
196bool MarkovAutomaton<ValueType, RewardModelType>::checkIsClosed()
const {
197 for (
auto state : markovianStates) {
198 if (this->getTransitionMatrix().getRowGroupSize(state) > 1) {
205template<
typename ValueType,
typename RewardModelType>
222 return std::make_shared<storm::models::sparse::Ctmc<ValueType, RewardModelType>>(std::move(components));
225template<
typename ValueType,
typename RewardModelType>
226bool MarkovAutomaton<ValueType, RewardModelType>::checkContainsZenoCycle()
const {
227 if (isClosed() && markovianStates.empty()) {
232 return !statesWithZenoCycle.
empty();
235template<
typename ValueType,
typename RewardModelType>
239 out <<
"Markovian St.: \t" << this->
getMarkovianStates().getNumberOfSetBits() <<
'\n';
240 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::StateValuations 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)
std::optional< storm::storage::sparse::StateValuations > stateValuations
storm::storage::SparseMatrix< ValueType > transitionMatrix
std::optional< std::shared_ptr< storm::storage::sparse::ChoiceOrigins > > choiceOrigins
std::optional< storm::models::sparse::ChoiceLabeling > choiceLabeling
boost::optional< std::vector< ValueType > > exitRates