Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
Multiplier.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <memory>
5#include <vector>
6
10
11namespace storm {
12
13class Environment;
14
15namespace storage {
16template<typename ValueType>
17class SparseMatrix;
18}
19
20namespace solver {
21
22template<typename ValueType, typename SolutionType = ValueType>
24 public:
26
27 virtual ~Multiplier() = default;
28
29 /*
30 * Clears the currently cached data of this multiplier in order to free some memory.
31 */
32 virtual void clearCache() const;
33
44 virtual void multiply(Environment const& env, std::vector<SolutionType> const& x, std::vector<ValueType> const* b,
45 std::vector<SolutionType>& result) const = 0;
46
56 virtual void multiplyGaussSeidel(Environment const& env, std::vector<SolutionType>& x, std::vector<ValueType> const* b, bool backwards = true) const = 0;
57
73 void multiplyAndReduce(Environment const& env, OptimizationDirection const& dir, std::vector<SolutionType> const& x, std::vector<ValueType> const* b,
74 std::vector<SolutionType>& result, UncertaintyResolutionMode const& uncertaintyResolutionMode = UncertaintyResolutionMode::Unset,
75 std::vector<uint_fast64_t>* choices = nullptr) const;
76 virtual void multiplyAndReduce(Environment const& env, OptimizationDirection const& dir, std::vector<uint64_t> const& rowGroupIndices,
77 std::vector<SolutionType> const& x, std::vector<ValueType> const* b, std::vector<SolutionType>& result,
78 UncertaintyResolutionMode const& uncertaintyResolutionMode = UncertaintyResolutionMode::Unset,
79 std::vector<uint_fast64_t>* choices = nullptr) const = 0;
80
96 void multiplyAndReduceGaussSeidel(Environment const& env, OptimizationDirection const& dir, std::vector<SolutionType>& x, std::vector<ValueType> const* b,
97 std::vector<uint_fast64_t>* choices = nullptr, bool backwards = true) const;
98 virtual void multiplyAndReduceGaussSeidel(Environment const& env, OptimizationDirection const& dir, std::vector<uint64_t> const& rowGroupIndices,
99 std::vector<SolutionType>& x, std::vector<ValueType> const* b, std::vector<uint_fast64_t>* choices = nullptr,
100 bool backwards = true) const = 0;
101
113 void repeatedMultiply(Environment const& env, std::vector<SolutionType>& x, std::vector<ValueType> const* b, uint64_t n) const;
114
129 void repeatedMultiplyAndReduce(Environment const& env, OptimizationDirection const& dir, std::vector<SolutionType>& x, std::vector<ValueType> const* b,
130 uint64_t n, UncertaintyResolutionMode const& uncertaintyResolutionMode = UncertaintyResolutionMode::Unset) const;
143 void repeatedMultiplyWithFactor(Environment const& env, std::vector<SolutionType>& x, std::vector<ValueType> const* b, uint64_t n,
144 SolutionType factor) const;
145
161 void repeatedMultiplyAndReduceWithFactor(Environment const& env, OptimizationDirection const& dir, std::vector<SolutionType>& x,
162 std::vector<ValueType> const* b, uint64_t n, SolutionType factor,
163 UncertaintyResolutionMode const& uncertaintyResolutionMode = UncertaintyResolutionMode::Unset) const;
164
165 protected:
166 std::vector<SolutionType>& provideCachedVector(uint64_t size) const;
167
168 mutable std::unique_ptr<std::vector<SolutionType>> cachedVector;
170};
171
172template<typename ValueType, typename SolutionType = ValueType>
174 public:
175 MultiplierFactory() = default;
177
178 std::unique_ptr<Multiplier<ValueType, SolutionType>> create(Environment const& env, storm::storage::SparseMatrix<ValueType> const& matrix);
179};
180
181} // namespace solver
182} // namespace storm
std::unique_ptr< Multiplier< ValueType, SolutionType > > create(Environment const &env, storm::storage::SparseMatrix< ValueType > const &matrix)
virtual void multiplyAndReduce(Environment const &env, OptimizationDirection const &dir, std::vector< uint64_t > const &rowGroupIndices, std::vector< SolutionType > const &x, std::vector< ValueType > const *b, std::vector< SolutionType > &result, UncertaintyResolutionMode const &uncertaintyResolutionMode=UncertaintyResolutionMode::Unset, std::vector< uint_fast64_t > *choices=nullptr) const =0
Multiplier(storm::storage::SparseMatrix< ValueType > const &matrix)
void repeatedMultiplyWithFactor(Environment const &env, std::vector< SolutionType > &x, std::vector< ValueType > const *b, uint64_t n, SolutionType factor) const
Performs repeated matrix-vector multiplication x' = A*(factor * x) + b.
void multiplyAndReduce(Environment const &env, OptimizationDirection const &dir, std::vector< SolutionType > const &x, std::vector< ValueType > const *b, std::vector< SolutionType > &result, UncertaintyResolutionMode const &uncertaintyResolutionMode=UncertaintyResolutionMode::Unset, std::vector< uint_fast64_t > *choices=nullptr) const
Performs a matrix-vector multiplication x' = A*x + b and then minimizes/maximizes over the row groups...
std::unique_ptr< std::vector< SolutionType > > cachedVector
Definition Multiplier.h:168
void repeatedMultiply(Environment const &env, std::vector< SolutionType > &x, std::vector< ValueType > const *b, uint64_t n) const
Performs repeated matrix-vector multiplication, using x[0] = x and x[i + 1] = A*x[i] + b.
virtual ~Multiplier()=default
void repeatedMultiplyAndReduceWithFactor(Environment const &env, OptimizationDirection const &dir, std::vector< SolutionType > &x, std::vector< ValueType > const *b, uint64_t n, SolutionType factor, UncertaintyResolutionMode const &uncertaintyResolutionMode=UncertaintyResolutionMode::Unset) const
Performs repeated matrix-vector multiplication x' = A*(factor * x) + b, minimizes/maximizes over the ...
void multiplyAndReduceGaussSeidel(Environment const &env, OptimizationDirection const &dir, std::vector< SolutionType > &x, std::vector< ValueType > const *b, std::vector< uint_fast64_t > *choices=nullptr, bool backwards=true) const
Performs a matrix-vector multiplication in gauss-seidel style and then minimizes/maximizes over the r...
virtual void multiplyGaussSeidel(Environment const &env, std::vector< SolutionType > &x, std::vector< ValueType > const *b, bool backwards=true) const =0
Performs a matrix-vector multiplication in gauss-seidel style.
std::vector< SolutionType > & provideCachedVector(uint64_t size) const
virtual void clearCache() const
storm::storage::SparseMatrix< ValueType > const & matrix
Definition Multiplier.h:169
virtual void multiplyAndReduceGaussSeidel(Environment const &env, OptimizationDirection const &dir, std::vector< uint64_t > const &rowGroupIndices, std::vector< SolutionType > &x, std::vector< ValueType > const *b, std::vector< uint_fast64_t > *choices=nullptr, bool backwards=true) const =0
virtual void multiply(Environment const &env, std::vector< SolutionType > const &x, std::vector< ValueType > const *b, std::vector< SolutionType > &result) const =0
Performs a matrix-vector multiplication x' = A*x + b.
void repeatedMultiplyAndReduce(Environment const &env, OptimizationDirection const &dir, std::vector< SolutionType > &x, std::vector< ValueType > const *b, uint64_t n, UncertaintyResolutionMode const &uncertaintyResolutionMode=UncertaintyResolutionMode::Unset) const
Performs repeated matrix-vector multiplication x' = A*x + b and then minimizes/maximizes over the row...
A class that holds a possibly non-square matrix in the compressed row storage format.