Browse Source

Jani Props may now hold info about shielding query

tempestpy_adaptions
Stefan Pranger 4 years ago
parent
commit
d4d3c0d9ea
  1. 1
      src/storm-parsers/parser/FormulaParser.cpp
  2. 2
      src/storm-parsers/parser/JaniParser.cpp
  3. 3
      src/storm/api/properties.cpp
  4. 2
      src/storm/logic/RewardAccumulationEliminationVisitor.cpp
  5. 33
      src/storm/storage/jani/Property.cpp
  6. 18
      src/storm/storage/jani/Property.h

1
src/storm-parsers/parser/FormulaParser.cpp

@ -93,7 +93,6 @@ namespace storm {
} catch (qi::expectation_failure<PositionIteratorType> const& e) {
STORM_LOG_THROW(false, storm::exceptions::WrongFormatException, e.what_);
}
return result;
}

2
src/storm-parsers/parser/JaniParser.cpp

@ -663,7 +663,7 @@ namespace storm {
STORM_LOG_THROW(statesFormula, storm::exceptions::NotImplementedException, "Could not derive states formula.");
STORM_LOG_THROW(expressionStructure.count("values") == 1, storm::exceptions::InvalidJaniException, "Values as input for a filter must be given");
auto formula = parseFormula(model, expressionStructure.at("values"), storm::logic::FormulaContext::Undefined, scope.refine("Values of property " + name));
return storm::jani::Property(name, storm::jani::FilterExpression(formula, ft, statesFormula), {}, comment);
return storm::jani::Property(name, storm::jani::FilterExpression(formula, ft, statesFormula), {}, nullptr, comment);
}
template <typename ValueType>

3
src/storm/api/properties.cpp

@ -67,9 +67,10 @@ namespace storm {
name += prop.getName();
comment += prop.getComment();
STORM_LOG_WARN_COND(prop.getFilter().isDefault(), "Non-default property filter of property " + prop.getName() + " will be dropped during conversion to multi-objective property.");
STORM_LOG_WARN_COND(!prop.isShieldingProperty(), "Shielding of multi-objective property is not possible yet. Dropping expression: '" + prop.getShieldingExpression()->toString() + "'.");
}
auto multiFormula = std::make_shared<storm::logic::MultiObjectiveFormula>(extractFormulasFromProperties(properties));
return storm::jani::Property(name, multiFormula, undefConstants, comment);
return storm::jani::Property(name, multiFormula, undefConstants, nullptr, comment);
}
}
}

2
src/storm/logic/RewardAccumulationEliminationVisitor.cpp

@ -31,7 +31,7 @@ namespace storm {
auto formula = eliminateRewardAccumulations(*property.getFilter().getFormula());
auto states = eliminateRewardAccumulations(*property.getFilter().getStatesFormula());
storm::jani::FilterExpression fe(formula, property.getFilter().getFilterType(), states);
property = storm::jani::Property(property.getName(), storm::jani::FilterExpression(formula, property.getFilter().getFilterType(), states), property.getUndefinedConstants(), property.getComment());
property = storm::jani::Property(property.getName(), storm::jani::FilterExpression(formula, property.getFilter().getFilterType(), states), property.getUndefinedConstants(), property.getShieldingExpression(), property.getComment());
}
boost::any RewardAccumulationEliminationVisitor::visit(BoundedUntilFormula const& f, boost::any const& data) const {

33
src/storm/storage/jani/Property.cpp

@ -7,19 +7,18 @@ namespace storm {
return os << "Obtain " << toString(fe.getFilterType()) << " of the '" << *fe.getStatesFormula() << "'-states with values described by '" << *fe.getFormula() << "'";
}
Property::Property(std::string const& name, std::shared_ptr<storm::logic::Formula const> const& formula, std::set<storm::expressions::Variable> const& undefinedConstants, std::string const& comment)
: name(name), comment(comment), filterExpression(FilterExpression(formula)), undefinedConstants(undefinedConstants) {
Property::Property(std::string const& name, std::shared_ptr<storm::logic::Formula const> const& formula, std::set<storm::expressions::Variable> const& undefinedConstants, std::shared_ptr<storm::logic::ShieldExpression const> const& shieldingExpression, std::string const& comment)
: name(name), comment(comment), filterExpression(FilterExpression(formula)), undefinedConstants(undefinedConstants), shieldingExpression(shieldingExpression) {
std::cout << "In Property ctor: " << *(this->shieldingExpression.get()) << std::endl;
std::cout << "In Property ctor: " << *(shieldingExpression.get()) << std::endl;
// Intentionally left empty.
}
Property::Property(std::string const& name, FilterExpression const& fe, std::set<storm::expressions::Variable> const& undefinedConstants, std::string const& comment)
: name(name), comment(comment), filterExpression(fe), undefinedConstants(undefinedConstants) {
// Intentionally left empty.
}
Property::Property(std::string const& name, std::shared_ptr<storm::logic::Formula const> const& formula, std::set<storm::expressions::Variable> const& undefinedConstants, storm::logic::ShieldExpression shieldExpression, std::string const& comment)
: name(name), comment(comment), filterExpression(FilterExpression(formula)), undefinedConstants(undefinedConstants), shieldingExpression(shieldingExpression) {
Property::Property(std::string const& name, FilterExpression const& fe, std::set<storm::expressions::Variable> const& undefinedConstants, std::shared_ptr<storm::logic::ShieldExpression const> const& shieldingExpression, std::string const& comment)
: name(name), comment(comment), filterExpression(fe), undefinedConstants(undefinedConstants), shieldingExpression(shieldingExpression) {
// Intentionally left empty.
std::cout << "In Property ctor with filterExpression: " << *(this->shieldingExpression.get()) << std::endl;
std::cout << "In Property ctor with filterExpression: " << *(shieldingExpression.get()) << std::endl;
}
std::string const& Property::getName() const {
@ -60,7 +59,7 @@ namespace storm {
remainingUndefinedConstants.insert(constant);
}
}
return Property(name, filterExpression.substitute(substitution), remainingUndefinedConstants, comment);
return Property(name, filterExpression.substitute(substitution), remainingUndefinedConstants, getShieldingExpression(), comment);
}
Property Property::substitute(std::function<storm::expressions::Expression(storm::expressions::Expression const&)> const& substitutionFunction) const {
@ -68,19 +67,19 @@ namespace storm {
for (auto const& constant : undefinedConstants) {
substitutionFunction(constant.getExpression()).getBaseExpression().gatherVariables(remainingUndefinedConstants);
}
return Property(name, filterExpression.substitute(substitutionFunction), remainingUndefinedConstants, comment);
return Property(name, filterExpression.substitute(substitutionFunction), remainingUndefinedConstants, getShieldingExpression(), comment);
}
Property Property::substituteLabels(std::map<std::string, std::string> const& substitution) const {
return Property(name, filterExpression.substituteLabels(substitution), undefinedConstants, comment);
return Property(name, filterExpression.substituteLabels(substitution), undefinedConstants, getShieldingExpression(), comment);
}
Property Property::substituteRewardModelNames(std::map<std::string, std::string> const& rewardModelNameSubstitution) const {
return Property(name, filterExpression.substituteRewardModelNames(rewardModelNameSubstitution), undefinedConstants, comment);
return Property(name, filterExpression.substituteRewardModelNames(rewardModelNameSubstitution), undefinedConstants, getShieldingExpression(), comment);
}
Property Property::clone() const {
return Property(name, filterExpression.clone(), undefinedConstants, comment);
return Property(name, filterExpression.clone(), undefinedConstants, getShieldingExpression(), comment);
}
FilterExpression const& Property::getFilter() const {
@ -95,6 +94,12 @@ namespace storm {
return shieldingExpression.is_initialized();
}
std::shared_ptr<storm::logic::ShieldExpression const> Property::getShieldingExpression() const {
//STORM_LOG_ASSERT(isShieldingProperty(), "This property does not have an associated shielding expression.");
if(!isShieldingProperty()) return nullptr;
return shieldingExpression.get();
}
std::set<storm::expressions::Variable> const& Property::getUndefinedConstants() const {
return undefinedConstants;
}

18
src/storm/storage/jani/Property.h

@ -102,26 +102,19 @@ namespace storm {
* @param name the name
* @param formula the formula representation
* @param undefinedConstants the undefined constants used in the property
* @param shieldingExpression An optional expression for a shield to be created
* @param comment An optional comment
*/
Property(std::string const& name, std::shared_ptr<storm::logic::Formula const> const& formula, std::set<storm::expressions::Variable> const& undefinedConstants, std::string const& comment = "");
Property(std::string const& name, std::shared_ptr<storm::logic::Formula const> const& formula, std::set<storm::expressions::Variable> const& undefinedConstants, std::shared_ptr<storm::logic::ShieldExpression const> const& shieldExpression = nullptr, std::string const& comment = "");
/**
* Constructs the property
* @param name the name
* @param formula the formula representation
* @param shieldingExpression An optional expression for a shield to be created
* @param comment An optional comment
*/
Property(std::string const& name, FilterExpression const& fe, std::set<storm::expressions::Variable> const& undefinedConstants, std::string const& comment = "");
/**
* Constructs the property
* @param name the name
* @param formula the formula representation
* @param shieldExpression the shielding expression
* @param comment An optional comment
*/
Property(std::string const& name, std::shared_ptr<storm::logic::Formula const> const& formula, std::set<storm::expressions::Variable> const& undefinedConstants, storm::logic::ShieldExpression shieldExpression, std::string const& comment = "");
Property(std::string const& name, FilterExpression const& fe, std::set<storm::expressions::Variable> const& undefinedConstants, std::shared_ptr<storm::logic::ShieldExpression const> const& shieldExpression = nullptr, std::string const& comment = "");
/**
* Get the provided name
@ -154,6 +147,7 @@ namespace storm {
std::shared_ptr<storm::logic::Formula const> getRawFormula() const;
bool isShieldingProperty() const;
std::shared_ptr<storm::logic::ShieldExpression const> getShieldingExpression() const;
private:
std::string name;
@ -162,7 +156,7 @@ namespace storm {
std::set<storm::expressions::Variable> undefinedConstants;
// TODO might need refactoring, this cannot be expressed by JANI yet, so this is totally wrong here.
boost::optional<storm::logic::ShieldExpression> shieldingExpression;
boost::optional<std::shared_ptr<storm::logic::ShieldExpression const>> shieldingExpression;
};

Loading…
Cancel
Save