Storm 1.14.0.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 (storm::utility::isInfinity(value)) {
87 out << "inf";
88 } else if (storm::utility::isNegativeInfinity(value)) {
89 out << "-inf";
90 } else {
91 out << value;
92 if (std::is_same_v<ValueType, storm::RationalNumber> || std::is_same_v<ValueType, storm::ExtendedRationalNumber>) {
93 out << " (approx. " << storm::utility::convertNumber<double>(value) << ")";
94 }
95 }
96}
97
98template<typename ValueType>
99void printRange(std::ostream& out, ValueType const& min, ValueType const& max) {
100 out << "[";
101 print(out, min);
102 out << ", ";
103 print(out, max);
104 out << "]";
105 if (std::is_same_v<ValueType, storm::RationalNumber> || std::is_same_v<ValueType, storm::ExtendedRationalNumber>) {
106 out << " (approx. [";
108 out << "inf";
109 } else {
110 out << storm::utility::convertNumber<double>(min);
111 }
112 out << ", ";
114 out << "inf";
115 } else {
116 out << storm::utility::convertNumber<double>(max);
117 }
118 out << "])";
119 }
120 out << " (range)";
121}
122
123template<storm::dd::DdType Type, typename ValueType>
125 uint64_t totalNumberOfStates = states.getNonZeroCount();
126 bool minMaxSupported = std::is_same<ValueType, double>::value || std::is_same<ValueType, storm::RationalNumber>::value;
127 bool printAsRange = false;
128
129 if (totalNumberOfStates == 1) {
130 print(out, storm::utility::fromSentinel(this->values.sumAbstract(this->values.getContainedMetaVariables()).getValue()));
131 } else if (states.getNonZeroCount() >= 10 || !minMaxSupported) {
132 printAsRange = true;
133 } else {
134 out << "{";
135 if (this->values.isZero()) {
136 out << "0";
137 } else {
138 bool first = true;
139 for (auto valuationValuePair : this->values) {
140 if (!first) {
141 out << ", ";
142 } else {
143 first = false;
144 }
145 print(out, storm::utility::fromSentinel(valuationValuePair.second));
146 }
147 if (states.getNonZeroCount() != this->values.getNonZeroCount()) {
148 out << ", 0";
149 }
150 }
151 out << "}";
152 }
153
154 if (printAsRange) {
155 printRange(out, this->getMin(), this->getMax());
156 }
157 return out;
158}
159
160template<storm::dd::DdType Type, typename ValueType>
162 STORM_LOG_THROW(filter.isSymbolicQualitativeCheckResult(), storm::exceptions::InvalidOperationException,
163 "Cannot filter symbolic check result with non-symbolic filter.");
164 this->states &= filter.asSymbolicQualitativeCheckResult<Type>().getTruthValuesVector();
165 this->values *= filter.asSymbolicQualitativeCheckResult<Type>().getTruthValuesVector().template toAdd<ValueType>();
166}
167
168template<storm::dd::DdType Type, typename ValueType>
170 // In order to not get false zeros, we need to set the values of all states whose values is not stored
171 // symbolically to infinity.
172 return storm::utility::fromSentinel(states.ite(this->values, states.getDdManager().getConstant(storm::utility::infinity<ValueType>())).getMin());
173}
174
175template<storm::dd::DdType Type, typename ValueType>
179
180template<storm::dd::DdType Type, typename ValueType>
184
185template<storm::dd::DdType Type, typename ValueType>
187 // The sentinel has to be recognised before the leaves are added up: two of them would sum to twice the sentinel,
188 // which is a value like any other. This goes away together with the sentinel on the decision diagram leaves.
189 if (!this->values.equals(this->values.getDdManager().getConstant(storm::utility::infinity<ValueType>())).isZero()) {
191 }
192 return storm::utility::fromSentinel(this->values.sumAbstract(this->values.getContainedMetaVariables()).getValue());
193}
194
195template<storm::dd::DdType Type, typename ValueType>
197 storm::dd::Add<Type, ValueType> one = values.getDdManager().template getAddOne<ValueType>();
198 values = one - values;
199}
200
201// Explicitly instantiate the class.
204
207} // namespace modelchecker
208} // 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
typename QuantitativeCheckResult< ValueType >::ExtendedValueType ExtendedValueType
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:39
void print(std::ostream &out, ValueType const &value)
void printRange(std::ostream &out, ValueType const &min, ValueType const &max)
ExtendedValueType< ValueType > positiveInfinity()
ExtendedValueType< ValueType > fromSentinel(ValueType &&value)
Recognises the value that storm::utility::infinity still yields for the value types that have no infi...
bool isNegativeInfinity(ExtendedNumber< ValueType > const &number)
ValueType infinity()
Definition constants.cpp:31
bool isInfinity(ValueType const &a)
TargetType convertNumber(SourceType const &number)