Browse Source

removed filename form shield classes

tempestpy_adaptions
Thomas Knoll 1 year ago
parent
commit
3a3dd67232
  1. 8
      src/storm-parsers/parser/FormulaParserGrammar.cpp
  2. 2
      src/storm-parsers/parser/FormulaParserGrammar.h
  3. 10
      src/storm/logic/ShieldExpression.cpp
  4. 7
      src/storm/logic/ShieldExpression.h
  5. 1
      src/storm/modelchecker/prctl/helper/SparseMdpPrctlHelper.cpp
  6. 6
      src/storm/shields/AbstractShield.cpp
  7. 3
      src/storm/shields/AbstractShield.h
  8. 4
      src/storm/shields/ShieldHandling.cpp
  9. 4
      src/storm/shields/ShieldHandling.h

8
src/storm-parsers/parser/FormulaParserGrammar.cpp

@ -180,7 +180,7 @@ namespace storm {
constantDefinition.name("constant definition"); constantDefinition.name("constant definition");
// Shielding properties // Shielding properties
shieldExpression = (qi::lit("<") > label > qi::lit(",") > shieldingType > -(qi::lit(",") > shieldComparison) > qi::lit(">"))[qi::_val = phoenix::bind(&FormulaParserGrammar::createShieldExpression, phoenix::ref(*this), qi::_2, qi::_1, qi::_3)];
shieldExpression = (qi::lit("<") > shieldingType > -(qi::lit(",") > shieldComparison) > qi::lit(">"))[qi::_val = phoenix::bind(&FormulaParserGrammar::createShieldExpression, phoenix::ref(*this), qi::_1, qi::_2)];
shieldExpression.name("shield expression"); shieldExpression.name("shield expression");
@ -645,12 +645,12 @@ namespace storm {
return std::make_pair(comparisonType, value); return std::make_pair(comparisonType, value);
} }
std::shared_ptr<storm::logic::ShieldExpression const> FormulaParserGrammar::createShieldExpression(storm::logic::ShieldingType type, std::string name, boost::optional<std::pair<storm::logic::ShieldComparison, double>> comparisonStruct) {
std::shared_ptr<storm::logic::ShieldExpression const> FormulaParserGrammar::createShieldExpression(storm::logic::ShieldingType type, boost::optional<std::pair<storm::logic::ShieldComparison, double>> comparisonStruct) {
if(comparisonStruct.is_initialized()) { if(comparisonStruct.is_initialized()) {
return std::shared_ptr<storm::logic::ShieldExpression>(new storm::logic::ShieldExpression(type, name, comparisonStruct.get().first, comparisonStruct.get().second));
return std::shared_ptr<storm::logic::ShieldExpression>(new storm::logic::ShieldExpression(type, comparisonStruct.get().first, comparisonStruct.get().second));
} else { } else {
STORM_LOG_INFO("Construction of shield without a comparison parameter (lambda or gamma) will default to 'lambda=0'"); STORM_LOG_INFO("Construction of shield without a comparison parameter (lambda or gamma) will default to 'lambda=0'");
return std::shared_ptr<storm::logic::ShieldExpression>(new storm::logic::ShieldExpression(type, name));
return std::shared_ptr<storm::logic::ShieldExpression>(new storm::logic::ShieldExpression(type));
} }
} }

2
src/storm-parsers/parser/FormulaParserGrammar.h

@ -249,7 +249,7 @@ namespace storm {
std::shared_ptr<storm::logic::Formula const> createGameFormula(storm::logic::PlayerCoalition const& coalition, std::shared_ptr<storm::logic::Formula const> const& subformula) const; std::shared_ptr<storm::logic::Formula const> createGameFormula(storm::logic::PlayerCoalition const& coalition, std::shared_ptr<storm::logic::Formula const> const& subformula) const;
std::pair<storm::logic::ShieldComparison, double> createShieldComparisonStruct(storm::logic::ShieldComparison comparisonType, double value); std::pair<storm::logic::ShieldComparison, double> createShieldComparisonStruct(storm::logic::ShieldComparison comparisonType, double value);
std::shared_ptr<storm::logic::ShieldExpression const> createShieldExpression(storm::logic::ShieldingType type, std::string name, boost::optional<std::pair<storm::logic::ShieldComparison, double>> comparisonStruct);
std::shared_ptr<storm::logic::ShieldExpression const> createShieldExpression(storm::logic::ShieldingType type, boost::optional<std::pair<storm::logic::ShieldComparison, double>> comparisonStruct);
bool areConstantDefinitionsAllowed() const; bool areConstantDefinitionsAllowed() const;
void addConstant(std::string const& name, ConstantDataType type, boost::optional<storm::expressions::Expression> const& expression); void addConstant(std::string const& name, ConstantDataType type, boost::optional<storm::expressions::Expression> const& expression);

10
src/storm/logic/ShieldExpression.cpp

@ -6,11 +6,11 @@ namespace storm {
namespace logic { namespace logic {
ShieldExpression::ShieldExpression() {} ShieldExpression::ShieldExpression() {}
ShieldExpression::ShieldExpression(ShieldingType type, std::string filename) : type(type), filename(filename) {
ShieldExpression::ShieldExpression(ShieldingType type) : type(type) {
//Intentionally left empty //Intentionally left empty
} }
ShieldExpression::ShieldExpression(ShieldingType type, std::string filename, ShieldComparison comparison, double value) : type(type), filename(filename), comparison(comparison), value(value) {
ShieldExpression::ShieldExpression(ShieldingType type, ShieldComparison comparison, double value) : type(type), comparison(comparison), value(value) {
//Intentionally left empty //Intentionally left empty
} }
@ -74,11 +74,7 @@ namespace storm {
prettyString += "-Shield "; prettyString += "-Shield ";
prettyString += "with " + comparisonType + " comparison (" + comparisonToString() + " = " + std::to_string(value) + "):"; prettyString += "with " + comparisonType + " comparison (" + comparisonToString() + " = " + std::to_string(value) + "):";
return prettyString; return prettyString;
}
std::string ShieldExpression::getFilename() const {
return filename;
}
}
std::ostream& operator<<(std::ostream& out, ShieldExpression const& shieldExpression) { std::ostream& operator<<(std::ostream& out, ShieldExpression const& shieldExpression) {
out << shieldExpression.toString(); out << shieldExpression.toString();

7
src/storm/logic/ShieldExpression.h

@ -18,8 +18,8 @@ namespace storm {
class ShieldExpression { class ShieldExpression {
public: public:
ShieldExpression(); ShieldExpression();
ShieldExpression(ShieldingType type, std::string filename);
ShieldExpression(ShieldingType type, std::string filename, ShieldComparison comparison, double value);
ShieldExpression(ShieldingType type);
ShieldExpression(ShieldingType type, ShieldComparison comparison, double value);
bool isRelative() const; bool isRelative() const;
bool isPreSafetyShield() const; bool isPreSafetyShield() const;
@ -34,15 +34,12 @@ namespace storm {
std::string comparisonToString() const; std::string comparisonToString() const;
std::string toString() const; std::string toString() const;
std::string prettify() const; std::string prettify() const;
std::string getFilename() const;
friend std::ostream& operator<<(std::ostream& stream, ShieldExpression const& shieldExpression); friend std::ostream& operator<<(std::ostream& stream, ShieldExpression const& shieldExpression);
private: private:
ShieldingType type; ShieldingType type;
ShieldComparison comparison = ShieldComparison::Relative; ShieldComparison comparison = ShieldComparison::Relative;
double value = 0; double value = 0;
std::string filename;
}; };
} }
} }

1
src/storm/modelchecker/prctl/helper/SparseMdpPrctlHelper.cpp

@ -695,6 +695,7 @@ namespace storm {
std::vector<ValueType> choiceValues = std::vector<ValueType>(transitionMatrix.getRowGroupIndices().at(transitionMatrix.getRowGroupIndices().size() - 1), storm::utility::zero<ValueType>()); std::vector<ValueType> choiceValues = std::vector<ValueType>(transitionMatrix.getRowGroupIndices().at(transitionMatrix.getRowGroupIndices().size() - 1), storm::utility::zero<ValueType>());
auto choice_it = maybeStateChoiceValues.begin(); auto choice_it = maybeStateChoiceValues.begin();
// TODO THIS IS BUGGY!!
for(uint state = 0; state < transitionMatrix.getRowGroupIndices().size() - 1; state++) { for(uint state = 0; state < transitionMatrix.getRowGroupIndices().size() - 1; state++) {
uint rowGroupSize = transitionMatrix.getRowGroupIndices().at(state + 1) - transitionMatrix.getRowGroupIndices().at(state); uint rowGroupSize = transitionMatrix.getRowGroupIndices().at(state + 1) - transitionMatrix.getRowGroupIndices().at(state);
if (qualitativeStateSets.maybeStates.get(state)) { if (qualitativeStateSets.maybeStates.get(state)) {

6
src/storm/shields/AbstractShield.cpp

@ -33,12 +33,6 @@ namespace tempest {
std::string AbstractShield<ValueType, IndexType>::getClassName() const { std::string AbstractShield<ValueType, IndexType>::getClassName() const {
return std::string(boost::core::demangled_name(BOOST_CORE_TYPEID(*this))); return std::string(boost::core::demangled_name(BOOST_CORE_TYPEID(*this)));
} }
template<typename ValueType, typename IndexType>
std::string AbstractShield<ValueType, IndexType>::getShieldFileName() const {
return shieldingExpression->getFilename() + ".shield";
}
// Explicitly instantiate appropriate // Explicitly instantiate appropriate
template class AbstractShield<double, typename storm::storage::SparseMatrix<double>::index_type>; template class AbstractShield<double, typename storm::storage::SparseMatrix<double>::index_type>;

3
src/storm/shields/AbstractShield.h

@ -49,8 +49,7 @@ namespace tempest {
storm::OptimizationDirection getOptimizationDirection(); storm::OptimizationDirection getOptimizationDirection();
std::string getClassName() const; std::string getClassName() const;
std::string getShieldFileName() const;
virtual void printToStream(std::ostream& out, std::shared_ptr<storm::models::sparse::Model<ValueType>> const& model) = 0; virtual void printToStream(std::ostream& out, std::shared_ptr<storm::models::sparse::Model<ValueType>> const& model) = 0;
virtual void printJsonToStream(std::ostream& out, std::shared_ptr<storm::models::sparse::Model<ValueType>> const& model) = 0; virtual void printJsonToStream(std::ostream& out, std::shared_ptr<storm::models::sparse::Model<ValueType>> const& model) = 0;

4
src/storm/shields/ShieldHandling.cpp

@ -2,10 +2,6 @@
namespace tempest { namespace tempest {
namespace shields { namespace shields {
std::string shieldFilename(std::shared_ptr<storm::logic::ShieldExpression const> const& shieldingExpression) {
return shieldingExpression->getFilename() + ".shield";
}
template<typename ValueType, typename IndexType> template<typename ValueType, typename IndexType>
std::unique_ptr<tempest::shields::AbstractShield<ValueType, IndexType>> createShield(std::shared_ptr<storm::models::sparse::Model<ValueType>> model, std::vector<ValueType> const& choiceValues, std::shared_ptr<storm::logic::ShieldExpression const> const& shieldingExpression, storm::OptimizationDirection optimizationDirection, storm::storage::BitVector relevantStates, boost::optional<storm::storage::BitVector> coalitionStates) { std::unique_ptr<tempest::shields::AbstractShield<ValueType, IndexType>> createShield(std::shared_ptr<storm::models::sparse::Model<ValueType>> model, std::vector<ValueType> const& choiceValues, std::shared_ptr<storm::logic::ShieldExpression const> const& shieldingExpression, storm::OptimizationDirection optimizationDirection, storm::storage::BitVector relevantStates, boost::optional<storm::storage::BitVector> coalitionStates) {
if(coalitionStates.is_initialized()) coalitionStates.get().complement(); if(coalitionStates.is_initialized()) coalitionStates.get().complement();

4
src/storm/shields/ShieldHandling.h

@ -20,9 +20,7 @@
#include "storm/exceptions/InvalidArgumentException.h" #include "storm/exceptions/InvalidArgumentException.h"
namespace tempest { namespace tempest {
namespace shields {
std::string shieldFilename(std::shared_ptr<storm::logic::ShieldExpression const> const& shieldingExpression);
namespace shields {
template<typename ValueType, typename IndexType = storm::storage::sparse::state_type> template<typename ValueType, typename IndexType = storm::storage::sparse::state_type>
std::unique_ptr<tempest::shields::AbstractShield<ValueType, IndexType>> createShield(std::shared_ptr<storm::models::sparse::Model<ValueType>> model, std::vector<ValueType> const& choiceValues, std::shared_ptr<storm::logic::ShieldExpression const> const& shieldingExpression, storm::OptimizationDirection optimizationDirection, storm::storage::BitVector relevantStates, boost::optional<storm::storage::BitVector> coalitionStates); std::unique_ptr<tempest::shields::AbstractShield<ValueType, IndexType>> createShield(std::shared_ptr<storm::models::sparse::Model<ValueType>> model, std::vector<ValueType> const& choiceValues, std::shared_ptr<storm::logic::ShieldExpression const> const& shieldingExpression, storm::OptimizationDirection optimizationDirection, storm::storage::BitVector relevantStates, boost::optional<storm::storage::BitVector> coalitionStates);

Loading…
Cancel
Save