Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
parameterlifting.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <set>
5#include <vector>
6
16
17namespace storm {
18namespace utility {
20
35template<typename ValueType>
38 // Check whether all numbers occurring in the model are multilinear
39
40 // Transition matrix
44 STORM_LOG_ERROR("Robust parameter lifting is only supported for DTMCs.");
45 return false;
46 }
47 } else {
48 for (auto const& entry : model.getTransitionMatrix()) {
50 STORM_LOG_WARN("The input model contains a non-linear polynomial as transition: '"
51 << entry.getValue() << "'. Can not validate that parameter lifting is sound on this model.");
52 return false;
53 }
54 }
55 }
57 auto const& ma = dynamic_cast<storm::models::sparse::MarkovAutomaton<ValueType> const&>(model);
58 // Markov Automata store the probability matrix and the exit rate vector. However, we need to considert the rate matrix.
59 if (!ma.isClosed()) {
60 STORM_LOG_ERROR("parameter lifting requires a closed Markov automaton.");
61 return false;
62 }
63 auto const& rateVector = ma.getExitRates();
64 auto const& markovianStates = ma.getMarkovianStates();
65 for (uint_fast64_t state = 0; state < model.getNumberOfStates(); ++state) {
66 if (markovianStates.get(state)) {
67 auto const& exitRate = rateVector[state];
68 for (auto const& entry : model.getTransitionMatrix().getRowGroup(state)) {
70 STORM_LOG_WARN("The input model contains a non-linear polynomial as transition rate: '"
71 << storm::utility::simplify(entry.getValue() * exitRate)
72 << "'. Can not validate that parameter lifting is sound on this model.");
73 return false;
74 }
75 }
76 } else {
77 for (auto const& entry : model.getTransitionMatrix().getRowGroup(state)) {
79 STORM_LOG_WARN("The input model contains a non-linear polynomial as transition: '"
80 << entry.getValue() << "'. Can not validate that parameter lifting is sound on this model.");
81 return false;
82 }
83 }
84 }
85 }
86 } else {
87 STORM_LOG_ERROR("Unsupported model type for parameter lifting.");
88 return false;
89 }
90
91 // Rewards
92 if (formula.isRewardOperatorFormula()) {
95 : model.getUniqueRewardModel();
96 if (rewardModel.hasStateRewards()) {
97 for (auto const& rew : rewardModel.getStateRewardVector()) {
99 STORM_LOG_WARN("The input model contains a non-linear polynomial as state reward: '"
100 << rew << "'. Can not validate that parameter lifting is sound on this model.");
101 return false;
102 }
103 }
104 }
105 // Parameters in transition rewards (and for continuous time models also action rewards) have to be disjoint from the probability/rate parameters.
106 // Note: This check could also be done action-wise.
107 std::set<typename storm::utility::parametric::VariableType<ValueType>::type> collectedRewardParameters;
108 if (rewardModel.hasStateActionRewards()) {
110 for (auto const& rew : rewardModel.getStateActionRewardVector()) {
112 STORM_LOG_WARN("The input model contains a non-linear polynomial as action reward: '"
113 << rew << "'. Can not validate that parameter lifting is sound on this model.");
114 return false;
115 }
116 storm::utility::parametric::gatherOccurringVariables(rew, collectedRewardParameters);
117 }
118 } else {
119 for (auto const& rew : rewardModel.getStateActionRewardVector()) {
121 STORM_LOG_WARN("The input model contains a non-linear polynomial as action reward: '"
122 << rew << "'. Can not validate that parameter lifting is sound on this model.");
123 return false;
124 }
125 }
126 }
127 }
128
129 if (rewardModel.hasTransitionRewards()) {
130 for (auto const& rewEntry : rewardModel.getTransitionRewardMatrix()) {
131 if (!storm::utility::parametric::isMultiLinearPolynomial(rewEntry.getValue())) {
132 STORM_LOG_WARN("The input model contains a non-linear polynomial as transition reward: '"
133 << rewEntry.getValue() << "'. Can not validate that parameter lifting is sound on this model.");
134 return false;
135 }
136 storm::utility::parametric::gatherOccurringVariables(rewEntry.getValue(), collectedRewardParameters);
137 }
138 }
139
140 if (!collectedRewardParameters.empty()) {
141 std::set<typename storm::utility::parametric::VariableType<ValueType>::type> transitionParameters =
143 auto rewParIt = collectedRewardParameters.begin();
144 auto trParIt = transitionParameters.begin();
145 while (rewParIt != collectedRewardParameters.end() && trParIt != transitionParameters.end()) {
146 if (*rewParIt == *trParIt) {
148 "Parameter "
149 << *trParIt
150 << " occurs in a transition probability/rate and in a transition/action reward. Parameter lifting might not be sound on this model.");
151 return false;
152 }
153 if (*rewParIt < *trParIt) {
154 ++rewParIt;
155 } else {
156 ++trParIt;
157 }
158 }
159 }
160 }
161 return true;
162}
163
164} // namespace parameterlifting
165} // namespace utility
166} // namespace storm
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.
std::vector< ValueType > const & getExitRates() const
Retrieves the vector representing the exit rates of the states.
Base class for all sparse models.
Definition Model.h:30
RewardModelType const & getUniqueRewardModel() const
Retrieves the unique reward model, if there exists exactly one.
Definition Model.cpp:304
storm::storage::SparseMatrix< ValueType > const & getTransitionMatrix() const
Retrieves the matrix representing the transitions of the model.
Definition Model.cpp:198
virtual uint_fast64_t getNumberOfStates() const override
Returns the number of states of the model.
Definition Model.cpp:163
RewardModelType const & getRewardModel(std::string const &rewardModelName) const
Retrieves the reward model with the given name, if one exists.
Definition Model.cpp:219
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:28
#define STORM_LOG_ERROR(message)
Definition logging.h:29
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:694
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)