diff --git a/src/storm/storage/expressions/SimpleValuation.cpp b/src/storm/storage/expressions/SimpleValuation.cpp index e60556305..4ed71239a 100644 --- a/src/storm/storage/expressions/SimpleValuation.cpp +++ b/src/storm/storage/expressions/SimpleValuation.cpp @@ -144,6 +144,23 @@ namespace storm { } } + typename SimpleValuation::Json SimpleValuation::toJson() const { + Json result; + for (auto const& variable : getManager()) { + if (variable.second.isBooleanType()) { + result[variable.first.getName()] = this->getBooleanValue(variable.first); + } else if (variable.second.isIntegerType()) { + result[variable.first.getName()] = this->getIntegerValue(variable.first); + } else if (variable.second.isRationalType()) { + result[variable.first.getName()] = this->getRationalValue(variable.first); + } else { + STORM_LOG_THROW(false, storm::exceptions::InvalidTypeException, "Unexpected variable type."); + } + } + return result; + } + + std::ostream& operator<<(std::ostream& out, SimpleValuation const& valuation) { out << valuation.toString(false) << std::endl; return out; diff --git a/src/storm/storage/expressions/SimpleValuation.h b/src/storm/storage/expressions/SimpleValuation.h index 3936ed546..b0569ff1f 100644 --- a/src/storm/storage/expressions/SimpleValuation.h +++ b/src/storm/storage/expressions/SimpleValuation.h @@ -6,6 +6,7 @@ #include #include "storm/storage/expressions/Valuation.h" +#include "storm/adapters/JsonAdapter.h" namespace storm { namespace expressions { @@ -17,6 +18,8 @@ namespace storm { public: friend class SimpleValuationPointerHash; friend class SimpleValuationPointerLess; + typedef storm::json Json; + /*! * Creates an empty simple valuation that is associated to no manager and has no variables. @@ -63,6 +66,7 @@ namespace storm { virtual std::string toPrettyString(std::set const& selectedVariables) const; virtual std::string toString(bool pretty = true) const; + Json toJson() const; friend std::ostream& operator<<(std::ostream& out, SimpleValuation const& valuation);