Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
SparseDeterministicStepBoundedHorizonHelper.cpp
Go to the documentation of this file.
4
7
11
15
17
19
20template<typename ValueType>
24
25template<typename ValueType>
27 storm::storage::SparseMatrix<ValueType> const& transitionMatrix,
28 storm::storage::SparseMatrix<ValueType> const& backwardTransitions,
29 storm::storage::BitVector const& phiStates,
30 storm::storage::BitVector const& psiStates, uint64_t lowerBound,
31 uint64_t upperBound, ModelCheckerHint const& hint) {
32 std::vector<ValueType> result(transitionMatrix.getRowCount(), storm::utility::zero<ValueType>());
33
34 // If we identify the states that have probability 0 of reaching the target states, we can exclude them in the further analysis.
35 storm::storage::BitVector maybeStates;
36 storm::storage::BitVector makeZeroColumns;
37
38 if (hint.isExplicitModelCheckerHint() && hint.template asExplicitModelCheckerHint<ValueType>().getComputeOnlyMaybeStates()) {
39 maybeStates = hint.template asExplicitModelCheckerHint<ValueType>().getMaybeStates();
40 } else {
41 maybeStates = storm::utility::graph::performProbGreater0(backwardTransitions, phiStates, psiStates, true, upperBound);
42 if (lowerBound == 0) {
43 maybeStates &= ~psiStates;
44 } else {
45 makeZeroColumns = psiStates;
46 }
47 }
48
49 STORM_LOG_INFO("Preprocessing: " << maybeStates.getNumberOfSetBits() << " non-target states with probability greater 0.");
50 if (lowerBound == 0) {
51 storm::utility::vector::setVectorValues<ValueType>(result, psiStates, storm::utility::one<ValueType>());
52 }
53
54 if (!maybeStates.empty()) {
55 // We can eliminate the rows and columns from the original transition probability matrix that have probability 0.
56 storm::storage::SparseMatrix<ValueType> submatrix = transitionMatrix.getSubmatrix(true, maybeStates, maybeStates, true, makeZeroColumns);
57
58 // Create the vector of one-step probabilities to go to target states.
59 std::vector<ValueType> b = transitionMatrix.getConstrainedRowSumVector(maybeStates, psiStates);
60
61 // Create the vector with which to multiply.
62 std::vector<ValueType> subresult(maybeStates.getNumberOfSetBits());
63
64 // Perform the matrix vector multiplication
65 auto multiplier = storm::solver::MultiplierFactory<ValueType>().create(env, submatrix);
66 if (lowerBound == 0) {
67 multiplier->repeatedMultiply(env, subresult, &b, upperBound);
68 } else {
69 multiplier->repeatedMultiply(env, subresult, &b, upperBound - lowerBound + 1);
70 submatrix = transitionMatrix.getSubmatrix(true, maybeStates, maybeStates, true);
71 multiplier = storm::solver::MultiplierFactory<ValueType>().create(env, submatrix);
72 b = std::vector<ValueType>(b.size(), storm::utility::zero<ValueType>());
73 multiplier->repeatedMultiply(env, subresult, &b, lowerBound - 1);
74 }
75
76 // Set the values of the resulting vector accordingly.
77 storm::utility::vector::setVectorValues(result, maybeStates, subresult);
78 }
79
80 return result;
81}
82
86} // namespace storm::modelchecker::helper
This class contains information that might accelerate the model checking process.
std::vector< ValueType > compute(Environment const &env, storm::solver::SolveGoal< ValueType > &&goal, storm::storage::SparseMatrix< ValueType > const &transitionMatrix, storm::storage::SparseMatrix< ValueType > const &backwardTransitions, storm::storage::BitVector const &phiStates, storm::storage::BitVector const &psiStates, uint64_t lowerBound, uint64_t upperBound, ModelCheckerHint const &hint=ModelCheckerHint())
std::unique_ptr< Multiplier< ValueType > > create(Environment const &env, storm::storage::SparseMatrix< ValueType > const &matrix)
A bit vector that is internally represented as a vector of 64-bit values.
Definition BitVector.h:18
bool empty() const
Retrieves whether no bits are set to true in this bit vector.
uint_fast64_t getNumberOfSetBits() const
Returns the number of bits that are set to true in this bit vector.
A class that holds a possibly non-square matrix in the compressed row storage format.
SparseMatrix getSubmatrix(bool useGroups, storm::storage::BitVector const &rowConstraint, storm::storage::BitVector const &columnConstraint, bool insertDiagonalEntries=false, storm::storage::BitVector const &makeZeroColumns=storm::storage::BitVector()) const
Creates a submatrix of the current matrix by dropping all rows and columns whose bits are not set to ...
std::vector< value_type > getConstrainedRowSumVector(storm::storage::BitVector const &rowConstraint, storm::storage::BitVector const &columnConstraint) const
Computes a vector whose i-th entry is the sum of the entries in the i-th selected row where only thos...
index_type getRowCount() const
Returns the number of rows of the matrix.
#define STORM_LOG_INFO(message)
Definition logging.h:29
storm::storage::BitVector performProbGreater0(storm::storage::SparseMatrix< T > const &backwardTransitions, storm::storage::BitVector const &phiStates, storm::storage::BitVector const &psiStates, bool useStepBound, uint_fast64_t maximalSteps)
Performs a backward depth-first search trough the underlying graph structure of the given model to de...
Definition graph.cpp:322
void setVectorValues(std::vector< T > &vector, storm::storage::BitVector const &positions, std::vector< T > const &values)
Sets the provided values at the provided positions in the given vector.
Definition vector.h:83