Browse Source

Merge branch 'mtbddIntegration' of https://sselab.de/lab9/private/git/storm into mtbddIntegration

Former-commit-id: 115d7a6c3b
main
dehnert 10 years ago
parent
commit
c7f262bf15
  1. 1
      src/logic/Formula.h
  2. 19
      src/modelchecker/AbstractModelChecker.cpp
  3. 73
      src/modelchecker/results/CheckResult.cpp
  4. 45
      src/modelchecker/results/CheckResult.h
  5. 65
      src/modelchecker/results/ExplicitQualitativeCheckResult.cpp
  6. 9
      src/modelchecker/results/ExplicitQualitativeCheckResult.h
  7. 49
      src/modelchecker/results/ExplicitQuantitativeCheckResult.cpp
  8. 7
      src/modelchecker/results/ExplicitQuantitativeCheckResult.h
  9. 15
      src/modelchecker/results/QualitativeCheckResult.cpp
  10. 4
      src/modelchecker/results/QualitativeCheckResult.h
  11. 13
      src/modelchecker/results/QuantitativeCheckResult.cpp
  12. 3
      src/modelchecker/results/QuantitativeCheckResult.h
  13. 55
      src/modelchecker/results/SymbolicQualitativeCheckResult.cpp
  14. 45
      src/modelchecker/results/SymbolicQualitativeCheckResult.h
  15. 0
      src/modelchecker/results/SymbolicQuantitativeCheckResult.cpp
  16. 43
      src/modelchecker/results/SymbolicQuantitativeCheckResult.h

1
src/logic/Formula.h

@ -2,6 +2,7 @@
#define STORM_LOGIC_FORMULA_H_ #define STORM_LOGIC_FORMULA_H_
#include <memory> #include <memory>
#include <vector>
#include <iostream> #include <iostream>
#include "src/modelchecker/results/CheckResult.h" #include "src/modelchecker/results/CheckResult.h"

19
src/modelchecker/AbstractModelChecker.cpp

@ -1,5 +1,7 @@
#include "src/modelchecker/AbstractModelChecker.h" #include "src/modelchecker/AbstractModelChecker.h"
#include "src/modelchecker/results/QualitativeCheckResult.h"
#include "src/modelchecker/results/QuantitativeCheckResult.h"
#include "src/utility/constants.h" #include "src/utility/constants.h"
#include "src/utility/macros.h" #include "src/utility/macros.h"
#include "src/exceptions/NotImplementedException.h" #include "src/exceptions/NotImplementedException.h"
@ -131,10 +133,12 @@ namespace storm {
std::unique_ptr<CheckResult> leftResult = this->check(stateFormula.getLeftSubformula().asStateFormula()); std::unique_ptr<CheckResult> leftResult = this->check(stateFormula.getLeftSubformula().asStateFormula());
std::unique_ptr<CheckResult> rightResult = this->check(stateFormula.getRightSubformula().asStateFormula()); std::unique_ptr<CheckResult> rightResult = this->check(stateFormula.getRightSubformula().asStateFormula());
STORM_LOG_THROW(leftResult->isQualitative() && rightResult->isQualitative(), storm::exceptions::InternalTypeErrorException, "Expected qualitative results.");
if (stateFormula.isAnd()) { if (stateFormula.isAnd()) {
*leftResult &= *rightResult; leftResult->asQualitativeCheckResult() &= rightResult->asQualitativeCheckResult();
} else if (stateFormula.isOr()) { } else if (stateFormula.isOr()) {
*leftResult |= *rightResult; leftResult->asQualitativeCheckResult() |= rightResult->asQualitativeCheckResult();
} else { } else {
STORM_LOG_THROW(false, storm::exceptions::InvalidArgumentException, "The given formula '" << stateFormula << "' is invalid."); STORM_LOG_THROW(false, storm::exceptions::InvalidArgumentException, "The given formula '" << stateFormula << "' is invalid.");
} }
@ -166,7 +170,7 @@ namespace storm {
if (stateFormula.hasBound()) { if (stateFormula.hasBound()) {
STORM_LOG_THROW(result->isQuantitative(), storm::exceptions::InvalidOperationException, "Unable to perform comparison operation on non-quantitative result."); STORM_LOG_THROW(result->isQuantitative(), storm::exceptions::InvalidOperationException, "Unable to perform comparison operation on non-quantitative result.");
return result->compareAgainstBound(stateFormula.getComparisonType(), stateFormula.getBound()); return result->asQuantitativeCheckResult().compareAgainstBound(stateFormula.getComparisonType(), stateFormula.getBound());
} else { } else {
return result; return result;
} }
@ -192,7 +196,7 @@ namespace storm {
if (stateFormula.hasBound()) { if (stateFormula.hasBound()) {
STORM_LOG_THROW(result->isQuantitative(), storm::exceptions::InvalidOperationException, "Unable to perform comparison operation on non-quantitative result."); STORM_LOG_THROW(result->isQuantitative(), storm::exceptions::InvalidOperationException, "Unable to perform comparison operation on non-quantitative result.");
return result->compareAgainstBound(stateFormula.getComparisonType(), stateFormula.getBound()); return result->asQuantitativeCheckResult().compareAgainstBound(stateFormula.getComparisonType(), stateFormula.getBound());
} else { } else {
return result; return result;
} }
@ -218,7 +222,7 @@ namespace storm {
if (stateFormula.hasBound()) { if (stateFormula.hasBound()) {
STORM_LOG_THROW(result->isQuantitative(), storm::exceptions::InvalidOperationException, "Unable to perform comparison operation on non-quantitative result."); STORM_LOG_THROW(result->isQuantitative(), storm::exceptions::InvalidOperationException, "Unable to perform comparison operation on non-quantitative result.");
return result->compareAgainstBound(stateFormula.getComparisonType(), stateFormula.getBound()); return result->asQuantitativeCheckResult().compareAgainstBound(stateFormula.getComparisonType(), stateFormula.getBound());
} else { } else {
return result; return result;
} }
@ -235,7 +239,7 @@ namespace storm {
std::unique_ptr<CheckResult> result; std::unique_ptr<CheckResult> result;
if (stateFormula.hasBound()) { if (stateFormula.hasBound()) {
return result->compareAgainstBound(stateFormula.getComparisonType(), stateFormula.getBound()); return result->asQuantitativeCheckResult().compareAgainstBound(stateFormula.getComparisonType(), stateFormula.getBound());
} else { } else {
return result; return result;
} }
@ -243,8 +247,9 @@ namespace storm {
std::unique_ptr<CheckResult> AbstractModelChecker::checkUnaryBooleanStateFormula(storm::logic::UnaryBooleanStateFormula const& stateFormula) { std::unique_ptr<CheckResult> AbstractModelChecker::checkUnaryBooleanStateFormula(storm::logic::UnaryBooleanStateFormula const& stateFormula) {
std::unique_ptr<CheckResult> subResult = this->check(stateFormula.getSubformula()); std::unique_ptr<CheckResult> subResult = this->check(stateFormula.getSubformula());
STORM_LOG_THROW(subResult->isQualitative(), storm::exceptions::InternalTypeErrorException, "Expected qualitative result.");
if (stateFormula.isNot()) { if (stateFormula.isNot()) {
subResult->complement(); subResult->asQualitativeCheckResult().complement();
} else { } else {
STORM_LOG_THROW(false, storm::exceptions::InvalidArgumentException, "The given formula '" << stateFormula << "' is invalid."); STORM_LOG_THROW(false, storm::exceptions::InvalidArgumentException, "The given formula '" << stateFormula << "' is invalid.");
} }

73
src/modelchecker/results/CheckResult.cpp

@ -3,31 +3,22 @@
#include "storm-config.h" #include "storm-config.h"
#include "src/adapters/CarlAdapter.h" #include "src/adapters/CarlAdapter.h"
#include "src/storage/dd/CuddDd.h"
#include "src/modelchecker/results/ExplicitQualitativeCheckResult.h" #include "src/modelchecker/results/ExplicitQualitativeCheckResult.h"
#include "src/modelchecker/results/ExplicitQuantitativeCheckResult.h" #include "src/modelchecker/results/ExplicitQuantitativeCheckResult.h"
#include "src/modelchecker/results/SymbolicQualitativeCheckResult.h"
#include "src/modelchecker/results/SymbolicQuantitativeCheckResult.h"
#include "src/utility/macros.h" #include "src/utility/macros.h"
#include "src/exceptions/InvalidOperationException.h" #include "src/exceptions/InvalidOperationException.h"
namespace storm { namespace storm {
namespace modelchecker { namespace modelchecker {
CheckResult& CheckResult::operator&=(CheckResult const& other) { bool CheckResult::isExplicit() const {
STORM_LOG_THROW(false, storm::exceptions::InvalidOperationException, "Unable to perform logical 'and' on the two check results."); return false;
}
CheckResult& CheckResult::operator|=(CheckResult const& other) {
STORM_LOG_THROW(false, storm::exceptions::InvalidOperationException, "Unable to perform logical 'or' on the two check results.");
}
void CheckResult::complement() {
STORM_LOG_THROW(false, storm::exceptions::InvalidOperationException, "Unable to perform logical 'not' on the check result.");
}
std::unique_ptr<CheckResult> CheckResult::compareAgainstBound(storm::logic::ComparisonType comparisonType, double bound) const {
STORM_LOG_THROW(false, storm::exceptions::InvalidOperationException, "Unable to perform comparison against bound on the check result.");
} }
bool CheckResult::isExplicit() const { bool CheckResult::isSymbolic() const {
return false; return false;
} }
@ -55,7 +46,15 @@ namespace storm {
bool CheckResult::isExplicitQuantitativeCheckResult() const { bool CheckResult::isExplicitQuantitativeCheckResult() const {
return false; return false;
} }
bool CheckResult::isSymbolicQualitativeCheckResult() const {
return false;
}
bool CheckResult::isSymbolicQuantitativeCheckResult() const {
return false;
}
ExplicitQualitativeCheckResult& CheckResult::asExplicitQualitativeCheckResult() { ExplicitQualitativeCheckResult& CheckResult::asExplicitQualitativeCheckResult() {
return dynamic_cast<ExplicitQualitativeCheckResult&>(*this); return dynamic_cast<ExplicitQualitativeCheckResult&>(*this);
} }
@ -74,25 +73,43 @@ namespace storm {
return dynamic_cast<ExplicitQuantitativeCheckResult<ValueType> const&>(*this); return dynamic_cast<ExplicitQuantitativeCheckResult<ValueType> const&>(*this);
} }
template<typename ValueType> QuantitativeCheckResult& CheckResult::asQuantitativeCheckResult() {
QuantitativeCheckResult<ValueType>& CheckResult::asQuantitativeCheckResult() { return dynamic_cast<QuantitativeCheckResult&>(*this);
return dynamic_cast<QuantitativeCheckResult<ValueType>&>(*this);
} }
template<typename ValueType> QuantitativeCheckResult const& CheckResult::asQuantitativeCheckResult() const {
QuantitativeCheckResult<ValueType> const& CheckResult::asQuantitativeCheckResult() const { return dynamic_cast<QuantitativeCheckResult const&>(*this);
return dynamic_cast<QuantitativeCheckResult<ValueType> const&>(*this); }
template <storm::dd::DdType Type>
SymbolicQualitativeCheckResult<Type>& CheckResult::asSymbolicQualitativeCheckResult() {
return dynamic_cast<SymbolicQualitativeCheckResult<Type>&>(*this);
}
template <storm::dd::DdType Type>
SymbolicQualitativeCheckResult<Type> const& CheckResult::asSymbolicQualitativeCheckResult() const {
return dynamic_cast<SymbolicQualitativeCheckResult<Type> const&>(*this);
}
template <storm::dd::DdType Type>
SymbolicQuantitativeCheckResult<Type>& CheckResult::asSymbolicQuantitativeCheckResult() {
return dynamic_cast<SymbolicQuantitativeCheckResult<Type>&>(*this);
}
template <storm::dd::DdType Type>
SymbolicQuantitativeCheckResult<Type> const& CheckResult::asSymbolicQuantitativeCheckResult() const {
return dynamic_cast<SymbolicQuantitativeCheckResult<Type> const&>(*this);
} }
// Explicitly instantiate the template functions. // Explicitly instantiate the template functions.
template QuantitativeCheckResult<double>& CheckResult::asQuantitativeCheckResult();
template QuantitativeCheckResult<double> const& CheckResult::asQuantitativeCheckResult() const;
template ExplicitQuantitativeCheckResult<double>& CheckResult::asExplicitQuantitativeCheckResult(); template ExplicitQuantitativeCheckResult<double>& CheckResult::asExplicitQuantitativeCheckResult();
template ExplicitQuantitativeCheckResult<double> const& CheckResult::asExplicitQuantitativeCheckResult() const; template ExplicitQuantitativeCheckResult<double> const& CheckResult::asExplicitQuantitativeCheckResult() const;
template SymbolicQualitativeCheckResult<storm::dd::DdType::CUDD>& CheckResult::asSymbolicQualitativeCheckResult();
template SymbolicQualitativeCheckResult<storm::dd::DdType::CUDD> const& CheckResult::asSymbolicQualitativeCheckResult() const;
template SymbolicQuantitativeCheckResult<storm::dd::DdType::CUDD>& CheckResult::asSymbolicQuantitativeCheckResult();
template SymbolicQuantitativeCheckResult<storm::dd::DdType::CUDD> const& CheckResult::asSymbolicQuantitativeCheckResult() const;
#ifdef STORM_HAVE_CARL #ifdef STORM_HAVE_CARL
template QuantitativeCheckResult<storm::RationalFunction>& CheckResult::asQuantitativeCheckResult();
template QuantitativeCheckResult<storm::RationalFunction> const& CheckResult::asQuantitativeCheckResult() const;
template ExplicitQuantitativeCheckResult<storm::RationalFunction>& CheckResult::asExplicitQuantitativeCheckResult(); template ExplicitQuantitativeCheckResult<storm::RationalFunction>& CheckResult::asExplicitQuantitativeCheckResult();
template ExplicitQuantitativeCheckResult<storm::RationalFunction> const& CheckResult::asExplicitQuantitativeCheckResult() const; template ExplicitQuantitativeCheckResult<storm::RationalFunction> const& CheckResult::asExplicitQuantitativeCheckResult() const;
#endif #endif

45
src/modelchecker/results/CheckResult.h

@ -4,40 +4,46 @@
#include <iostream> #include <iostream>
#include <memory> #include <memory>
#include "src/storage/BitVector.h" #include "src/storage/dd/DdType.h"
#include "src/logic/ComparisonType.h" #include "src/logic/ComparisonType.h"
namespace storm { namespace storm {
namespace modelchecker { namespace modelchecker {
// Forward-declare the existing subclasses. // Forward-declare the existing subclasses.
class QualitativeCheckResult; class QualitativeCheckResult;
template <typename ValueType> class QuantitativeCheckResult; class QuantitativeCheckResult;
class ExplicitQualitativeCheckResult; class ExplicitQualitativeCheckResult;
template <typename ValueType> class ExplicitQuantitativeCheckResult; template <typename ValueType> class ExplicitQuantitativeCheckResult;
template <storm::dd::DdType Type> class SymbolicQualitativeCheckResult;
template <storm::dd::DdType Type> class SymbolicQuantitativeCheckResult;
// The base class of all check results. // The base class of all check results.
class CheckResult { class CheckResult {
public: public:
virtual CheckResult& operator&=(CheckResult const& other); /*!
virtual CheckResult& operator|=(CheckResult const& other); * Filters the current result wrt. to the filter, i.e. only keeps the entries that are selected by the filter.
virtual void complement(); * This means that the filter must be a qualitative result of proper type (symbolic/explicit).
virtual std::unique_ptr<CheckResult> compareAgainstBound(storm::logic::ComparisonType comparisonType, double bound) const; *
* @param filter A qualitative result that serves as a filter.
*/
virtual void filter(QualitativeCheckResult const& filter) = 0;
// Methods to retrieve the actual type of the check result.
virtual bool isExplicit() const; virtual bool isExplicit() const;
virtual bool isSymbolic() const;
virtual bool isQuantitative() const; virtual bool isQuantitative() const;
virtual bool isQualitative() const; virtual bool isQualitative() const;
virtual bool isResultForAllStates() const;
virtual bool isExplicitQualitativeCheckResult() const; virtual bool isExplicitQualitativeCheckResult() const;
virtual bool isExplicitQuantitativeCheckResult() const; virtual bool isExplicitQuantitativeCheckResult() const;
virtual bool isSymbolicQualitativeCheckResult() const;
virtual bool isSymbolicQuantitativeCheckResult() const;
virtual bool isResultForAllStates() const;
QualitativeCheckResult& asQualitativeCheckResult(); QualitativeCheckResult& asQualitativeCheckResult();
QualitativeCheckResult const& asQualitativeCheckResult() const; QualitativeCheckResult const& asQualitativeCheckResult() const;
template<typename ValueType> QuantitativeCheckResult& asQuantitativeCheckResult();
QuantitativeCheckResult<ValueType>& asQuantitativeCheckResult(); QuantitativeCheckResult const& asQuantitativeCheckResult() const;
template<typename ValueType>
QuantitativeCheckResult<ValueType> const& asQuantitativeCheckResult() const;
ExplicitQualitativeCheckResult& asExplicitQualitativeCheckResult(); ExplicitQualitativeCheckResult& asExplicitQualitativeCheckResult();
ExplicitQualitativeCheckResult const& asExplicitQualitativeCheckResult() const; ExplicitQualitativeCheckResult const& asExplicitQualitativeCheckResult() const;
@ -48,8 +54,19 @@ namespace storm {
template<typename ValueType> template<typename ValueType>
ExplicitQuantitativeCheckResult<ValueType> const& asExplicitQuantitativeCheckResult() const; ExplicitQuantitativeCheckResult<ValueType> const& asExplicitQuantitativeCheckResult() const;
template <storm::dd::DdType Type>
SymbolicQualitativeCheckResult<Type>& asSymbolicQualitativeCheckResult();
template <storm::dd::DdType Type>
SymbolicQualitativeCheckResult<Type> const& asSymbolicQualitativeCheckResult() const;
template <storm::dd::DdType Type>
SymbolicQuantitativeCheckResult<Type>& asSymbolicQuantitativeCheckResult();
template <storm::dd::DdType Type>
SymbolicQuantitativeCheckResult<Type> const& asSymbolicQuantitativeCheckResult() const;
virtual std::ostream& writeToStream(std::ostream& out) const = 0; virtual std::ostream& writeToStream(std::ostream& out) const = 0;
virtual std::ostream& writeToStream(std::ostream& out, storm::storage::BitVector const& filter) const = 0;
}; };
std::ostream& operator<<(std::ostream& out, CheckResult& checkResult); std::ostream& operator<<(std::ostream& out, CheckResult& checkResult);

65
src/modelchecker/results/ExplicitQualitativeCheckResult.cpp

@ -29,7 +29,7 @@ namespace storm {
// Intentionally left empty. // Intentionally left empty.
} }
void ExplicitQualitativeCheckResult::performLogicalOperation(ExplicitQualitativeCheckResult& first, CheckResult const& second, std::function<bool (bool, bool)> const& function) { void ExplicitQualitativeCheckResult::performLogicalOperation(ExplicitQualitativeCheckResult& first, QualitativeCheckResult const& second, std::function<bool (bool, bool)> const& function) {
STORM_LOG_THROW(typeid(second) == typeid(ExplicitQualitativeCheckResult), storm::exceptions::InvalidOperationException, "Cannot perform logical 'and' on check results of incompatible type."); STORM_LOG_THROW(typeid(second) == typeid(ExplicitQualitativeCheckResult), storm::exceptions::InvalidOperationException, "Cannot perform logical 'and' on check results of incompatible type.");
STORM_LOG_THROW(first.isResultForAllStates() == second.isResultForAllStates(), storm::exceptions::InvalidOperationException, "Cannot perform logical 'and' on check results of incompatible type."); STORM_LOG_THROW(first.isResultForAllStates() == second.isResultForAllStates(), storm::exceptions::InvalidOperationException, "Cannot perform logical 'and' on check results of incompatible type.");
ExplicitQualitativeCheckResult const& secondCheckResult = static_cast<ExplicitQualitativeCheckResult const&>(second); ExplicitQualitativeCheckResult const& secondCheckResult = static_cast<ExplicitQualitativeCheckResult const&>(second);
@ -52,12 +52,12 @@ namespace storm {
} }
} }
CheckResult& ExplicitQualitativeCheckResult::operator&=(CheckResult const& other) { QualitativeCheckResult& ExplicitQualitativeCheckResult::operator&=(QualitativeCheckResult const& other) {
performLogicalOperation(*this, other, [] (bool a, bool b) { return a && b; }); performLogicalOperation(*this, other, [] (bool a, bool b) { return a && b; });
return *this; return *this;
} }
CheckResult& ExplicitQualitativeCheckResult::operator|=(CheckResult const& other) { QualitativeCheckResult& ExplicitQualitativeCheckResult::operator|=(QualitativeCheckResult const& other) {
performLogicalOperation(*this, other, [] (bool a, bool b) { return a || b; }); performLogicalOperation(*this, other, [] (bool a, bool b) { return a || b; });
return *this; return *this;
} }
@ -109,19 +109,19 @@ namespace storm {
} else { } else {
std::ios::fmtflags oldflags(std::cout.flags()); std::ios::fmtflags oldflags(std::cout.flags());
out << std::boolalpha; out << std::boolalpha;
map_type const& map = boost::get<map_type>(truthValues); map_type const& map = boost::get<map_type>(truthValues);
#ifndef WINDOWS #ifndef WINDOWS
typename map_type::const_iterator it = map.begin(); typename map_type::const_iterator it = map.begin();
typename map_type::const_iterator itPlusOne = map.begin(); typename map_type::const_iterator itPlusOne = map.begin();
++itPlusOne; ++itPlusOne;
typename map_type::const_iterator ite = map.end(); typename map_type::const_iterator ite = map.end();
#else #else
map_type::const_iterator it = map.begin(); map_type::const_iterator it = map.begin();
map_type::const_iterator itPlusOne = map.begin(); map_type::const_iterator itPlusOne = map.begin();
++itPlusOne; ++itPlusOne;
map_type::const_iterator ite = map.end(); map_type::const_iterator ite = map.end();
#endif #endif
for (; it != ite; ++itPlusOne, ++it) { for (; it != ite; ++itPlusOne, ++it) {
@ -135,43 +135,32 @@ namespace storm {
return out; return out;
} }
std::ostream& ExplicitQualitativeCheckResult::writeToStream(std::ostream& out, storm::storage::BitVector const& filter) const { void ExplicitQualitativeCheckResult::filter(QualitativeCheckResult const& filter) {
std::ios::fmtflags oldflags(std::cout.flags()); STORM_LOG_THROW(filter.isExplicitQualitativeCheckResult(), storm::exceptions::InvalidOperationException, "Cannot filter explicit check result with non-explicit filter.");
STORM_LOG_THROW(filter.isResultForAllStates(), storm::exceptions::InvalidOperationException, "Cannot filter check result with non-complete filter.");
out << "["; ExplicitQualitativeCheckResult const& explicitFilter = filter.asExplicitQualitativeCheckResult();
storm::storage::BitVector::const_iterator it = filter.begin(); vector_type const& filterTruthValues = explicitFilter.getTruthValuesVector();
storm::storage::BitVector::const_iterator itPlusOne = filter.begin();
++itPlusOne;
storm::storage::BitVector::const_iterator ite = filter.end();
out << std::boolalpha;
if (this->isResultForAllStates()) { if (this->isResultForAllStates()) {
vector_type const& vector = boost::get<vector_type>(truthValues); map_type newMap;
for (; it != ite; ++itPlusOne, ++it) { for (auto const& element : filterTruthValues) {
out << vector[*it]; newMap.emplace(element, this->getTruthValuesVector().get(element));
if (itPlusOne != ite) {
out << ", ";
}
} }
this->truthValues = newMap;
} else { } else {
map_type const& map = boost::get<map_type>(truthValues); map_type const& map = boost::get<map_type>(truthValues);
bool allResultsAvailable = true; map_type newMap;
for (; it != ite; ++itPlusOne, ++it) { for (auto const& element : map) {
auto const& keyValuePair = map.find(*it); if (filterTruthValues.get(element.first)) {
if (keyValuePair != map.end()) { newMap.insert(element);
out << keyValuePair->second;
if (itPlusOne != ite) {
out << ", ";
}
} else {
allResultsAvailable = false;
} }
} }
STORM_LOG_THROW(newMap.size() == filterTruthValues.getNumberOfSetBits(), storm::exceptions::InvalidOperationException, "The check result fails to contain some results referred to by the filter.");
this->truthValues = newMap;
} }
out << "]";
std::cout.flags(oldflags);
return out;
} }
} }
} }

9
src/modelchecker/results/ExplicitQualitativeCheckResult.h

@ -39,18 +39,19 @@ namespace storm {
virtual bool isExplicitQualitativeCheckResult() const override; virtual bool isExplicitQualitativeCheckResult() const override;
virtual CheckResult& operator&=(CheckResult const& other) override; virtual QualitativeCheckResult& operator&=(QualitativeCheckResult const& other) override;
virtual CheckResult& operator|=(CheckResult const& other) override; virtual QualitativeCheckResult& operator|=(QualitativeCheckResult const& other) override;
virtual void complement() override; virtual void complement() override;
vector_type const& getTruthValuesVector() const; vector_type const& getTruthValuesVector() const;
map_type const& getTruthValuesVectorMap() const; map_type const& getTruthValuesVectorMap() const;
virtual std::ostream& writeToStream(std::ostream& out) const override; virtual std::ostream& writeToStream(std::ostream& out) const override;
virtual std::ostream& writeToStream(std::ostream& out, storm::storage::BitVector const& filter) const override; virtual void filter(QualitativeCheckResult const& filter) override;
private: private:
static void performLogicalOperation(ExplicitQualitativeCheckResult& first, CheckResult const& second, std::function<bool (bool, bool)> const& function); static void performLogicalOperation(ExplicitQualitativeCheckResult& first, QualitativeCheckResult const& second, std::function<bool (bool, bool)> const& function);
// The values of the quantitative check result. // The values of the quantitative check result.
boost::variant<vector_type, map_type> truthValues; boost::variant<vector_type, map_type> truthValues;

49
src/modelchecker/results/ExplicitQuantitativeCheckResult.cpp

@ -3,6 +3,7 @@
#include "src/modelchecker/results/ExplicitQualitativeCheckResult.h" #include "src/modelchecker/results/ExplicitQualitativeCheckResult.h"
#include "src/storage/BitVector.h" #include "src/storage/BitVector.h"
#include "src/utility/macros.h" #include "src/utility/macros.h"
#include "src/utility/vector.h"
#include "src/exceptions/InvalidOperationException.h" #include "src/exceptions/InvalidOperationException.h"
#include "src/adapters/CarlAdapter.h" #include "src/adapters/CarlAdapter.h"
@ -49,40 +50,32 @@ namespace storm {
} }
template<typename ValueType> template<typename ValueType>
std::ostream& ExplicitQuantitativeCheckResult<ValueType>::writeToStream(std::ostream& out, storm::storage::BitVector const& filter) const { void ExplicitQuantitativeCheckResult<ValueType>::filter(QualitativeCheckResult const& filter) {
out << "["; STORM_LOG_THROW(filter.isExplicitQualitativeCheckResult(), storm::exceptions::InvalidOperationException, "Cannot filter explicit check result with non-explicit filter.");
storm::storage::BitVector::const_iterator it = filter.begin(); STORM_LOG_THROW(filter.isResultForAllStates(), storm::exceptions::InvalidOperationException, "Cannot filter check result with non-complete filter.");
storm::storage::BitVector::const_iterator itPlusOne = filter.begin(); ExplicitQualitativeCheckResult const& explicitFilter = filter.asExplicitQualitativeCheckResult();
++itPlusOne; ExplicitQualitativeCheckResult::vector_type const& filterTruthValues = explicitFilter.getTruthValuesVector();
storm::storage::BitVector::const_iterator ite = filter.end();
if (this->isResultForAllStates()) { if (this->isResultForAllStates()) {
vector_type const& valuesAsVector = boost::get<vector_type>(values); map_type newMap;
for (; it != ite; ++itPlusOne, ++it) { for (auto const& element : filterTruthValues) {
out << valuesAsVector[*it]; newMap.emplace(element, this->getValueVector()[element]);
if (itPlusOne != ite) {
out << ", ";
}
} }
this->values = newMap;
} else { } else {
map_type const& valuesAsMap = boost::get<map_type>(values); map_type const& map = boost::get<map_type>(values);
bool allResultsAvailable = true; map_type newMap;
for (; it != ite; ++itPlusOne, ++it) { for (auto const& element : map) {
auto const& keyValuePair = valuesAsMap.find(*it); if (filterTruthValues.get(element.first)) {
if (keyValuePair != valuesAsMap.end()) { newMap.insert(element);
out << keyValuePair->second;
if (itPlusOne != ite) {
out << ", ";
}
} else {
allResultsAvailable = false;
} }
} }
STORM_LOG_THROW(allResultsAvailable, storm::exceptions::InvalidOperationException, "Unable to print result for some states, because the result is not available."); STORM_LOG_THROW(newMap.size() == filterTruthValues.getNumberOfSetBits(), storm::exceptions::InvalidOperationException, "The check result fails to contain some results referred to by the filter.");
this->values = newMap;
} }
out << "]";
return out;
} }
template<typename ValueType> template<typename ValueType>

7
src/modelchecker/results/ExplicitQuantitativeCheckResult.h

@ -12,7 +12,7 @@
namespace storm { namespace storm {
namespace modelchecker { namespace modelchecker {
template<typename ValueType> template<typename ValueType>
class ExplicitQuantitativeCheckResult : public QuantitativeCheckResult<ValueType> { class ExplicitQuantitativeCheckResult : public QuantitativeCheckResult {
public: public:
typedef std::vector<ValueType> vector_type; typedef std::vector<ValueType> vector_type;
typedef std::map<storm::storage::sparse::state_type, ValueType> map_type; typedef std::map<storm::storage::sparse::state_type, ValueType> map_type;
@ -45,8 +45,9 @@ namespace storm {
map_type const& getValueMap() const; map_type const& getValueMap() const;
virtual std::ostream& writeToStream(std::ostream& out) const override; virtual std::ostream& writeToStream(std::ostream& out) const override;
virtual std::ostream& writeToStream(std::ostream& out, storm::storage::BitVector const& filter) const override; virtual void filter(QualitativeCheckResult const& filter) override;
private: private:
// The values of the quantitative check result. // The values of the quantitative check result.
boost::variant<vector_type, map_type> values; boost::variant<vector_type, map_type> values;

15
src/modelchecker/results/QualitativeCheckResult.cpp

@ -1,7 +1,22 @@
#include "src/modelchecker/results/QualitativeCheckResult.h" #include "src/modelchecker/results/QualitativeCheckResult.h"
#include "src/utility/macros.h"
#include "src/exceptions/InvalidOperationException.h"
namespace storm { namespace storm {
namespace modelchecker { namespace modelchecker {
QualitativeCheckResult& QualitativeCheckResult::operator&=(QualitativeCheckResult const& other) {
STORM_LOG_THROW(false, storm::exceptions::InvalidOperationException, "Unable to perform logical 'and' on the two check results.");
}
QualitativeCheckResult& QualitativeCheckResult::operator|=(QualitativeCheckResult const& other) {
STORM_LOG_THROW(false, storm::exceptions::InvalidOperationException, "Unable to perform logical 'or' on the two check results.");
}
void QualitativeCheckResult::complement() {
STORM_LOG_THROW(false, storm::exceptions::InvalidOperationException, "Unable to perform logical 'not' on the check result.");
}
bool QualitativeCheckResult::isQualitative() const { bool QualitativeCheckResult::isQualitative() const {
return true; return true;
} }

4
src/modelchecker/results/QualitativeCheckResult.h

@ -7,6 +7,10 @@ namespace storm {
namespace modelchecker { namespace modelchecker {
class QualitativeCheckResult : public CheckResult { class QualitativeCheckResult : public CheckResult {
public: public:
virtual QualitativeCheckResult& operator&=(QualitativeCheckResult const& other);
virtual QualitativeCheckResult& operator|=(QualitativeCheckResult const& other);
virtual void complement();
virtual bool isQualitative() const override; virtual bool isQualitative() const override;
}; };
} }

13
src/modelchecker/results/QuantitativeCheckResult.cpp

@ -8,15 +8,12 @@
namespace storm { namespace storm {
namespace modelchecker { namespace modelchecker {
template<typename ValueType> std::unique_ptr<CheckResult> QuantitativeCheckResult::compareAgainstBound(storm::logic::ComparisonType comparisonType, double bound) const {
bool QuantitativeCheckResult<ValueType>::isQuantitative() const { STORM_LOG_THROW(false, storm::exceptions::InvalidOperationException, "Unable to perform comparison against bound on the check result.");
return true;
} }
template class QuantitativeCheckResult<double>; bool QuantitativeCheckResult::isQuantitative() const {
return true;
#ifdef STORM_HAVE_CARL }
template class QuantitativeCheckResult<storm::RationalFunction>;
#endif
} }
} }

3
src/modelchecker/results/QuantitativeCheckResult.h

@ -5,9 +5,10 @@
namespace storm { namespace storm {
namespace modelchecker { namespace modelchecker {
template<typename ValueType>
class QuantitativeCheckResult : public CheckResult { class QuantitativeCheckResult : public CheckResult {
public: public:
virtual std::unique_ptr<CheckResult> compareAgainstBound(storm::logic::ComparisonType comparisonType, double bound) const;
virtual bool isQuantitative() const override; virtual bool isQuantitative() const override;
}; };
} }

55
src/modelchecker/results/SymbolicQualitativeCheckResult.cpp

@ -0,0 +1,55 @@
#include "src/modelcheckers/result/SymbolicQualitativeCheckResult.h"
namespace storm {
namespace modelcheckers {
template <storm::dd::DdType Type>
SymbolicQualitativeCheckResult(storm::dd::Dd<Type> const& values) {
}
template <storm::dd::DdType Type>
bool isSymbolic() const {
}
template <storm::dd::DdType Type>
bool isResultForAllStates() const {
}
template <storm::dd::DdType Type>
bool isSymbolicQualitativeCheckResult() const {
}
template <storm::dd::DdType Type>
QualitativeCheckResult& operator&=(QualitativeCheckResult const& other) {
}
template <storm::dd::DdType Type>
QualitativeCheckResult& operator|=(QualitativeCheckResult const& other) {
}
template <storm::dd::DdType Type>
void complement() {
}
template <storm::dd::DdType Type>
storm::dd::Dd<Type> const& getTruthValuesVector() const {
}
template <storm::dd::DdType Type>
std::ostream& writeToStream(std::ostream& out) const {
}
template <storm::dd::DdType Type>
void filter(QualitativeCheckResult const& filter) {
}
}
}

45
src/modelchecker/results/SymbolicQualitativeCheckResult.h

@ -0,0 +1,45 @@
#ifndef STORM_MODELCHECKER_SYMBOLICQUALITATIVECHECKRESULT_H_
#define STORM_MODELCHECKER_SYMBOLICQUALITATIVECHECKRESULT_H_
#include "src/storage/dd/DdType.h"
#include "src/modelchecker/results/QualitativeCheckResult.h"
#include "src/utility/OsDetection.h"
namespace storm {
namespace modelchecker {
template <storm::dd::DdType Type>
class SymbolicQualitativeCheckResult : public QualitativeCheckResult {
public:
SymbolicQualitativeCheckResult() = default;
SymbolicQualitativeCheckResult(storm::dd::Dd<Type> const& values);
SymbolicQualitativeCheckResult(SymbolicQualitativeCheckResult const& other) = default;
SymbolicQualitativeCheckResult& operator=(SymbolicQualitativeCheckResult const& other) = default;
#ifndef WINDOWS
SymbolicQualitativeCheckResult(SymbolicQualitativeCheckResult&& other) = default;
SymbolicQualitativeCheckResult& operator=(SymbolicQualitativeCheckResult&& other) = default;
#endif
virtual bool isSymbolic() const override;
virtual bool isResultForAllStates() const override;
virtual bool isSymbolicQualitativeCheckResult() const override;
virtual QualitativeCheckResult& operator&=(QualitativeCheckResult const& other) override;
virtual QualitativeCheckResult& operator|=(QualitativeCheckResult const& other) override;
virtual void complement() override;
storm::dd::Dd<Type> const& getTruthValuesVector() const;
virtual std::ostream& writeToStream(std::ostream& out) const override;
virtual void filter(QualitativeCheckResult const& filter) override;
private:
// The values of the qualitative check result.
storm::dd::Dd<Type> truthValues;
};
}
}
#endif /* STORM_MODELCHECKER_SYMBOLICQUALITATIVECHECKRESULT_H_ */

0
src/modelchecker/results/SymbolicQuantitativeCheckResult.cpp

43
src/modelchecker/results/SymbolicQuantitativeCheckResult.h

@ -0,0 +1,43 @@
#ifndef STORM_MODELCHECKER_SYMBOLICQUANTITATIVECHECKRESULT_H_
#define STORM_MODELCHECKER_SYMBOLICQUANTITATIVECHECKRESULT_H_
#include "src/storage/dd/DdType.h"
#include "src/modelchecker/results/QuantitativeCheckResult.h"
#include "src/utility/OsDetection.h"
namespace storm {
namespace modelchecker {
template<storm::dd::DdType Type>
class SymbolicQuantitativeCheckResult : public QuantitativeCheckResult {
public:
SymbolicQuantitativeCheckResult();
SymbolicQuantitativeCheckResult(storm::dd::Dd<Type> const& values);
SymbolicQuantitativeCheckResult(SymbolicQuantitativeCheckResult const& other) = default;
SymbolicQuantitativeCheckResult& operator=(SymbolicQuantitativeCheckResult const& other) = default;
#ifndef WINDOWS
SymbolicQuantitativeCheckResult(SymbolicQuantitativeCheckResult&& other) = default;
SymbolicQuantitativeCheckResult& operator=(SymbolicQuantitativeCheckResult&& other) = default;
#endif
virtual std::unique_ptr<CheckResult> compareAgainstBound(storm::logic::ComparisonType comparisonType, double bound) const override;
virtual bool isSymbolic() const override;
virtual bool isResultForAllStates() const override;
virtual bool isSymbolicQuantitativeCheckResult() const override;
storm::dd::Dd<Type> const& getValueVector() const;
virtual std::ostream& writeToStream(std::ostream& out) const override;
virtual void filter(QualitativeCheckResult const& filter) override;
private:
// The values of the quantitative check result.
storm::dd::Dd<Type> values;
};
}
}
#endif /* STORM_MODELCHECKER_SYMBOLICQUANTITATIVECHECKRESULT_H_ */
|||||||
100:0
Loading…
Cancel
Save