Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
NondeterministicModel.cpp
Go to the documentation of this file.
2
6
8
9#include "storm-config.h"
11
12namespace storm {
13namespace models {
14namespace symbolic {
15
16template<storm::dd::DdType Type, typename ValueType>
18 storm::models::ModelType const& modelType, std::shared_ptr<storm::dd::DdManager<Type>> manager, storm::dd::Bdd<Type> reachableStates,
19 storm::dd::Bdd<Type> initialStates, storm::dd::Bdd<Type> deadlockStates, storm::dd::Add<Type, ValueType> transitionMatrix,
20 std::set<storm::expressions::Variable> const& rowVariables, std::shared_ptr<storm::adapters::AddExpressionAdapter<Type, ValueType>> rowExpressionAdapter,
21 std::set<storm::expressions::Variable> const& columnVariables,
22 std::vector<std::pair<storm::expressions::Variable, storm::expressions::Variable>> const& rowColumnMetaVariablePairs,
23 std::set<storm::expressions::Variable> const& nondeterminismVariables, std::map<std::string, storm::expressions::Expression> labelToExpressionMap,
24 std::unordered_map<std::string, RewardModelType> const& rewardModels)
25 : Model<Type, ValueType>(modelType, manager, reachableStates, initialStates, deadlockStates, transitionMatrix, rowVariables, rowExpressionAdapter,
26 columnVariables, rowColumnMetaVariablePairs, labelToExpressionMap, rewardModels),
27 nondeterminismVariables(nondeterminismVariables) {
28 createIllegalMask();
29}
30
31template<storm::dd::DdType Type, typename ValueType>
33 storm::models::ModelType const& modelType, std::shared_ptr<storm::dd::DdManager<Type>> manager, storm::dd::Bdd<Type> reachableStates,
34 storm::dd::Bdd<Type> initialStates, storm::dd::Bdd<Type> deadlockStates, storm::dd::Add<Type, ValueType> transitionMatrix,
35 std::set<storm::expressions::Variable> const& rowVariables, std::set<storm::expressions::Variable> const& columnVariables,
36 std::vector<std::pair<storm::expressions::Variable, storm::expressions::Variable>> const& rowColumnMetaVariablePairs,
37 std::set<storm::expressions::Variable> const& nondeterminismVariables, std::map<std::string, storm::dd::Bdd<Type>> labelToBddMap,
38 std::unordered_map<std::string, RewardModelType> const& rewardModels)
39 : Model<Type, ValueType>(modelType, manager, reachableStates, initialStates, deadlockStates, transitionMatrix, rowVariables, columnVariables,
40 rowColumnMetaVariablePairs, labelToBddMap, rewardModels),
41 nondeterminismVariables(nondeterminismVariables) {
42 createIllegalMask();
43}
44
45template<storm::dd::DdType Type, typename ValueType>
47 std::set<storm::expressions::Variable> rowAndNondeterminismVariables;
48 std::set_union(this->getNondeterminismVariables().begin(), this->getNondeterminismVariables().end(), this->getRowVariables().begin(),
49 this->getRowVariables().end(), std::inserter(rowAndNondeterminismVariables, rowAndNondeterminismVariables.begin()));
50
51 storm::dd::Add<Type, uint_fast64_t> tmp = this->getTransitionMatrix()
52 .notZero()
53 .existsAbstract(this->getColumnVariables())
54 .template toAdd<uint_fast64_t>()
55 .sumAbstract(rowAndNondeterminismVariables);
56 return tmp.getValue();
57}
58
59template<storm::dd::DdType Type, typename ValueType>
60std::set<storm::expressions::Variable> const& NondeterministicModel<Type, ValueType>::getNondeterminismVariables() const {
61 return nondeterminismVariables;
62}
63
64template<storm::dd::DdType Type, typename ValueType>
68
69template<storm::dd::DdType Type, typename ValueType>
71 storm::dd::Bdd<Type> transitionMatrixBdd = this->getTransitionMatrix().notZero();
72 return !transitionMatrixBdd && transitionMatrixBdd.existsAbstract(this->getColumnVariables());
73}
74
75template<storm::dd::DdType Type, typename ValueType>
77 this->printModelInformationHeaderToStream(out);
78 out << "Choices: \t" << this->getNumberOfChoices() << '\n';
79 this->printModelInformationFooterToStream(out);
80}
81
82template<storm::dd::DdType Type, typename ValueType>
84 uint_fast64_t nondeterminismVariableCount = 0;
85 for (auto const& metaVariable : this->getNondeterminismVariables()) {
86 nondeterminismVariableCount += this->getManager().getMetaVariable(metaVariable).getNumberOfDdVariables();
87 }
89 out << ", nondeterminism: " << this->getNondeterminismVariables().size() << " meta variables (" << nondeterminismVariableCount << " DD variables)";
90}
92template<storm::dd::DdType Type, typename ValueType>
94 for (auto& rewardModel : this->getRewardModels()) {
95 rewardModel.second.reduceToStateBasedRewards(this->getTransitionMatrix(), this->getRowVariables(), this->getColumnVariables(), false);
96 }
97}
99template<storm::dd::DdType Type, typename ValueType>
101 // Prepare the mask of illegal nondeterministic choices.
102 illegalMask = !(this->getTransitionMatrix().notZero().existsAbstract(this->getColumnVariables())) && this->getReachableStates();
103}
104
105template<storm::dd::DdType Type, typename ValueType>
107 if (!keepNondeterminism) {
108 return this->getTransitionMatrix().notZero().existsAbstract(this->getNondeterminismVariables());
109 } else {
111 }
112}
113
114// Explicitly instantiate the template class.
117
118#ifdef STORM_HAVE_CARL
121#endif
122} // namespace symbolic
123} // namespace models
124} // namespace storm
ValueType getValue(std::map< storm::expressions::Variable, int_fast64_t > const &metaVariableToValueMap=std::map< storm::expressions::Variable, int_fast64_t >()) const
Retrieves the value of the function when all meta variables are assigned the values of the given mapp...
Definition Add.cpp:508
Bdd< LibraryType > notZero() const
Computes a BDD that represents the function in which all assignments with a function value unequal to...
Definition Add.cpp:431
Bdd< LibraryType > existsAbstract(std::set< storm::expressions::Variable > const &metaVariables) const
Existentially abstracts from the given meta variables.
Definition Bdd.cpp:178
Base class for all symbolic models.
Definition Model.h:46
virtual void printDdVariableInformationToStream(std::ostream &out) const
Prints information about the DD variables to the specified stream.
Definition Model.cpp:368
virtual storm::dd::Bdd< Type > getQualitativeTransitionMatrix(bool keepNondeterminism=true) const
Retrieves the matrix qualitatively (i.e.
Definition Model.cpp:187
Base class for all nondeterministic symbolic models.
virtual uint_fast64_t getNumberOfChoices() const override
Retrieves the number of nondeterministic choices in the model.
virtual std::set< storm::expressions::Variable > const & getNondeterminismVariables() const override
Retrieves the meta variables used to encode the nondeterminism in the model.
virtual void printModelInformationToStream(std::ostream &out) const override
Prints information about the model to the specified stream.
storm::dd::Bdd< Type > const & getIllegalMask() const
Retrieves a BDD characterizing all illegal nondeterminism encodings in the model.
storm::dd::Bdd< Type > getIllegalSuccessorMask() const
Retrieves a BDD characterizing the illegal successors for each choice.
virtual void reduceToStateBasedRewards() override
Converts the transition rewards of all reward models to state-based rewards.
virtual void printDdVariableInformationToStream(std::ostream &out) const override
Prints information about the DD variables to the specified stream.
NondeterministicModel(NondeterministicModel< Type, ValueType > const &other)=default
virtual storm::dd::Bdd< Type > getQualitativeTransitionMatrix(bool keepNondeterminism=true) const override
Retrieves the matrix qualitatively (i.e.
LabParser.cpp.
Definition cli.cpp:18