Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
Module.h
Go to the documentation of this file.
1#pragma once
2
3#include <map>
4#include <memory>
5#include <set>
6#include <string>
7#include <vector>
8
15
16namespace storm {
17namespace prism {
18class Module : public LocatedInformation {
19 public:
32 Module(std::string const& moduleName, std::vector<storm::prism::BooleanVariable> const& booleanVariables,
33 std::vector<storm::prism::IntegerVariable> const& integerVariables, std::vector<storm::prism::ClockVariable> const& clockVariables,
34 storm::expressions::Expression const& invariant, std::vector<storm::prism::Command> const& commands, std::string const& filename = "",
35 uint_fast64_t lineNumber = 0);
36
52 Module(std::string const& moduleName, std::vector<storm::prism::BooleanVariable> const& booleanVariables,
53 std::vector<storm::prism::IntegerVariable> const& integerVariables, std::vector<storm::prism::ClockVariable> const& clockVariables,
54 storm::expressions::Expression const& invariant, std::vector<storm::prism::Command> const& commands, std::string const& renamedFromModule,
55 storm::prism::ModuleRenaming const& renaming, std::string const& filename = "", uint_fast64_t lineNumber = 0);
56
57 // Create default implementations of constructors/assignment.
58 Module() = default;
59 Module(Module const& other) = default;
60 Module& operator=(Module const& other) = default;
61 Module(Module&& other) = default;
62 Module& operator=(Module&& other) = default;
63
67 bool hasUnboundedVariables() const;
68
74 std::size_t getNumberOfBooleanVariables() const;
75
81 std::size_t getNumberOfIntegerVariables() const;
82
89 storm::prism::BooleanVariable const& getBooleanVariable(std::string const& variableName) const;
90
96 std::vector<storm::prism::BooleanVariable> const& getBooleanVariables() const;
97
104 storm::prism::IntegerVariable const& getIntegerVariable(std::string const& variableName) const;
105
111 std::vector<storm::prism::IntegerVariable> const& getIntegerVariables() const;
112
118 std::size_t getNumberOfClockVariables() const;
119
126 storm::prism::ClockVariable const& getClockVariable(std::string const& variableName) const;
127
133 std::vector<storm::prism::ClockVariable> const& getClockVariables() const;
134
140 std::set<storm::expressions::Variable> getAllExpressionVariables() const;
141
148 std::vector<storm::expressions::Expression> getAllRangeExpressions() const;
149
155 std::size_t getNumberOfCommands() const;
156
162 std::size_t getNumberOfUpdates() const;
163
170 storm::prism::Command const& getCommand(uint_fast64_t index) const;
171
177 std::vector<storm::prism::Command> const& getCommands() const;
178
184 std::vector<storm::prism::Command>& getCommands();
185
191 std::string const& getName() const;
192
198 std::set<uint_fast64_t> const& getSynchronizingActionIndices() const;
199
206 bool hasActionIndex(uint_fast64_t actionIndex) const;
207
213 bool isRenamedFromModule() const;
214
221 std::string const& getBaseModule() const;
222
229 std::map<std::string, std::string> const& getRenaming() const;
230
237 std::set<uint_fast64_t> const& getCommandIndicesByActionIndex(uint_fast64_t actionIndex) const;
238
246
254
261 Module substitute(std::map<storm::expressions::Variable, storm::expressions::Expression> const& substitution) const;
262
268
277 Module labelUnlabelledCommands(std::map<uint64_t, std::string> const& suggestions, uint64_t& newId, std::map<std::string, uint64_t>& nameToIdMapping) const;
278
285 bool containsVariablesOnlyInUpdateProbabilities(std::set<storm::expressions::Variable> const& undefinedConstantVariables) const;
286
291
297
298 /*
299 * Gets the number of commands without a label
300 */
301 uint64_t getNumberOfUnlabeledCommands() const;
302
306 bool hasInvariant() const;
307
312
313 friend std::ostream& operator<<(std::ostream& stream, Module const& module);
314
315 private:
319 void createMappings();
320
321 // The name of the module.
322 std::string moduleName;
323
324 // A list of boolean variables.
325 std::vector<storm::prism::BooleanVariable> booleanVariables;
326
327 // A mapping from boolean variables to the corresponding indices in the vector.
328 std::map<std::string, uint_fast64_t> booleanVariableToIndexMap;
329
330 // A list of integer variables.
331 std::vector<storm::prism::IntegerVariable> integerVariables;
332
333 // A mapping from integer variables to the corresponding indices in the vector.
334 std::map<std::string, uint_fast64_t> integerVariableToIndexMap;
335
336 // A list of clock variables.
337 std::vector<storm::prism::ClockVariable> clockVariables;
338
339 // A mapping from clock variables to the corresponding indices in the vector.
340 std::map<std::string, uint_fast64_t> clockVariableToIndexMap;
341
342 // An invariant (only for PTA models)
344
345 // The commands associated with the module.
346 std::vector<storm::prism::Command> commands;
347
348 // The set of action indices present in this module.
349 std::set<uint_fast64_t> synchronizingActionIndices;
350
351 // A map of actions to the set of commands labeled with this action.
352 std::map<uint_fast64_t, std::set<uint_fast64_t>> actionIndicesToCommandIndexMap;
353
354 // This string indicates whether and from what module this module was created via renaming.
355 std::string renamedFromModule;
356
357 // If the module was created by renaming, this mapping contains the provided renaming of identifiers.
359};
360
361} // namespace prism
362} // namespace storm
LocatedInformation(std::string const &filename, uint_fast64_t lineNumber)
Constructs a located information with the given filename and line number.
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
Module(std::string const &moduleName, std::vector< storm::prism::BooleanVariable > const &booleanVariables, std::vector< storm::prism::IntegerVariable > const &integerVariables, std::vector< storm::prism::ClockVariable > const &clockVariables, storm::expressions::Expression const &invariant, std::vector< storm::prism::Command > const &commands, std::string const &filename="", uint_fast64_t lineNumber=0)
Creates a module with the given name, variables and commands.
Definition Module.cpp:9
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