Storm
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
13
14namespace storm {
15namespace utility {
16namespace parameterlifting {
17
32template<typename ValueType>
34 // Check whether all numbers occurring in the model are multilinear
35
36 // Transition matrix
38 for (auto const& entry : model.getTransitionMatrix()) {
40 STORM_LOG_WARN("The input model contains a non-linear polynomial as transition: '"
41 << entry.getValue() << "'. Can not validate that parameter lifting is sound on this model.");
42 return false;
43 }
44 }
46 auto const& ma = dynamic_cast<storm::models::sparse::MarkovAutomaton<ValueType> const&>(model);
47 // Markov Automata store the probability matrix and the exit rate vector. However, we need to considert the rate matrix.
48 if (!ma.isClosed()) {
49 STORM_LOG_ERROR("parameter lifting requires a closed Markov automaton.");
50 return false;
51 }
52 auto const& rateVector = ma.getExitRates();
53 auto const& markovianStates = ma.getMarkovianStates();
54 for (uint_fast64_t state = 0; state < model.getNumberOfStates(); ++state) {
55 if (markovianStates.get(state)) {
56 auto const& exitRate = rateVector[state];
57 for (auto const& entry : model.getTransitionMatrix().getRowGroup(state)) {
59 STORM_LOG_WARN("The input model contains a non-linear polynomial as transition rate: '"
60 << storm::utility::simplify(entry.getValue() * exitRate)
61 << "'. Can not validate that parameter lifting is sound on this model.");
62 return false;
63 }
64 }
65 } else {
66 for (auto const& entry : model.getTransitionMatrix().getRowGroup(state)) {
68 STORM_LOG_WARN("The input model contains a non-linear polynomial as transition: '"
69 << entry.getValue() << "'. Can not validate that parameter lifting is sound on this model.");
70 return false;
71 }
72 }
73 }
74 }
75 } else {
76 STORM_LOG_ERROR("Unsupported model type for parameter lifting.");
77 return false;
78 }
79
80 // Rewards
81 if (formula.isRewardOperatorFormula()) {
84 : model.getUniqueRewardModel();
85 if (rewardModel.hasStateRewards()) {
86 for (auto const& rew : rewardModel.getStateRewardVector()) {
88 STORM_LOG_WARN("The input model contains a non-linear polynomial as state reward: '"
89 << rew << "'. Can not validate that parameter lifting is sound on this model.");
90 return false;
91 }
92 }
93 }
94 // Parameters in transition rewards (and for continuous time models also action rewards) have to be disjoint from the probability/rate parameters.
95 // Note: This check could also be done action-wise.
96 std::set<typename storm::utility::parametric::VariableType<ValueType>::type> collectedRewardParameters;
97 if (rewardModel.hasStateActionRewards()) {
99 for (auto const& rew : rewardModel.getStateActionRewardVector()) {
101 STORM_LOG_WARN("The input model contains a non-linear polynomial as action reward: '"
102 << rew << "'. Can not validate that parameter lifting is sound on this model.");
103 return false;
104 }
105 storm::utility::parametric::gatherOccurringVariables(rew, collectedRewardParameters);
106 }
107 } else {
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 }
115 }
116 }
117
118 if (rewardModel.hasTransitionRewards()) {
119 for (auto const& rewEntry : rewardModel.getTransitionRewardMatrix()) {
120 if (!storm::utility::parametric::isMultiLinearPolynomial(rewEntry.getValue())) {
121 STORM_LOG_WARN("The input model contains a non-linear polynomial as transition reward: '"
122 << rewEntry.getValue() << "'. Can not validate that parameter lifting is sound on this model.");
123 return false;
124 }
125 storm::utility::parametric::gatherOccurringVariables(rewEntry.getValue(), collectedRewardParameters);
126 }
127 }
128
129 if (!collectedRewardParameters.empty()) {
130 std::set<typename storm::utility::parametric::VariableType<ValueType>::type> transitionParameters =
132 auto rewParIt = collectedRewardParameters.begin();
133 auto trParIt = transitionParameters.begin();
134 while (rewParIt != collectedRewardParameters.end() && trParIt != transitionParameters.end()) {
135 if (*rewParIt == *trParIt) {
137 "Parameter "
138 << *trParIt
139 << " occurs in a transition probability/rate and in a transition/action reward. Parameter lifting might not be sound on this model.");
140 return false;
141 }
142 if (*rewParIt < *trParIt) {
143 ++rewParIt;
144 } else {
145 ++trParIt;
146 }
147 }
148 }
149 }
150 return true;
151}
152
153} // namespace parameterlifting
154} // namespace utility
155} // namespace storm
156
157#endif /* STORM_UTILITY_PARAMETERLIFTING_H */
RewardOperatorFormula & asRewardOperatorFormula()
Definition Formula.cpp:461
virtual bool isRewardOperatorFormula() const
Definition Formula.cpp:176
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:19
This class represents a Markov automaton.
Base class for all sparse models.
Definition Model.h:33
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:30
#define STORM_LOG_ERROR(message)
Definition logging.h:31
std::set< storm::RationalFunctionVariable > getProbabilityParameters(Model< storm::RationalFunction > const &model)
Get all probability parameters occurring on transitions.
Definition Model.cpp:703
static bool validateParameterLiftingSound(storm::models::sparse::Model< ValueType > const &model, storm::logic::Formula const &formula)
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)
LabParser.cpp.
Definition cli.cpp:18