Browse Source

More to string methods for simplevaluation

Former-commit-id: 487ed4a8d6
tempestpy_adaptions
sjunges 9 years ago
parent
commit
66736c3626
  1. 68
      src/storage/expressions/SimpleValuation.cpp
  2. 4
      src/storage/expressions/SimpleValuation.h

68
src/storage/expressions/SimpleValuation.cpp

@ -109,30 +109,58 @@ namespace storm {
}
return "[" + boost::join(assignments, ", ") + "]";
}
std::ostream& operator<<(std::ostream& out, SimpleValuation const& valuation) {
out << "valuation {" << std::endl;
out << valuation.getManager() << std::endl;
if (!valuation.booleanValues.empty()) {
for (auto const& element : valuation.booleanValues) {
out << element << " ";
std::string SimpleValuation::toString(bool pretty) const {
std::stringstream sstr;
if(pretty) {
sstr << "valuation {" << std::endl;
for(auto const& e : getManager()) {
sstr << e.first.getName() << "=";
if (e.first.hasBooleanType()) {
sstr << std::boolalpha << this->getBooleanValue(e.first) << std::noboolalpha;
} else if (e.first.hasIntegerType()) {
sstr << this->getIntegerValue(e.first);
} else if (e.first.hasRationalType()) {
sstr << this->getRationalValue(e.first);
} else {
STORM_LOG_THROW(false, storm::exceptions::InvalidTypeException, "Unexpected variable type.");
}
sstr << std::endl;
}
out << std::endl;
}
if (!valuation.integerValues.empty()) {
for (auto const& element : valuation.integerValues) {
out << element << " ";
sstr << "}";
} else {
sstr << "valuation {" << std::endl;
sstr << getManager() << std::endl;
if (!booleanValues.empty()) {
for (auto const& element : booleanValues) {
sstr << element << " ";
}
sstr << std::endl;
}
out << std::endl;
}
if (!valuation.rationalValues.empty()) {
for (auto const& element : valuation.rationalValues) {
out << element << " ";
if (!integerValues.empty()) {
for (auto const& element : integerValues) {
sstr << element << " ";
}
sstr << std::endl;
}
if (!rationalValues.empty()) {
for (auto const& element : rationalValues) {
sstr << element << " ";
}
sstr << std::endl;
}
out << std::endl;
sstr << "}";
}
out << "}" << std::endl;
return sstr.str();
}
std::ostream& operator<<(std::ostream& out, SimpleValuation const& valuation) {
out << valuation.toString(false) << std::endl;
return out;
}

4
src/storage/expressions/SimpleValuation.h

@ -61,7 +61,9 @@ namespace storm {
* @return The string representation.
*/
virtual std::string toPrettyString(std::set<storm::expressions::Variable> const& selectedVariables) const;
virtual std::string toString(bool pretty = true) const;
friend std::ostream& operator<<(std::ostream& out, SimpleValuation const& valuation);
private:

Loading…
Cancel
Save