Storm 1.11.1.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
SparseDeterministicStepBoundedHorizonHelper.cpp
Go to the documentation of this file.
2
10
12
13template<typename ValueType>
17
18template<typename ValueType>
20 storm::storage::SparseMatrix<ValueType> const& transitionMatrix,
21 storm::storage::SparseMatrix<ValueType> const& backwardTransitions,
22 storm::storage::BitVector const& phiStates,
23 storm::storage::BitVector const& psiStates, uint64_t lowerBound,
24 uint64_t upperBound, ModelCheckerHint const& hint) {
25 std::vector<ValueType> result(transitionMatrix.getRowCount(), storm::utility::zero<ValueType>());
26
27 // If we identify the states that have probability 0 of reaching the target states, we can exclude them in the further analysis.
28 storm::storage::BitVector maybeStates;
29 storm::storage::BitVector makeZeroColumns;
30
31 if (hint.isExplicitModelCheckerHint() && hint.template asExplicitModelCheckerHint<ValueType>().getComputeOnlyMaybeStates()) {
32 maybeStates = hint.template asExplicitModelCheckerHint<ValueType>().getMaybeStates();
33 } else {
34 maybeStates = storm::utility::graph::performProbGreater0(backwardTransitions, phiStates, psiStates, true, upperBound);
35 if (lowerBound == 0) {
36 maybeStates &= ~psiStates;
37 } else {
38 makeZeroColumns = psiStates;
39 }
40 }
41
42 STORM_LOG_INFO("Preprocessing: " << maybeStates.getNumberOfSetBits() << " non-target states with probability greater 0.");
43 if (lowerBound == 0) {
44 storm::utility::vector::setVectorValues<ValueType>(result, psiStates, storm::utility::one<ValueType>());
45 }
46
47 if (!maybeStates.empty()) {
48 // We can eliminate the rows and columns from the original transition probability matrix that have probability 0.
49 storm::storage::SparseMatrix<ValueType> submatrix = transitionMatrix.getSubmatrix(true, maybeStates, maybeStates, true, makeZeroColumns);
50
51 // Create the vector of one-step probabilities to go to target states.
52 std::vector<ValueType> b = transitionMatrix.getConstrainedRowSumVector(maybeStates, psiStates);
53
54 // Create the vector with which to multiply.
55 std::vector<ValueType> subresult(maybeStates.getNumberOfSetBits());
56
57 // Perform the matrix vector multiplication
58 auto multiplier = storm::solver::MultiplierFactory<ValueType>().create(env, submatrix);
59 if (lowerBound == 0) {
60 multiplier->repeatedMultiply(env, subresult, &b, upperBound);
61 } else {
62 multiplier->repeatedMultiply(env, subresult, &b, upperBound - lowerBound + 1);
63 submatrix = transitionMatrix.getSubmatrix(true, maybeStates, maybeStates, true);
64 multiplier = storm::solver::MultiplierFactory<ValueType>().create(env, submatrix);
65 b = std::vector<ValueType>(b.size(), storm::utility::zero<ValueType>());
66 multiplier->repeatedMultiply(env, subresult, &b, lowerBound - 1);
67 }
68
69 // Set the values of the resulting vector accordingly.
70 storm::utility::vector::setVectorValues(result, maybeStates, subresult);
71 }
72
73 return result;
74}
75
79} // 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:16
bool empty() const
Retrieves whether no bits are set to true in this bit vector.
uint64_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:24
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:315
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:78