Storm 1.11.1.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
Engine.cpp
Go to the documentation of this file.
2
22
23namespace storm {
24namespace utility {
25
26// Returns a list of all available engines (excluding Unknown)
27std::vector<Engine> getEngines() {
28 std::vector<Engine> res;
29 for (int i = 0; i != static_cast<int>(Engine::Unknown); ++i) {
30 res.push_back(static_cast<Engine>(i));
31 }
32 return res;
33}
34
35std::string toString(Engine const& engine) {
36 switch (engine) {
37 case Engine::Sparse:
38 return "sparse";
39 case Engine::Hybrid:
40 return "hybrid";
41 case Engine::Dd:
42 return "dd";
44 return "dd-to-sparse";
46 return "expl";
48 return "abs";
50 return "automatic";
51 case Engine::Unknown:
52 return "UNKNOWN";
53 default:
54 STORM_LOG_ASSERT(false, "The given engine has no name assigned to it.");
55 return "UNKNOWN";
56 }
57}
58
59std::ostream& operator<<(std::ostream& os, Engine const& engine) {
60 os << toString(engine);
61 return os;
62}
63
64Engine engineFromString(std::string const& engineStr) {
65 for (Engine const& e : getEngines()) {
66 if (engineStr == toString(e)) {
67 return e;
68 }
69 }
70 if (engineStr == "portfolio") {
71 STORM_LOG_WARN("The engine name \"portfolio\" is deprecated. The name of this engine has been changed to \"" << toString(Engine::Automatic) << "\".");
72 return Engine::Automatic;
73 }
74 STORM_LOG_ERROR("The engine '" << engineStr << "' was not found.");
75 return Engine::Unknown;
76}
77
79 switch (engine) {
80 case Engine::Sparse:
82 case Engine::Hybrid:
84 case Engine::Dd:
92 default:
93 STORM_LOG_THROW(false, storm::exceptions::InvalidArgumentException, "The given engine has no builder type to it.");
95 }
96}
97
98template<typename ValueType>
101 // Define types to improve readability
103 // The Dd library does not make much of a difference (in case of exact or parametric models we will switch to sylvan anyway).
104 // Therefore, we always use sylvan here
106 switch (engine) {
107 case Engine::Sparse:
108 case Engine::DdSparse:
109 switch (modelType) {
110 case ModelType::DTMC:
112 case ModelType::MDP:
114 case ModelType::CTMC:
116 case ModelType::MA:
118 checkTask);
119 case ModelType::POMDP:
120 return false;
121 case ModelType::SMG:
123 }
124 break;
125 case Engine::Hybrid:
126 switch (modelType) {
127 case ModelType::DTMC:
129 case ModelType::MDP:
131 case ModelType::CTMC:
133 case ModelType::MA:
136 case ModelType::POMDP:
137 case ModelType::SMG:
138 return false;
139 }
140 break;
141 case Engine::Dd:
142 switch (modelType) {
143 case ModelType::DTMC:
145 case ModelType::MDP:
147 case ModelType::CTMC:
148 case ModelType::MA:
149 case ModelType::POMDP:
150 case ModelType::SMG:
151 return false;
152 }
153 break;
155 if constexpr (std::is_same_v<ValueType, storm::RationalNumber>) {
156 return false;
157 }
158 switch (modelType) {
159 case ModelType::DTMC:
161 case ModelType::MDP:
163 case ModelType::CTMC:
164 case ModelType::MA:
165 case ModelType::POMDP:
166 case ModelType::SMG:
167 return false;
168 }
169 break;
171 if constexpr (std::is_same_v<ValueType, storm::RationalNumber>) {
172 return false;
173 }
174 switch (modelType) {
175 case ModelType::DTMC:
176 case ModelType::MDP:
177 // Since the corresponding model checker is in a separate library, we can only make a very crude over-approximation of what can be handled
178 // at this point.
179 return true;
180 case ModelType::CTMC:
181 case ModelType::MA:
182 case ModelType::POMDP:
183 case ModelType::SMG:
184 return false;
185 }
186 break;
187 default:
188 STORM_LOG_ERROR("The selected engine " << engine << " is not considered.");
189 }
190 STORM_LOG_ERROR("The selected combination of engine (" << engine << ") and model type (" << modelType
191 << ") does not seem to be supported for this value type.");
192 return false;
193}
194
195template<>
198 // Define types to improve readability
200 // The Dd library does not make much of a difference (in case of exact or parametric models we will switch to sylvan anyway).
201 // Therefore, we always use sylvan here
203 switch (engine) {
204 case Engine::Sparse:
205 case Engine::DdSparse:
206 switch (modelType) {
207 case ModelType::DTMC:
209 case ModelType::CTMC:
211 case ModelType::MDP:
212 case ModelType::MA:
213 case ModelType::POMDP:
214 case ModelType::SMG:
215 return false;
216 }
217 break;
218 case Engine::Hybrid:
219 switch (modelType) {
220 case ModelType::DTMC:
222 checkTask);
223 case ModelType::CTMC:
225 checkTask);
226 case ModelType::MDP:
227 case ModelType::MA:
228 case ModelType::POMDP:
229 case ModelType::SMG:
230 return false;
231 }
232 break;
233 case Engine::Dd:
234 switch (modelType) {
235 case ModelType::DTMC:
237 checkTask);
238 case ModelType::MDP:
239 case ModelType::CTMC:
240 case ModelType::MA:
241 case ModelType::POMDP:
242 case ModelType::SMG:
243 return false;
244 }
245 break;
248 return false;
249 default:
250 STORM_LOG_ERROR("The selected engine" << engine << " is not considered.");
251 }
252 STORM_LOG_ERROR("The selected combination of engine (" << engine << ") and model type (" << modelType
253 << ") does not seem to be supported for this value type.");
254 return false;
255}
256
257template<typename ValueType>
258bool canHandle(storm::utility::Engine const& engine, std::vector<storm::jani::Property> const& properties,
259 storm::storage::SymbolicModelDescription const& modelDescription) {
260 auto canHandleFormula = [&engine, &modelDescription](auto const& formula, bool onlyInitialStatesRelevant) {
261 auto task = storm::modelchecker::CheckTask<storm::logic::Formula, ValueType>(formula, onlyInitialStatesRelevant);
262 bool result = canHandle(engine, modelDescription.getModelType(), task);
263 STORM_LOG_INFO_COND(result, "Engine " << engine << " can not handle formula '" << task.getFormula() << "' on models of type "
264 << modelDescription.getModelType() << ".");
265 return result;
266 };
267 auto canHandleProperty = [&canHandleFormula](auto const& property) {
268 if (property.getFilter().isDefault()) {
269 return canHandleFormula(*property.getRawFormula(), true);
270 } else {
271 return canHandleFormula(*property.getRawFormula(), false) && canHandleFormula(*property.getFilter().getStatesFormula(), false);
272 }
273 };
274 return std::all_of(properties.begin(), properties.end(), canHandleProperty) &&
275 storm::builder::canHandle<ValueType>(getBuilderType(engine), modelDescription, properties);
276}
277
278// explicit template instantiations.
279template bool canHandle<double>(storm::utility::Engine const&, std::vector<storm::jani::Property> const&, storm::storage::SymbolicModelDescription const&);
280template bool canHandle<storm::RationalNumber>(storm::utility::Engine const&, std::vector<storm::jani::Property> const&,
282template bool canHandle<storm::RationalFunction>(storm::utility::Engine const&, std::vector<storm::jani::Property> const&,
284
285} // namespace utility
286} // namespace storm
This class represents a discrete-time Markov decision process.
#define STORM_LOG_WARN(message)
Definition logging.h:25
#define STORM_LOG_ERROR(message)
Definition logging.h:26
#define STORM_LOG_ASSERT(cond, message)
Definition macros.h:11
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:30
#define STORM_LOG_INFO_COND(cond, message)
Definition macros.h:45
bool canHandle< storm::RationalFunction >(storm::utility::Engine const &engine, storm::storage::SymbolicModelDescription::ModelType const &modelType, storm::modelchecker::CheckTask< storm::logic::Formula, storm::RationalFunction > const &checkTask)
Definition Engine.cpp:196
Engine
An enumeration of all engines.
Definition Engine.h:31
template bool canHandle< storm::RationalNumber >(storm::utility::Engine const &, std::vector< storm::jani::Property > const &, storm::storage::SymbolicModelDescription const &)
template bool canHandle< double >(storm::utility::Engine const &, std::vector< storm::jani::Property > const &, storm::storage::SymbolicModelDescription const &)
storm::builder::BuilderType getBuilderType(Engine const &engine)
Returns the builder type used for the given engine.
Definition Engine.cpp:78
std::string toString(Engine const &engine)
Returns a string representation of the given engine.
Definition Engine.cpp:35
std::vector< Engine > getEngines()
Returns a list of all available engines (excluding Unknown)
Definition Engine.cpp:27
Engine engineFromString(std::string const &engineStr)
Parses the string representation of an engine and returns the corresponding engine.
Definition Engine.cpp:64
bool canHandle(storm::utility::Engine const &engine, storm::storage::SymbolicModelDescription::ModelType const &modelType, storm::modelchecker::CheckTask< storm::logic::Formula, ValueType > const &checkTask)
Definition Engine.cpp:99