Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
Model.h
Go to the documentation of this file.
1#ifndef STORM_MODELS_SYMBOLIC_MODEL_H_
2#define STORM_MODELS_SYMBOLIC_MODEL_H_
3
4#include <memory>
5#include <set>
6#include <unordered_map>
7
16
17#include "storm-config.h"
19
20namespace storm {
21namespace dd {
22
23template<storm::dd::DdType Type>
24class Dd;
25
26template<storm::dd::DdType Type>
27class DdManager;
28
29} // namespace dd
30
31namespace adapters {
32template<storm::dd::DdType Type, typename ValueType>
33class AddExpressionAdapter;
34}
35
36namespace models {
37namespace symbolic {
38
39template<storm::dd::DdType Type, typename ValueType>
40class StandardRewardModel;
41
45template<storm::dd::DdType Type, typename CValueType = double>
46class Model : public storm::models::Model<CValueType> {
47 public:
48 typedef CValueType ValueType;
49
50 static const storm::dd::DdType DdType = Type;
52
54
55 Model(Model<Type, ValueType> const& other) = default;
56 Model& operator=(Model<Type, ValueType> const& other) = default;
57
58#ifndef WINDOWS
59 Model(Model<Type, ValueType>&& other) = default;
61#endif
62
80 Model(storm::models::ModelType const& modelType, std::shared_ptr<storm::dd::DdManager<Type>> manager, storm::dd::Bdd<Type> reachableStates,
82 std::set<storm::expressions::Variable> const& rowVariables,
83 std::shared_ptr<storm::adapters::AddExpressionAdapter<Type, ValueType>> rowExpressionAdapter,
84 std::set<storm::expressions::Variable> const& columnVariables,
85 std::vector<std::pair<storm::expressions::Variable, storm::expressions::Variable>> const& rowColumnMetaVariablePairs,
86 std::map<std::string, storm::expressions::Expression> labelToExpressionMap = std::map<std::string, storm::expressions::Expression>(),
87 std::unordered_map<std::string, RewardModelType> const& rewardModels = std::unordered_map<std::string, RewardModelType>());
88
104 Model(storm::models::ModelType const& modelType, std::shared_ptr<storm::dd::DdManager<Type>> manager, storm::dd::Bdd<Type> reachableStates,
106 std::set<storm::expressions::Variable> const& rowVariables, std::set<storm::expressions::Variable> const& columnVariables,
107 std::vector<std::pair<storm::expressions::Variable, storm::expressions::Variable>> const& rowColumnMetaVariablePairs,
108 std::map<std::string, storm::dd::Bdd<Type>> labelToBddMap = std::map<std::string, storm::dd::Bdd<Type>>(),
109 std::unordered_map<std::string, RewardModelType> const& rewardModels = std::unordered_map<std::string, RewardModelType>());
110
111 virtual uint_fast64_t getNumberOfStates() const override;
112
113 virtual uint_fast64_t getNumberOfTransitions() const override;
114
115 virtual uint_fast64_t getNumberOfChoices() const override;
116
123
129 std::shared_ptr<storm::dd::DdManager<Type>> const& getManagerAsSharedPointer() const;
130
137
144
145 /*
146 * Retrieves the deadlock states of the model.
147 */
149
156 virtual storm::dd::Bdd<Type> getStates(std::string const& label) const;
157
164 virtual storm::expressions::Expression getExpression(std::string const& label) const;
165
172 virtual storm::dd::Bdd<Type> getStates(storm::expressions::Expression const& expression) const;
173
180 virtual bool hasLabel(std::string const& label) const;
181
188
195
203 virtual storm::dd::Bdd<Type> getQualitativeTransitionMatrix(bool keepNondeterminism = true) const;
204
210 std::set<storm::expressions::Variable> const& getRowVariables() const;
211
217 std::set<storm::expressions::Variable> const& getColumnVariables() const;
218
224 std::set<storm::expressions::Variable> getRowAndNondeterminismVariables() const;
225
231 std::set<storm::expressions::Variable> getColumnAndNondeterminismVariables() const;
232
238 virtual std::set<storm::expressions::Variable> const& getNondeterminismVariables() const;
239
245 std::vector<std::pair<storm::expressions::Variable, storm::expressions::Variable>> const& getRowColumnMetaVariablePairs() const;
246
253
259 virtual bool hasRewardModel(std::string const& rewardModelName) const override;
260
266 RewardModelType const& getRewardModel(std::string const& rewardModelName) const;
267
274
280 virtual std::string const& getUniqueRewardModelName() const override;
281
288
294 virtual bool hasUniqueRewardModel() const override;
295
301 bool hasRewardModel() const;
302
303 std::unordered_map<std::string, RewardModelType>& getRewardModels();
304 std::unordered_map<std::string, RewardModelType> const& getRewardModels() const;
305
311 uint_fast64_t getNumberOfRewardModels() const;
312
313 virtual void printModelInformationToStream(std::ostream& out) const override;
314
315 virtual bool isSymbolicModel() const override;
316
317 virtual bool supportsParameters() const override;
318
325 virtual bool hasParameters() const override;
326
327 std::vector<std::string> getLabels() const;
328
329 void addParameters(std::set<storm::RationalFunctionVariable> const& parameters);
330
331 std::set<storm::RationalFunctionVariable> const& getParameters() const;
332
333 template<typename NewValueType>
334 typename std::enable_if<!std::is_same<ValueType, NewValueType>::value, std::shared_ptr<Model<Type, NewValueType>>>::type toValueType() const;
335
336 template<typename NewValueType>
337 typename std::enable_if<std::is_same<ValueType, NewValueType>::value, std::shared_ptr<Model<Type, NewValueType>>>::type toValueType() const;
338
339 void writeDotToFile(std::string const& filename) const;
340
341 protected:
348
354 std::map<std::string, storm::expressions::Expression> const& getLabelToExpressionMap() const;
355
361 std::map<std::string, storm::dd::Bdd<Type>> const& getLabelToBddMap() const;
362
368 void printModelInformationHeaderToStream(std::ostream& out) const;
369
376 void printModelInformationFooterToStream(std::ostream& out) const;
377
383 void printRewardModelsInformationToStream(std::ostream& out) const;
384
390 virtual void printDdVariableInformationToStream(std::ostream& out) const;
391
392 protected:
398 std::shared_ptr<storm::adapters::AddExpressionAdapter<Type, ValueType>> const& getRowExpressionAdapter() const;
399
400 private:
401 // The manager responsible for the decision diagrams.
402 std::shared_ptr<storm::dd::DdManager<Type>> manager;
403
404 // A vector representing the reachable states of the model.
405 storm::dd::Bdd<Type> reachableStates;
406
407 protected:
408 // A matrix representing transition relation.
410
411 private:
412 // The meta variables used to encode the rows of the transition matrix.
413 std::set<storm::expressions::Variable> rowVariables;
414
415 // An adapter that can translate expressions to DDs over the row meta variables.
416 std::shared_ptr<storm::adapters::AddExpressionAdapter<Type, ValueType>> rowExpressionAdapter;
417
418 // The meta variables used to encode the columns of the transition matrix.
419 std::set<storm::expressions::Variable> columnVariables;
420
421 // A vector holding all pairs of row and column meta variable pairs. This is used to swap the variables
422 // in the DDs from row to column variables and vice versa.
423 std::vector<std::pair<storm::expressions::Variable, storm::expressions::Variable>> rowColumnMetaVariablePairs;
424
425 // A mapping from labels to expressions defining them.
426 std::map<std::string, storm::expressions::Expression> labelToExpressionMap;
427
428 // A mapping from labels to BDDs characterizing the labeled states.
429 std::map<std::string, storm::dd::Bdd<Type>> labelToBddMap;
430
431 // The reward models associated with the model.
432 std::unordered_map<std::string, RewardModelType> rewardModels;
433
434 // The parameters. Only meaningful for models over rational functions.
435 std::set<storm::RationalFunctionVariable> parameters;
436
437 // An empty variable set that can be used when references to non-existing sets need to be returned.
438 std::set<storm::expressions::Variable> emptyVariableSet;
439};
440
441} // namespace symbolic
442} // namespace models
443} // namespace storm
444
445#endif /* STORM_MODELS_SYMBOLIC_MODEL_H_ */
Definition DdTest.cpp:25
Base class for all symbolic models.
Definition Model.h:46
virtual bool hasParameters() const override
Checks whether the model has parameters.
Definition Model.cpp:407
storm::dd::DdManager< Type > & getManager() const
Retrieves the manager responsible for the DDs that represent this model.
Definition Model.cpp:92
RewardModelType const & getRewardModel(std::string const &rewardModelName) const
Retrieves the reward model with the given name, if one exists.
Definition Model.cpp:254
void addParameters(std::set< storm::RationalFunctionVariable > const &parameters)
Definition Model.cpp:422
storm::dd::Add< Type, ValueType > const & getTransitionMatrix() const
Retrieves the matrix representing the transitions of the model.
Definition Model.cpp:177
storm::dd::Bdd< Type > const & getDeadlockStates() const
Definition Model.cpp:112
virtual void printModelInformationToStream(std::ostream &out) const override
Prints information about the model to the specified stream.
Definition Model.cpp:313
virtual storm::expressions::Expression getExpression(std::string const &label) const
Returns the expression for the given label.
Definition Model.cpp:132
std::shared_ptr< storm::adapters::AddExpressionAdapter< Type, ValueType > > const & getRowExpressionAdapter() const
Retrieves the expression adapter of this model.
Definition Model.cpp:383
void writeDotToFile(std::string const &filename) const
Definition Model.cpp:398
Model & operator=(Model< Type, ValueType > &&other)=default
RewardModelType const & getUniqueRewardModel() const
Retrieves the unique reward model, if there exists exactly one.
Definition Model.cpp:272
virtual bool isSymbolicModel() const override
Checks whether the model is a symbolic model.
Definition Model.cpp:388
virtual void printDdVariableInformationToStream(std::ostream &out) const
Prints information about the DD variables to the specified stream.
Definition Model.cpp:368
virtual std::string const & getUniqueRewardModelName() const override
Retrieves the name of the unique reward model, if there exists exactly one.
Definition Model.cpp:279
virtual storm::dd::Bdd< Type > getQualitativeTransitionMatrix(bool keepNondeterminism=true) const
Retrieves the matrix qualitatively (i.e.
Definition Model.cpp:187
std::set< storm::expressions::Variable > const & getColumnVariables() const
Retrieves the meta variables used to encode the columns of the transition matrix and the vector indic...
Definition Model.cpp:197
std::shared_ptr< storm::dd::DdManager< Type > > const & getManagerAsSharedPointer() const
Retrieves the manager responsible for the DDs that represent this model.
Definition Model.cpp:97
Model(Model< Type, ValueType > &&other)=default
Model & operator=(Model< Type, ValueType > const &other)=default
uint_fast64_t getNumberOfRewardModels() const
Retrieves the number of reward models associated with this model.
Model(Model< Type, ValueType > const &other)=default
std::enable_if<!std::is_same< ValueType, NewValueType >::value, std::shared_ptr< Model< Type, NewValueType > > >::type toValueType() const
Definition Model.cpp:443
std::vector< std::string > getLabels() const
Definition Model.cpp:319
storm::dd::Add< Type, ValueType > getRowColumnIdentity() const
Retrieves an ADD that represents the diagonal of the transition matrix.
Definition Model.cpp:243
static const storm::models::ModelRepresentation Representation
Definition Model.h:53
void printRewardModelsInformationToStream(std::ostream &out) const
Prints information about the reward models to the specified stream.
Definition Model.cpp:350
virtual bool supportsParameters() const override
Checks whether the model supports parameters.
Definition Model.cpp:393
std::map< std::string, storm::dd::Bdd< Type > > const & getLabelToBddMap() const
Retrieves the mapping of labels to their defining expressions.
Definition Model.cpp:238
std::set< storm::RationalFunctionVariable > const & getParameters() const
Definition Model.cpp:427
storm::dd::Bdd< Type > const & getInitialStates() const
Retrieves the initial states of the model.
Definition Model.cpp:107
storm::dd::Add< Type, ValueType > transitionMatrix
Definition Model.h:409
virtual std::set< storm::expressions::Variable > const & getNondeterminismVariables() const
Retrieves all meta variables used to encode the nondeterminism.
Definition Model.cpp:218
void printModelInformationFooterToStream(std::ostream &out) const
Prints the information footer (reward models, labels) of the model to the specified stream.
Definition Model.cpp:336
std::vector< std::pair< storm::expressions::Variable, storm::expressions::Variable > > const & getRowColumnMetaVariablePairs() const
Retrieves the pairs of row and column meta variables.
Definition Model.cpp:223
std::set< storm::expressions::Variable > const & getRowVariables() const
Retrieves the meta variables used to encode the rows of the transition matrix and the vector indices.
Definition Model.cpp:192
static const storm::dd::DdType DdType
Definition Model.h:50
virtual bool hasLabel(std::string const &label) const
Retrieves whether the given label is a valid label in this model.
Definition Model.cpp:162
std::map< std::string, storm::expressions::Expression > const & getLabelToExpressionMap() const
Retrieves the mapping of labels to their defining expressions.
Definition Model.cpp:233
void printModelInformationHeaderToStream(std::ostream &out) const
Prints the information header (number of states and transitions) of the model to the specified stream...
Definition Model.cpp:328
std::unordered_map< std::string, RewardModelType > & getRewardModels()
Definition Model.cpp:303
virtual uint_fast64_t getNumberOfChoices() const override
Returns the number of choices ine the model.
Definition Model.cpp:87
std::set< storm::expressions::Variable > getRowAndNondeterminismVariables() const
Retrieves all meta variables used to encode rows and nondetermism.
Definition Model.cpp:202
void setTransitionMatrix(storm::dd::Add< Type, ValueType > const &transitionMatrix)
Sets the transition matrix of the model.
Definition Model.cpp:228
std::set< storm::expressions::Variable > getColumnAndNondeterminismVariables() const
Retrieves all meta variables used to encode columns and nondetermism.
Definition Model.cpp:210
virtual storm::dd::Bdd< Type > getStates(std::string const &label) const
Returns the sets of states labeled with the given label.
Definition Model.cpp:117
virtual uint_fast64_t getNumberOfTransitions() const override
Returns the number of (non-zero) transitions of the model.
Definition Model.cpp:82
std::enable_if< std::is_same< ValueType, NewValueType >::value, std::shared_ptr< Model< Type, NewValueType > > >::type toValueType() const
StandardRewardModel< Type, ValueType > RewardModelType
Definition Model.h:51
bool hasRewardModel() const
Retrieves whether the model has at least one reward model.
Definition Model.cpp:298
virtual bool hasUniqueRewardModel() const override
Retrieves whether the model has a unique reward model.
Definition Model.cpp:293
storm::dd::Bdd< Type > const & getReachableStates() const
Retrieves the reachable states of the model.
Definition Model.cpp:102
virtual uint_fast64_t getNumberOfStates() const override
Returns the number of states of the model.
Definition Model.cpp:77
LabParser.cpp.
Definition cli.cpp:18