Browse Source

added util functions to shieldExpression

tempestpy_adaptions
Stefan Pranger 4 years ago
parent
commit
8b73f0a0d1
  1. 25
      src/storm/logic/ShieldExpression.cpp
  2. 7
      src/storm/logic/ShieldExpression.h

25
src/storm/logic/ShieldExpression.cpp

@ -6,7 +6,11 @@ namespace storm {
namespace logic {
ShieldExpression::ShieldExpression() {}
ShieldExpression::ShieldExpression(ShieldingType type, ShieldComparison comparison, double value) : type(type), comparison(comparison), value(value) {
ShieldExpression::ShieldExpression(ShieldingType type, std::string filename) : type(type), filename(filename) {
//Intentionally left empty
}
ShieldExpression::ShieldExpression(ShieldingType type, std::string filename, ShieldComparison comparison, double value) : type(type), filename(filename), comparison(comparison), value(value) {
//Intentionally left empty
}
@ -49,6 +53,25 @@ namespace storm {
return "<" + typeToString() + ", " + comparisonToString() + "=" + std::to_string(value) + ">";
}
std::string ShieldExpression::prettify() const {
std::string prettyString = "";
std::string comparisonType = isRelative() ? "relative" : "absolute";
switch(type) {
case storm::logic::ShieldingType::PostSafety: prettyString += "Post-Safety"; break;
case storm::logic::ShieldingType::PreSafety: prettyString += "Pre-Safety"; break;
case storm::logic::ShieldingType::Optimal: prettyString += "Optimal"; break;
}
prettyString += "-Shield ";
if(!(type == storm::logic::ShieldingType::Optimal)) {
prettyString += "with " + comparisonType + " comparison (" + comparisonToString() + " = " + std::to_string(value) + "):";
}
return prettyString;
}
std::string ShieldExpression::getFilename() const {
return filename;
}
std::ostream& operator<<(std::ostream& out, ShieldExpression const& shieldExpression) {
out << shieldExpression.toString();
return out;

7
src/storm/logic/ShieldExpression.h

@ -17,7 +17,8 @@ namespace storm {
class ShieldExpression {
public:
ShieldExpression();
ShieldExpression(ShieldingType type, ShieldComparison comparison, double value);
ShieldExpression(ShieldingType type, std::string filename);
ShieldExpression(ShieldingType type, std::string filename, ShieldComparison comparison, double value);
bool isRelative() const;
bool isPreSafetyShield() const;
@ -29,12 +30,16 @@ namespace storm {
std::string typeToString() const;
std::string comparisonToString() const;
std::string toString() const;
std::string prettify() const;
std::string getFilename() const;
friend std::ostream& operator<<(std::ostream& stream, ShieldExpression const& shieldExpression);
private:
ShieldingType type;
ShieldComparison comparison;
double value;
std::string filename;
};
}
}
Loading…
Cancel
Save