Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
Automaton.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <string>
5#include <unordered_map>
6#include <vector>
7
13
14namespace storm {
15namespace jani {
16
17class Automaton;
18class Edge;
19class TemplateEdge;
20class Location;
21
22class Model;
23
24class Automaton {
25 public:
26 friend class detail::Edges;
27 friend class detail::ConstEdges;
28
31
35 Automaton(std::string const& name, storm::expressions::Variable const& locationExpressionVariable);
36
37 Automaton(Automaton const& other) = default;
38 Automaton& operator=(Automaton const& other) = default;
39 Automaton(Automaton&& other) = default;
40 Automaton& operator=(Automaton&& other) = default;
41
42 Automaton clone(storm::expressions::ExpressionManager& manager, std::string const& nameOfClone, std::string const& variablePrefix) const;
43
47 std::string const& getName() const;
48
52 Variable const& addVariable(Variable const& variable);
53
58
62 VariableSet const& getVariables() const;
63
64 bool hasVariable(std::string const& name) const;
65
71 std::set<storm::expressions::Variable> getAllExpressionVariables() const;
72
76 bool hasTransientVariable() const;
77
81 FunctionDefinition const& addFunctionDefinition(FunctionDefinition const& functionDefinition);
82
86 std::unordered_map<std::string, FunctionDefinition> const& getFunctionDefinitions() const;
87
91 std::unordered_map<std::string, FunctionDefinition>& getFunctionDefinitions();
92
96 bool hasLocation(std::string const& name) const;
97
104 uint64_t getLocationIndex(std::string const& name) const;
105
109 std::vector<Location> const& getLocations() const;
110
114 std::vector<Location>& getLocations();
115
119 Location const& getLocation(uint64_t index) const;
120
124 Location& getLocation(uint64_t index);
125
129 uint64_t addLocation(Location const& location);
130
134 void addInitialLocation(std::string const& name);
135
139 void addInitialLocation(uint64_t index);
140
144 std::set<uint64_t> const& getInitialLocationIndices() const;
145
149 std::map<uint64_t, std::string> buildIdToLocationNameMap() const;
150
155
159 Edge const& getEdge(uint64_t index) const;
160
164 Edges getEdgesFromLocation(std::string const& name);
165
169 Edges getEdgesFromLocation(uint64_t index);
170
174 ConstEdges getEdgesFromLocation(std::string const& name) const;
175
179 ConstEdges getEdgesFromLocation(uint64_t index) const;
180
184 Edges getEdgesFromLocation(uint64_t locationIndex, uint64_t actionIndex);
185
189 ConstEdges getEdgesFromLocation(uint64_t locationIndex, uint64_t actionIndex) const;
190
194 EdgeContainer const& getEdgeContainer() const;
195
200
204 void registerTemplateEdge(std::shared_ptr<TemplateEdge> const&);
205
209 void addEdge(Edge const& edge);
210
211 bool validate() const;
212
216 std::vector<Edge>& getEdges();
217
221 std::vector<Edge> const& getEdges() const;
222
226 std::set<uint64_t> getActionIndices() const;
227
231 uint64_t getNumberOfLocations() const;
232
236 uint64_t getNumberOfEdges() const;
237
241 bool hasRestrictedInitialStates() const;
242
246 bool hasInitialStatesRestriction() const;
247
251 bool hasNonTrivialInitialStates() const;
252
257
261 void setInitialStatesRestriction(storm::expressions::Expression const& initialStatesRestriction);
262
267
273
277 bool hasEdgeLabeledWithActionIndex(uint64_t actionIndex) const;
278
282 std::vector<storm::expressions::Expression> getAllRangeExpressions() const;
283
287 void substitute(std::map<storm::expressions::Variable, storm::expressions::Expression> const& substitution, bool const substituteTranscendentalNumbers);
288
292 void changeAssignmentVariables(std::map<Variable const*, std::reference_wrapper<Variable const>> const& remapping);
293
298 void finalize(Model const& containingModel);
299
303 std::set<uint64_t> getUsedActionIndices() const;
304
309 bool containsVariablesOnlyInProbabilitiesOrTransientAssignments(std::set<storm::expressions::Variable> const& variables) const;
310
315
321
326
330 void liftTransientEdgeDestinationAssignments(int64_t maxLevel = 0);
331
335 bool usesAssignmentLevels(bool onlyTransient = false) const;
336
338
342 bool isLinear() const;
343
344 void writeDotToStream(std::ostream& outStream, std::vector<std::string> const& actionNames) const;
345
350
351 private:
353 std::string name;
354
356 storm::expressions::Variable locationExpressionVariable;
357
359 VariableSet variables;
360
363 std::unordered_map<std::string, FunctionDefinition> functionDefinitions;
364
366 std::vector<Location> locations;
367
369 std::unordered_map<std::string, uint64_t> locationToIndex;
370
372 EdgeContainer edges;
373
376 std::vector<uint64_t> locationToStartingIndex;
377
379 std::set<uint64_t> initialLocationIndices;
380
382 storm::expressions::Expression initialStatesRestriction;
383
385 std::set<uint64_t> actionIndices;
386};
387
388} // namespace jani
389} // namespace storm
This class is responsible for managing a set of typed variables and all expressions using these varia...
Automaton(Automaton &&other)=default
detail::ConstEdges ConstEdges
Definition Automaton.h:30
VariableSet & getVariables()
Retrieves the variables of this automaton.
Definition Automaton.cpp:59
Automaton clone(storm::expressions::ExpressionManager &manager, std::string const &nameOfClone, std::string const &variablePrefix) const
Definition Automaton.cpp:31
bool usesAssignmentLevels(bool onlyTransient=false) const
Retrieves whether the automaton uses an assignment level other than zero.
std::set< storm::expressions::Variable > getAllExpressionVariables() const
Retrieves all expression variables used by this automaton.
Definition Automaton.cpp:67
void addEdge(Edge const &edge)
Adds an edge to the automaton.
storm::expressions::Expression const & getInitialStatesRestriction() const
Gets the expression restricting the legal initial values of the automaton's variables.
Automaton & operator=(Automaton &&other)=default
bool hasLocation(std::string const &name) const
Retrieves whether the automaton has a location with the given name.
Definition Automaton.cpp:94
Automaton(Automaton const &other)=default
void registerTemplateEdge(std::shared_ptr< TemplateEdge > const &)
Adds the template edge to the list of edges.
Automaton & operator=(Automaton const &other)=default
void finalize(Model const &containingModel)
Finalizes the building of this automaton.
bool hasVariable(std::string const &name) const
Definition Automaton.cpp:55
storm::expressions::Expression getInitialStatesExpression() const
Retrieves the expression defining the legal initial values of the automaton's variables.
storm::expressions::Variable const & getLocationExpressionVariable() const
Retrieves the expression variable that represents the location of this automaton.
Location const & getLocation(uint64_t index) const
Retrieves the location with the given index.
std::set< uint64_t > const & getInitialLocationIndices() const
Retrieves the indices of the initial locations.
std::vector< storm::expressions::Expression > getAllRangeExpressions() const
Retrieves a list of expressions that characterize the legal values of the variables in this automaton...
bool isLinear() const
Checks the automaton for linearity.
void setInitialStatesRestriction(storm::expressions::Expression const &initialStatesRestriction)
Sets the expression restricting the legal initial values of the automaton's variables.
Variable const & addVariable(Variable const &variable)
Adds the given variable to this automaton.
Definition Automaton.cpp:51
bool hasTrivialInitialStatesExpression() const
Retrieves whether the initial states expression is trivial in the sense that the automaton has no ini...
std::set< uint64_t > getUsedActionIndices() const
Retrieves the action indices appearing at some edge of the automaton.
FunctionDefinition const & addFunctionDefinition(FunctionDefinition const &functionDefinition)
Adds the given function definition.
Definition Automaton.cpp:79
void addInitialLocation(std::string const &name)
Adds the location with the given name to the initial locations.
uint64_t getNumberOfEdges() const
Retrieves the number of edges.
bool hasRestrictedInitialStates() const
Retrieves whether the initial restriction is set and unequal to true.
uint64_t addLocation(Location const &location)
Adds the given location to the automaton.
void changeAssignmentVariables(std::map< Variable const *, std::reference_wrapper< Variable const > > const &remapping)
Changes all variables in assignments based on the given mapping.
void substitute(std::map< storm::expressions::Variable, storm::expressions::Expression > const &substitution, bool const substituteTranscendentalNumbers)
Substitutes all variables in all expressions according to the given substitution.
bool containsVariablesOnlyInProbabilitiesOrTransientAssignments(std::set< storm::expressions::Variable > const &variables) const
Checks whether the provided variables only appear in the probability expressions or the expressions b...
std::vector< Location > const & getLocations() const
Retrieves the locations of the automaton.
Definition Automaton.cpp:98
Edge const & getEdge(uint64_t index) const
Retrieves the edge with the given index in this automaton.
uint64_t getNumberOfLocations() const
Retrieves the number of locations.
Edges getEdgesFromLocation(std::string const &name)
Retrieves the edges of the location with the given name.
bool hasNonTrivialInitialStates() const
Retrieves whether this automaton has non-trivial initial states.
bool hasEdgeLabeledWithActionIndex(uint64_t actionIndex) const
Retrieves whether there is an edge labeled with the action with the given index in this automaton.
bool hasTransientVariable() const
Retrieves whether this automaton has a transient variable.
Definition Automaton.cpp:75
bool hasInitialStatesRestriction() const
Retrieves whether this automaton has an initial states restriction.
void pushTransientRealLocationAssignmentsToEdges()
Pushes the assignments to real-valued transient variables to the edges.
void writeDotToStream(std::ostream &outStream, std::vector< std::string > const &actionNames) const
std::unordered_map< std::string, FunctionDefinition > const & getFunctionDefinitions() const
Retrieves all function definitions of this automaton.
Definition Automaton.cpp:86
std::string const & getName() const
Retrieves the name of the automaton.
Definition Automaton.cpp:47
bool hasTransientEdgeDestinationAssignments() const
Retrieves whether there is any transient edge destination assignment in the automaton.
std::set< uint64_t > getActionIndices() const
Retrieves the set of action indices that are labels of edges of this automaton.
detail::Edges Edges
Definition Automaton.h:29
void liftTransientEdgeDestinationAssignments(int64_t maxLevel=0)
Lifts the common edge destination assignments to edge assignments.
std::vector< Edge > & getEdges()
Retrieves the edges of the automaton.
void pushEdgeAssignmentsToDestinations()
Pushes the edge assignments to the corresponding destinations.
uint64_t getLocationIndex(std::string const &name) const
EdgeContainer const & getEdgeContainer() const
Retrieves the container of all edges of this automaton.
void restrictToEdges(storm::storage::FlatSet< uint_fast64_t > const &edgeIndices)
Restricts the automaton to the edges given by the indices.
std::map< uint64_t, std::string > buildIdToLocationNameMap() const
Builds a map from ID to Location Name.
Jani Location:
Definition Location.h:15
boost::container::flat_set< Key, std::less< Key >, boost::container::new_allocator< Key > > FlatSet
Redefinition of flat_set was needed, because from Boost 1.70 on the default allocator is set to void.
Definition BoostTypes.h:13
LabParser.cpp.
Definition cli.cpp:18