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