Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
GuessingValueIterationHelper.h
Go to the documentation of this file.
1#pragma once
2
3#include <vector>
4
6
10
11namespace storm::solver::helper {
12
13template<typename ValueType>
14struct GVIData {
15 std::vector<ValueType> const& x;
16 std::vector<ValueType> const& y;
18};
19
20namespace gviinternal {
21
22typedef uint64_t IndexType;
24
25template<typename ValueType>
27 public:
29
30 IndexType selectRowGroupToGuess(const std::vector<ValueType>& lowerX, const std::vector<ValueType>& upperX);
31
32 bool checkConvergence(std::vector<ValueType> const& lower, std::vector<ValueType> const& upper, bool relative, ValueType const& precision) const;
33 ValueType getSumLength(std::vector<ValueType>& lower, std::vector<ValueType>& upper) const;
34
35 private:
37 // this is only used to avoid reallocations
38 std::vector<ValueType> weights;
39
40 void swipeWeights();
41};
42
43} // namespace gviinternal
44
45template<typename ValueType, OptimizationDirection Dir>
46class GVIBackend;
47
52template<typename ValueType, bool TrivialRowGrouping>
54 public:
57
68 SolverStatus solveEquations(std::vector<ValueType>& lowerX, std::vector<ValueType>& upperX, const std::vector<ValueType>& b, uint64_t& numIterations,
69 bool relative, ValueType precision, std::optional<storm::solver::OptimizationDirection> dir,
70 std::function<SolverStatus(GVIData<ValueType> const&)> const& iterationCallback);
71
72 private:
73 std::shared_ptr<ValueIterationOperator<ValueType, TrivialRowGrouping>> viOperator;
75 std::vector<ValueType> guessLower, guessUpper;
76 gviinternal::IndexType selectRowGroupToGuess(std::vector<ValueType>& lowerX, std::vector<ValueType>& upperX);
77
78 template<OptimizationDirection Dir>
79 SolverStatus solveEquations(std::vector<ValueType>& lowerX, std::vector<ValueType>& upperX, const std::vector<ValueType>& b, uint64_t& numIterations,
80 bool relative, ValueType precision, std::function<SolverStatus(GVIData<ValueType> const&)> const& iterationCallback);
81
82 template<OptimizationDirection Dir>
83 void applyInPlace(std::vector<ValueType>& lowerX, std::vector<ValueType>& upperX, const std::vector<ValueType>& b, GVIBackend<ValueType, Dir>& backend);
84
85 template<OptimizationDirection Dir>
86 std::pair<gviinternal::VerifyResult, SolverStatus> tryVerify(std::vector<ValueType>& lowerX, std::vector<ValueType>& upperX,
87 const std::vector<ValueType>& b, uint64_t& numIterations,
88 gviinternal::IndexType rowGroupToGuess, ValueType guessValue, bool relative,
89 ValueType precision,
90 std::function<SolverStatus(GVIData<ValueType> const&)> const& iterationCallback);
91
92 template<OptimizationDirection Dir>
93 SolverStatus doIterations(std::vector<ValueType>& lowerX, std::vector<ValueType>& upperX, const std::vector<ValueType>& b, uint64_t& numIterations,
94 std::optional<uint64_t> maxIterations, bool relative, const ValueType& precision,
95 std::function<SolverStatus(GVIData<ValueType> const&)> const& iterationCallback);
96};
97} // namespace storm::solver::helper
GuessingValueIterationHelper(std::shared_ptr< ValueIterationOperator< ValueType, TrivialRowGrouping > > viOperator, const storage::SparseMatrix< ValueType > &matrix)
SolverStatus solveEquations(std::vector< ValueType > &lowerX, std::vector< ValueType > &upperX, const std::vector< ValueType > &b, uint64_t &numIterations, bool relative, ValueType precision, std::optional< storm::solver::OptimizationDirection > dir, std::function< SolverStatus(GVIData< ValueType > const &)> const &iterationCallback)
This class represents the Value Iteration Operator (also known as Bellman operator).
ValueType getSumLength(std::vector< ValueType > &lower, std::vector< ValueType > &upper) const
bool checkConvergence(std::vector< ValueType > const &lower, std::vector< ValueType > const &upper, bool relative, ValueType const &precision) const
IndexType selectRowGroupToGuess(const std::vector< ValueType > &lowerX, const std::vector< ValueType > &upperX)
IterationHelper(storm::storage::SparseMatrix< ValueType > const &matrix_)
A class that holds a possibly non-square matrix in the compressed row storage format.
std::vector< ValueType > const & x
std::vector< ValueType > const & y