Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
TopologicalMinMaxLinearEquationSolver.h
Go to the documentation of this file.
1#pragma once
2
3#include <optional>
4
6
10
11namespace storm {
12
13class Environment;
14
15namespace solver {
16
17template<typename ValueType, typename SolutionType = ValueType>
19 public:
23
25
26 virtual void clearCache() const override;
27
29 boost::optional<storm::solver::OptimizationDirection> const& direction = boost::none,
30 bool const& hasInitialScheduler = false) const override;
31
32 protected:
33 virtual bool internalSolveEquations(storm::Environment const& env, OptimizationDirection d, std::vector<SolutionType>& x,
34 std::vector<ValueType> const& b) const override;
35
36 private:
37 storm::Environment getEnvironmentForUnderlyingSolver(storm::Environment const& env, bool adaptPrecision = false) const;
38
39 // Creates an SCC decomposition and sorts the SCCs according to a topological sort.
40 void createSortedSccDecomposition(bool needLongestChainSize) const;
41
42 // Reports what the SCC-wise solve established about the solution: the values themselves if every SCC was
43 // solved exactly, otherwise the precision they were solved with, if every SCC was solved that accurately.
44 void trySetSolutionBounds(Environment const& env, std::vector<SolutionType> const& x, bool allSccsExact, bool allSccsPrecise) const;
45
46 // Retrieves whether the SCC solver met the precision the given environment asked of it for the given values it
47 // just produced. Adding up the errors of the SCCs relies on that.
48 bool lastSccMetPrecision(Environment const& sccSolverEnvironment, std::vector<SolutionType> const& sccValues) const;
49
50 // Solves the SCC with the given index
51 // ... for the case that the SCC is trivial
52 bool solveTrivialScc(uint64_t const& sccState, OptimizationDirection d, std::vector<SolutionType>& globalX, std::vector<ValueType> const& globalB) const;
53 // ... for the case that there is just one large SCC
54 bool solveFullyConnectedEquationSystem(storm::Environment const& sccSolverEnvironment, OptimizationDirection d, std::vector<SolutionType>& x,
55 std::vector<ValueType> const& b) const;
56 // ... for the remaining cases (1 < scc.size() < x.size())
57 bool solveScc(storm::Environment const& sccSolverEnvironment, OptimizationDirection d, storm::storage::StronglyConnectedComponent const& scc,
58 storm::storage::BitVector const& sccAsBitVector, std::vector<SolutionType>& globalX, std::vector<ValueType> const& globalB,
59 std::optional<storm::storage::BitVector> const& globalRelevantValues, bool& metPrecision) const;
60
61 // cached auxiliary data
62 mutable std::unique_ptr<storm::storage::StronglyConnectedComponentDecomposition<ValueType>> sortedSccDecomposition;
63 mutable boost::optional<uint64_t> longestSccChainSize;
64 mutable std::unique_ptr<storm::solver::MinMaxLinearEquationSolver<ValueType>> sccSolver;
65 // Builds the submatrices of all SCCs (reuses its internal lookup table between SCCs)
66 mutable std::unique_ptr<storm::storage::SubmatrixBuilder<ValueType>> sccSubmatrixBuilder;
67 mutable std::unique_ptr<std::vector<ValueType>> auxiliaryRowGroupVector; // A.rowGroupCount() entries
68};
69} // namespace solver
70} // namespace storm
virtual bool internalSolveEquations(storm::Environment const &env, OptimizationDirection d, std::vector< SolutionType > &x, std::vector< ValueType > const &b) const override
virtual void clearCache() const override
Clears the currently cached data that has been stored during previous calls of the solver.
virtual MinMaxLinearEquationSolverRequirements getRequirements(Environment const &env, boost::optional< storm::solver::OptimizationDirection > const &direction=boost::none, bool const &hasInitialScheduler=false) const override
Retrieves the requirements of this solver for solving equations with the current settings.
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.
This class represents a strongly connected component, i.e., a set of states such that every state can...