Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
MemoryStateManager.cpp
Go to the documentation of this file.
2
4
6
7namespace storm {
8namespace modelchecker {
9namespace helper {
10namespace rewardbounded {
11
13 : dimensionCount(dimensionCount),
14 dimensionBitMask(1ull),
15 relevantBitsMask((1ull << dimensionCount) - 1),
16 stateCount(dimensionBitMask << dimensionCount),
17 dimensionsWithoutMemoryMask(0),
18 upperMemoryStateBound(stateCount) {
19 STORM_LOG_THROW(dimensionCount > 0, storm::exceptions::IllegalArgumentException, "Invoked MemoryStateManager with zero dimension count.");
20 STORM_LOG_THROW(dimensionCount <= 64, storm::exceptions::IllegalArgumentException, "Invoked MemoryStateManager with too many dimensions.");
21}
22
24 return dimensionCount;
25}
26
28 return stateCount;
29}
30
32 return upperMemoryStateBound;
33}
34
36 STORM_LOG_ASSERT(dimensionCount > 0, "Invoked MemoryStateManager with zero dimension count.");
37 STORM_LOG_ASSERT(dimension < dimensionCount, "Tried to set a dimension that is larger then the number of considered dimensions");
38 if (((dimensionBitMask << dimension) & dimensionsWithoutMemoryMask) == 0) {
39 stateCount = (stateCount >> 1);
40 }
41 dimensionsWithoutMemoryMask |= (dimensionBitMask << dimension);
42}
43
45 STORM_LOG_ASSERT(dimensionCount > 0, "Invoked MemoryStateManager with zero dimension count.");
46 return relevantBitsMask;
47}
48
49bool MemoryStateManager::isRelevantDimension(MemoryState const& state, uint64_t dimension) const {
50 STORM_LOG_ASSERT(dimensionCount > 0, "Invoked MemoryStateManager with zero dimension count.");
51 STORM_LOG_ASSERT((state & dimensionsWithoutMemoryMask) == dimensionsWithoutMemoryMask, "Invalid memory state found.");
52 return (state & (dimensionBitMask << dimension)) != 0;
53}
54
55void MemoryStateManager::setRelevantDimension(MemoryState& state, uint64_t dimension, bool value) const {
56 STORM_LOG_ASSERT(dimensionCount > 0, "Invoked MemoryStateManager with zero dimension count.");
57 STORM_LOG_ASSERT(dimension < dimensionCount, "Tried to set a dimension that is larger then the number of considered dimensions");
58 STORM_LOG_ASSERT(((dimensionBitMask << dimension) & dimensionsWithoutMemoryMask) == 0,
59 "Tried to change a memory state for a dimension but the dimension is assumed to have no memory.");
60 if (value) {
61 state |= (dimensionBitMask << dimension);
62 } else {
63 state &= ~(dimensionBitMask << dimension);
64 }
65}
66
67void MemoryStateManager::setRelevantDimensions(MemoryState& state, storm::storage::BitVector const& dimensions, bool value) const {
68 STORM_LOG_ASSERT(dimensionCount > 0, "Invoked MemoryStateManager with zero dimension count.");
69 STORM_LOG_ASSERT(dimensions.size() == dimensionCount, "Invalid size of given bitset.");
70 if (value) {
71 for (auto d : dimensions) {
72 STORM_LOG_ASSERT(((dimensionBitMask << d) & dimensionsWithoutMemoryMask) == 0,
73 "Tried to set a dimension to 'relevant'-memory state but the dimension is assumed to have no memory.");
74 state |= (dimensionBitMask << d);
75 }
76 } else {
77 for (auto d : dimensions) {
78 STORM_LOG_ASSERT(((dimensionBitMask << d) & dimensionsWithoutMemoryMask) == 0,
79 "Tried to set a dimension to 'unrelevant'-memory state but the dimension is assumed to have no memory.");
80 state &= ~(dimensionBitMask << d);
81 }
82 }
83}
84
85std::string MemoryStateManager::toString(MemoryState const& state) const {
86 STORM_LOG_ASSERT(dimensionCount > 0, "Invoked EpochManager with zero dimension count.");
87 std::string res = "[";
88 res += (isRelevantDimension(state, 0) ? "1" : "0");
89 for (uint64_t d = 1; d < dimensionCount; ++d) {
90 res += ", ";
91 res += (isRelevantDimension(state, d) ? "1" : "0");
92 }
93 res += "]";
94 return res;
95}
96} // namespace rewardbounded
97} // namespace helper
98} // namespace modelchecker
99} // namespace storm
bool isRelevantDimension(MemoryState const &state, uint64_t dimension) const
void setRelevantDimension(MemoryState &state, uint64_t dimension, bool value=true) const
void setRelevantDimensions(MemoryState &state, storm::storage::BitVector const &dimensions, bool value=true) const
A bit vector that is internally represented as a vector of 64-bit values.
Definition BitVector.h:18
size_t size() const
Retrieves the number of bits this bit vector can store.
#define STORM_LOG_ASSERT(cond, message)
Definition macros.h:11
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:30
LabParser.cpp.
Definition cli.cpp:18