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