#include "src/modelchecker/results/SymbolicQuantitativeCheckResult.h" #include "src/modelchecker/results/SymbolicQualitativeCheckResult.h" #include "src/storage/dd/DdManager.h" #include "src/storage/dd/cudd/CuddAddIterator.h" #include "src/exceptions/InvalidOperationException.h" #include "src/exceptions/NotImplementedException.h" #include "src/utility/macros.h" #include "src/utility/constants.h" namespace storm { namespace modelchecker { template SymbolicQuantitativeCheckResult::SymbolicQuantitativeCheckResult(storm::dd::Bdd const& reachableStates, storm::dd::Add const& values) : reachableStates(reachableStates), states(reachableStates), values(values) { // Intentionally left empty. } template std::unique_ptr SymbolicQuantitativeCheckResult::compareAgainstBound(storm::logic::ComparisonType comparisonType, ValueType const& bound) const { storm::dd::Bdd states; if (comparisonType == storm::logic::ComparisonType::Less) { states = values.less(bound); } else if (comparisonType == storm::logic::ComparisonType::LessEqual) { states = values.lessOrEqual(bound); } else if (comparisonType == storm::logic::ComparisonType::Greater) { states = values.greater(bound); } else if (comparisonType == storm::logic::ComparisonType::GreaterEqual) { states = values.greaterOrEqual(bound); } return std::unique_ptr>(new SymbolicQualitativeCheckResult(reachableStates, states)); } template bool SymbolicQuantitativeCheckResult::isSymbolic() const { return true; } template bool SymbolicQuantitativeCheckResult::isResultForAllStates() const { return states == reachableStates; } template bool SymbolicQuantitativeCheckResult::isSymbolicQuantitativeCheckResult() const { return true; } template storm::dd::Add const& SymbolicQuantitativeCheckResult::getValueVector() const { return values; } template std::ostream& SymbolicQuantitativeCheckResult::writeToStream(std::ostream& out) const { out << "["; if (this->values.isZero()) { out << "0"; } else { bool first = true; for (auto valuationValuePair : this->values) { if (!first) { out << ", "; } else { first = false; } out << valuationValuePair.second; } } out << "]"; return out; } template void SymbolicQuantitativeCheckResult::filter(QualitativeCheckResult const& filter) { STORM_LOG_THROW(filter.isSymbolicQualitativeCheckResult(), storm::exceptions::InvalidOperationException, "Cannot filter symbolic check result with non-symbolic filter."); this->states &= filter.asSymbolicQualitativeCheckResult().getTruthValuesVector(); this->values *= filter.asSymbolicQualitativeCheckResult().getTruthValuesVector().template toAdd(); } template ValueType SymbolicQuantitativeCheckResult::getMin() const { // In order to not get false zeros, we need to set the values of all states whose values is not stored // symbolically to infinity. return states.ite(this->values, states.getDdManager().getConstant(storm::utility::infinity())).getMin(); } template ValueType SymbolicQuantitativeCheckResult::getMax() const { return this->values.getMax(); } template ValueType SymbolicQuantitativeCheckResult::average() const { return this->sum() / this->states.getNonZeroCount(); } template ValueType SymbolicQuantitativeCheckResult::sum() const { return this->values.sumAbstract(this->values.getContainedMetaVariables()).getValue(); } template void SymbolicQuantitativeCheckResult::oneMinus() { storm::dd::Add one = values.getDdManager().template getAddOne(); values = one - values; } // Explicitly instantiate the class. template class SymbolicQuantitativeCheckResult; template class SymbolicQuantitativeCheckResult; } }