Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
Dtmc.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::Dtmc, 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 std::set<storm::expressions::Variable> const& rowVariables, 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::dd::Bdd<Type>> labelToBddMap, std::unordered_map<std::string, RewardModelType> const& rewardModels)
35 : DeterministicModel<Type, ValueType>(storm::models::ModelType::Dtmc, manager, reachableStates, initialStates, deadlockStates, transitionMatrix,
36 rowVariables, columnVariables, rowColumnMetaVariablePairs, labelToBddMap, rewardModels) {
37 // Intentionally left empty.
38}
39
40template<storm::dd::DdType Type, typename ValueType>
42 for (auto& rewardModel : this->getRewardModels()) {
43 rewardModel.second.reduceToStateBasedRewards(this->getTransitionMatrix(), this->getRowVariables(), this->getColumnVariables(), true);
44 }
45}
46
47template<storm::dd::DdType Type, typename ValueType>
48template<typename NewValueType>
49std::shared_ptr<Dtmc<Type, NewValueType>> Dtmc<Type, ValueType>::toValueType() const {
50 typedef typename DeterministicModel<Type, NewValueType>::RewardModelType NewRewardModelType;
51 std::unordered_map<std::string, NewRewardModelType> newRewardModels;
52
53 for (auto const& e : this->getRewardModels()) {
54 newRewardModels.emplace(e.first, e.second.template toValueType<NewValueType>());
55 }
56
57 auto newLabelToBddMap = this->getLabelToBddMap();
58 newLabelToBddMap.erase("init");
59 newLabelToBddMap.erase("deadlock");
60
61 return std::make_shared<Dtmc<Type, NewValueType>>(this->getManagerAsSharedPointer(), this->getReachableStates(), this->getInitialStates(),
62 this->getDeadlockStates(), this->getTransitionMatrix().template toValueType<NewValueType>(),
63 this->getRowVariables(), this->getColumnVariables(), this->getRowColumnMetaVariablePairs(),
64 newLabelToBddMap, newRewardModels);
65}
66
67// Explicitly instantiate the template class.
70
72template std::shared_ptr<Dtmc<storm::dd::DdType::Sylvan, double>> Dtmc<storm::dd::DdType::Sylvan, storm::RationalNumber>::toValueType() const;
74
75} // namespace symbolic
76} // namespace models
77} // 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:41
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:13
Base class for all deterministic symbolic models.
Model< Type, ValueType >::RewardModelType RewardModelType
This class represents a discrete-time Markov chain.
Definition Dtmc.h:15
LabParser.cpp.
Definition cli.cpp:18