diff --git a/src/builder/ExplicitDFTModelBuilder.cpp b/src/builder/ExplicitDFTModelBuilder.cpp index 1840ba40a..a1973d519 100644 --- a/src/builder/ExplicitDFTModelBuilder.cpp +++ b/src/builder/ExplicitDFTModelBuilder.cpp @@ -15,42 +15,10 @@ namespace storm { } template - ExplicitDFTModelBuilder::ExplicitDFTModelBuilder(storm::storage::DFT const& dft) : mDft(dft), mStates(((mDft.stateVectorSize() / 64) + 1) * 64, INITIAL_BUCKETSIZE) { + ExplicitDFTModelBuilder::ExplicitDFTModelBuilder(storm::storage::DFT const& dft, storm::storage::DFTIndependentSymmetries const& symmetries) : mDft(dft), mStates(((mDft.stateVectorSize() / 64) + 1) * 64, INITIAL_BUCKETSIZE) { // stateVectorSize is bound for size of bitvector - // Find symmetries - // TODO activate - // Currently using hack to test - std::vector> symmetriesTmp; - std::vector vecB; - std::vector vecC; - std::vector vecD; - if (false) { - for (size_t i = 0; i < mDft.nrElements(); ++i) { - std::string name = mDft.getElement(i)->name(); - size_t id = mDft.getElement(i)->id(); - if (boost::starts_with(name, "B")) { - vecB.push_back(id); - } else if (boost::starts_with(name, "C")) { - vecC.push_back(id); - } else if (boost::starts_with(name, "D")) { - vecD.push_back(id); - } - } - symmetriesTmp.push_back(vecB); - symmetriesTmp.push_back(vecC); - symmetriesTmp.push_back(vecD); - std::cout << "Found the following symmetries:" << std::endl; - for (auto const& symmetry : symmetriesTmp) { - for (auto const& elem : symmetry) { - std::cout << elem << " -> "; - } - std::cout << std::endl; - } - } else { - vecB.push_back(mDft.getTopLevelIndex()); - } - mStateGenerationInfo = std::make_shared(mDft.buildStateGenerationInfo(vecB, symmetriesTmp)); + mStateGenerationInfo = std::make_shared(mDft.buildStateGenerationInfo(symmetries)); } diff --git a/src/builder/ExplicitDFTModelBuilder.h b/src/builder/ExplicitDFTModelBuilder.h index 42ca2755d..6d17375b2 100644 --- a/src/builder/ExplicitDFTModelBuilder.h +++ b/src/builder/ExplicitDFTModelBuilder.h @@ -1,13 +1,13 @@ #ifndef EXPLICITDFTMODELBUILDER_H #define EXPLICITDFTMODELBUILDER_H -#include "../storage/dft/DFT.h" - #include #include #include #include #include +#include +#include #include #include #include @@ -65,7 +65,7 @@ namespace storm { std::set beLabels = {}; }; - ExplicitDFTModelBuilder(storm::storage::DFT const& dft); + ExplicitDFTModelBuilder(storm::storage::DFT const& dft, storm::storage::DFTIndependentSymmetries const& symmetries); std::shared_ptr> buildModel(LabelOptions const& labelOpts); diff --git a/src/storage/dft/DFT.cpp b/src/storage/dft/DFT.cpp index 3fbcd5ee1..c88fbee1c 100644 --- a/src/storage/dft/DFT.cpp +++ b/src/storage/dft/DFT.cpp @@ -68,7 +68,7 @@ namespace storm { } template - DFTStateGenerationInfo DFT::buildStateGenerationInfo(std::vector const& subTreeRoots, std::vector> const& symmetries) const { + DFTStateGenerationInfo DFT::buildStateGenerationInfo(storm::storage::DFTIndependentSymmetries const& symmetries) const { // Use symmetry // Collect all elements in the first subtree // TODO make recursive to use for nested subtrees @@ -79,7 +79,13 @@ namespace storm { size_t stateIndex = 0; std::queue visitQueue; std::set visited; - visitQueue.push(subTreeRoots[0]); + size_t firstRoot; + if (symmetries.groups.empty()) { + firstRoot = mTopLevelIndex; + } else { + firstRoot = symmetries.groups.begin()->first; + } + visitQueue.push(firstRoot); stateIndex = performStateGenerationInfoDFS(generationInfo, visitQueue, visited, stateIndex); // Consider dependencies diff --git a/src/storage/dft/DFT.h b/src/storage/dft/DFT.h index 1f3e8cceb..d8d6aa9bc 100644 --- a/src/storage/dft/DFT.h +++ b/src/storage/dft/DFT.h @@ -126,7 +126,7 @@ namespace storm { public: DFT(DFTElementVector const& elements, DFTElementPointer const& tle); - DFTStateGenerationInfo buildStateGenerationInfo(std::vector const& subTreeRoots, std::vector> const& symmetries) const; + DFTStateGenerationInfo buildStateGenerationInfo(storm::storage::DFTIndependentSymmetries const& symmetries) const; size_t performStateGenerationInfoDFS(DFTStateGenerationInfo& generationInfo, std::queue& visitQueue, std::set& visited, size_t stateIndex) const; diff --git a/src/storm-dyftee.cpp b/src/storm-dyftee.cpp index aa2e0879f..ba50d90f3 100644 --- a/src/storm-dyftee.cpp +++ b/src/storm-dyftee.cpp @@ -28,17 +28,19 @@ void analyzeDFT(std::string filename, std::string property, bool symred = false) std::vector> parsedFormulas = storm::parseFormulasForExplicit(property); std::vector> formulas(parsedFormulas.begin(), parsedFormulas.end()); assert(formulas.size() == 1); - std::cout << "parsed formula." << std::endl; + std::cout << "Parsed formula." << std::endl; + std::map>> emptySymmetry; + storm::storage::DFTIndependentSymmetries symmetries(emptySymmetry); if(symred) { std::cout << dft.getElementsString() << std::endl; auto colouring = dft.colourDFT(); - storm::storage::DFTIndependentSymmetries symmetries = dft.findSymmetries(colouring); - std::cout << symmetries; + symmetries = dft.findSymmetries(colouring); + std::cout << "Symmetries: " << symmetries << std::endl; } // Building Markov Automaton std::cout << "Building Model..." << std::endl; - storm::builder::ExplicitDFTModelBuilder builder(dft); + storm::builder::ExplicitDFTModelBuilder builder(dft, symmetries); typename storm::builder::ExplicitDFTModelBuilder::LabelOptions labeloptions; // TODO initialize this with the formula std::shared_ptr> model = builder.buildModel(labeloptions); std::cout << "Built Model" << std::endl; @@ -52,7 +54,6 @@ void analyzeDFT(std::string filename, std::string property, bool symred = false) model = storm::performDeterministicSparseBisimulationMinimization>(model->template as>(), formulas, storm::storage::BisimulationType::Weak)->template as>(); } - model->printModelInformationToStream(std::cout); // Model checking