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