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