Browse Source

Symmetries are given to StateGenerationInfo

Former-commit-id: b91cce3a81
tempestpy_adaptions
Mavo 9 years ago
parent
commit
a44d38e0bf
  1. 36
      src/builder/ExplicitDFTModelBuilder.cpp
  2. 6
      src/builder/ExplicitDFTModelBuilder.h
  3. 10
      src/storage/dft/DFT.cpp
  4. 2
      src/storage/dft/DFT.h
  5. 11
      src/storm-dyftee.cpp

36
src/builder/ExplicitDFTModelBuilder.cpp

@ -15,42 +15,10 @@ namespace storm {
} }
template <typename ValueType> template <typename ValueType>
ExplicitDFTModelBuilder<ValueType>::ExplicitDFTModelBuilder(storm::storage::DFT<ValueType> const& dft) : mDft(dft), mStates(((mDft.stateVectorSize() / 64) + 1) * 64, INITIAL_BUCKETSIZE) {
ExplicitDFTModelBuilder<ValueType>::ExplicitDFTModelBuilder(storm::storage::DFT<ValueType> const& dft, storm::storage::DFTIndependentSymmetries const& symmetries) : mDft(dft), mStates(((mDft.stateVectorSize() / 64) + 1) * 64, INITIAL_BUCKETSIZE) {
// stateVectorSize is bound for size of bitvector // stateVectorSize is bound for size of bitvector
// Find symmetries
// TODO activate
// Currently using hack to test
std::vector<std::vector<size_t>> symmetriesTmp;
std::vector<size_t> vecB;
std::vector<size_t> vecC;
std::vector<size_t> 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<storm::storage::DFTStateGenerationInfo>(mDft.buildStateGenerationInfo(vecB, symmetriesTmp));
mStateGenerationInfo = std::make_shared<storm::storage::DFTStateGenerationInfo>(mDft.buildStateGenerationInfo(symmetries));
} }

6
src/builder/ExplicitDFTModelBuilder.h

@ -1,13 +1,13 @@
#ifndef EXPLICITDFTMODELBUILDER_H #ifndef EXPLICITDFTMODELBUILDER_H
#define EXPLICITDFTMODELBUILDER_H #define EXPLICITDFTMODELBUILDER_H
#include "../storage/dft/DFT.h"
#include <src/models/sparse/StateLabeling.h> #include <src/models/sparse/StateLabeling.h>
#include <src/models/sparse/StandardRewardModel.h> #include <src/models/sparse/StandardRewardModel.h>
#include <src/models/sparse/Model.h> #include <src/models/sparse/Model.h>
#include <src/storage/SparseMatrix.h> #include <src/storage/SparseMatrix.h>
#include <src/storage/BitVectorHashMap.h> #include <src/storage/BitVectorHashMap.h>
#include <src/storage/dft/DFT.h>
#include <src/storage/dft/SymmetricUnits.h>
#include <boost/container/flat_set.hpp> #include <boost/container/flat_set.hpp>
#include <boost/optional/optional.hpp> #include <boost/optional/optional.hpp>
#include <stack> #include <stack>
@ -65,7 +65,7 @@ namespace storm {
std::set<std::string> beLabels = {}; std::set<std::string> beLabels = {};
}; };
ExplicitDFTModelBuilder(storm::storage::DFT<ValueType> const& dft);
ExplicitDFTModelBuilder(storm::storage::DFT<ValueType> const& dft, storm::storage::DFTIndependentSymmetries const& symmetries);
std::shared_ptr<storm::models::sparse::Model<ValueType>> buildModel(LabelOptions const& labelOpts); std::shared_ptr<storm::models::sparse::Model<ValueType>> buildModel(LabelOptions const& labelOpts);

10
src/storage/dft/DFT.cpp

@ -68,7 +68,7 @@ namespace storm {
} }
template<typename ValueType> template<typename ValueType>
DFTStateGenerationInfo DFT<ValueType>::buildStateGenerationInfo(std::vector<size_t> const& subTreeRoots, std::vector<std::vector<size_t>> const& symmetries) const {
DFTStateGenerationInfo DFT<ValueType>::buildStateGenerationInfo(storm::storage::DFTIndependentSymmetries const& symmetries) const {
// Use symmetry // Use symmetry
// Collect all elements in the first subtree // Collect all elements in the first subtree
// TODO make recursive to use for nested subtrees // TODO make recursive to use for nested subtrees
@ -79,7 +79,13 @@ namespace storm {
size_t stateIndex = 0; size_t stateIndex = 0;
std::queue<size_t> visitQueue; std::queue<size_t> visitQueue;
std::set<size_t> visited; std::set<size_t> 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); stateIndex = performStateGenerationInfoDFS(generationInfo, visitQueue, visited, stateIndex);
// Consider dependencies // Consider dependencies

2
src/storage/dft/DFT.h

@ -126,7 +126,7 @@ namespace storm {
public: public:
DFT(DFTElementVector const& elements, DFTElementPointer const& tle); DFT(DFTElementVector const& elements, DFTElementPointer const& tle);
DFTStateGenerationInfo buildStateGenerationInfo(std::vector<size_t> const& subTreeRoots, std::vector<std::vector<size_t>> const& symmetries) const;
DFTStateGenerationInfo buildStateGenerationInfo(storm::storage::DFTIndependentSymmetries const& symmetries) const;
size_t performStateGenerationInfoDFS(DFTStateGenerationInfo& generationInfo, std::queue<size_t>& visitQueue, std::set<size_t>& visited, size_t stateIndex) const; size_t performStateGenerationInfoDFS(DFTStateGenerationInfo& generationInfo, std::queue<size_t>& visitQueue, std::set<size_t>& visited, size_t stateIndex) const;

11
src/storm-dyftee.cpp

@ -28,17 +28,19 @@ void analyzeDFT(std::string filename, std::string property, bool symred = false)
std::vector<std::shared_ptr<storm::logic::Formula>> parsedFormulas = storm::parseFormulasForExplicit(property); std::vector<std::shared_ptr<storm::logic::Formula>> parsedFormulas = storm::parseFormulasForExplicit(property);
std::vector<std::shared_ptr<const storm::logic::Formula>> formulas(parsedFormulas.begin(), parsedFormulas.end()); std::vector<std::shared_ptr<const storm::logic::Formula>> formulas(parsedFormulas.begin(), parsedFormulas.end());
assert(formulas.size() == 1); assert(formulas.size() == 1);
std::cout << "parsed formula." << std::endl;
std::cout << "Parsed formula." << std::endl;
std::map<size_t, std::vector<std::vector<size_t>>> emptySymmetry;
storm::storage::DFTIndependentSymmetries symmetries(emptySymmetry);
if(symred) { if(symred) {
std::cout << dft.getElementsString() << std::endl; std::cout << dft.getElementsString() << std::endl;
auto colouring = dft.colourDFT(); 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 // Building Markov Automaton
std::cout << "Building Model..." << std::endl; std::cout << "Building Model..." << std::endl;
storm::builder::ExplicitDFTModelBuilder<ValueType> builder(dft);
storm::builder::ExplicitDFTModelBuilder<ValueType> builder(dft, symmetries);
typename storm::builder::ExplicitDFTModelBuilder<ValueType>::LabelOptions labeloptions; // TODO initialize this with the formula typename storm::builder::ExplicitDFTModelBuilder<ValueType>::LabelOptions labeloptions; // TODO initialize this with the formula
std::shared_ptr<storm::models::sparse::Model<ValueType>> model = builder.buildModel(labeloptions); std::shared_ptr<storm::models::sparse::Model<ValueType>> model = builder.buildModel(labeloptions);
std::cout << "Built Model" << std::endl; std::cout << "Built Model" << std::endl;
@ -52,7 +54,6 @@ void analyzeDFT(std::string filename, std::string property, bool symred = false)
model = storm::performDeterministicSparseBisimulationMinimization<storm::models::sparse::Ctmc<ValueType>>(model->template as<storm::models::sparse::Ctmc<ValueType>>(), formulas, storm::storage::BisimulationType::Weak)->template as<storm::models::sparse::Ctmc<ValueType>>(); model = storm::performDeterministicSparseBisimulationMinimization<storm::models::sparse::Ctmc<ValueType>>(model->template as<storm::models::sparse::Ctmc<ValueType>>(), formulas, storm::storage::BisimulationType::Weak)->template as<storm::models::sparse::Ctmc<ValueType>>();
} }
model->printModelInformationToStream(std::cout); model->printModelInformationToStream(std::cout);
// Model checking // Model checking

Loading…
Cancel
Save