Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
EliminationLinearEquationSolver.cpp
Go to the documentation of this file.
2
3#include <numeric>
4
11#include "storm/utility/graph.h"
14
15namespace storm {
16namespace solver {
17
18using namespace stateelimination;
19
20template<typename ValueType>
24
25template<typename ValueType>
29
30template<typename ValueType>
34
35template<typename ValueType>
37 this->A = &A;
38 localA.reset();
39 this->clearCache();
40}
41
42template<typename ValueType>
44 localA = std::make_unique<storm::storage::SparseMatrix<ValueType>>(std::move(A));
45 this->A = localA.get();
46 this->clearCache();
47}
48
49template<typename ValueType>
51 std::vector<ValueType> const& b) const {
52 // This solver computes the least fixed point of systems of the form x = A*x + b. Systems that have a one on
53 // the diagonal (i.e., absorbing states) are handled by the state eliminator: the value of an absorbing state
54 // is zero. However, arbitrary matrices that are not such fixed-point systems would require pivoting, which is
55 // not currently implemented.
56
57 STORM_LOG_INFO("Solving linear equation system (" << x.size() << " rows) with elimination");
58
59 storm::storage::SparseMatrix<ValueType> const& transitionMatrix = localA ? *localA : *A;
60 storm::storage::SparseMatrix<ValueType> backwardTransitions = transitionMatrix.transpose();
61
62 // Initialize the solution to the right-hand side of the equation system.
63 x = b;
64
65 // Translate the matrix and its transpose into the flexible format.
66 storm::storage::FlexibleSparseMatrix<ValueType> flexibleMatrix(transitionMatrix, false);
67 storm::storage::FlexibleSparseMatrix<ValueType> flexibleBackwardTransitions(backwardTransitions, true);
68
69 boost::optional<std::vector<uint_fast64_t>> distanceBasedPriorities;
70
72
74 // Since we have no initial states at this point, we determine a representative of every BSCC regarding
75 // the backward transitions, because this means that every row is reachable from this set of rows, which
76 // we require to make sure we cover every row.
77 storm::storage::BitVector initialRows = storm::utility::graph::getBsccCover(backwardTransitions);
78 distanceBasedPriorities = getDistanceBasedPriorities(order, transitionMatrix, backwardTransitions, initialRows, b,
80 }
81
82 std::shared_ptr<StatePriorityQueue> priorityQueue = createStatePriorityQueue<ValueType>(
83 order, distanceBasedPriorities, flexibleMatrix, flexibleBackwardTransitions, b, storm::storage::BitVector(x.size(), true));
84
85 // Create a state eliminator to perform the actual elimination.
86 PrioritizedStateEliminator<ValueType> eliminator(flexibleMatrix, flexibleBackwardTransitions, priorityQueue, x);
87
88 // Eliminate all states.
89 while (priorityQueue->hasNext()) {
90 auto state = priorityQueue->pop();
91 eliminator.eliminateState(state, false);
92 }
93
94 return true;
95}
96
97template<typename ValueType>
101
102template<typename ValueType>
103uint64_t EliminationLinearEquationSolver<ValueType>::getMatrixRowCount() const {
104 return this->A->getRowCount();
105}
106
107template<typename ValueType>
108uint64_t EliminationLinearEquationSolver<ValueType>::getMatrixColumnCount() const {
109 return this->A->getColumnCount();
110}
111
112template<typename ValueType>
113std::unique_ptr<storm::solver::LinearEquationSolver<ValueType>> EliminationLinearEquationSolverFactory<ValueType>::create(Environment const& env) const {
114 return std::make_unique<storm::solver::EliminationLinearEquationSolver<ValueType>>();
115}
116
117template<typename ValueType>
118std::unique_ptr<LinearEquationSolverFactory<ValueType>> EliminationLinearEquationSolverFactory<ValueType>::clone() const {
119 return std::make_unique<EliminationLinearEquationSolverFactory<ValueType>>(*this);
120}
121
124
127
130} // namespace solver
131} // namespace storm
storm::solver::stateelimination::EliminationOrder const & getOrder() const
SolverEnvironment & solver()
EliminationSolverEnvironment & elimination()
virtual std::unique_ptr< storm::solver::LinearEquationSolver< ValueType > > create(Environment const &env) const override
Creates an equation solver with the current settings, but without a matrix.
virtual std::unique_ptr< LinearEquationSolverFactory< ValueType > > clone() const override
Creates a copy of this factory.
A class that uses gaussian elimination to implement the LinearEquationSolver interface.
virtual LinearEquationSolverProblemFormat getEquationProblemFormat(Environment const &env) const override
Retrieves the format in which this solver expects to solve equations.
virtual void setMatrix(storm::storage::SparseMatrix< ValueType > const &A) override
virtual bool internalSolveEquations(Environment const &env, std::vector< ValueType > &x, std::vector< ValueType > const &b) const override
void eliminateState(storm::storage::sparse::state_type state, bool removeForwardTransitions)
A bit vector that is internally represented as a vector of 64-bit values.
Definition BitVector.h:16
The flexible sparse matrix is used during state elimination.
A class that holds a possibly non-square matrix in the compressed row storage format.
storm::storage::SparseMatrix< value_type > transpose(bool joinGroups=false, bool keepZeros=false) const
Transposes the matrix.
#define STORM_LOG_INFO(message)
Definition logging.h:27
bool eliminationOrderNeedsReversedDistances(EliminationOrder const &order)
bool eliminationOrderNeedsForwardDistances(EliminationOrder const &order)
std::shared_ptr< StatePriorityQueue > createStatePriorityQueue(EliminationOrder const &order, boost::optional< std::vector< uint_fast64_t > > const &distanceBasedStatePriorities, storm::storage::FlexibleSparseMatrix< ValueType > const &transitionMatrix, storm::storage::FlexibleSparseMatrix< ValueType > const &backwardTransitions, std::vector< ValueType > const &oneStepProbabilities, storm::storage::BitVector const &states)
bool eliminationOrderNeedsDistances(EliminationOrder const &order)
EliminationOrder
An enum that contains all available state elimination orders.
std::vector< uint_fast64_t > getDistanceBasedPriorities(EliminationOrder const &order, storm::storage::SparseMatrix< ValueType > const &transitionMatrix, storm::storage::SparseMatrix< ValueType > const &transitionMatrixTransposed, storm::storage::BitVector const &initialStates, std::vector< ValueType > const &oneStepProbabilities, bool forward, bool reverse)
storm::storage::BitVector getBsccCover(storm::storage::SparseMatrix< T > const &transitionMatrix)
Retrieves a set of states that covers als BSCCs of the system in the sense that for every BSCC exactl...
Definition graph.cpp:122