Storm 1.10.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
AutomaticSettings.cpp
Go to the documentation of this file.
1#include "AutomaticSettings.h"
2
3#include <sstream>
4
9
12
13namespace storm {
14namespace utility {
15
16namespace pfinternal {
18
20 auto formulaInfo = property.getRawFormula()->info();
21 if (formulaInfo.containsBoundedUntilFormula() || formulaInfo.containsNextFormula() || formulaInfo.containsCumulativeRewardFormula()) {
22 STORM_LOG_INFO("Assuming step or time bounded property:" << property);
24 } else if (formulaInfo.containsLongRunFormula()) {
25 STORM_LOG_INFO("Assuming Long Run property:" << property);
27 } else {
28 STORM_LOG_INFO("Assuming Unbounded property:" << property);
30 }
31}
32
33struct Features {
34 Features(storm::jani::Model const& model, storm::jani::Property const& property) {
37 propertyType = getPropertyType(property);
38 auto modelInfo = model.getModelInformation();
39 numVariables = modelInfo.nrVariables;
40 numEdges = modelInfo.nrEdges;
41 numAutomata = modelInfo.nrAutomata;
42 stateDomainSize = modelInfo.stateDomainSize;
43 avgDomainSize = modelInfo.avgVarDomainSize;
44 stateEstimate = 0;
45 }
46
47 std::string toString() const {
48 std::stringstream str;
49 str << std::boolalpha << "continuous-time=" << continuousTime << "\tnondeterminism=" << nondeterminism << "\tpropertytype=";
50 switch (propertyType) {
52 str << "unbounded";
53 break;
55 str << "bounded";
56 break;
58 str << "longrun";
59 break;
60 }
61 str << "\tnumVariables=" << numVariables;
62 str << "\tnumEdges=" << numEdges;
63 str << "\tnumAutomata=" << numAutomata;
64 if (stateDomainSize > 0) {
65 str << "\tstateDomainSize=" << stateDomainSize;
66 }
67 if (avgDomainSize > 0.0) {
68 str << "\tavgDomainSize=" << avgDomainSize;
69 }
70 if (stateEstimate > 0) {
71 str << "\tstateEstimate=" << stateEstimate;
72 }
73 return str.str();
74 }
75
79 uint64_t numVariables;
80 uint64_t numAutomata;
81 uint64_t numEdges;
83 uint64_t stateEstimate;
85};
86} // namespace pfinternal
87
88AutomaticSettings::AutomaticSettings() : engine(storm::utility::Engine::Unknown), useBisimulation(false), useExact(false) {
89 // Intentionally left empty
90}
91
93 typedef pfinternal::PropertyType PropertyType;
94 auto f = pfinternal::Features(model, property);
95 STORM_LOG_INFO("Automatic engine using features " << f.toString() << ".");
96
97 if (f.numVariables <= 12) {
98 if (f.avgDomainSize <= 323.25) {
99 if (f.stateDomainSize <= 381703) {
100 if (f.numAutomata <= 1) {
101 exact();
102 } else { // f.numAutomata > 1
103 if (f.numEdges <= 34) {
104 if (!f.nondeterminism) {
105 sparse();
106 } else { // f.nondeterminism
107 if (f.stateDomainSize <= 1764) {
108 ddbisim();
109 } else { // f.stateDomainSize > 1764
110 sparse();
111 }
112 }
113 } else { // f.numEdges > 34
114 sparse();
115 }
116 }
117 } else { // f.stateDomainSize > 381703
118 if (!f.continuousTime) {
119 if (f.numEdges <= 6002) {
120 if (f.propertyType == PropertyType::Bounded) {
121 if (f.numEdges <= 68) {
122 hybrid();
123 } else { // f.numEdges > 68
124 ddbisim();
125 }
126 } else { // !(f.propertyType == PropertyType::Bounded)
127 if (f.avgDomainSize <= 26.4375) {
128 hybrid();
129 } else { // f.avgDomainSize > 26.4375
130 if (f.stateDomainSize <= 208000000) {
131 sparse();
132 } else { // f.stateDomainSize > 208000000
133 hybrid();
134 }
135 }
136 }
137 } else { // f.numEdges > 6002
138 sparse();
139 }
140 } else { // f.continuousTime
141 if (f.numAutomata <= 16) {
142 sparse();
143 } else { // f.numAutomata > 16
144 if (f.propertyType == PropertyType::Bounded) {
145 sparse();
146 } else { // !(f.propertyType == PropertyType::Bounded)
147 hybrid();
148 }
149 }
150 }
151 }
152 } else { // f.avgDomainSize > 323.25
153 sparse();
154 }
155 } else { // f.numVariables > 12
156 if (f.stateDomainSize <= 47006507008) {
157 if (f.avgDomainSize <= 4.538461446762085) {
158 if (f.numVariables <= 82) {
159 if (!f.continuousTime) {
160 if (f.numAutomata <= 8) {
161 sparse();
162 } else { // f.numAutomata > 8
163 hybrid();
164 }
165 } else { // f.continuousTime
166 hybrid();
167 }
168 } else { // f.numVariables > 82
169 if (f.numVariables <= 114) {
170 ddbisim();
171 } else { // f.numVariables > 114
172 hybrid();
173 }
174 }
175 } else { // f.avgDomainSize > 4.538461446762085
176 ddbisim();
177 }
178 } else { // f.stateDomainSize > 47006507008
179 if (f.numVariables <= 19) {
180 if (f.avgDomainSize <= 20.430288314819336) {
181 hybrid();
182 } else { // f.avgDomainSize > 20.430288314819336
183 if (f.stateDomainSize <= 209736679590723584) {
184 ddbisim();
185 } else { // f.stateDomainSize > 209736679590723584
186 if (f.propertyType == PropertyType::Bounded) {
187 hybrid();
188 } else { // !(f.propertyType == PropertyType::Bounded)
189 sparse();
190 }
191 }
192 }
193 } else { // f.numVariables > 19
194 if (!f.nondeterminism) {
195 if (f.numVariables <= 27) {
196 if (f.propertyType == PropertyType::Bounded) {
197 hybrid();
198 } else { // !(f.propertyType == PropertyType::Bounded)
199 sparse();
200 }
201 } else { // f.numVariables > 27
202 ddbisim();
203 }
204 } else { // f.nondeterminism
205 if (f.numAutomata <= 8) {
206 sparse();
207 } else { // f.numAutomata > 8
208 hybrid();
209 }
210 }
211 }
212 }
213 }
214}
215
216void AutomaticSettings::predict(storm::jani::Model const& model, storm::jani::Property const& property, uint64_t) {
217 // typedef pfinternal::PropertyType PropertyType;
218 // auto f = pfinternal::Features(model, property);
219 // f.stateEstimate = stateEstimate;
220 // STORM_LOG_INFO("Automatic engine using features " << f.toString() << ".");
221
222 // Right now, we do not make use of the state estimate, so we just ask the 'default' decision tree.
223 predict(model, property);
224}
225
227 STORM_LOG_THROW(engine != storm::utility::Engine::Unknown, storm::exceptions::InvalidOperationException,
228 "Tried to get the engine but apparently no prediction was done before.");
229 return engine;
230}
231
233 return useBisimulation;
234}
235
237 return useExact;
238}
239
240void AutomaticSettings::sparse() {
242 useBisimulation = false;
243 useExact = false;
244}
245
246void AutomaticSettings::hybrid() {
248 useBisimulation = false;
249 useExact = false;
250}
251
252void AutomaticSettings::dd() {
254 useBisimulation = false;
255 useExact = false;
256}
257
258void AutomaticSettings::exact() {
260 useBisimulation = false;
261 useExact = true;
262}
263
264void AutomaticSettings::ddbisim() {
266 useBisimulation = true;
267 useExact = false;
268}
269
270} // namespace utility
271} // namespace storm
InformationObject getModelInformation() const
Returns various information of this model.
Definition Model.cpp:713
bool isDeterministicModel() const
Determines whether this model is a deterministic one in the sense that each state only has one choice...
Definition Model.cpp:1369
bool isDiscreteTimeModel() const
Determines whether this model is a discrete-time model.
Definition Model.cpp:1373
storm::utility::Engine getEngine() const
Retrieve "good" settings after calling predict.
void predict(storm::jani::Model const &model, storm::jani::Property const &property)
Predicts "good" settings for the provided model checking query.
#define STORM_LOG_INFO(message)
Definition logging.h:24
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:30
PropertyType getPropertyType(storm::jani::Property const &property)
Engine
An enumeration of all engines.
Definition Engine.h:31
LabParser.cpp.
uint64_t nrVariables
The type of the model.
Features(storm::jani::Model const &model, storm::jani::Property const &property)