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