Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
SparseModelMemoryProduct.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4#include <string>
5#include <unordered_map>
6
12
13namespace storm {
14namespace storage {
24template<typename ValueType, typename RewardModelType = storm::models::sparse::StandardRewardModel<ValueType>>
26 public:
27 // Constructs the product w.r.t. the given model and the given memory structure
29 storm::storage::MemoryStructure const& memoryStructure);
30
31 // Constructs the product w.r.t. the given model and the given (finite memory) scheduler.
34
35 // Enforces that the given model and memory state as well as the successor(s) are considered reachable -- even if they are not reachable from an initial
36 // state.
37 void addReachableState(uint64_t const& modelState, uint64_t const& memoryState);
38
39 // Enforces that every state is considered reachable. If this is set, the result has size #modelStates * #memoryStates
41
42 // Returns true iff the given model and memory state is reachable in the product
43 bool isStateReachable(uint64_t const& modelState, uint64_t const& memoryState);
44
45 // Retrieves the state of the resulting model that represents the given memory and model state.
46 // This method should only be called if the given state is reachable.
47 uint64_t const& getResultState(uint64_t const& modelState, uint64_t const& memoryState);
48
49 // Invokes the building of the product under the specified scheduler (if given).
50 std::shared_ptr<storm::models::sparse::Model<ValueType, RewardModelType>> build();
51
54
55 private:
56 // Initializes auxiliary data for building the product
57 void initialize();
58
59 // Computes for each pair of memory state and model transition index the successor memory state
60 // The resulting vector maps (modelTransition * memoryStateCount) + memoryState to the corresponding successor state of the memory structure
61 void computeMemorySuccessors();
62
63 // Computes the reachable states of the resulting model
64 void computeReachableStates(storm::storage::BitVector const& initialStates);
65
66 // Methods that build the model components
67 // Matrix for deterministic models
68 storm::storage::SparseMatrix<ValueType> buildDeterministicTransitionMatrix();
69 // Matrix for nondeterministic models
70 storm::storage::SparseMatrix<ValueType> buildNondeterministicTransitionMatrix();
71 // Matrix for models that consider a scheduler
72 storm::storage::SparseMatrix<ValueType> buildTransitionMatrixForScheduler();
73 // State labeling.
74 storm::models::sparse::StateLabeling buildStateLabeling(storm::storage::SparseMatrix<ValueType> const& resultTransitionMatrix);
75 // Reward models
76 std::unordered_map<std::string, RewardModelType> buildRewardModels(storm::storage::SparseMatrix<ValueType> const& resultTransitionMatrix);
77
78 // Builds the resulting model
79 std::shared_ptr<storm::models::sparse::Model<ValueType, RewardModelType>> buildResult(storm::storage::SparseMatrix<ValueType>&& matrix,
81 std::unordered_map<std::string, RewardModelType>&& rewardModels);
82
83 // Stores whether this builder has already been initialized.
84 bool isInitialized;
85
86 // stores the successor memory states for each transition in the product
87 std::vector<uint64_t> memorySuccessors;
88
89 // Maps (modelState * memoryStateCount) + memoryState to the state in the result that represents (memoryState,modelState)
90 std::vector<uint64_t> toResultStateMapping;
91
92 // Indicates which states are considered reachable. (s, m) is reachable if this BitVector is true at (s * memoryStateCount) + m
93 storm::storage::BitVector reachableStates;
94
95 uint64_t const memoryStateCount;
96
98 boost::optional<storm::storage::MemoryStructure> localMemory;
100 boost::optional<storm::storage::Scheduler<ValueType> const&> scheduler;
101};
102} // namespace storage
103} // namespace storm
Base class for all sparse models.
Definition Model.h:33
This class manages the labeling of the state space with a number of (atomic) labels.
A bit vector that is internally represented as a vector of 64-bit values.
Definition BitVector.h:18
This class represents a (deterministic) memory structure that can be used to encode certain events (s...
This class defines which action is chosen in a particular state of a non-deterministic model.
Definition Scheduler.h:18
A class that holds a possibly non-square matrix in the compressed row storage format.
This class builds the product of the given sparse model and the given memory structure.
storm::storage::MemoryStructure const & getMemory() const
std::shared_ptr< storm::models::sparse::Model< ValueType, RewardModelType > > build()
void addReachableState(uint64_t const &modelState, uint64_t const &memoryState)
storm::models::sparse::Model< ValueType, RewardModelType > const & getOriginalModel() const
bool isStateReachable(uint64_t const &modelState, uint64_t const &memoryState)
uint64_t const & getResultState(uint64_t const &modelState, uint64_t const &memoryState)
LabParser.cpp.
Definition cli.cpp:18