Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
Ctmc.cpp
Go to the documentation of this file.
2
6
8
10
11namespace storm {
12namespace models {
13namespace symbolic {
14
15template<storm::dd::DdType Type, typename ValueType>
17 storm::dd::Bdd<Type> deadlockStates, storm::dd::Add<Type, ValueType> transitionMatrix,
18 std::set<storm::expressions::Variable> const& rowVariables,
19 std::shared_ptr<storm::adapters::AddExpressionAdapter<Type, ValueType>> rowExpressionAdapter,
20 std::set<storm::expressions::Variable> const& columnVariables,
21 std::vector<std::pair<storm::expressions::Variable, storm::expressions::Variable>> const& rowColumnMetaVariablePairs,
22 std::map<std::string, storm::expressions::Expression> labelToExpressionMap,
23 std::unordered_map<std::string, RewardModelType> const& rewardModels)
24 : DeterministicModel<Type, ValueType>(storm::models::ModelType::Ctmc, manager, reachableStates, initialStates, deadlockStates, transitionMatrix,
25 rowVariables, rowExpressionAdapter, columnVariables, rowColumnMetaVariablePairs, labelToExpressionMap, rewardModels) {
26 // Intentionally left empty.
27}
28
29template<storm::dd::DdType Type, typename ValueType>
31 storm::dd::Bdd<Type> deadlockStates, storm::dd::Add<Type, ValueType> transitionMatrix,
32 boost::optional<storm::dd::Add<Type, ValueType>> exitRateVector, std::set<storm::expressions::Variable> const& rowVariables,
33 std::shared_ptr<storm::adapters::AddExpressionAdapter<Type, ValueType>> rowExpressionAdapter,
34 std::set<storm::expressions::Variable> const& columnVariables,
35 std::vector<std::pair<storm::expressions::Variable, storm::expressions::Variable>> const& rowColumnMetaVariablePairs,
36 std::map<std::string, storm::expressions::Expression> labelToExpressionMap,
37 std::unordered_map<std::string, RewardModelType> const& rewardModels)
38 : DeterministicModel<Type, ValueType>(storm::models::ModelType::Ctmc, manager, reachableStates, initialStates, deadlockStates, transitionMatrix,
39 rowVariables, rowExpressionAdapter, columnVariables, rowColumnMetaVariablePairs, labelToExpressionMap, rewardModels),
40 exitRates(exitRateVector) {
41 // Intentionally left empty.
42}
43
44template<storm::dd::DdType Type, typename ValueType>
46 storm::dd::Bdd<Type> deadlockStates, storm::dd::Add<Type, ValueType> transitionMatrix,
47 std::set<storm::expressions::Variable> const& rowVariables, std::set<storm::expressions::Variable> const& columnVariables,
48 std::vector<std::pair<storm::expressions::Variable, storm::expressions::Variable>> const& rowColumnMetaVariablePairs,
49 std::map<std::string, storm::dd::Bdd<Type>> labelToBddMap, std::unordered_map<std::string, RewardModelType> const& rewardModels)
50 : DeterministicModel<Type, ValueType>(storm::models::ModelType::Ctmc, manager, reachableStates, initialStates, deadlockStates, transitionMatrix,
51 rowVariables, columnVariables, rowColumnMetaVariablePairs, labelToBddMap, rewardModels) {
52 // Intentionally left empty.
53}
54
55template<storm::dd::DdType Type, typename ValueType>
57 storm::dd::Bdd<Type> deadlockStates, storm::dd::Add<Type, ValueType> transitionMatrix,
58 boost::optional<storm::dd::Add<Type, ValueType>> exitRateVector, std::set<storm::expressions::Variable> const& rowVariables,
59 std::set<storm::expressions::Variable> const& columnVariables,
60 std::vector<std::pair<storm::expressions::Variable, storm::expressions::Variable>> const& rowColumnMetaVariablePairs,
61 std::map<std::string, storm::dd::Bdd<Type>> labelToBddMap, std::unordered_map<std::string, RewardModelType> const& rewardModels)
62 : DeterministicModel<Type, ValueType>(storm::models::ModelType::Ctmc, manager, reachableStates, initialStates, deadlockStates, transitionMatrix,
63 rowVariables, columnVariables, rowColumnMetaVariablePairs, labelToBddMap, rewardModels),
64 exitRates(exitRateVector) {
65 // Intentionally left empty.
66}
67
68template<storm::dd::DdType Type, typename ValueType>
70 if (!exitRates) {
71 exitRates = this->getTransitionMatrix().sumAbstract(this->getColumnVariables());
72 }
73 return exitRates.get();
74}
75
76template<storm::dd::DdType Type, typename ValueType>
78 for (auto& rewardModel : this->getRewardModels()) {
79 if (rewardModel.second.hasStateActionRewards()) {
80 rewardModel.second.getStateActionRewardVector() *= getExitRateVector();
81 }
82 rewardModel.second.reduceToStateBasedRewards(this->getTransitionMatrix(), this->getRowVariables(), this->getColumnVariables(), true);
83 }
84}
85
86template<storm::dd::DdType Type, typename ValueType>
88 return this->getTransitionMatrix() / this->getExitRateVector();
89}
90
91template<storm::dd::DdType Type, typename ValueType>
92template<typename NewValueType>
93std::shared_ptr<Ctmc<Type, NewValueType>> Ctmc<Type, ValueType>::toValueType() const {
94 typedef typename DeterministicModel<Type, NewValueType>::RewardModelType NewRewardModelType;
95 std::unordered_map<std::string, NewRewardModelType> newRewardModels;
96
97 for (auto const& e : this->getRewardModels()) {
98 newRewardModels.emplace(e.first, e.second.template toValueType<NewValueType>());
99 }
100
101 auto newLabelToBddMap = this->getLabelToBddMap();
102 newLabelToBddMap.erase("init");
103 newLabelToBddMap.erase("deadlock");
104
105 return std::make_shared<Ctmc<Type, NewValueType>>(this->getManagerAsSharedPointer(), this->getReachableStates(), this->getInitialStates(),
106 this->getDeadlockStates(), this->getTransitionMatrix().template toValueType<NewValueType>(),
107 this->getExitRateVector().template toValueType<NewValueType>(), this->getRowVariables(),
108 this->getColumnVariables(), this->getRowColumnMetaVariablePairs(), newLabelToBddMap, newRewardModels);
109}
110
111// Explicitly instantiate the template class.
114
116template std::shared_ptr<Ctmc<storm::dd::DdType::Sylvan, double>> Ctmc<storm::dd::DdType::Sylvan, storm::RationalNumber>::toValueType() const;
118
119} // namespace symbolic
120} // namespace models
121} // namespace storm
Add< LibraryType, ValueType > sumAbstract(std::set< storm::expressions::Variable > const &metaVariables) const
Sum-abstracts from the given meta variables.
Definition Add.cpp:178
This class represents a continuous-time Markov chain.
Definition Ctmc.h:15
storm::dd::Add< Type, ValueType > const & getExitRateVector() const
Retrieves the exit rate vector of the CTMC.
Definition Ctmc.cpp:69
std::shared_ptr< Ctmc< Type, NewValueType > > toValueType() const
Definition Ctmc.cpp:93
storm::dd::Add< Type, ValueType > computeProbabilityMatrix() const
Definition Ctmc.cpp:87
virtual void reduceToStateBasedRewards() override
Converts the transition rewards of all reward models to state-based rewards.
Definition Ctmc.cpp:77
Ctmc(Ctmc< Type, ValueType > const &other)=default
Base class for all deterministic symbolic models.
Model< Type, ValueType >::RewardModelType RewardModelType
LabParser.cpp.
Definition cli.cpp:18