Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
SparseNondeterministicStepBoundedHorizonHelper.cpp
Go to the documentation of this file.
4
6
10
15
16namespace storm {
17namespace modelchecker {
18namespace helper {
19
20template<typename ValueType>
22 /*storm::storage::SparseMatrix<ValueType> const& transitionMatrix, storm::storage::SparseMatrix<ValueType> const& backwardTransitions*/)
23// transitionMatrix(transitionMatrix), backwardTransitions(backwardTransitions)
24{
25 // Intentionally left empty.
26}
27
28template<typename ValueType>
30 storm::storage::SparseMatrix<ValueType> const& transitionMatrix,
31 storm::storage::SparseMatrix<ValueType> const& backwardTransitions,
32 storm::storage::BitVector const& phiStates,
33 storm::storage::BitVector const& psiStates, uint64_t lowerBound,
34 uint64_t upperBound, ModelCheckerHint const& hint) {
35 std::vector<ValueType> result(transitionMatrix.getRowGroupCount(), storm::utility::zero<ValueType>());
36 storm::storage::BitVector makeZeroColumns;
37
38 // Determine the states that have 0 probability of reaching the target states.
39 storm::storage::BitVector maybeStates;
40 if (hint.isExplicitModelCheckerHint() && hint.template asExplicitModelCheckerHint<ValueType>().getComputeOnlyMaybeStates()) {
41 maybeStates = hint.template asExplicitModelCheckerHint<ValueType>().getMaybeStates();
42 } else {
43 if (goal.minimize()) {
44 maybeStates = storm::utility::graph::performProbGreater0A(transitionMatrix, transitionMatrix.getRowGroupIndices(), backwardTransitions, phiStates,
45 psiStates, true, upperBound);
46 } else {
47 maybeStates = storm::utility::graph::performProbGreater0E(backwardTransitions, phiStates, psiStates, true, upperBound);
48 }
49 if (lowerBound == 0) {
50 maybeStates &= ~psiStates;
51 } else {
52 makeZeroColumns = psiStates;
53 }
54 }
55
56 STORM_LOG_INFO("Preprocessing: " << maybeStates.getNumberOfSetBits() << " non-target states with probability greater 0.");
57
58 if (!maybeStates.empty()) {
59 // We can eliminate the rows and columns from the original transition probability matrix that have probability 0.
60 storm::storage::SparseMatrix<ValueType> submatrix = transitionMatrix.getSubmatrix(true, maybeStates, maybeStates, false, makeZeroColumns);
61 std::vector<ValueType> b = transitionMatrix.getConstrainedRowGroupSumVector(maybeStates, psiStates);
62
63 // Create the vector with which to multiply.
64 std::vector<ValueType> subresult(maybeStates.getNumberOfSetBits());
65
66 auto multiplier = storm::solver::MultiplierFactory<ValueType>().create(env, submatrix);
67 if (lowerBound == 0) {
68 multiplier->repeatedMultiplyAndReduce(env, goal.direction(), subresult, &b, upperBound);
69 } else {
70 multiplier->repeatedMultiplyAndReduce(env, goal.direction(), subresult, &b, upperBound - lowerBound + 1);
71 storm::storage::SparseMatrix<ValueType> submatrix = transitionMatrix.getSubmatrix(true, maybeStates, maybeStates, false);
72 auto multiplier = storm::solver::MultiplierFactory<ValueType>().create(env, submatrix);
73 b = std::vector<ValueType>(b.size(), storm::utility::zero<ValueType>());
74 multiplier->repeatedMultiplyAndReduce(env, goal.direction(), subresult, &b, lowerBound - 1);
75 }
76 // Set the values of the resulting vector accordingly.
77 storm::utility::vector::setVectorValues(result, maybeStates, subresult);
78 }
79 if (lowerBound == 0) {
80 storm::utility::vector::setVectorValues(result, psiStates, storm::utility::one<ValueType>());
81 }
82 return result;
83}
84
87} // namespace helper
88} // namespace modelchecker
89} // namespace storm
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 ...
index_type getRowGroupCount() const
Returns the number of row groups in the matrix.
std::vector< index_type > const & getRowGroupIndices() const
Returns the grouping of rows of this matrix.
std::vector< value_type > getConstrainedRowGroupSumVector(storm::storage::BitVector const &rowGroupConstraint, storm::storage::BitVector const &columnConstraint) const
Computes a vector whose entries represent the sums of selected columns for all rows in selected row g...
#define STORM_LOG_INFO(message)
Definition logging.h:29
storm::storage::BitVector performProbGreater0A(storm::storage::SparseMatrix< T > const &transitionMatrix, std::vector< uint_fast64_t > const &nondeterministicChoiceIndices, storm::storage::SparseMatrix< T > const &backwardTransitions, storm::storage::BitVector const &phiStates, storm::storage::BitVector const &psiStates, bool useStepBound, uint_fast64_t maximalSteps, boost::optional< storm::storage::BitVector > const &choiceConstraint)
Computes the sets of states that have probability greater 0 of satisfying phi until psi under any pos...
Definition graph.cpp:857
storm::storage::BitVector performProbGreater0E(storm::storage::SparseMatrix< T > const &backwardTransitions, storm::storage::BitVector const &phiStates, storm::storage::BitVector const &psiStates, bool useStepBound, uint_fast64_t maximalSteps)
Computes the sets of states that have probability greater 0 of satisfying phi until psi under at leas...
Definition graph.cpp:689
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
LabParser.cpp.
Definition cli.cpp:18