Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
JaniTraverser.cpp
Go to the documentation of this file.
2
3namespace storm {
4namespace jani {
5
6void JaniTraverser::traverse(Model& model, boost::any const& data) {
7 for (auto& act : model.getActions()) {
8 traverse(act, data);
9 }
10 for (auto& c : model.getConstants()) {
11 traverse(c, data);
12 }
13 for (auto& f : model.getGlobalFunctionDefinitions()) {
14 traverse(f.second, data);
15 }
17 for (auto& aut : model.getAutomata()) {
18 traverse(aut, data);
19 }
22 }
23 for (auto& nonTrivRew : model.getNonTrivialRewardExpressions()) {
24 traverse(nonTrivRew.second, data);
25 }
28void JaniTraverser::traverse(Action const&, boost::any const&) {
29 // Intentionally left empty.
32void JaniTraverser::traverse(Automaton& automaton, boost::any const& data) {
33 traverse(automaton.getVariables(), data);
34 for (auto& f : automaton.getFunctionDefinitions()) {
35 traverse(f.second, data);
36 }
37 for (auto& loc : automaton.getLocations()) {
38 traverse(loc, data);
39 }
40 traverse(automaton.getEdgeContainer(), data);
41 if (automaton.hasInitialStatesRestriction()) {
43 }
46void JaniTraverser::traverse(Constant& constant, boost::any const& data) {
47 if (constant.isDefined()) {
48 traverse(constant.getExpression(), data);
49 }
50 if (constant.hasConstraint()) {
52 }
55void JaniTraverser::traverse(FunctionDefinition& functionDefinition, boost::any const& data) {
56 traverse(functionDefinition.getFunctionBody(), data);
57}
58
59void JaniTraverser::traverse(VariableSet& variableSet, boost::any const& data) {
60 for (auto& v : variableSet) {
61 traverse(v, data);
62 }
63}
64
65void JaniTraverser::traverse(Location& location, boost::any const& data) {
66 traverse(location.getAssignments(), data);
67 if (location.hasTimeProgressInvariant()) {
68 traverse(location.getTimeProgressInvariant(), data);
69 }
70}
71
72void JaniTraverser::traverse(Variable& variable, boost::any const& data) {
73 if (variable.hasInitExpression()) {
74 traverse(variable.getInitExpression(), data);
75 }
76 traverse(variable.getType(), data);
77}
78
79void JaniTraverser::traverse(JaniType& type, boost::any const& data) {
80 if (type.isBoundedType()) {
81 auto& boundedType = type.asBoundedType();
82 if (boundedType.hasLowerBound()) {
83 traverse(boundedType.getLowerBound(), data);
84 }
85 if (boundedType.hasUpperBound()) {
86 traverse(boundedType.getUpperBound(), data);
87 }
88 } else if (type.isArrayType()) {
89 traverse(type.asArrayType().getBaseType(), data);
90 }
91}
92
93void JaniTraverser::traverse(EdgeContainer& edgeContainer, boost::any const& data) {
94 for (auto& templateEdge : edgeContainer.getTemplateEdges()) {
95 traverse(*templateEdge, data);
96 }
97 for (auto& concreteEdge : edgeContainer.getConcreteEdges()) {
98 traverse(concreteEdge, data);
99 }
100}
101
102void JaniTraverser::traverse(TemplateEdge& templateEdge, boost::any const& data) {
103 traverse(templateEdge.getGuard(), data);
104 for (auto& dest : templateEdge.getDestinations()) {
105 traverse(dest, data);
106 }
107 traverse(templateEdge.getAssignments(), data);
108}
109
110void JaniTraverser::traverse(TemplateEdgeDestination& templateEdgeDestination, boost::any const& data) {
111 traverse(templateEdgeDestination.getOrderedAssignments(), data);
112}
113
114void JaniTraverser::traverse(Edge& edge, boost::any const& data) {
115 if (edge.hasRate()) {
116 traverse(edge.getRate(), data);
117 }
118 for (auto& dest : edge.getDestinations()) {
119 traverse(dest, data);
120 }
121}
122
123void JaniTraverser::traverse(EdgeDestination& edgeDestination, boost::any const& data) {
124 traverse(edgeDestination.getProbability(), data);
125}
126
127void JaniTraverser::traverse(OrderedAssignments& orderedAssignments, boost::any const& data) {
128 for (auto& assignment : orderedAssignments) {
129 traverse(assignment, data);
130 }
131 STORM_LOG_ASSERT(orderedAssignments.checkOrder(), "Order of ordered assignment\n" << orderedAssignments << "\nhas been violated.");
132}
133
134void JaniTraverser::traverse(Assignment& assignment, boost::any const& data) {
135 traverse(assignment.getAssignedExpression(), data);
136 traverse(assignment.getLValue(), data);
137}
138
139void JaniTraverser::traverse(LValue& lValue, boost::any const& data) {
140 if (lValue.isArrayAccess()) {
141 for (auto& index : lValue.getArrayIndexVector()) {
142 traverse(index, data);
143 }
144 }
145}
146
148 // intentionally left empty.
149}
150
151void ConstJaniTraverser::traverse(Model const& model, boost::any const& data) {
152 for (auto const& act : model.getActions()) {
153 traverse(act, data);
154 }
155 for (auto const& c : model.getConstants()) {
156 traverse(c, data);
157 }
158 for (auto const& f : model.getGlobalFunctionDefinitions()) {
159 traverse(f.second, data);
160 }
161 traverse(model.getGlobalVariables(), data);
162 for (auto const& aut : model.getAutomata()) {
163 traverse(aut, data);
164 }
165 if (model.hasInitialStatesRestriction()) {
167 }
168 for (auto const& nonTrivRew : model.getNonTrivialRewardExpressions()) {
169 traverse(nonTrivRew.second, data);
170 }
171}
172
173void ConstJaniTraverser::traverse(Action const&, boost::any const&) {
174 // Intentionally left empty.
175}
176
177void ConstJaniTraverser::traverse(Automaton const& automaton, boost::any const& data) {
178 traverse(automaton.getVariables(), data);
179 for (auto const& f : automaton.getFunctionDefinitions()) {
180 traverse(f.second, data);
181 }
182 for (auto const& loc : automaton.getLocations()) {
183 traverse(loc, data);
184 }
185 traverse(automaton.getEdgeContainer(), data);
186 if (automaton.hasInitialStatesRestriction()) {
187 traverse(automaton.getInitialStatesRestriction(), data);
188 }
189}
190
191void ConstJaniTraverser::traverse(Constant const& constant, boost::any const& data) {
192 if (constant.isDefined()) {
193 traverse(constant.getExpression(), data);
194 }
195 if (constant.hasConstraint()) {
196 traverse(constant.getConstraintExpression(), data);
197 }
198}
199
200void ConstJaniTraverser::traverse(FunctionDefinition const& functionDefinition, boost::any const& data) {
201 traverse(functionDefinition.getFunctionBody(), data);
202}
203
204void ConstJaniTraverser::traverse(VariableSet const& variableSet, boost::any const& data) {
205 for (auto const& v : variableSet) {
206 traverse(v, data);
207 }
208}
209
210void ConstJaniTraverser::traverse(Location const& location, boost::any const& data) {
211 traverse(location.getAssignments(), data);
212 if (location.hasTimeProgressInvariant()) {
213 traverse(location.getTimeProgressInvariant(), data);
214 }
215}
216
217void ConstJaniTraverser::traverse(Variable const& variable, boost::any const& data) {
218 if (variable.hasInitExpression()) {
219 traverse(variable.getInitExpression(), data);
220 }
221 traverse(variable.getType(), data);
222}
223
224void ConstJaniTraverser::traverse(JaniType const& type, boost::any const& data) {
225 if (type.isBoundedType()) {
226 auto const& boundedType = type.asBoundedType();
227 if (boundedType.hasLowerBound()) {
228 traverse(boundedType.getLowerBound(), data);
229 }
230 if (boundedType.hasUpperBound()) {
231 traverse(boundedType.getUpperBound(), data);
232 }
233 } else if (type.isArrayType()) {
234 traverse(type.asArrayType().getBaseType(), data);
235 }
236}
237
238void ConstJaniTraverser::traverse(EdgeContainer const& edgeContainer, boost::any const& data) {
239 for (auto const& templateEdge : edgeContainer.getTemplateEdges()) {
240 traverse(*templateEdge, data);
241 }
242 for (auto const& concreteEdge : edgeContainer.getConcreteEdges()) {
243 traverse(concreteEdge, data);
244 }
245}
246
247void ConstJaniTraverser::traverse(TemplateEdge const& templateEdge, boost::any const& data) {
248 traverse(templateEdge.getGuard(), data);
249 for (auto const& dest : templateEdge.getDestinations()) {
250 traverse(dest, data);
251 }
252 traverse(templateEdge.getAssignments(), data);
253}
254
255void ConstJaniTraverser::traverse(TemplateEdgeDestination const& templateEdgeDestination, boost::any const& data) {
256 traverse(templateEdgeDestination.getOrderedAssignments(), data);
257}
258
259void ConstJaniTraverser::traverse(Edge const& edge, boost::any const& data) {
260 if (edge.hasRate()) {
261 traverse(edge.getRate(), data);
262 }
263 for (auto const& dest : edge.getDestinations()) {
264 traverse(dest, data);
265 }
266}
267
268void ConstJaniTraverser::traverse(EdgeDestination const& edgeDestination, boost::any const& data) {
269 traverse(edgeDestination.getProbability(), data);
270}
271
272void ConstJaniTraverser::traverse(OrderedAssignments const& orderedAssignments, boost::any const& data) {
273 for (auto const& assignment : orderedAssignments) {
274 traverse(assignment, data);
275 }
276}
277
278void ConstJaniTraverser::traverse(Assignment const& assignment, boost::any const& data) {
279 traverse(assignment.getAssignedExpression(), data);
280 traverse(assignment.getLValue(), data);
281}
282
283void ConstJaniTraverser::traverse(LValue const& lValue, boost::any const& data) {
284 if (lValue.isArrayAccess()) {
285 for (auto const& index : lValue.getArrayIndexVector()) {
286 traverse(index, data);
287 }
288 }
289}
290
292 // intentionally left empty.
293}
294
295} // namespace jani
296} // namespace storm
JaniType & getBaseType()
Definition ArrayType.cpp:18
storm::expressions::Expression const & getAssignedExpression() const
Retrieves the expression whose value is assigned to the target variable.
storm::jani::LValue const & getLValue() const
Retrieves the lValue that is written in this assignment.
VariableSet & getVariables()
Retrieves the variables of this automaton.
Definition Automaton.cpp:59
storm::expressions::Expression const & getInitialStatesRestriction() const
Gets the expression restricting the legal initial values of the automaton's variables.
std::vector< Location > const & getLocations() const
Retrieves the locations of the automaton.
Definition Automaton.cpp:98
bool hasInitialStatesRestriction() const
Retrieves whether this automaton has an initial states restriction.
std::unordered_map< std::string, FunctionDefinition > const & getFunctionDefinitions() const
Retrieves all function definitions of this automaton.
Definition Automaton.cpp:86
EdgeContainer const & getEdgeContainer() const
Retrieves the container of all edges of this automaton.
virtual void traverse(Model const &model, boost::any const &data)
bool hasConstraint() const
Retrieves whether there is a constraint for the possible values of this constant.
Definition Constant.cpp:72
storm::expressions::Expression const & getConstraintExpression() const
Retrieves the expression that constraints the possible values of this constant (if any).
Definition Constant.cpp:76
bool isDefined() const
Retrieves whether the constant is defined in the sense that it has a defining expression.
Definition Constant.cpp:34
storm::expressions::Expression const & getExpression() const
Retrieves the expression that defines this constant (if any).
Definition Constant.cpp:67
TemplateEdgeContainer const & getTemplateEdges() const
std::vector< Edge > const & getConcreteEdges() const
storm::expressions::Expression const & getProbability() const
Retrieves the probability of choosing this destination.
std::vector< EdgeDestination > const & getDestinations() const
Retrieves the destinations of this edge.
Definition Edge.cpp:77
bool hasRate() const
Retrieves whether this edge has an associated rate.
Definition Edge.cpp:49
storm::expressions::Expression const & getRate() const
Retrieves the rate of this edge.
Definition Edge.cpp:53
storm::expressions::Expression const & getFunctionBody() const
Retrieves the expression that defines the function.
virtual void traverse(Model &model, boost::any const &data)
ArrayType const & asArrayType() const
Definition JaniType.cpp:47
virtual bool isArrayType() const
Definition JaniType.cpp:19
virtual bool isBoundedType() const
Definition JaniType.cpp:15
BoundedType const & asBoundedType() const
Definition JaniType.cpp:39
std::vector< storm::expressions::Expression > & getArrayIndexVector()
Returns the referred variable. In case of an array access, this is the referred array variable.
Definition LValue.cpp:40
bool isArrayAccess() const
Returns true if the lValue refers either to an array variable or to an array access.
Definition LValue.cpp:32
Jani Location:
Definition Location.h:15
OrderedAssignments const & getAssignments() const
Retrieves the assignments of this location.
Definition Location.cpp:23
storm::expressions::Expression const & getTimeProgressInvariant() const
Retrieves the time progress invariant.
Definition Location.cpp:40
bool hasTimeProgressInvariant() const
Retrieves whether a time progress invariant is attached to this location.
Definition Location.cpp:36
VariableSet & getGlobalVariables()
Retrieves the variables of this automaton.
Definition Model.cpp:721
std::unordered_map< std::string, storm::expressions::Expression > const & getNonTrivialRewardExpressions() const
Retrieves all available non-trivial reward model names and expressions of the model.
Definition Model.cpp:855
bool hasInitialStatesRestriction() const
Retrieves whether there is an expression restricting the legal initial values of the global variables...
Definition Model.cpp:1284
storm::expressions::Expression const & getInitialStatesRestriction() const
Gets the expression restricting the legal initial values of the global variables.
Definition Model.cpp:1288
std::vector< Automaton > & getAutomata()
Retrieves the automata of the model.
Definition Model.cpp:872
std::vector< Constant > const & getConstants() const
Retrieves the constants of the model.
Definition Model.cpp:689
std::vector< Action > const & getActions() const
Retrieves the actions of the model.
Definition Model.cpp:646
std::unordered_map< std::string, FunctionDefinition > const & getGlobalFunctionDefinitions() const
Retrieves all global function definitions.
Definition Model.cpp:781
bool checkOrder() const
Checks whether this ordered assignment is in the correct order.
OrderedAssignments const & getOrderedAssignments() const
storm::expressions::Expression const & getGuard() const
std::vector< TemplateEdgeDestination > const & getDestinations() const
OrderedAssignments const & getAssignments() const
bool hasInitExpression() const
Retrieves whether an initial expression is set.
Definition Variable.cpp:46
JaniType & getType()
Definition Variable.cpp:67
storm::expressions::Expression const & getInitExpression() const
Retrieves the initial expression Should only be called if an initial expression is set for this varia...
Definition Variable.cpp:50
#define STORM_LOG_ASSERT(cond, message)
Definition macros.h:11
LabParser.cpp.
Definition cli.cpp:18