Storm 1.11.1.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
ParameterLifter.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4#include <set>
5#include <unordered_map>
6#include <vector>
7
14
15namespace storm {
16
17namespace analysis {
18class Order;
19} // namespace analysis
20
21namespace storage {
22template<typename ParametricType>
23class ParameterRegion;
24} // namespace storage
25
26namespace transformer {
27
38template<typename ParametricType, typename ConstantType>
40 public:
44
52 ParameterLifter(storm::storage::SparseMatrix<ParametricType> const& pMatrix, std::vector<ParametricType> const& pVector,
53 storm::storage::BitVector const& selectedRows, storm::storage::BitVector const& selectedColumns, bool generateRowLabels = false,
54 bool useMonotonicity = false);
55
57
65 storm::storage::BitVector const& selectedRows);
66
75 std::shared_ptr<storm::analysis::Order> reachabilityOrder,
76 std::shared_ptr<storm::analysis::LocalMonotonicityResult<VariableType>> localMonotonicityResult);
77
78 // Returns the resulting matrix. Should only be called AFTER specifying a region
80
81 // Returns the resulting vector. Should only be called AFTER specifying a region
82 std::vector<ConstantType> const& getVector() const;
83
84 std::vector<std::set<VariableType>> const& getOccurringVariablesAtState() const;
85
86 std::map<VariableType, std::set<uint_fast64_t>> const& getOccuringStatesAtVariable() const;
87
88 uint_fast64_t getRowGroupIndex(uint_fast64_t originalState) const;
89 uint_fast64_t getOriginalStateNumber(uint_fast64_t newState) const;
90 uint_fast64_t getRowGroupSize(uint_fast64_t originalState) const;
91 uint_fast64_t getRowGroupCount() const;
92
93 /*
94 * During initialization, the actual regions are not known. Hence, we consider abstract valuations,
95 * where it is only known whether a parameter will be set to either the lower/upper bound of the region or whether this is unspecified
96 */
98 public:
99 AbstractValuation() = default;
100 AbstractValuation(AbstractValuation const& other) = default;
101 bool operator==(AbstractValuation const& other) const;
102
103 void addParameterLower(VariableType const& var);
104 void addParameterUpper(VariableType const& var);
105 void addParameterUnspecified(VariableType const& var);
106
107 std::size_t getHashValue() const;
108 AbstractValuation getSubValuation(std::set<VariableType> const& pars) const;
109 std::set<VariableType> const& getLowerParameters() const;
110 std::set<VariableType> const& getUpperParameters() const;
111 std::set<VariableType> const& getUnspecifiedParameters() const;
112
117 std::vector<storm::utility::parametric::Valuation<ParametricType>> getConcreteValuations(
119
120 private:
121 std::set<VariableType> lowerPars, upperPars, unspecifiedPars;
122 };
123
124 // Returns for each row the abstract valuation for this row
125 // Note: the returned vector might be empty if row label generaion was disabled initially
126 std::vector<AbstractValuation> const& getRowLabels() const;
127
128 private:
129 /*
130 * We minimize the number of function evaluations by only calling evaluate() once for each unique pair of function and valuation.
131 * The result of each evaluation is then written to all positions in the matrix (and the vector) where the corresponding (function,valuation) occurred.
132 */
133
139 class FunctionValuationCollector {
140 public:
141 FunctionValuationCollector() = default;
142
147 ConstantType& add(ParametricType const& function, AbstractValuation const& valuation);
148
149 void evaluateCollectedFunctions(storm::storage::ParameterRegion<ParametricType> const& region,
150 storm::solver::OptimizationDirection const& dirForUnspecifiedParameters);
151
152 private:
153 // Stores a function and a valuation. The valuation is stored as an index of the collectedValuations-vector.
154 typedef std::pair<ParametricType, AbstractValuation> FunctionValuation;
155
156 class FuncValHash {
157 public:
158 std::size_t operator()(FunctionValuation const& fv) const {
159 std::size_t seed = 0;
160 carl::hash_add(seed, fv.first);
161 carl::hash_add(seed, fv.second.getHashValue());
162 return seed;
163 }
164 };
165
166 // Stores the collected functions with the valuations together with a placeholder for the result.
167 std::unordered_map<FunctionValuation, ConstantType, FuncValHash> collectedFunctions;
168 };
169
170 FunctionValuationCollector functionValuationCollector;
171
172 // Returns the 2^(variables.size()) vertices of the region
173 std::vector<AbstractValuation> getVerticesOfAbstractRegion(std::set<VariableType> const& variables) const;
174
175 std::vector<AbstractValuation> rowLabels;
176
177 std::vector<uint_fast64_t> oldToNewColumnIndexMapping; // Mapping from old to new columnIndex used for monotonicity
178 std::vector<uint_fast64_t> rowGroupToStateNumber; // Mapping from new to old columnIndex used for monotonicity
179
180 storm::storage::SparseMatrix<ConstantType> matrix; // The resulting matrix;
181 std::vector<std::pair<typename storm::storage::SparseMatrix<ConstantType>::iterator, ConstantType&>>
182 matrixAssignment; // Connection of matrix entries with placeholders
183
184 std::vector<ConstantType> vector; // The resulting vector
185 std::vector<std::pair<typename std::vector<ConstantType>::iterator, ConstantType&>> vectorAssignment; // Connection of vector entries with placeholders
186
187 // Used for monotonicity in sparsedtmcparameterlifter
188 std::vector<std::set<VariableType>> occurringVariablesAtState;
189 std::map<VariableType, std::set<uint_fast64_t>> occuringStatesAtVariable;
190};
191
192} // namespace transformer
193} // namespace storm
A bit vector that is internally represented as a vector of 64-bit values.
Definition BitVector.h:16
A class that holds a possibly non-square matrix in the compressed row storage format.
std::set< VariableType > const & getUnspecifiedParameters() const
std::vector< storm::utility::parametric::Valuation< ParametricType > > getConcreteValuations(storm::storage::ParameterRegion< ParametricType > const &region) const
Returns the concrete valuation(s) (w.r.t.
AbstractValuation(AbstractValuation const &other)=default
std::set< VariableType > const & getUpperParameters() const
AbstractValuation getSubValuation(std::set< VariableType > const &pars) const
bool operator==(AbstractValuation const &other) const
std::set< VariableType > const & getLowerParameters() const
This class lifts parameter choices to nondeterminism: For each row in the given matrix that considerd...
uint_fast64_t getRowGroupSize(uint_fast64_t originalState) const
uint_fast64_t getOriginalStateNumber(uint_fast64_t newState) const
void specifyRegion(storm::storage::ParameterRegion< ParametricType > const &region, storm::solver::OptimizationDirection const &dirForParameters)
void specifyRegion(storm::storage::ParameterRegion< ParametricType > const &region, storm::solver::OptimizationDirection const &dirForParameters, storm::storage::BitVector const &selectedRows)
Specifies the region for the parameterlifter, the Bitvector works as a fixed (partial) scheduler,...
storm::storage::SparseMatrix< ConstantType > const & getMatrix() const
std::vector< AbstractValuation > const & getRowLabels() const
uint_fast64_t getRowGroupIndex(uint_fast64_t originalState) const
std::map< VariableType, std::set< uint_fast64_t > > const & getOccuringStatesAtVariable() const
std::vector< ConstantType > const & getVector() const
void specifyRegion(storm::storage::ParameterRegion< ParametricType > const &region, storm::solver::OptimizationDirection const &dirForParameters, std::shared_ptr< storm::analysis::Order > reachabilityOrder, std::shared_ptr< storm::analysis::LocalMonotonicityResult< VariableType > > localMonotonicityResult)
Specifies the region for the parameterlifter, the reachability order is used to see if there is local...
storm::utility::parametric::CoefficientType< ParametricType >::type CoefficientType
storm::utility::parametric::VariableType< ParametricType >::type VariableType
storm::analysis::MonotonicityResult< VariableType >::Monotonicity Monotonicity
std::vector< std::set< VariableType > > const & getOccurringVariablesAtState() const
MonotonicityKind
The results of monotonicity checking for a single Parameter Region.
LabParser.cpp.