Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
Module.h
Go to the documentation of this file.
1#ifndef STORM_STORAGE_PRISM_MODULE_H_
2#define STORM_STORAGE_PRISM_MODULE_H_
3
4#include <map>
5#include <memory>
6#include <set>
7#include <string>
8#include <vector>
9
17
18namespace storm {
19namespace prism {
20class Module : public LocatedInformation {
21 public:
34 Module(std::string const& moduleName, std::vector<storm::prism::BooleanVariable> const& booleanVariables,
35 std::vector<storm::prism::IntegerVariable> const& integerVariables, std::vector<storm::prism::ClockVariable> const& clockVariables,
36 storm::expressions::Expression const& invariant, std::vector<storm::prism::Command> const& commands, std::string const& filename = "",
37 uint_fast64_t lineNumber = 0);
38
54 Module(std::string const& moduleName, std::vector<storm::prism::BooleanVariable> const& booleanVariables,
55 std::vector<storm::prism::IntegerVariable> const& integerVariables, std::vector<storm::prism::ClockVariable> const& clockVariables,
56 storm::expressions::Expression const& invariant, std::vector<storm::prism::Command> const& commands, std::string const& renamedFromModule,
57 storm::prism::ModuleRenaming const& renaming, std::string const& filename = "", uint_fast64_t lineNumber = 0);
58
59 // Create default implementations of constructors/assignment.
60 Module() = default;
61 Module(Module const& other) = default;
62 Module& operator=(Module const& other) = default;
63 Module(Module&& other) = default;
64 Module& operator=(Module&& other) = default;
65
69 bool hasUnboundedVariables() const;
70
76 std::size_t getNumberOfBooleanVariables() const;
77
83 std::size_t getNumberOfIntegerVariables() const;
84
91 storm::prism::BooleanVariable const& getBooleanVariable(std::string const& variableName) const;
92
98 std::vector<storm::prism::BooleanVariable> const& getBooleanVariables() const;
99
106 storm::prism::IntegerVariable const& getIntegerVariable(std::string const& variableName) const;
107
113 std::vector<storm::prism::IntegerVariable> const& getIntegerVariables() const;
114
120 std::size_t getNumberOfClockVariables() const;
121
128 storm::prism::ClockVariable const& getClockVariable(std::string const& variableName) const;
129
135 std::vector<storm::prism::ClockVariable> const& getClockVariables() const;
136
142 std::set<storm::expressions::Variable> getAllExpressionVariables() const;
143
150 std::vector<storm::expressions::Expression> getAllRangeExpressions() const;
151
157 std::size_t getNumberOfCommands() const;
158
164 std::size_t getNumberOfUpdates() const;
165
172 storm::prism::Command const& getCommand(uint_fast64_t index) const;
173
179 std::vector<storm::prism::Command> const& getCommands() const;
180
186 std::vector<storm::prism::Command>& getCommands();
187
193 std::string const& getName() const;
194
200 std::set<uint_fast64_t> const& getSynchronizingActionIndices() const;
201
208 bool hasActionIndex(uint_fast64_t actionIndex) const;
209
215 bool isRenamedFromModule() const;
216
223 std::string const& getBaseModule() const;
224
231 std::map<std::string, std::string> const& getRenaming() const;
232
239 std::set<uint_fast64_t> const& getCommandIndicesByActionIndex(uint_fast64_t actionIndex) const;
240
248
256
263 Module substitute(std::map<storm::expressions::Variable, storm::expressions::Expression> const& substitution) const;
264
270
279 Module labelUnlabelledCommands(std::map<uint64_t, std::string> const& suggestions, uint64_t& newId, std::map<std::string, uint64_t>& nameToIdMapping) const;
280
287 bool containsVariablesOnlyInUpdateProbabilities(std::set<storm::expressions::Variable> const& undefinedConstantVariables) const;
288
293
299
300 /*
301 * Gets the number of commands without a label
302 */
303 uint64_t getNumberOfUnlabeledCommands() const;
304
308 bool hasInvariant() const;
309
314
315 friend std::ostream& operator<<(std::ostream& stream, Module const& module);
316
317 private:
321 void createMappings();
322
323 // The name of the module.
324 std::string moduleName;
325
326 // A list of boolean variables.
327 std::vector<storm::prism::BooleanVariable> booleanVariables;
328
329 // A mapping from boolean variables to the corresponding indices in the vector.
330 std::map<std::string, uint_fast64_t> booleanVariableToIndexMap;
331
332 // A list of integer variables.
333 std::vector<storm::prism::IntegerVariable> integerVariables;
334
335 // A mapping from integer variables to the corresponding indices in the vector.
336 std::map<std::string, uint_fast64_t> integerVariableToIndexMap;
337
338 // A list of clock variables.
339 std::vector<storm::prism::ClockVariable> clockVariables;
340
341 // A mapping from clock variables to the corresponding indices in the vector.
342 std::map<std::string, uint_fast64_t> clockVariableToIndexMap;
343
344 // An invariant (only for PTA models)
346
347 // The commands associated with the module.
348 std::vector<storm::prism::Command> commands;
349
350 // The set of action indices present in this module.
351 std::set<uint_fast64_t> synchronizingActionIndices;
352
353 // A map of actions to the set of commands labeled with this action.
354 std::map<uint_fast64_t, std::set<uint_fast64_t>> actionIndicesToCommandIndexMap;
355
356 // This string indicates whether and from what module this module was created via renaming.
357 std::string renamedFromModule;
358
359 // If the module was created by renaming, this mapping contains the provided renaming of identifiers.
361};
362
363} // namespace prism
364} // namespace storm
365
366#endif /* STORM_STORAGE_PRISM_MODULE_H_ */
Module substitute(std::map< storm::expressions::Variable, storm::expressions::Expression > const &substitution) const
Substitutes all variables in the module according to the given map.
Definition Module.cpp:254
std::size_t getNumberOfBooleanVariables() const
Retrieves the number of boolean variables in the module.
Definition Module.cpp:48
uint64_t getNumberOfUnlabeledCommands() const
Definition Module.cpp:153
void createMissingInitialValues()
Equips all of the modules' variables without initial values with initial values based on their type.
Definition Module.cpp:360
bool containsVariablesOnlyInUpdateProbabilities(std::set< storm::expressions::Variable > const &undefinedConstantVariables) const
Checks whether the given variables only appear in the update probabilities of the module and nowhere ...
Definition Module.cpp:333
Module(Module &&other)=default
Module(Module const &other)=default
std::vector< storm::prism::Command > const & getCommands() const
Retrieves the commands of the module.
Definition Module.cpp:133
std::map< std::string, std::string > const & getRenaming() const
If the module was created via renaming, this method returns the applied renaming of identifiers used ...
Definition Module.cpp:173
storm::prism::Command const & getCommand(uint_fast64_t index) const
Retrieves a reference to the command with the given index.
Definition Module.cpp:129
Module & operator=(Module const &other)=default
storm::prism::ClockVariable const & getClockVariable(std::string const &variableName) const
Retrieves a reference to the clock variable with the given name.
Definition Module.cpp:82
std::string const & getBaseModule() const
If the module was created via renaming, this method retrieves the name of the module that was used as...
Definition Module.cpp:167
bool hasActionIndex(uint_fast64_t actionIndex) const
Retrieves whether or not this module contains a command labeled with the given action index.
Definition Module.cpp:149
Module substituteNonStandardPredicates() const
Nonstandard predicates such as ExacltyOneOff etc can be substituted.
Definition Module.cpp:277
void removeVariableInitialization()
Auxiliary function for Program::replaceVariableInitializationByInitExpression Effect: All of the modu...
Definition Module.cpp:372
std::vector< storm::prism::IntegerVariable > const & getIntegerVariables() const
Retrieves the integer variables of the module.
Definition Module.cpp:74
storm::prism::IntegerVariable const & getIntegerVariable(std::string const &variableName) const
Retrieves a reference to the integer variable with the given name.
Definition Module.cpp:67
friend std::ostream & operator<<(std::ostream &stream, Module const &module)
Definition Module.cpp:392
std::set< uint_fast64_t > const & getCommandIndicesByActionIndex(uint_fast64_t actionIndex) const
Retrieves the indices of all commands within this module that are labelled by the given action.
Definition Module.cpp:179
Module restrictCommands(storm::storage::FlatSet< uint_fast64_t > const &indexSet) const
Creates a new module that drops all commands whose indices are not in the given set.
Definition Module.cpp:230
std::vector< storm::prism::BooleanVariable > const & getBooleanVariables() const
Retrieves the boolean variables of the module.
Definition Module.cpp:63
std::size_t getNumberOfClockVariables() const
Retrieves the number of clock variables in the module.
Definition Module.cpp:78
storm::expressions::Expression const & getInvariant() const
Returns the specified invariant (only relevant for PTA models)
Definition Module.cpp:388
bool isRenamedFromModule() const
Retrieves whether this module was created from another module via renaming.
Definition Module.cpp:163
bool hasInvariant() const
Returns true, if an invariant was specified (only relevant for PTA models)
Definition Module.cpp:384
Module labelUnlabelledCommands(std::map< uint64_t, std::string > const &suggestions, uint64_t &newId, std::map< std::string, uint64_t > &nameToIdMapping) const
Label unlabelled commands.
Definition Module.cpp:300
Module & operator=(Module &&other)=default
bool hasUnboundedVariables() const
Definition Module.cpp:39
std::string const & getName() const
Retrieves the name of the module.
Definition Module.cpp:141
std::set< storm::expressions::Variable > getAllExpressionVariables() const
Retrieves all expression variables used by this module.
Definition Module.cpp:93
std::size_t getNumberOfUpdates() const
Retrieves the total number of updates of this module.
Definition Module.cpp:121
std::set< uint_fast64_t > const & getSynchronizingActionIndices() const
Retrieves the set of synchronizing action indices present in this module.
Definition Module.cpp:145
std::vector< storm::prism::ClockVariable > const & getClockVariables() const
Retrieves the clock variables of the module.
Definition Module.cpp:89
Module restrictActionIndices(storm::storage::FlatSet< uint_fast64_t > const &actionIndices) const
Creates a new module that drops all commands whose action indices are not in the given set.
Definition Module.cpp:242
std::size_t getNumberOfIntegerVariables() const
Retrieves the number of integer variables in the module.
Definition Module.cpp:52
std::size_t getNumberOfCommands() const
Retrieves the number of commands of this module.
Definition Module.cpp:117
storm::prism::BooleanVariable const & getBooleanVariable(std::string const &variableName) const
Retrieves a reference to the boolean variable with the given name.
Definition Module.cpp:56
std::vector< storm::expressions::Expression > getAllRangeExpressions() const
Retrieves a list of expressions that characterize the legal ranges of all variables declared by this ...
Definition Module.cpp:107
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