Storm 1.11.1.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
SymbolicQuantitativeCheckResult.cpp
Go to the documentation of this file.
2
9
10namespace storm {
11namespace modelchecker {
12template<storm::dd::DdType Type, typename ValueType>
15 : reachableStates(reachableStates), states(reachableStates), values(values) {
16 // Intentionally left empty.
17}
18
19template<storm::dd::DdType Type, typename ValueType>
21 storm::dd::Bdd<Type> const& states,
23 : reachableStates(reachableStates), states(states), values(values) {
24 // Intentionally left empty.
25}
26
27template<storm::dd::DdType Type, typename ValueType>
29 : reachableStates(other.getReachableStates()), states(other.getStates()), values(other.getTruthValuesVector().template toAdd<ValueType>()) {
30 // Intentionally left empty.
31}
32
33template<storm::dd::DdType Type, typename ValueType>
34std::unique_ptr<CheckResult> SymbolicQuantitativeCheckResult<Type, ValueType>::clone() const {
35 return std::make_unique<SymbolicQuantitativeCheckResult<Type, ValueType>>(this->reachableStates, this->states, this->values);
36}
37
38template<storm::dd::DdType Type, typename ValueType>
40 ValueType const& bound) const {
41 storm::dd::Bdd<Type> states = this->states;
42 if (comparisonType == storm::logic::ComparisonType::Less) {
43 states &= values.less(bound);
44 } else if (comparisonType == storm::logic::ComparisonType::LessEqual) {
45 states &= values.lessOrEqual(bound);
46 } else if (comparisonType == storm::logic::ComparisonType::Greater) {
47 states &= values.greater(bound);
48 } else if (comparisonType == storm::logic::ComparisonType::GreaterEqual) {
49 states &= values.greaterOrEqual(bound);
50 }
51 return std::unique_ptr<SymbolicQualitativeCheckResult<Type>>(new SymbolicQualitativeCheckResult<Type>(reachableStates, this->states, states));
52}
53
54template<storm::dd::DdType Type, typename ValueType>
58
59template<storm::dd::DdType Type, typename ValueType>
61 return states == reachableStates;
62}
63
64template<storm::dd::DdType Type, typename ValueType>
68
69template<storm::dd::DdType Type, typename ValueType>
73
74template<storm::dd::DdType Type, typename ValueType>
78
79template<storm::dd::DdType Type, typename ValueType>
83
84template<typename ValueType>
85void print(std::ostream& out, ValueType const& value) {
86 if (value == storm::utility::infinity<ValueType>()) {
87 out << "inf";
88 } else {
89 out << value;
90 if (std::is_same<ValueType, storm::RationalNumber>::value) {
91 out << " (approx. " << storm::utility::convertNumber<double>(value) << ")";
92 }
93 }
94}
95
96template<typename ValueType>
97void printRange(std::ostream& out, ValueType const& min, ValueType const& max) {
98 out << "[";
99 if (min == storm::utility::infinity<ValueType>()) {
100 out << "inf";
101 } else {
102 out << min;
103 }
104 out << ", ";
105 if (max == storm::utility::infinity<ValueType>()) {
106 out << "inf";
107 } else {
108 out << max;
109 }
110 out << "]";
111 if (std::is_same<ValueType, storm::RationalNumber>::value) {
112 out << " (approx. [";
113 if (min == storm::utility::infinity<ValueType>()) {
114 out << "inf";
115 } else {
116 out << storm::utility::convertNumber<double>(min);
117 }
118 out << ", ";
119 if (max == storm::utility::infinity<ValueType>()) {
120 out << "inf";
121 } else {
122 out << storm::utility::convertNumber<double>(max);
123 }
124 out << "])";
125 }
126 out << " (range)";
127}
128
129template<storm::dd::DdType Type, typename ValueType>
131 uint64_t totalNumberOfStates = states.getNonZeroCount();
132 bool minMaxSupported = std::is_same<ValueType, double>::value || std::is_same<ValueType, storm::RationalNumber>::value;
133 bool printAsRange = false;
134
135 if (totalNumberOfStates == 1) {
136 print(out, this->values.sumAbstract(this->values.getContainedMetaVariables()).getValue());
137 } else if (states.getNonZeroCount() >= 10 || !minMaxSupported) {
138 printAsRange = true;
139 } else {
140 out << "{";
141 if (this->values.isZero()) {
142 out << "0";
143 } else {
144 bool first = true;
145 for (auto valuationValuePair : this->values) {
146 if (!first) {
147 out << ", ";
148 } else {
149 first = false;
150 }
151 print(out, valuationValuePair.second);
152 }
153 if (states.getNonZeroCount() != this->values.getNonZeroCount()) {
154 out << ", 0";
155 }
156 }
157 out << "}";
158 }
159
160 if (printAsRange) {
161 printRange(out, this->getMin(), this->getMax());
162 }
163 return out;
164}
165
166template<storm::dd::DdType Type, typename ValueType>
168 STORM_LOG_THROW(filter.isSymbolicQualitativeCheckResult(), storm::exceptions::InvalidOperationException,
169 "Cannot filter symbolic check result with non-symbolic filter.");
170 this->states &= filter.asSymbolicQualitativeCheckResult<Type>().getTruthValuesVector();
171 this->values *= filter.asSymbolicQualitativeCheckResult<Type>().getTruthValuesVector().template toAdd<ValueType>();
172}
173
174template<storm::dd::DdType Type, typename ValueType>
176 // In order to not get false zeros, we need to set the values of all states whose values is not stored
177 // symbolically to infinity.
178 return states.ite(this->values, states.getDdManager().getConstant(storm::utility::infinity<ValueType>())).getMin();
179}
180
181template<storm::dd::DdType Type, typename ValueType>
183 return this->values.getMax();
184}
185
186template<storm::dd::DdType Type, typename ValueType>
188 return this->sum() / storm::utility::convertNumber<ValueType>(this->states.getNonZeroCount());
189}
190
191template<storm::dd::DdType Type, typename ValueType>
193 return this->values.sumAbstract(this->values.getContainedMetaVariables()).getValue();
194}
195
196template<storm::dd::DdType Type, typename ValueType>
198 storm::dd::Add<Type, ValueType> one = values.getDdManager().template getAddOne<ValueType>();
199 values = one - values;
200}
201
202// Explicitly instantiate the class.
205
208} // namespace modelchecker
209} // namespace storm
virtual std::unique_ptr< CheckResult > clone() const override
storm::dd::Add< Type, ValueType > const & getValueVector() const
virtual void filter(QualitativeCheckResult const &filter) override
Filters the current result wrt.
virtual std::unique_ptr< CheckResult > compareAgainstBound(storm::logic::ComparisonType comparisonType, ValueType const &bound) const override
virtual std::ostream & writeToStream(std::ostream &out) const override
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:30
void print(std::ostream &out, ValueType const &value)
void printRange(std::ostream &out, ValueType const &min, ValueType const &max)
ValueType max(ValueType const &first, ValueType const &second)
ValueType min(ValueType const &first, ValueType const &second)