From 19070a27a9b544a73b720d2110ae4268e28f3858 Mon Sep 17 00:00:00 2001 From: TimQu Date: Tue, 6 Mar 2018 18:14:21 +0100 Subject: [PATCH] added 'fixed ring' pattern --- .../settings/modules/POMDPSettings.cpp | 6 ++++-- src/storm-pomdp/storage/PomdpMemory.cpp | 20 +++++++++++++++---- src/storm-pomdp/storage/PomdpMemory.h | 8 ++++++-- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/storm-pomdp-cli/settings/modules/POMDPSettings.cpp b/src/storm-pomdp-cli/settings/modules/POMDPSettings.cpp index 8a04f152d..2eb418dab 100644 --- a/src/storm-pomdp-cli/settings/modules/POMDPSettings.cpp +++ b/src/storm-pomdp-cli/settings/modules/POMDPSettings.cpp @@ -20,7 +20,7 @@ namespace storm { const std::string selfloopReductionOption = "selfloopreduction"; const std::string memoryBoundOption = "memorybound"; const std::string memoryPatternOption = "memorypattern"; - std::vector memoryPatterns = {"trivial", "fixedcounter", "selectivecounter", "ring", "settablebits", "full"}; + std::vector memoryPatterns = {"trivial", "fixedcounter", "selectivecounter", "ring", "fixedring", "settablebits", "full"}; const std::string fscmode = "fscmode"; std::vector fscModes = {"standard", "simple-linear", "simple-linear-inverse"}; const std::string transformBinaryOption = "transformbinary"; @@ -76,7 +76,9 @@ namespace storm { } else if (pattern == "selectivecounter") { return storm::storage::PomdpMemoryPattern::SelectiveCounter; } else if (pattern == "ring") { - return storm::storage::PomdpMemoryPattern::Ring; + return storm::storage::PomdpMemoryPattern::SelectiveRing; + } else if (pattern == "fixedring") { + return storm::storage::PomdpMemoryPattern::FixedRing; } else if (pattern == "settablebits") { return storm::storage::PomdpMemoryPattern::SettableBits; } else if (pattern == "full") { diff --git a/src/storm-pomdp/storage/PomdpMemory.cpp b/src/storm-pomdp/storage/PomdpMemory.cpp index bd9c2593b..1c5f74cf4 100644 --- a/src/storm-pomdp/storage/PomdpMemory.cpp +++ b/src/storm-pomdp/storage/PomdpMemory.cpp @@ -80,7 +80,9 @@ namespace storm { return "fixedcounter"; case PomdpMemoryPattern::SelectiveCounter: return "selectivecounter"; - case PomdpMemoryPattern::Ring: + case PomdpMemoryPattern::FixedRing: + return "fixedring"; + case PomdpMemoryPattern::SelectiveRing: return "ring"; case PomdpMemoryPattern::SettableBits: return "settablebits"; @@ -99,8 +101,10 @@ namespace storm { return buildFixedCountingMemory(numStates); case PomdpMemoryPattern::SelectiveCounter: return buildSelectiveCountingMemory(numStates); - case PomdpMemoryPattern::Ring: - return buildRingMemory(numStates); + case PomdpMemoryPattern::FixedRing: + return buildFixedRingMemory(numStates); + case PomdpMemoryPattern::SelectiveRing: + return buildSelectiveRingMemory(numStates); case PomdpMemoryPattern::SettableBits: return buildSettableBitsMemory(numStates); case PomdpMemoryPattern::Full: @@ -129,7 +133,15 @@ namespace storm { return PomdpMemory(transitions, 0); } - PomdpMemory PomdpMemoryBuilder::buildRingMemory(uint64_t numStates) const { + PomdpMemory PomdpMemoryBuilder::buildFixedRingMemory(uint64_t numStates) const { + std::vector transitions(numStates, storm::storage::BitVector(numStates, false)); + for (uint64_t state = 0; state < numStates; ++state) { + transitions[state].set((state + 1) % numStates); + } + return PomdpMemory(transitions, 0); + } + + PomdpMemory PomdpMemoryBuilder::buildSelectiveRingMemory(uint64_t numStates) const { std::vector transitions(numStates, storm::storage::BitVector(numStates, false)); for (uint64_t state = 0; state < numStates; ++state) { transitions[state].set(state); diff --git a/src/storm-pomdp/storage/PomdpMemory.h b/src/storm-pomdp/storage/PomdpMemory.h index 50ff309fa..812661427 100644 --- a/src/storm-pomdp/storage/PomdpMemory.h +++ b/src/storm-pomdp/storage/PomdpMemory.h @@ -23,7 +23,7 @@ namespace storm { }; enum class PomdpMemoryPattern { - Trivial, FixedCounter, SelectiveCounter, Ring, SettableBits, Full + Trivial, FixedCounter, SelectiveCounter, FixedRing, SelectiveRing, SettableBits, Full }; std::string toString(PomdpMemoryPattern const& pattern); @@ -44,9 +44,13 @@ namespace storm { // Every state has a selfloop and a transition to the next state. The last state just has a selfloop. PomdpMemory buildSelectiveCountingMemory(uint64_t numStates) const; + // Builds a memory structure that consists of a ring of the given number of states. + // Every state has a transition to the successor state + PomdpMemory buildFixedRingMemory(uint64_t numStates) const; + // Builds a memory structure that consists of a ring of the given number of states. // Every state has a transition to the successor state and a selfloop - PomdpMemory buildRingMemory(uint64_t numStates) const; + PomdpMemory buildSelectiveRingMemory(uint64_t numStates) const; // Builds a memory structure that represents floor(log(numStates)) bits that can only be set from zero to one or from zero to zero. PomdpMemory buildSettableBitsMemory(uint64_t numStates) const;