Storm 1.11.1.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
NondeterministicModel.cpp
Go to the documentation of this file.
2
8
9namespace storm {
10namespace models {
11namespace symbolic {
12
13template<storm::dd::DdType Type, typename ValueType>
15 storm::models::ModelType const& modelType, std::shared_ptr<storm::dd::DdManager<Type>> manager, storm::dd::Bdd<Type> reachableStates,
16 storm::dd::Bdd<Type> initialStates, storm::dd::Bdd<Type> deadlockStates, storm::dd::Add<Type, ValueType> transitionMatrix,
17 std::set<storm::expressions::Variable> const& rowVariables, std::shared_ptr<storm::adapters::AddExpressionAdapter<Type, ValueType>> rowExpressionAdapter,
18 std::set<storm::expressions::Variable> const& columnVariables,
19 std::vector<std::pair<storm::expressions::Variable, storm::expressions::Variable>> const& rowColumnMetaVariablePairs,
20 std::set<storm::expressions::Variable> const& nondeterminismVariables, std::map<std::string, storm::expressions::Expression> labelToExpressionMap,
21 std::unordered_map<std::string, RewardModelType> const& rewardModels)
22 : Model<Type, ValueType>(modelType, manager, reachableStates, initialStates, deadlockStates, transitionMatrix, rowVariables, rowExpressionAdapter,
23 columnVariables, rowColumnMetaVariablePairs, labelToExpressionMap, rewardModels),
24 nondeterminismVariables(nondeterminismVariables) {
25 createIllegalMask();
26}
27
28template<storm::dd::DdType Type, typename ValueType>
30 storm::models::ModelType const& modelType, std::shared_ptr<storm::dd::DdManager<Type>> manager, storm::dd::Bdd<Type> reachableStates,
31 storm::dd::Bdd<Type> initialStates, storm::dd::Bdd<Type> deadlockStates, storm::dd::Add<Type, ValueType> transitionMatrix,
32 std::set<storm::expressions::Variable> const& rowVariables, std::set<storm::expressions::Variable> const& columnVariables,
33 std::vector<std::pair<storm::expressions::Variable, storm::expressions::Variable>> const& rowColumnMetaVariablePairs,
34 std::set<storm::expressions::Variable> const& nondeterminismVariables, std::map<std::string, storm::dd::Bdd<Type>> labelToBddMap,
35 std::unordered_map<std::string, RewardModelType> const& rewardModels)
36 : Model<Type, ValueType>(modelType, manager, reachableStates, initialStates, deadlockStates, transitionMatrix, rowVariables, columnVariables,
37 rowColumnMetaVariablePairs, labelToBddMap, rewardModels),
38 nondeterminismVariables(nondeterminismVariables) {
39 createIllegalMask();
40}
42template<storm::dd::DdType Type, typename ValueType>
44 std::set<storm::expressions::Variable> rowAndNondeterminismVariables;
45 std::set_union(this->getNondeterminismVariables().begin(), this->getNondeterminismVariables().end(), this->getRowVariables().begin(),
46 this->getRowVariables().end(), std::inserter(rowAndNondeterminismVariables, rowAndNondeterminismVariables.begin()));
47
48 storm::dd::Add<Type, uint_fast64_t> tmp = this->getTransitionMatrix()
49 .notZero()
50 .existsAbstract(this->getColumnVariables())
51 .template toAdd<uint_fast64_t>()
52 .sumAbstract(rowAndNondeterminismVariables);
53 return tmp.getValue();
54}
55
56template<storm::dd::DdType Type, typename ValueType>
57std::set<storm::expressions::Variable> const& NondeterministicModel<Type, ValueType>::getNondeterminismVariables() const {
58 return nondeterminismVariables;
59}
60
61template<storm::dd::DdType Type, typename ValueType>
65
66template<storm::dd::DdType Type, typename ValueType>
68 storm::dd::Bdd<Type> transitionMatrixBdd = this->getTransitionMatrix().notZero();
69 return !transitionMatrixBdd && transitionMatrixBdd.existsAbstract(this->getColumnVariables());
70}
71
72template<storm::dd::DdType Type, typename ValueType>
74 this->printModelInformationHeaderToStream(out);
75 out << "Choices: \t" << this->getNumberOfChoices() << '\n';
76 this->printModelInformationFooterToStream(out);
77}
78
79template<storm::dd::DdType Type, typename ValueType>
81 uint_fast64_t nondeterminismVariableCount = 0;
82 for (auto const& metaVariable : this->getNondeterminismVariables()) {
83 nondeterminismVariableCount += this->getManager().getMetaVariable(metaVariable).getNumberOfDdVariables();
84 }
86 out << ", nondeterminism: " << this->getNondeterminismVariables().size() << " meta variables (" << nondeterminismVariableCount << " DD variables)";
88
89template<storm::dd::DdType Type, typename ValueType>
91 for (auto& rewardModel : this->getRewardModels()) {
92 rewardModel.second.reduceToStateBasedRewards(this->getTransitionMatrix(), this->getRowVariables(), this->getColumnVariables(), false);
93 }
95
96template<storm::dd::DdType Type, typename ValueType>
98 // Prepare the mask of illegal nondeterministic choices.
99 illegalMask = !(this->getTransitionMatrix().notZero().existsAbstract(this->getColumnVariables())) && this->getReachableStates();
100}
102template<storm::dd::DdType Type, typename ValueType>
104 if (!keepNondeterminism) {
105 return this->getTransitionMatrix().notZero().existsAbstract(this->getNondeterminismVariables());
106 } else {
108 }
109}
111// Explicitly instantiate the template class.
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:42
virtual void printDdVariableInformationToStream(std::ostream &out) const
Prints information about the DD variables to the specified stream.
Definition Model.cpp:358
virtual storm::dd::Bdd< Type > getQualitativeTransitionMatrix(bool keepNondeterminism=true) const
Retrieves the matrix qualitatively (i.e.
Definition Model.cpp:182
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.