diff --git a/src/storage/dft/DFT.cpp b/src/storage/dft/DFT.cpp index 2aa557d8c..9a12fe2f6 100644 --- a/src/storage/dft/DFT.cpp +++ b/src/storage/dft/DFT.cpp @@ -77,12 +77,22 @@ namespace storm { // TODO make recursive to use for nested subtrees DFTStateGenerationInfo generationInfo(nrElements(), mMaxSpareChildCount); + + // Generate Pre and Post info for restrictions + for(auto const& elem : mElements) { + if(!elem->isDependency() && !elem->isRestriction()) { + generationInfo.setRestrictionPreElements(elem->id(), elem->seqRestrictionPres()); + generationInfo.setRestrictionPostElements(elem->id(), elem->seqRestrictionPosts()); + } + } + // Perform DFS and insert all elements of subtree sequentially size_t stateIndex = 0; std::queue visitQueue; storm::storage::BitVector visited(nrElements(), false); + // TODO make subfunction for this? if (symmetries.groups.empty()) { // Perform DFS for whole tree visitQueue.push(mTopLevelIndex); diff --git a/src/storage/dft/DFTStateGenerationInfo.h b/src/storage/dft/DFTStateGenerationInfo.h index f82d4e8af..a89add9bf 100644 --- a/src/storage/dft/DFTStateGenerationInfo.h +++ b/src/storage/dft/DFTStateGenerationInfo.h @@ -8,12 +8,16 @@ namespace storm { std::map mSpareUsageIndex; // id spare -> index first bit in state std::map mSpareActivationIndex; // id spare representative -> index in state std::vector mIdToStateIndex; // id -> index first bit in state - std::map mRestrictedItems; + std::map> mSeqRestrictionPreElements; // id -> list of restriction pre elements; + std::map> mSeqRestrictionPostElements; // id -> list of restriction post elements; std::vector>> mSymmetries; // pair (lenght of symmetry group, vector indicating the starting points of the symmetry groups) public: - DFTStateGenerationInfo(size_t nrElements, size_t maxSpareChildCount) : mUsageInfoBits(storm::utility::math::uint64_log2(maxSpareChildCount) + 1), mIdToStateIndex(nrElements) { + DFTStateGenerationInfo(size_t nrElements, size_t maxSpareChildCount) : + mUsageInfoBits(storm::utility::math::uint64_log2(maxSpareChildCount) + 1), + mIdToStateIndex(nrElements) + { assert(maxSpareChildCount < pow(2, mUsageInfoBits)); } @@ -26,6 +30,14 @@ namespace storm { mIdToStateIndex[id] = index; } + void setRestrictionPreElements(size_t id, std::vector const& elems) { + mSeqRestrictionPreElements[id] = elems; + } + + void setRestrictionPostElements(size_t id, std::vector const& elems) { + mSeqRestrictionPostElements[id] = elems; + } + void addSpareActivationIndex(size_t id, size_t index) { mSpareActivationIndex[id] = index; } diff --git a/src/storage/dft/elements/DFTElement.h b/src/storage/dft/elements/DFTElement.h index 11223f3fa..2d57567e9 100644 --- a/src/storage/dft/elements/DFTElement.h +++ b/src/storage/dft/elements/DFTElement.h @@ -205,39 +205,55 @@ namespace storm { return mOutgoingDependencies.size(); } - /*std::set> restrictedItems() const { - std::set> result; - for(auto const& restr : mRestrictions) { - bool foundThis = false; - for(auto const& child : restr->children()) { - if(!foundThis) { - if(child->id() == mId) { - foundThis = true; - } - } else if(result.count(child) == 0) { - result.insert(child); + /** + * Obtains ids of elements which are the direct successor in the list of children of a restriction + * @return A vector of ids + */ + std::vector seqRestrictionPosts() const { + std::vector res; + for (auto const& restr : mRestrictions) { + if(!restr->isSeqEnforcer()) { + continue; + } + auto it = restr->children().cbegin(); + for(; it != restr->children().cend(); ++it) { + if((*it)->id() == mId) { + break; } } + assert(it != restr->children().cend()); + ++it; + if(it != restr->children().cend()) { + res.push_back((*it)->id()); + } } + return res; } - std::set> restrictedItemsTC() const { - std::set> result; - for(auto const& restr : mRestrictions) { - bool foundThis = false; - for(auto const& child : restr->children()) { - if(!foundThis) { - if(child->id() == mId) { - foundThis = true; - } - } else if(result.count(child) == 0) { - result.insert(child); - std::set> tmpRes = child->restrictedItemsTC(); - result.insert(tmpRes.begin(), tmpRes.end()); + /** + * Obtains ids of elements which are the direct predecessor in the list of children of a restriction + * @return A vector of ids + */ + std::vector seqRestrictionPres() const { + std::vector res; + for (auto const& restr : mRestrictions) { + if(!restr->isSeqEnforcer()) { + continue; + } + auto it = restr->children().cbegin(); + for(++it; it != restr->children().cend(); ++it) { + if((*it)->id() == mId) { + break; } } + assert(it != restr->children().cend()); + if(it != restr->children().cbegin()) { + --it; + res.push_back((*it)->id()); + } } - }*/ + return res; + } DFTDependencyVector const& outgoingDependencies() const { return mOutgoingDependencies; diff --git a/src/storage/dft/elements/DFTRestriction.h b/src/storage/dft/elements/DFTRestriction.h index 78036528e..dc2e6116e 100644 --- a/src/storage/dft/elements/DFTRestriction.h +++ b/src/storage/dft/elements/DFTRestriction.h @@ -32,6 +32,10 @@ namespace storm { virtual bool isRestriction() const override { return true; } + + virtual bool isSeqEnforcer() const { + return false; + } virtual std::string typestring() const = 0; @@ -162,6 +166,12 @@ namespace storm { DFTRestriction(id, name, children) {} + virtual bool isSeqEnforcer() const override { + return true; + } + + + void checkFails(storm::storage::DFTState& state, DFTStateSpaceGenerationQueues& queues) const override { assert(queues.failurePropagationDone()); bool childOperationalBefore = false;