17template<
typename ValueType,
typename RewardModelType>
21 std::unordered_map<std::string, RewardModelType>
const& rewardModels)
27template<
typename ValueType,
typename RewardModelType>
30 std::unordered_map<std::string, RewardModelType>&& rewardModels)
32 std::move(transitionMatrix),
std::move(stateLabeling),
std::move(rewardModels), true,
std::move(markovianStates))) {
36template<
typename ValueType,
typename RewardModelType>
44 this->turnRatesToProbabilities();
46 closed = this->checkIsClosed();
49template<
typename ValueType,
typename RewardModelType>
52 markovianStates(
std::move(components.markovianStates.get())) {
53 if (components.exitRates) {
54 exitRates = std::move(components.exitRates.get());
57 if (components.rateTransitions) {
58 this->turnRatesToProbabilities();
60 closed = this->checkIsClosed();
63template<
typename ValueType,
typename RewardModelType>
68template<
typename ValueType,
typename RewardModelType>
70 if (!this->hasZenoCycle.is_initialized()) {
71 this->hasZenoCycle = this->checkContainsZenoCycle();
73 return this->hasZenoCycle.get();
76template<
typename ValueType,
typename RewardModelType>
78 return isMarkovianState(state) && (this->getTransitionMatrix().getRowGroupSize(state) > 1);
81template<
typename ValueType,
typename RewardModelType>
83 return this->markovianStates.get(state);
86template<
typename ValueType,
typename RewardModelType>
88 return !this->markovianStates.get(state);
91template<
typename ValueType,
typename RewardModelType>
93 return this->exitRates;
96template<
typename ValueType,
typename RewardModelType>
98 return this->exitRates;
101template<
typename ValueType,
typename RewardModelType>
103 return this->exitRates[state];
106template<
typename ValueType,
typename RewardModelType>
111template<
typename ValueType,
typename RewardModelType>
113 return this->markovianStates;
116template<
typename ValueType,
typename RewardModelType>
121 for (
auto state : this->getMarkovianStates()) {
122 if (this->getTransitionMatrix().getRowGroupSize(state) > 1) {
124 keptChoices.
set(this->getTransitionMatrix().getRowGroupIndices()[state],
false);
126 this->markovianStates.set(state,
false);
127 exitRates[state] = storm::utility::zero<ValueType>();
131 if (!keptChoices.
full()) {
141template<
typename ValueType,
typename RewardModelType>
143 bool assertRates = (this->exitRates.size() == this->getNumberOfStates());
145 STORM_LOG_THROW(this->exitRates.empty(), storm::exceptions::InvalidArgumentException,
"The specified exit rate vector has an unexpected size.");
146 this->exitRates.reserve(this->getNumberOfStates());
149 for (uint_fast64_t state = 0; state < this->getNumberOfStates(); ++state) {
150 uint_fast64_t row = this->getTransitionMatrix().getRowGroupIndices()[state];
151 if (this->markovianStates.get(state)) {
153 STORM_LOG_THROW(this->exitRates[state] == this->getTransitionMatrix().getRowSum(row), storm::exceptions::InvalidArgumentException,
154 "The specified exit rate is inconsistent with the rate matrix. Difference is "
155 << (this->exitRates[state] - this->getTransitionMatrix().getRowSum(row)) <<
".");
157 this->exitRates.push_back(this->getTransitionMatrix().getRowSum(row));
159 for (
auto& transition : this->getTransitionMatrix().getRow(row)) {
160 transition.setValue(transition.getValue() / this->exitRates[state]);
166 "The specified exit rate for (non-Markovian) choice should be 0.");
168 this->exitRates.push_back(storm::utility::zero<ValueType>());
174template<
typename ValueType,
typename RewardModelType>
176 return isClosed() && markovianStates.full();
179template<
typename ValueType,
typename RewardModelType>
182 for (uint_fast64_t state = 0; state < this->getNumberOfStates(); ++state) {
184 if (this->getNumberOfChoices(state) > 1) {
186 STORM_LOG_ASSERT(isProbabilisticState(state),
"State is not probabilistic.");
193template<
typename ValueType,
typename RewardModelType>
195 for (
auto state : markovianStates) {
196 if (this->getTransitionMatrix().getRowGroupSize(state) > 1) {
203template<
typename ValueType,
typename RewardModelType>
205 STORM_LOG_THROW(isConvertibleToCtmc(), storm::exceptions::InvalidArgumentException,
"MA cannot be converted to CTMC.");
208 this->getRewardModels(),
false);
210 components.
exitRates = this->getExitRates();
211 if (this->hasChoiceLabeling()) {
214 if (this->hasStateValuations()) {
217 if (this->hasChoiceOrigins()) {
220 return std::make_shared<storm::models::sparse::Ctmc<ValueType, RewardModelType>>(std::move(components));
223template<
typename ValueType,
typename RewardModelType>
225 if (isClosed() && markovianStates.empty()) {
230 return !statesWithZenoCycle.
empty();
233template<
typename ValueType,
typename RewardModelType>
235 this->printModelInformationHeaderToStream(out);
236 out <<
"Choices: \t" << this->getNumberOfChoices() <<
'\n';
237 out <<
"Markovian St.: \t" << this->getMarkovianStates().getNumberOfSetBits() <<
'\n';
238 out <<
"Max. Rate: \t";
239 if (this->getMarkovianStates().empty()) {
242 out << this->getMaximalExitRate();
245 this->printModelInformationFooterToStream(out);
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.
CRewardModelType RewardModelType
The base class of sparse nondeterministic models.
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