Storm 2.0.0.3
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
BackwardTransitionCache.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4#include <optional>
5
6namespace storm::storage {
7
8template<typename ValueType>
9class SparseMatrix;
10
21template<typename ValueType>
23 public:
28 explicit BackwardTransitionCache(SparseMatrix<ValueType> const& forwardTransitionMatrix, bool keepZeros = false);
29
35 explicit BackwardTransitionCache(SparseMatrix<ValueType> const& forwardTransitionMatrix, SparseMatrix<ValueType>&& backwardTransitionMatrix,
36 bool keepZeros = false);
37
41 // The cache references the forward transition matrix and is thus not assignable.
44
48 SparseMatrix<ValueType> const& get() const;
49
53 void clearCache() const;
54
58 bool isCached() const;
59
60 private:
61 SparseMatrix<ValueType> const& forwardTransitionMatrixRef;
62 bool const keepZeros;
63 // The backward transitions are shared between all copies of this cache. For this reason, we use a shared pointer to an optional (and not just a shared
64 // pointer that is the nullptr as long as the transitions are not computed): Resetting a shared pointer would only affect this copy of the cache,
65 // whereas resetting the optional also clears the cache of all other copies.
66 mutable std::shared_ptr<std::optional<SparseMatrix<ValueType>>> backwardTransitions;
67};
68} // namespace storm::storage
BackwardTransitionCache(SparseMatrix< ValueType > const &forwardTransitionMatrix, bool keepZeros=false)
BackwardTransitionCache(BackwardTransitionCache const &)=default
bool isCached() const
Retrieves whether the backward transitions are currently cached.
BackwardTransitionCache(BackwardTransitionCache &&)=default
BackwardTransitionCache & operator=(BackwardTransitionCache &&)=delete
void clearCache() const
Clears the cache (for this and all copies of this cache).
BackwardTransitionCache & operator=(BackwardTransitionCache const &)=delete
SparseMatrix< ValueType > const & get() const
Retrieves the backward transitions.
A class that holds a possibly non-square matrix in the compressed row storage format.