Browse Source

Added Export of state valuations to JSON

tempestpy_adaptions
Tim Quatmann 5 years ago
parent
commit
42be5537ae
  1. 17
      src/storm/storage/expressions/SimpleValuation.cpp
  2. 4
      src/storm/storage/expressions/SimpleValuation.h

17
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;

4
src/storm/storage/expressions/SimpleValuation.h

@ -6,6 +6,7 @@
#include <set>
#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<double> 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<storm::expressions::Variable> const& selectedVariables) const;
virtual std::string toString(bool pretty = true) const;
Json toJson() const;
friend std::ostream& operator<<(std::ostream& out, SimpleValuation const& valuation);

Loading…
Cancel
Save