Storm 1.11.1.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
parameterlifting.h
Go to the documentation of this file.
1#ifndef STORM_UTILITY_PARAMETERLIFTING_H
2#define STORM_UTILITY_PARAMETERLIFTING_H
3
4#include <vector>
5
14
15namespace storm {
16namespace utility {
17namespace parameterlifting {
18
33template<typename ValueType>
36 // Check whether all numbers occurring in the model are multilinear
37
38 // Transition matrix
42 STORM_LOG_ERROR("Robust parameter lifting is only supported for DTMCs.");
43 return false;
44 }
45 } else {
46 for (auto const& entry : model.getTransitionMatrix()) {
48 STORM_LOG_WARN("The input model contains a non-linear polynomial as transition: '"
49 << entry.getValue() << "'. Can not validate that parameter lifting is sound on this model.");
50 return false;
51 }
52 }
53 }
55 auto const& ma = dynamic_cast<storm::models::sparse::MarkovAutomaton<ValueType> const&>(model);
56 // Markov Automata store the probability matrix and the exit rate vector. However, we need to considert the rate matrix.
57 if (!ma.isClosed()) {
58 STORM_LOG_ERROR("parameter lifting requires a closed Markov automaton.");
59 return false;
60 }
61 auto const& rateVector = ma.getExitRates();
62 auto const& markovianStates = ma.getMarkovianStates();
63 for (uint_fast64_t state = 0; state < model.getNumberOfStates(); ++state) {
64 if (markovianStates.get(state)) {
65 auto const& exitRate = rateVector[state];
66 for (auto const& entry : model.getTransitionMatrix().getRowGroup(state)) {
68 STORM_LOG_WARN("The input model contains a non-linear polynomial as transition rate: '"
69 << storm::utility::simplify(entry.getValue() * exitRate)
70 << "'. Can not validate that parameter lifting is sound on this model.");
71 return false;
72 }
73 }
74 } else {
75 for (auto const& entry : model.getTransitionMatrix().getRowGroup(state)) {
77 STORM_LOG_WARN("The input model contains a non-linear polynomial as transition: '"
78 << entry.getValue() << "'. Can not validate that parameter lifting is sound on this model.");
79 return false;
80 }
81 }
82 }
83 }
84 } else {
85 STORM_LOG_ERROR("Unsupported model type for parameter lifting.");
86 return false;
87 }
88
89 // Rewards
90 if (formula.isRewardOperatorFormula()) {
93 : model.getUniqueRewardModel();
94 if (rewardModel.hasStateRewards()) {
95 for (auto const& rew : rewardModel.getStateRewardVector()) {
97 STORM_LOG_WARN("The input model contains a non-linear polynomial as state reward: '"
98 << rew << "'. Can not validate that parameter lifting is sound on this model.");
99 return false;
100 }
101 }
102 }
103 // Parameters in transition rewards (and for continuous time models also action rewards) have to be disjoint from the probability/rate parameters.
104 // Note: This check could also be done action-wise.
105 std::set<typename storm::utility::parametric::VariableType<ValueType>::type> collectedRewardParameters;
106 if (rewardModel.hasStateActionRewards()) {
108 for (auto const& rew : rewardModel.getStateActionRewardVector()) {
110 STORM_LOG_WARN("The input model contains a non-linear polynomial as action reward: '"
111 << rew << "'. Can not validate that parameter lifting is sound on this model.");
112 return false;
113 }
114 storm::utility::parametric::gatherOccurringVariables(rew, collectedRewardParameters);
115 }
116 } else {
117 for (auto const& rew : rewardModel.getStateActionRewardVector()) {
119 STORM_LOG_WARN("The input model contains a non-linear polynomial as action reward: '"
120 << rew << "'. Can not validate that parameter lifting is sound on this model.");
121 return false;
122 }
123 }
124 }
125 }
126
127 if (rewardModel.hasTransitionRewards()) {
128 for (auto const& rewEntry : rewardModel.getTransitionRewardMatrix()) {
129 if (!storm::utility::parametric::isMultiLinearPolynomial(rewEntry.getValue())) {
130 STORM_LOG_WARN("The input model contains a non-linear polynomial as transition reward: '"
131 << rewEntry.getValue() << "'. Can not validate that parameter lifting is sound on this model.");
132 return false;
133 }
134 storm::utility::parametric::gatherOccurringVariables(rewEntry.getValue(), collectedRewardParameters);
135 }
136 }
137
138 if (!collectedRewardParameters.empty()) {
139 std::set<typename storm::utility::parametric::VariableType<ValueType>::type> transitionParameters =
141 auto rewParIt = collectedRewardParameters.begin();
142 auto trParIt = transitionParameters.begin();
143 while (rewParIt != collectedRewardParameters.end() && trParIt != transitionParameters.end()) {
144 if (*rewParIt == *trParIt) {
146 "Parameter "
147 << *trParIt
148 << " occurs in a transition probability/rate and in a transition/action reward. Parameter lifting might not be sound on this model.");
149 return false;
150 }
151 if (*rewParIt < *trParIt) {
152 ++rewParIt;
153 } else {
154 ++trParIt;
155 }
156 }
157 }
158 }
159 return true;
160}
161
162} // namespace parameterlifting
163} // namespace utility
164} // namespace storm
165
166#endif /* STORM_UTILITY_PARAMETERLIFTING_H */
RewardOperatorFormula & asRewardOperatorFormula()
Definition Formula.cpp:484
virtual bool isRewardOperatorFormula() const
Definition Formula.cpp:184
std::string const & getRewardModelName() const
Retrieves the name of the reward model this property refers to (if any).
bool hasRewardModelName() const
Retrieves whether the reward model refers to a specific reward model.
bool isOfType(storm::models::ModelType const &modelType) const
Checks whether the model is of the given type.
Definition ModelBase.cpp:27
This class represents a Markov automaton.
Base class for all sparse models.
Definition Model.h:32
RewardModelType const & getUniqueRewardModel() const
Retrieves the unique reward model, if there exists exactly one.
Definition Model.cpp:303
storm::storage::SparseMatrix< ValueType > const & getTransitionMatrix() const
Retrieves the matrix representing the transitions of the model.
Definition Model.cpp:197
virtual uint_fast64_t getNumberOfStates() const override
Returns the number of states of the model.
Definition Model.cpp:162
RewardModelType const & getRewardModel(std::string const &rewardModelName) const
Retrieves the reward model with the given name, if one exists.
Definition Model.cpp:218
storm::storage::SparseMatrix< ValueType > const & getTransitionRewardMatrix() const
Retrieves the transition rewards of the reward model.
bool hasTransitionRewards() const
Retrieves whether the reward model has transition rewards.
std::vector< ValueType > const & getStateActionRewardVector() const
Retrieves the state-action rewards of the reward model.
std::vector< ValueType > const & getStateRewardVector() const
Retrieves the state rewards of the reward model.
bool hasStateRewards() const
Retrieves whether the reward model has state rewards.
bool hasStateActionRewards() const
Retrieves whether the reward model has state-action rewards.
#define STORM_LOG_WARN(message)
Definition logging.h:25
#define STORM_LOG_ERROR(message)
Definition logging.h:26
RegionCheckEngine
The considered engine for region checking.
@ RobustParameterLifting
Parameter lifting approach based on robust markov models instead of generating nondeterminism.
std::set< storm::RationalFunctionVariable > getProbabilityParameters(Model< storm::RationalFunction > const &model)
Get all probability parameters occurring on transitions.
Definition Model.cpp:693
static bool validateParameterLiftingSound(storm::models::sparse::Model< ValueType > const &model, storm::logic::Formula const &formula, storm::modelchecker::RegionCheckEngine engine)
Checks whether the parameter lifting approach is sound on the given model with respect to the provide...
bool isMultiLinearPolynomial(FunctionType const &function)
Checks whether the function is a multilinear polynomial, i.e., a polynomial which only considers vari...
void gatherOccurringVariables(FunctionType const &function, std::set< typename VariableType< FunctionType >::type > &variableSet)
Add all variables that occur in the given function to the the given set.
ValueType simplify(ValueType value)