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
11#include "storm/adapters/RationalFunctionAdapter.h" // TODO: use forward header
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
59 // Returns the resulting matrix. Should only be called AFTER specifying a region
61
62 // Returns the resulting vector. Should only be called AFTER specifying a region
63 std::vector<ConstantType> const& getVector() const;
64
65 std::vector<std::set<VariableType>> const& getOccurringVariablesAtState() const;
66
67 std::map<VariableType, std::set<uint_fast64_t>> const& getOccuringStatesAtVariable() const;
68
69 uint_fast64_t getRowGroupIndex(uint_fast64_t originalState) const;
70 uint_fast64_t getOriginalStateNumber(uint_fast64_t newState) const;
71 uint_fast64_t getRowGroupSize(uint_fast64_t originalState) const;
72 uint_fast64_t getRowGroupCount() const;
73
74 /*
75 * During initialization, the actual regions are not known. Hence, we consider abstract valuations,
76 * 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
77 */
79 public:
80 AbstractValuation() = default;
81 AbstractValuation(AbstractValuation const& other) = default;
82 bool operator==(AbstractValuation const& other) const;
83
84 void addParameterLower(VariableType const& var);
85 void addParameterUpper(VariableType const& var);
87
88 std::size_t getHashValue() const;
89 AbstractValuation getSubValuation(std::set<VariableType> const& pars) const;
90 std::set<VariableType> const& getLowerParameters() const;
91 std::set<VariableType> const& getUpperParameters() const;
92 std::set<VariableType> const& getUnspecifiedParameters() const;
93
98 std::vector<storm::utility::parametric::Valuation<ParametricType>> getConcreteValuations(
100
101 private:
102 std::set<VariableType> lowerPars, upperPars, unspecifiedPars;
103 };
104
105 // Returns for each row the abstract valuation for this row
106 // Note: the returned vector might be empty if row label generaion was disabled initially
107 std::vector<AbstractValuation> const& getRowLabels() const;
108
109 private:
110 /*
111 * We minimize the number of function evaluations by only calling evaluate() once for each unique pair of function and valuation.
112 * The result of each evaluation is then written to all positions in the matrix (and the vector) where the corresponding (function,valuation) occurred.
113 */
114
120 class FunctionValuationCollector {
121 public:
122 FunctionValuationCollector() = default;
123
128 ConstantType& add(ParametricType const& function, AbstractValuation const& valuation);
129
130 void evaluateCollectedFunctions(storm::storage::ParameterRegion<ParametricType> const& region,
131 storm::solver::OptimizationDirection const& dirForUnspecifiedParameters);
132
133 private:
134 // Stores a function and a valuation. The valuation is stored as an index of the collectedValuations-vector.
135 typedef std::pair<ParametricType, AbstractValuation> FunctionValuation;
136
137 class FuncValHash {
138 public:
139 std::size_t operator()(FunctionValuation const& fv) const {
140 std::size_t seed = 0;
141 carl::hash_add(seed, fv.first);
142 carl::hash_add(seed, fv.second.getHashValue());
143 return seed;
144 }
145 };
146
147 // Stores the collected functions with the valuations together with a placeholder for the result.
148 std::unordered_map<FunctionValuation, ConstantType, FuncValHash> collectedFunctions;
149 };
150
151 FunctionValuationCollector functionValuationCollector;
152
153 // Returns the 2^(variables.size()) vertices of the region
154 std::vector<AbstractValuation> getVerticesOfAbstractRegion(std::set<VariableType> const& variables) const;
155
156 std::vector<AbstractValuation> rowLabels;
157
158 std::vector<uint_fast64_t> oldToNewColumnIndexMapping; // Mapping from old to new columnIndex used for monotonicity
159 std::vector<uint_fast64_t> rowGroupToStateNumber; // Mapping from new to old columnIndex used for monotonicity
160
161 storm::storage::SparseMatrix<ConstantType> matrix; // The resulting matrix;
162 std::vector<std::pair<typename storm::storage::SparseMatrix<ConstantType>::iterator, ConstantType&>>
163 matrixAssignment; // Connection of matrix entries with placeholders
164
165 std::vector<ConstantType> vector; // The resulting vector
166 std::vector<std::pair<typename std::vector<ConstantType>::iterator, ConstantType&>> vectorAssignment; // Connection of vector entries with placeholders
167
168 // Used for monotonicity in sparsedtmcparameterlifter
169 std::vector<std::set<VariableType>> occurringVariablesAtState;
170 std::map<VariableType, std::set<uint_fast64_t>> occuringStatesAtVariable;
171};
172
173} // namespace transformer
174} // 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)
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
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.