Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
properties.cpp
Go to the documentation of this file.
2
3#include <boost/algorithm/string.hpp>
8
10
11#include "storm/utility/cli.h"
12
13namespace storm {
14namespace api {
15
16std::vector<storm::jani::Property> substituteConstantsInProperties(std::vector<storm::jani::Property> const& properties,
17 std::map<storm::expressions::Variable, storm::expressions::Expression> const& substitution) {
18 std::vector<storm::jani::Property> preprocessedProperties;
19 for (auto const& property : properties) {
20 preprocessedProperties.emplace_back(property.substitute(substitution));
21 }
22 return preprocessedProperties;
23}
24
25std::vector<storm::jani::Property> substituteTranscendentalNumbersInProperties(std::vector<storm::jani::Property> const& properties) {
26 std::vector<storm::jani::Property> preprocessedProperties;
27 for (auto const& property : properties) {
28 preprocessedProperties.emplace_back(property.substituteTranscendentalNumbers());
29 }
30 return preprocessedProperties;
31}
32
33std::vector<storm::jani::Property> filterProperties(std::vector<storm::jani::Property> const& properties,
34 boost::optional<std::set<std::string>> const& propertyFilter) {
35 if (propertyFilter) {
36 std::set<std::string> const& propertyNameSet = propertyFilter.get();
37 std::vector<storm::jani::Property> result;
38 std::set<std::string> reducedPropertyNames;
39
40 if (propertyNameSet.empty()) {
41 STORM_LOG_WARN("Filtering all properties.");
42 }
43
44 for (auto const& property : properties) {
45 if (propertyNameSet.find(property.getName()) != propertyNameSet.end()) {
46 result.push_back(property);
47 reducedPropertyNames.insert(property.getName());
48 }
49 }
50
51 if (reducedPropertyNames.size() < propertyNameSet.size()) {
52 std::set<std::string> missingProperties;
53 std::set_difference(propertyNameSet.begin(), propertyNameSet.end(), reducedPropertyNames.begin(), reducedPropertyNames.end(),
54 std::inserter(missingProperties, missingProperties.begin()));
55 STORM_LOG_WARN("Filtering unknown properties " << boost::join(missingProperties, ", ") << ".");
56 }
57
58 return result;
59 } else {
60 return properties;
61 }
62}
63
64std::vector<std::shared_ptr<storm::logic::Formula const>> extractFormulasFromProperties(std::vector<storm::jani::Property> const& properties) {
65 std::vector<std::shared_ptr<storm::logic::Formula const>> formulas;
66 for (auto const& prop : properties) {
67 formulas.push_back(prop.getRawFormula());
68 }
69 return formulas;
70}
71
72storm::jani::Property createMultiObjectiveProperty(std::vector<storm::jani::Property> const& properties) {
73 std::set<storm::expressions::Variable> undefConstants;
74 std::string name = "";
75 std::string comment = "";
76 for (auto const& prop : properties) {
77 undefConstants.insert(prop.getUndefinedConstants().begin(), prop.getUndefinedConstants().end());
78 name += prop.getName();
79 comment += prop.getComment();
80 STORM_LOG_WARN_COND(prop.getFilter().isDefault(),
81 "Non-default property filter of property " + prop.getName() + " will be dropped during conversion to multi-objective property.");
82 }
83 auto multiFormula = std::make_shared<storm::logic::MultiObjectiveFormula>(extractFormulasFromProperties(properties));
84 return storm::jani::Property(name, multiFormula, undefConstants, comment);
85}
86} // namespace api
87} // namespace storm
std::string const & getName() const
Get the provided name.
Definition Property.cpp:23
#define STORM_LOG_WARN(message)
Definition logging.h:30
#define STORM_LOG_WARN_COND(cond, message)
Definition macros.h:38
std::pair< storm::jani::Model, std::vector< storm::jani::Property > > filterProperties(std::pair< storm::jani::Model, std::vector< storm::jani::Property > > &modelAndFormulae, boost::optional< std::vector< std::string > > const &propertyFilter)
std::vector< storm::jani::Property > substituteTranscendentalNumbersInProperties(std::vector< storm::jani::Property > const &properties)
storm::jani::Property createMultiObjectiveProperty(std::vector< storm::jani::Property > const &properties)
std::vector< std::shared_ptr< storm::logic::Formula const > > extractFormulasFromProperties(std::vector< storm::jani::Property > const &properties)
std::vector< storm::jani::Property > substituteConstantsInProperties(std::vector< storm::jani::Property > const &properties, std::map< storm::expressions::Variable, storm::expressions::Expression > const &substitution)
LabParser.cpp.
Definition cli.cpp:18