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>
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>
80 return isMarkovianState(state) && (this->getTransitionMatrix().getRowGroupSize(state) > 1);
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>
123 for (
auto state : this->getMarkovianStates()) {
124 if (this->getTransitionMatrix().getRowGroupSize(state) > 1) {
126 keptChoices.
set(this->getTransitionMatrix().getRowGroupIndices()[state],
false);
128 this->markovianStates.set(state,
false);
129 exitRates[state] = storm::utility::zero<ValueType>();
133 if (!keptChoices.
full()) {
143template<
typename ValueType,
typename RewardModelType>
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.");
170 this->exitRates.push_back(storm::utility::zero<ValueType>());
176template<
typename ValueType,
typename RewardModelType>
178 return isClosed() && markovianStates.full();
181template<
typename ValueType,
typename RewardModelType>
184 for (uint_fast64_t state = 0; state < this->getNumberOfStates(); ++state) {
186 if (this->getNumberOfChoices(state) > 1) {
188 STORM_LOG_ASSERT(isProbabilisticState(state),
"State is not probabilistic.");
195template<
typename ValueType,
typename RewardModelType>
197 for (
auto state : markovianStates) {
198 if (this->getTransitionMatrix().getRowGroupSize(state) > 1) {
205template<
typename ValueType,
typename RewardModelType>
207 STORM_LOG_THROW(isConvertibleToCtmc(), storm::exceptions::InvalidArgumentException,
"MA cannot be converted to CTMC.");
210 this->getRewardModels(),
false);
212 components.
exitRates = this->getExitRates();
213 if (this->hasChoiceLabeling()) {
216 if (this->hasStateValuations()) {
219 if (this->hasChoiceOrigins()) {
222 return std::make_shared<storm::models::sparse::Ctmc<ValueType, RewardModelType>>(std::move(components));
225template<
typename ValueType,
typename RewardModelType>
227 if (isClosed() && markovianStates.empty()) {
232 return !statesWithZenoCycle.
empty();
235template<
typename ValueType,
typename RewardModelType>
237 this->printModelInformationHeaderToStream(out);
238 out <<
"Choices: \t" << this->getNumberOfChoices() <<
'\n';
239 out <<
"Markovian St.: \t" << this->getMarkovianStates().getNumberOfSetBits() <<
'\n';
240 out <<
"Max. Rate: \t";
241 if (this->getMarkovianStates().empty()) {
244 out << this->getMaximalExitRate();
247 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