Storm 1.11.1.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
Dtmc.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::Dtmc, 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 std::set<storm::expressions::Variable> const& rowVariables, std::set<storm::expressions::Variable> const& columnVariables,
31 std::vector<std::pair<storm::expressions::Variable, storm::expressions::Variable>> const& rowColumnMetaVariablePairs,
32 std::map<std::string, storm::dd::Bdd<Type>> labelToBddMap, std::unordered_map<std::string, RewardModelType> const& rewardModels)
33 : DeterministicModel<Type, ValueType>(storm::models::ModelType::Dtmc, manager, reachableStates, initialStates, deadlockStates, transitionMatrix,
34 rowVariables, columnVariables, rowColumnMetaVariablePairs, labelToBddMap, rewardModels) {
35 // Intentionally left empty.
36}
37
38template<storm::dd::DdType Type, typename ValueType>
40 for (auto& rewardModel : this->getRewardModels()) {
41 rewardModel.second.reduceToStateBasedRewards(this->getTransitionMatrix(), this->getRowVariables(), this->getColumnVariables(), true);
42 }
43}
44
45template<storm::dd::DdType Type, typename ValueType>
46template<typename NewValueType>
47std::shared_ptr<Dtmc<Type, NewValueType>> Dtmc<Type, ValueType>::toValueType() const {
48 typedef typename DeterministicModel<Type, NewValueType>::RewardModelType NewRewardModelType;
49 std::unordered_map<std::string, NewRewardModelType> newRewardModels;
50
51 for (auto const& e : this->getRewardModels()) {
52 newRewardModels.emplace(e.first, e.second.template toValueType<NewValueType>());
53 }
54
55 auto newLabelToBddMap = this->getLabelToBddMap();
56 newLabelToBddMap.erase("init");
57 newLabelToBddMap.erase("deadlock");
58
59 return std::make_shared<Dtmc<Type, NewValueType>>(this->getManagerAsSharedPointer(), this->getReachableStates(), this->getInitialStates(),
60 this->getDeadlockStates(), this->getTransitionMatrix().template toValueType<NewValueType>(),
61 this->getRowVariables(), this->getColumnVariables(), this->getRowColumnMetaVariablePairs(),
62 newLabelToBddMap, newRewardModels);
63}
64
65// Explicitly instantiate the template class.
67
70template std::shared_ptr<Dtmc<storm::dd::DdType::Sylvan, double>> Dtmc<storm::dd::DdType::Sylvan, storm::RationalNumber>::toValueType() const;
72
73} // namespace symbolic
74} // namespace models
75} // namespace storm
virtual void reduceToStateBasedRewards()=0
Converts the transition rewards of all reward models to state-based rewards.
virtual void reduceToStateBasedRewards() override
Converts the transition rewards of all reward models to state-based rewards.
Definition Dtmc.cpp:39
Dtmc(storm::storage::SparseMatrix< ValueType > const &transitionMatrix, storm::models::sparse::StateLabeling const &stateLabeling, std::unordered_map< std::string, RewardModelType > const &rewardModels=std::unordered_map< std::string, RewardModelType >())
Constructs a model from the given data.
Definition Dtmc.cpp:11
Base class for all deterministic symbolic models.
Model< Type, ValueType >::RewardModelType RewardModelType
This class represents a discrete-time Markov chain.
Definition Dtmc.h:13