Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
SymbolicQuantitativeCheckResult.cpp
Go to the documentation of this file.
3
5
8
10
14
15namespace storm {
16namespace modelchecker {
17template<storm::dd::DdType Type, typename ValueType>
20 : reachableStates(reachableStates), states(reachableStates), values(values) {
21 // Intentionally left empty.
22}
23
24template<storm::dd::DdType Type, typename ValueType>
26 storm::dd::Bdd<Type> const& states,
28 : reachableStates(reachableStates), states(states), values(values) {
29 // Intentionally left empty.
30}
31
32template<storm::dd::DdType Type, typename ValueType>
34 : reachableStates(other.getReachableStates()), states(other.getStates()), values(other.getTruthValuesVector().template toAdd<ValueType>()) {
35 // Intentionally left empty.
36}
37
38template<storm::dd::DdType Type, typename ValueType>
39std::unique_ptr<CheckResult> SymbolicQuantitativeCheckResult<Type, ValueType>::clone() const {
40 return std::make_unique<SymbolicQuantitativeCheckResult<Type, ValueType>>(this->reachableStates, this->states, this->values);
41}
42
43template<storm::dd::DdType Type, typename ValueType>
45 ValueType const& bound) const {
46 storm::dd::Bdd<Type> states = this->states;
47 if (comparisonType == storm::logic::ComparisonType::Less) {
48 states &= values.less(bound);
49 } else if (comparisonType == storm::logic::ComparisonType::LessEqual) {
50 states &= values.lessOrEqual(bound);
51 } else if (comparisonType == storm::logic::ComparisonType::Greater) {
52 states &= values.greater(bound);
53 } else if (comparisonType == storm::logic::ComparisonType::GreaterEqual) {
54 states &= values.greaterOrEqual(bound);
55 }
56 return std::unique_ptr<SymbolicQualitativeCheckResult<Type>>(new SymbolicQualitativeCheckResult<Type>(reachableStates, this->states, states));
57}
58
59template<storm::dd::DdType Type, typename ValueType>
63
64template<storm::dd::DdType Type, typename ValueType>
66 return states == reachableStates;
67}
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<storm::dd::DdType Type, typename ValueType>
88
89template<typename ValueType>
90void print(std::ostream& out, ValueType const& value) {
91 if (value == storm::utility::infinity<ValueType>()) {
92 out << "inf";
93 } else {
94 out << value;
95 if (std::is_same<ValueType, storm::RationalNumber>::value) {
96 out << " (approx. " << storm::utility::convertNumber<double>(value) << ")";
97 }
98 }
99}
100
101template<typename ValueType>
102void printRange(std::ostream& out, ValueType const& min, ValueType const& max) {
103 out << "[";
104 if (min == storm::utility::infinity<ValueType>()) {
105 out << "inf";
106 } else {
107 out << min;
108 }
109 out << ", ";
110 if (max == storm::utility::infinity<ValueType>()) {
111 out << "inf";
112 } else {
113 out << max;
114 }
115 out << "]";
116 if (std::is_same<ValueType, storm::RationalNumber>::value) {
117 out << " (approx. [";
118 if (min == storm::utility::infinity<ValueType>()) {
119 out << "inf";
120 } else {
121 out << storm::utility::convertNumber<double>(min);
122 }
123 out << ", ";
124 if (max == storm::utility::infinity<ValueType>()) {
125 out << "inf";
126 } else {
127 out << storm::utility::convertNumber<double>(max);
128 }
129 out << "])";
130 }
131 out << " (range)";
132}
133
134template<storm::dd::DdType Type, typename ValueType>
136 uint64_t totalNumberOfStates = states.getNonZeroCount();
137 bool minMaxSupported = std::is_same<ValueType, double>::value || std::is_same<ValueType, storm::RationalNumber>::value;
138 bool printAsRange = false;
139
140 if (totalNumberOfStates == 1) {
141 print(out, this->values.sumAbstract(this->values.getContainedMetaVariables()).getValue());
142 } else if (states.getNonZeroCount() >= 10 || !minMaxSupported) {
143 printAsRange = true;
144 } else {
145 out << "{";
146 if (this->values.isZero()) {
147 out << "0";
148 } else {
149 bool first = true;
150 for (auto valuationValuePair : this->values) {
151 if (!first) {
152 out << ", ";
153 } else {
154 first = false;
155 }
156 print(out, valuationValuePair.second);
157 }
158 if (states.getNonZeroCount() != this->values.getNonZeroCount()) {
159 out << ", 0";
160 }
161 }
162 out << "}";
163 }
164
165 if (printAsRange) {
166 printRange(out, this->getMin(), this->getMax());
167 }
168 return out;
169}
170
171template<storm::dd::DdType Type, typename ValueType>
173 STORM_LOG_THROW(filter.isSymbolicQualitativeCheckResult(), storm::exceptions::InvalidOperationException,
174 "Cannot filter symbolic check result with non-symbolic filter.");
175 this->states &= filter.asSymbolicQualitativeCheckResult<Type>().getTruthValuesVector();
176 this->values *= filter.asSymbolicQualitativeCheckResult<Type>().getTruthValuesVector().template toAdd<ValueType>();
177}
178
179template<storm::dd::DdType Type, typename ValueType>
181 // In order to not get false zeros, we need to set the values of all states whose values is not stored
182 // symbolically to infinity.
183 return states.ite(this->values, states.getDdManager().getConstant(storm::utility::infinity<ValueType>())).getMin();
184}
185
186template<storm::dd::DdType Type, typename ValueType>
188 return this->values.getMax();
189}
190
191template<storm::dd::DdType Type, typename ValueType>
193 return this->sum() / storm::utility::convertNumber<ValueType>(this->states.getNonZeroCount());
194}
195
196template<storm::dd::DdType Type, typename ValueType>
198 return this->values.sumAbstract(this->values.getContainedMetaVariables()).getValue();
199}
200
201template<storm::dd::DdType Type, typename ValueType>
203 storm::dd::Add<Type, ValueType> one = values.getDdManager().template getAddOne<ValueType>();
204 values = one - values;
205}
206
207// Explicitly instantiate the class.
210
213} // namespace modelchecker
214} // 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)
LabParser.cpp.
Definition cli.cpp:18