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. 8
      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. 1
      src/storm/shields/AbstractShield.h
  8. 4
      src/storm/shields/ShieldHandling.cpp
  9. 2
      src/storm/shields/ShieldHandling.h

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

@ -180,7 +180,7 @@ namespace storm {
constantDefinition.name("constant definition");
// 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");
@ -645,12 +645,12 @@ namespace storm {
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()) {
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 {
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::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;
void addConstant(std::string const& name, ConstantDataType type, boost::optional<storm::expressions::Expression> const& expression);

8
src/storm/logic/ShieldExpression.cpp

@ -6,11 +6,11 @@ namespace storm {
namespace logic {
ShieldExpression::ShieldExpression() {}
ShieldExpression::ShieldExpression(ShieldingType type, std::string filename) : type(type), filename(filename) {
ShieldExpression::ShieldExpression(ShieldingType type) : type(type) {
//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
}
@ -76,10 +76,6 @@ namespace storm {
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

@ -18,8 +18,8 @@ namespace storm {
class ShieldExpression {
public:
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 isPreSafetyShield() const;
@ -34,15 +34,12 @@ namespace storm {
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 = ShieldComparison::Relative;
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>());
auto choice_it = maybeStateChoiceValues.begin();
// TODO THIS IS BUGGY!!
for(uint state = 0; state < transitionMatrix.getRowGroupIndices().size() - 1; state++) {
uint rowGroupSize = transitionMatrix.getRowGroupIndices().at(state + 1) - transitionMatrix.getRowGroupIndices().at(state);
if (qualitativeStateSets.maybeStates.get(state)) {

6
src/storm/shields/AbstractShield.cpp

@ -34,12 +34,6 @@ namespace tempest {
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
template class AbstractShield<double, typename storm::storage::SparseMatrix<double>::index_type>;
#ifdef STORM_HAVE_CARL

1
src/storm/shields/AbstractShield.h

@ -49,7 +49,6 @@ namespace tempest {
storm::OptimizationDirection getOptimizationDirection();
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 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 shields {
std::string shieldFilename(std::shared_ptr<storm::logic::ShieldExpression const> const& shieldingExpression) {
return shieldingExpression->getFilename() + ".shield";
}
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) {
if(coalitionStates.is_initialized()) coalitionStates.get().complement();

2
src/storm/shields/ShieldHandling.h

@ -21,8 +21,6 @@
namespace tempest {
namespace shields {
std::string shieldFilename(std::shared_ptr<storm::logic::ShieldExpression const> const& shieldingExpression);
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);

Loading…
Cancel
Save