Browse Source
Created new class for storing hybrid check results (symbolic as well as explicit parts) and the surrounding functionality.
Created new class for storing hybrid check results (symbolic as well as explicit parts) and the surrounding functionality.
Former-commit-id: d4ad6da5a1
tempestpy_adaptions
dehnert
10 years ago
13 changed files with 438 additions and 19 deletions
-
17src/modelchecker/prctl/HybridDtmcPrctlModelChecker.cpp
-
2src/modelchecker/prctl/HybridDtmcPrctlModelChecker.h
-
21src/modelchecker/results/CheckResult.cpp
-
9src/modelchecker/results/CheckResult.h
-
128src/modelchecker/results/HybridQuantitativeCheckResult.cpp
-
69src/modelchecker/results/HybridQuantitativeCheckResult.h
-
2src/modelchecker/results/SymbolicQuantitativeCheckResult.cpp
-
2src/modelchecker/results/SymbolicQuantitativeCheckResult.h
-
2src/storage/SparseMatrix.cpp
-
86src/storage/dd/CuddBdd.cpp
-
41src/storage/dd/CuddBdd.h
-
52src/storage/dd/CuddOdd.cpp
-
26src/storage/dd/CuddOdd.h
@ -0,0 +1,128 @@ |
|||
#include "src/modelchecker/results/HybridQuantitativeCheckResult.h"
|
|||
#include "src/modelchecker/results/SymbolicQualitativeCheckResult.h"
|
|||
|
|||
#include "src/exceptions/InvalidOperationException.h"
|
|||
|
|||
namespace storm { |
|||
namespace modelchecker { |
|||
template<storm::dd::DdType Type> |
|||
HybridQuantitativeCheckResult<Type>::HybridQuantitativeCheckResult(storm::dd::Bdd<Type> const& reachableStates, storm::dd::Bdd<Type> const& symbolicStates, storm::dd::Add<Type> const& symbolicValues, storm::dd::Bdd<Type> const& explicitStates, storm::dd::Odd<Type> const& odd, std::vector<double> const& explicitValues) : reachableStates(reachableStates), symbolicStates(symbolicStates), symbolicValues(symbolicValues), explicitStates(explicitStates), odd(odd), explicitValues(explicitValues) { |
|||
// Intentionally left empty.
|
|||
} |
|||
|
|||
template<storm::dd::DdType Type> |
|||
std::unique_ptr<CheckResult> HybridQuantitativeCheckResult<Type>::compareAgainstBound(storm::logic::ComparisonType comparisonType, double bound) const { |
|||
storm::dd::Bdd<Type> symbolicResult; |
|||
|
|||
// First compute the symbolic part of the result.
|
|||
if (comparisonType == storm::logic::ComparisonType::Less) { |
|||
symbolicResult = symbolicValues.less(bound); |
|||
} else if (comparisonType == storm::logic::ComparisonType::LessEqual) { |
|||
symbolicResult = symbolicValues.lessOrEqual(bound); |
|||
} else if (comparisonType == storm::logic::ComparisonType::Greater) { |
|||
symbolicResult = symbolicValues.greater(bound); |
|||
} else if (comparisonType == storm::logic::ComparisonType::GreaterEqual) { |
|||
symbolicResult = symbolicValues.greaterOrEqual(bound); |
|||
} |
|||
|
|||
// Then translate the explicit part to a symbolic format and simultaneously to a qualitative result.
|
|||
symbolicResult |= storm::dd::Bdd<Type>(this->reachableStates.getDdManager(), this->explicitValues, this->odd, this->symbolicValues.getContainedMetaVariables(), comparisonType, bound); |
|||
|
|||
return std::unique_ptr<SymbolicQualitativeCheckResult<Type>>(new SymbolicQualitativeCheckResult<Type>(reachableStates, symbolicResult)); |
|||
} |
|||
|
|||
template<storm::dd::DdType Type> |
|||
bool HybridQuantitativeCheckResult<Type>::isHybrid() const { |
|||
return true; |
|||
} |
|||
|
|||
template<storm::dd::DdType Type> |
|||
bool HybridQuantitativeCheckResult<Type>::isResultForAllStates() const { |
|||
return true; |
|||
} |
|||
|
|||
template<storm::dd::DdType Type> |
|||
bool HybridQuantitativeCheckResult<Type>::isHybridQuantitativeCheckResult() const { |
|||
return true; |
|||
} |
|||
|
|||
template<storm::dd::DdType Type> |
|||
storm::dd::Bdd<Type> const& HybridQuantitativeCheckResult<Type>::getSymbolicStates() const { |
|||
return symbolicStates; |
|||
} |
|||
|
|||
template<storm::dd::DdType Type> |
|||
storm::dd::Add<Type> const& HybridQuantitativeCheckResult<Type>::getSymbolicValueVector() const { |
|||
return symbolicValues; |
|||
} |
|||
|
|||
template<storm::dd::DdType Type> |
|||
storm::dd::Bdd<Type> const& HybridQuantitativeCheckResult<Type>::getExplicitStates() const { |
|||
return explicitStates; |
|||
} |
|||
|
|||
template<storm::dd::DdType Type> |
|||
storm::dd::Odd<Type> const& HybridQuantitativeCheckResult<Type>::getOdd() const { |
|||
return odd; |
|||
} |
|||
|
|||
template<storm::dd::DdType Type> |
|||
std::vector<double> const& HybridQuantitativeCheckResult<Type>::getExplicitValueVector() const { |
|||
return explicitValues; |
|||
} |
|||
|
|||
template<storm::dd::DdType Type> |
|||
std::ostream& HybridQuantitativeCheckResult<Type>::writeToStream(std::ostream& out) const { |
|||
out << "["; |
|||
bool first = true; |
|||
if (!this->symbolicStates.isZero()) { |
|||
if (this->symbolicValues.isZero()) { |
|||
out << "0"; |
|||
} else { |
|||
for (auto valuationValuePair : this->symbolicValues) { |
|||
if (!first) { |
|||
out << ", "; |
|||
} else { |
|||
first = false; |
|||
} |
|||
out << valuationValuePair.second; |
|||
} |
|||
} |
|||
} |
|||
if (!this->explicitStates.isZero()) { |
|||
for (auto const& element : this->explicitValues) { |
|||
if (!first) { |
|||
out << ", "; |
|||
} else { |
|||
first = false; |
|||
} |
|||
out << element; |
|||
} |
|||
} |
|||
out << "]"; |
|||
return out; |
|||
} |
|||
|
|||
template<storm::dd::DdType Type> |
|||
void HybridQuantitativeCheckResult<Type>::filter(QualitativeCheckResult const& filter) { |
|||
STORM_LOG_THROW(filter.isSymbolicQualitativeCheckResult(), storm::exceptions::InvalidOperationException, "Cannot filter hybrid check result with non-symbolic filter."); |
|||
|
|||
// First, we filter the symbolic values.
|
|||
this->symbolicStates = this->symbolicStates && filter.asSymbolicQualitativeCheckResult<Type>().getTruthValuesVector(); |
|||
this->symbolicValues *= symbolicStates.toAdd(); |
|||
|
|||
// Next, we filter the explicit values.
|
|||
|
|||
// Start by computing the new set of states that is stored explictly and the corresponding ODD.
|
|||
this->explicitStates = this->explicitStates && filter.asSymbolicQualitativeCheckResult<Type>().getTruthValuesVector(); |
|||
storm::dd::Odd<Type> newOdd(explicitStates); |
|||
|
|||
// Then compute the new vector of explicit values and set the new data fields.
|
|||
this->explicitValues = this->odd.filterExplicitVector(explicitStates, this->explicitValues); |
|||
this->odd = newOdd; |
|||
} |
|||
|
|||
// Explicitly instantiate the class.
|
|||
template class HybridQuantitativeCheckResult<storm::dd::DdType::CUDD>; |
|||
} |
|||
} |
@ -0,0 +1,69 @@ |
|||
#ifndef STORM_MODELCHECKER_HYBRIDQUANTITATIVECHECKRESULT_H_ |
|||
#define STORM_MODELCHECKER_HYBRIDQUANTITATIVECHECKRESULT_H_ |
|||
|
|||
#include "src/storage/dd/DdType.h" |
|||
#include "src/storage/dd/CuddAdd.h" |
|||
#include "src/storage/dd/CuddBdd.h" |
|||
#include "src/storage/dd/CuddOdd.h" |
|||
#include "src/modelchecker/results/QuantitativeCheckResult.h" |
|||
#include "src/utility/OsDetection.h" |
|||
|
|||
namespace storm { |
|||
namespace modelchecker { |
|||
template<storm::dd::DdType Type> |
|||
class HybridQuantitativeCheckResult : public QuantitativeCheckResult { |
|||
public: |
|||
HybridQuantitativeCheckResult() = default; |
|||
HybridQuantitativeCheckResult(storm::dd::Bdd<Type> const& reachableStates, storm::dd::Bdd<Type> const& symbolicStates, storm::dd::Add<Type> const& symbolicValues, storm::dd::Bdd<Type> const& explicitStates, storm::dd::Odd<Type> const& odd, std::vector<double> const& explicitValues); |
|||
|
|||
HybridQuantitativeCheckResult(HybridQuantitativeCheckResult const& other) = default; |
|||
HybridQuantitativeCheckResult& operator=(HybridQuantitativeCheckResult const& other) = default; |
|||
#ifndef WINDOWS |
|||
HybridQuantitativeCheckResult(HybridQuantitativeCheckResult&& other) = default; |
|||
HybridQuantitativeCheckResult& operator=(HybridQuantitativeCheckResult&& other) = default; |
|||
#endif |
|||
|
|||
virtual std::unique_ptr<CheckResult> compareAgainstBound(storm::logic::ComparisonType comparisonType, double bound) const override; |
|||
|
|||
virtual bool isHybrid() const override; |
|||
virtual bool isResultForAllStates() const override; |
|||
|
|||
virtual bool isHybridQuantitativeCheckResult() const override; |
|||
|
|||
storm::dd::Bdd<Type> const& getSymbolicStates() const; |
|||
|
|||
storm::dd::Add<Type> const& getSymbolicValueVector() const; |
|||
|
|||
storm::dd::Bdd<Type> const& getExplicitStates() const; |
|||
|
|||
storm::dd::Odd<Type> const& getOdd() const; |
|||
|
|||
std::vector<double> const& getExplicitValueVector() const; |
|||
|
|||
virtual std::ostream& writeToStream(std::ostream& out) const override; |
|||
|
|||
virtual void filter(QualitativeCheckResult const& filter) override; |
|||
|
|||
private: |
|||
// The set of all reachable states. |
|||
storm::dd::Bdd<Type> reachableStates; |
|||
|
|||
// The set of all states whose result is stored symbolically. |
|||
storm::dd::Bdd<Type> symbolicStates; |
|||
|
|||
// The symbolic value vector. |
|||
storm::dd::Add<Type> symbolicValues; |
|||
|
|||
// The set of all states whose result is stored explicitly. |
|||
storm::dd::Bdd<Type> explicitStates; |
|||
|
|||
// The ODD that enables translation of the explicit values to a symbolic format. |
|||
storm::dd::Odd<Type> odd; |
|||
|
|||
// The explicit value vector. |
|||
std::vector<double> explicitValues; |
|||
}; |
|||
} |
|||
} |
|||
|
|||
#endif /* STORM_MODELCHECKER_HYBRIDQUANTITATIVECHECKRESULT_H_ */ |
Write
Preview
Loading…
Cancel
Save
Reference in new issue