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
15
16namespace storm {
17
18namespace analysis {
19class Order;
20} // namespace analysis
21
22namespace storage {
23template<typename ParametricType>
24class ParameterRegion;
25} // namespace storage
26
27namespace transformer {
28
39template<typename ParametricType, typename ConstantType>
41 public:
45
53 ParameterLifter(storm::storage::SparseMatrix<ParametricType> const& pMatrix, std::vector<ParametricType> const& pVector,
54 storm::storage::BitVector const& selectedRows, storm::storage::BitVector const& selectedColumns, bool generateRowLabels = false,
55 bool useMonotonicity = false);
56
58
66 storm::storage::BitVector const& selectedRows);
67
76 std::shared_ptr<storm::analysis::Order> reachabilityOrder,
77 std::shared_ptr<storm::analysis::LocalMonotonicityResult<VariableType>> localMonotonicityResult);
78
79 // Returns the resulting matrix. Should only be called AFTER specifying a region
81
82 // Returns the resulting vector. Should only be called AFTER specifying a region
83 std::vector<ConstantType> const& getVector() const;
84
85 std::vector<std::set<VariableType>> const& getOccurringVariablesAtState() const;
86
87 std::map<VariableType, std::set<uint_fast64_t>> const& getOccuringStatesAtVariable() const;
88
89 uint_fast64_t getRowGroupIndex(uint_fast64_t originalState) const;
90 uint_fast64_t getOriginalStateNumber(uint_fast64_t newState) const;
91 uint_fast64_t getRowGroupSize(uint_fast64_t originalState) const;
92 uint_fast64_t getRowGroupCount() const;
93
94 /*
95 * During initialization, the actual regions are not known. Hence, we consider abstract valuations,
96 * 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
97 */
99 public:
100 AbstractValuation() = default;
101 AbstractValuation(AbstractValuation const& other) = default;
102 bool operator==(AbstractValuation const& other) const;
103
104 void addParameterLower(VariableType const& var);
105 void addParameterUpper(VariableType const& var);
106 void addParameterUnspecified(VariableType const& var);
107
108 std::size_t getHashValue() const;
109 AbstractValuation getSubValuation(std::set<VariableType> const& pars) const;
110 std::set<VariableType> const& getLowerParameters() const;
111 std::set<VariableType> const& getUpperParameters() const;
112 std::set<VariableType> const& getUnspecifiedParameters() const;
113
118 std::vector<storm::utility::parametric::Valuation<ParametricType>> getConcreteValuations(
120
121 private:
122 std::set<VariableType> lowerPars, upperPars, unspecifiedPars;
123 };
124
125 // Returns for each row the abstract valuation for this row
126 // Note: the returned vector might be empty if row label generaion was disabled initially
127 std::vector<AbstractValuation> const& getRowLabels() const;
128
129 private:
130 /*
131 * We minimize the number of function evaluations by only calling evaluate() once for each unique pair of function and valuation.
132 * The result of each evaluation is then written to all positions in the matrix (and the vector) where the corresponding (function,valuation) occurred.
133 */
134
140 class FunctionValuationCollector {
141 public:
142 FunctionValuationCollector() = default;
143
148 ConstantType& add(ParametricType const& function, AbstractValuation const& valuation);
149
150 void evaluateCollectedFunctions(storm::storage::ParameterRegion<ParametricType> const& region,
151 storm::solver::OptimizationDirection const& dirForUnspecifiedParameters);
152
153 private:
154 // Stores a function and a valuation. The valuation is stored as an index of the collectedValuations-vector.
155 typedef std::pair<ParametricType, AbstractValuation> FunctionValuation;
156
157 class FuncValHash {
158 public:
159 std::size_t operator()(FunctionValuation const& fv) const {
160 std::size_t seed = 0;
161 carl::hash_add(seed, fv.first);
162 carl::hash_add(seed, fv.second.getHashValue());
163 return seed;
164 }
165 };
166
167 // Stores the collected functions with the valuations together with a placeholder for the result.
168 std::unordered_map<FunctionValuation, ConstantType, FuncValHash> collectedFunctions;
169 };
170
171 FunctionValuationCollector functionValuationCollector;
172
173 // Returns the 2^(variables.size()) vertices of the region
174 std::vector<AbstractValuation> getVerticesOfAbstractRegion(std::set<VariableType> const& variables) const;
175
176 std::vector<AbstractValuation> rowLabels;
177
178 std::vector<uint_fast64_t> oldToNewColumnIndexMapping; // Mapping from old to new columnIndex used for monotonicity
179 std::vector<uint_fast64_t> rowGroupToStateNumber; // Mapping from new to old columnIndex used for monotonicity
180
181 storm::storage::SparseMatrix<ConstantType> matrix; // The resulting matrix;
182 std::vector<std::pair<typename storm::storage::SparseMatrix<ConstantType>::iterator, ConstantType&>>
183 matrixAssignment; // Connection of matrix entries with placeholders
184
185 std::vector<ConstantType> vector; // The resulting vector
186 std::vector<std::pair<typename std::vector<ConstantType>::iterator, ConstantType&>> vectorAssignment; // Connection of vector entries with placeholders
187
188 // Used for monotonicity in sparsedtmcparameterlifter
189 std::vector<std::set<VariableType>> occurringVariablesAtState;
190 std::map<VariableType, std::set<uint_fast64_t>> occuringStatesAtVariable;
191};
192
193} // namespace transformer
194} // 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.