Browse Source

(stateformula) CheckResults: provide constructor for quantitative from qualitative result

tempestpy_adaptions
Joachim Klein 4 years ago
committed by Stefan Pranger
parent
commit
a639836f6f
  1. 25
      src/storm/modelchecker/results/ExplicitQuantitativeCheckResult.cpp
  2. 5
      src/storm/modelchecker/results/ExplicitQuantitativeCheckResult.h
  3. 6
      src/storm/modelchecker/results/SymbolicQuantitativeCheckResult.cpp
  4. 6
      src/storm/modelchecker/results/SymbolicQuantitativeCheckResult.h

25
src/storm/modelchecker/results/ExplicitQuantitativeCheckResult.cpp

@ -51,6 +51,31 @@ namespace storm {
ExplicitQuantitativeCheckResult<ValueType>::ExplicitQuantitativeCheckResult(boost::variant<vector_type, map_type>&& values, boost::optional<std::shared_ptr<storm::storage::Scheduler<ValueType>>> scheduler) : values(std::move(values)), scheduler(scheduler) { ExplicitQuantitativeCheckResult<ValueType>::ExplicitQuantitativeCheckResult(boost::variant<vector_type, map_type>&& values, boost::optional<std::shared_ptr<storm::storage::Scheduler<ValueType>>> scheduler) : values(std::move(values)), scheduler(scheduler) {
// Intentionally left empty. // Intentionally left empty.
} }
template<typename ValueType>
ExplicitQuantitativeCheckResult<ValueType>::ExplicitQuantitativeCheckResult(ExplicitQualitativeCheckResult const& other) {
if (other.isResultForAllStates()) {
storm::storage::BitVector const& bvValues = other.getTruthValuesVector();
vector_type newVector;
newVector.reserve(bvValues.size());
for (std::size_t i = 0, n = bvValues.size(); i < n; i++) {
newVector.push_back(bvValues.get(i) ? storm::utility::one<ValueType>() : storm::utility::zero<ValueType>());
}
values = newVector;
} else {
ExplicitQualitativeCheckResult::map_type const& bitMap = other.getTruthValuesMap();
map_type newMap;
for (auto const& e : bitMap) {
newMap[e.first] = e.second ? storm::utility::one<ValueType>() : storm::utility::zero<ValueType>();
}
values = newMap;
}
}
template<typename ValueType> template<typename ValueType>
std::unique_ptr<CheckResult> ExplicitQuantitativeCheckResult<ValueType>::clone() const { std::unique_ptr<CheckResult> ExplicitQuantitativeCheckResult<ValueType>::clone() const {

5
src/storm/modelchecker/results/ExplicitQuantitativeCheckResult.h

@ -16,6 +16,9 @@
namespace storm { namespace storm {
namespace modelchecker { namespace modelchecker {
// fwd
class ExplicitQualitativeCheckResult;
template<typename ValueType> template<typename ValueType>
class ExplicitQuantitativeCheckResult : public QuantitativeCheckResult<ValueType> { class ExplicitQuantitativeCheckResult : public QuantitativeCheckResult<ValueType> {
public: public:
@ -37,6 +40,8 @@ namespace storm {
ExplicitQuantitativeCheckResult(ExplicitQuantitativeCheckResult&& other) = default; ExplicitQuantitativeCheckResult(ExplicitQuantitativeCheckResult&& other) = default;
ExplicitQuantitativeCheckResult& operator=(ExplicitQuantitativeCheckResult&& other) = default; ExplicitQuantitativeCheckResult& operator=(ExplicitQuantitativeCheckResult&& other) = default;
#endif #endif
explicit ExplicitQuantitativeCheckResult(ExplicitQualitativeCheckResult const& other);
virtual ~ExplicitQuantitativeCheckResult() = default; virtual ~ExplicitQuantitativeCheckResult() = default;
virtual std::unique_ptr<CheckResult> clone() const override; virtual std::unique_ptr<CheckResult> clone() const override;

6
src/storm/modelchecker/results/SymbolicQuantitativeCheckResult.cpp

@ -22,6 +22,12 @@ namespace storm {
// Intentionally left empty. // Intentionally left empty.
} }
template<storm::dd::DdType Type, typename ValueType>
SymbolicQuantitativeCheckResult<Type, ValueType>::SymbolicQuantitativeCheckResult(SymbolicQualitativeCheckResult<Type> const& other) : reachableStates(other.getReachableStates()), states(other.getStates()), values(other.getTruthValuesVector().template toAdd<ValueType>()) {
// Intentionally left empty.
}
template<storm::dd::DdType Type, typename ValueType> template<storm::dd::DdType Type, typename ValueType>
std::unique_ptr<CheckResult> SymbolicQuantitativeCheckResult<Type, ValueType>::clone() const { std::unique_ptr<CheckResult> SymbolicQuantitativeCheckResult<Type, ValueType>::clone() const {
return std::make_unique<SymbolicQuantitativeCheckResult<Type, ValueType>>(this->reachableStates, this->states, this->values); return std::make_unique<SymbolicQuantitativeCheckResult<Type, ValueType>>(this->reachableStates, this->states, this->values);

6
src/storm/modelchecker/results/SymbolicQuantitativeCheckResult.h

@ -8,6 +8,10 @@
namespace storm { namespace storm {
namespace modelchecker { namespace modelchecker {
// fwd
template<storm::dd::DdType Type>
class SymbolicQualitativeCheckResult;
template<storm::dd::DdType Type, typename ValueType = double> template<storm::dd::DdType Type, typename ValueType = double>
class SymbolicQuantitativeCheckResult : public QuantitativeCheckResult<ValueType> { class SymbolicQuantitativeCheckResult : public QuantitativeCheckResult<ValueType> {
public: public:
@ -21,6 +25,8 @@ namespace storm {
SymbolicQuantitativeCheckResult(SymbolicQuantitativeCheckResult&& other) = default; SymbolicQuantitativeCheckResult(SymbolicQuantitativeCheckResult&& other) = default;
SymbolicQuantitativeCheckResult& operator=(SymbolicQuantitativeCheckResult&& other) = default; SymbolicQuantitativeCheckResult& operator=(SymbolicQuantitativeCheckResult&& other) = default;
#endif #endif
SymbolicQuantitativeCheckResult(SymbolicQualitativeCheckResult<Type> const& other);
virtual std::unique_ptr<CheckResult> clone() const override; virtual std::unique_ptr<CheckResult> clone() const override;

Loading…
Cancel
Save