Storm
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
16
17namespace storm {
18namespace transformer {
19
30template<typename ParametricType, typename ConstantType>
32 public:
36
44 ParameterLifter(storm::storage::SparseMatrix<ParametricType> const& pMatrix, std::vector<ParametricType> const& pVector,
45 storm::storage::BitVector const& selectedRows, storm::storage::BitVector const& selectedColumns, bool generateRowLabels = false,
46 bool useMonotonicity = false);
47
49
57 storm::storage::BitVector const& selectedRows);
58
67 std::shared_ptr<storm::analysis::Order> reachabilityOrder,
68 std::shared_ptr<storm::analysis::LocalMonotonicityResult<VariableType>> localMonotonicityResult);
69
70 // Returns the resulting matrix. Should only be called AFTER specifying a region
72
73 // Returns the resulting vector. Should only be called AFTER specifying a region
74 std::vector<ConstantType> const& getVector() const;
75
76 std::vector<std::set<VariableType>> const& getOccurringVariablesAtState() const;
77
78 std::map<VariableType, std::set<uint_fast64_t>> getOccuringStatesAtVariable() const;
79
80 uint_fast64_t getRowGroupIndex(uint_fast64_t originalState) const;
81 uint_fast64_t getOriginalStateNumber(uint_fast64_t newState) const;
82 uint_fast64_t getRowGroupSize(uint_fast64_t originalState) const;
83 uint_fast64_t getRowGroupCount() const;
84
85 /*
86 * During initialization, the actual regions are not known. Hence, we consider abstract valuations,
87 * 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
88 */
90 public:
91 AbstractValuation() = default;
92 AbstractValuation(AbstractValuation const& other) = default;
93 bool operator==(AbstractValuation const& other) const;
94
95 void addParameterLower(VariableType const& var);
96 void addParameterUpper(VariableType const& var);
98
99 std::size_t getHashValue() const;
100 AbstractValuation getSubValuation(std::set<VariableType> const& pars) const;
101 std::set<VariableType> const& getLowerParameters() const;
102 std::set<VariableType> const& getUpperParameters() const;
103 std::set<VariableType> const& getUnspecifiedParameters() const;
104
109 std::vector<storm::utility::parametric::Valuation<ParametricType>> getConcreteValuations(
111
112 private:
113 std::set<VariableType> lowerPars, upperPars, unspecifiedPars;
114 };
115
116 // Returns for each row the abstract valuation for this row
117 // Note: the returned vector might be empty if row label generaion was disabled initially
118 std::vector<AbstractValuation> const& getRowLabels() const;
119
120 private:
121 /*
122 * We minimize the number of function evaluations by only calling evaluate() once for each unique pair of function and valuation.
123 * The result of each evaluation is then written to all positions in the matrix (and the vector) where the corresponding (function,valuation) occurred.
124 */
125
131 class FunctionValuationCollector {
132 public:
133 FunctionValuationCollector() = default;
134
139 ConstantType& add(ParametricType const& function, AbstractValuation const& valuation);
140
141 void evaluateCollectedFunctions(storm::storage::ParameterRegion<ParametricType> const& region,
142 storm::solver::OptimizationDirection const& dirForUnspecifiedParameters);
143
144 private:
145 // Stores a function and a valuation. The valuation is stored as an index of the collectedValuations-vector.
146 typedef std::pair<ParametricType, AbstractValuation> FunctionValuation;
147
148 class FuncValHash {
149 public:
150 std::size_t operator()(FunctionValuation const& fv) const {
151 std::size_t seed = 0;
152 carl::hash_add(seed, fv.first);
153 carl::hash_add(seed, fv.second.getHashValue());
154 return seed;
155 }
156 };
157
158 // Stores the collected functions with the valuations together with a placeholder for the result.
159 std::unordered_map<FunctionValuation, ConstantType, FuncValHash> collectedFunctions;
160 };
161
162 FunctionValuationCollector functionValuationCollector;
163
164 // Returns the 2^(variables.size()) vertices of the region
165 std::vector<AbstractValuation> getVerticesOfAbstractRegion(std::set<VariableType> const& variables) const;
166
167 std::vector<AbstractValuation> rowLabels;
168
169 std::vector<uint_fast64_t> oldToNewColumnIndexMapping; // Mapping from old to new columnIndex used for monotonicity
170 std::vector<uint_fast64_t> rowGroupToStateNumber; // Mapping from new to old columnIndex used for monotonicity
171
172 storm::storage::SparseMatrix<ConstantType> matrix; // The resulting matrix;
173 std::vector<std::pair<typename storm::storage::SparseMatrix<ConstantType>::iterator, ConstantType&>>
174 matrixAssignment; // Connection of matrix entries with placeholders
175
176 std::vector<ConstantType> vector; // The resulting vector
177 std::vector<std::pair<typename std::vector<ConstantType>::iterator, ConstantType&>> vectorAssignment; // Connection of vector entries with placeholders
178
179 // Used for monotonicity in sparsedtmcparameterlifter
180 std::vector<std::set<VariableType>> occurringVariablesAtState;
181 std::map<VariableType, std::set<uint_fast64_t>> occuringStatesAtVariable;
182};
183
184} // namespace transformer
185} // namespace storm
Monotonicity
The results of monotonicity checking for a single Parameter Region.
A bit vector that is internally represented as a vector of 64-bit values.
Definition BitVector.h:18
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::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
std::map< VariableType, std::set< uint_fast64_t > > getOccuringStatesAtVariable() const
LabParser.cpp.
Definition cli.cpp:18