Browse Source

Fix in SubDFT computation.

Former-commit-id: aec3f5d0de
tempestpy_adaptions
sjunges 9 years ago
parent
commit
7663c29c5d
  1. 20
      src/storage/dft/DFTElements.cpp
  2. 51
      src/storage/dft/DFTElements.h

20
src/storage/dft/DFTElements.cpp

@ -46,14 +46,20 @@ namespace storm {
template<typename ValueType> template<typename ValueType>
std::vector<size_t> DFTElement<ValueType>::independentSubDft() const { std::vector<size_t> DFTElement<ValueType>::independentSubDft() const {
std::cout << "INDEPENDENT SUBTREE CALL " << this->id() << std::endl;
std::vector<size_t> res; std::vector<size_t> res;
res.push_back(this->id()); res.push_back(this->id());
// Extend for pdeps.
return res; return res;
} }
template<typename ValueType> template<typename ValueType>
void DFTElement<ValueType>::extendSubDft(std::set<size_t> elemsInSubtree, std::vector<size_t> const& parentsOfSubRoot) const {
void DFTElement<ValueType>::extendSubDft(std::set<size_t>& elemsInSubtree, std::vector<size_t> const& parentsOfSubRoot) const {
if(elemsInSubtree.count(this->id()) > 0) return;
std::cout << "ID " << this->id() << "PREL elems ";
for(auto const& i : elemsInSubtree) {
std::cout << i << " ";
}
std::cout << "in subtree." << std::endl;
if(std::find(parentsOfSubRoot.begin(), parentsOfSubRoot.end(), mId) != parentsOfSubRoot.end()) { if(std::find(parentsOfSubRoot.begin(), parentsOfSubRoot.end(), mId) != parentsOfSubRoot.end()) {
// This is a parent of the suspected root, thus it is not a subdft. // This is a parent of the suspected root, thus it is not a subdft.
elemsInSubtree.clear(); elemsInSubtree.clear();
@ -61,12 +67,18 @@ namespace storm {
} }
elemsInSubtree.insert(mId); elemsInSubtree.insert(mId);
for(auto const& parent : mParents) { for(auto const& parent : mParents) {
if(elemsInSubtree.count(parent->id()) != 0) {
parent->extendUnit(elemsInSubtree);
parent->extendSubDft(elemsInSubtree, parentsOfSubRoot);
if(elemsInSubtree.empty()) { if(elemsInSubtree.empty()) {
return; return;
} }
} }
for(auto const& dep : mOutgoingDependencies) {
dep->extendSubDft(elemsInSubtree, parentsOfSubRoot);
if(elemsInSubtree.empty()) {
return;
}
} }
} }

51
src/storage/dft/DFTElements.h

@ -202,7 +202,7 @@ namespace storm {
* Helper to the independent subtree computation * Helper to the independent subtree computation
* @see independentSubDft * @see independentSubDft
*/ */
virtual void extendSubDft(std::set<size_t> elemsInSubtree, std::vector<size_t> const& parentsOfSubRoot) const;
virtual void extendSubDft(std::set<size_t>& elemsInSubtree, std::vector<size_t> const& parentsOfSubRoot) const;
virtual bool isTypeEqualTo(DFTElement<ValueType> const& other) const { virtual bool isTypeEqualTo(DFTElement<ValueType> const& other) const {
return type() == other.type(); return type() == other.type();
@ -291,6 +291,11 @@ namespace storm {
std::vector<size_t> pids = this->parentIds(); std::vector<size_t> pids = this->parentIds();
for(auto const& child : mChildren) { for(auto const& child : mChildren) {
child->extendSubDft(unit, pids); child->extendSubDft(unit, pids);
std::cout << "int sub ";
for(auto const& i : unit) {
std::cout << i << " ";
}
std::cout << std::endl;
if(unit.empty()) { if(unit.empty()) {
// Parent in the subdft, ie it is *not* a subdft // Parent in the subdft, ie it is *not* a subdft
break; break;
@ -299,9 +304,10 @@ namespace storm {
return std::vector<size_t>(unit.begin(), unit.end()); return std::vector<size_t>(unit.begin(), unit.end());
} }
virtual void extendSubDft(std::set<size_t> elemsInSubtree, std::vector<size_t> const& parentsOfSubRoot) const override {
virtual void extendSubDft(std::set<size_t>& elemsInSubtree, std::vector<size_t> const& parentsOfSubRoot) const override {
if(elemsInSubtree.count(this->id()) > 0) return;
DFTElement<ValueType>::extendSubDft(elemsInSubtree, parentsOfSubRoot); DFTElement<ValueType>::extendSubDft(elemsInSubtree, parentsOfSubRoot);
if(!elemsInSubtree.empty()) {
if(elemsInSubtree.empty()) {
// Parent in the subdft, ie it is *not* a subdft // Parent in the subdft, ie it is *not* a subdft
return; return;
} }
@ -309,7 +315,7 @@ namespace storm {
child->extendSubDft(elemsInSubtree, parentsOfSubRoot); child->extendSubDft(elemsInSubtree, parentsOfSubRoot);
if(elemsInSubtree.empty()) { if(elemsInSubtree.empty()) {
// Parent in the subdft, ie it is *not* a subdft // Parent in the subdft, ie it is *not* a subdft
break;
return;
} }
} }
} }
@ -437,7 +443,7 @@ namespace storm {
return mIngoingDependencies.size(); return mIngoingDependencies.size();
} }
DFTDependencyVector const& getIngoingDependencies() const {
DFTDependencyVector const& ingoingDependencies() const {
return mIngoingDependencies; return mIngoingDependencies;
} }
@ -455,6 +461,22 @@ namespace storm {
return storm::utility::isZero(mPassiveFailureRate); return storm::utility::isZero(mPassiveFailureRate);
} }
virtual void extendSubDft(std::set<size_t>& elemsInSubtree, std::vector<size_t> const& parentsOfSubRoot) const override {
if(elemsInSubtree.count(this->id())) return;
DFTElement<ValueType>::extendSubDft(elemsInSubtree, parentsOfSubRoot);
if(elemsInSubtree.empty()) {
// Parent in the subdft, ie it is *not* a subdft
return;
}
for(auto const& incDep : mIngoingDependencies) {
incDep->extendSubDft(elemsInSubtree, parentsOfSubRoot);
if(elemsInSubtree.empty()) {
// Parent in the subdft, ie it is *not* a subdft
return;
}
}
}
bool isTypeEqualTo(DFTElement<ValueType> const& other) const override { bool isTypeEqualTo(DFTElement<ValueType> const& other) const override {
if(!DFTElement<ValueType>::isTypeEqualTo(other)) return false; if(!DFTElement<ValueType>::isTypeEqualTo(other)) return false;
DFTBE<ValueType> const& otherBE = static_cast<DFTBE<ValueType> const&>(other); DFTBE<ValueType> const& otherBE = static_cast<DFTBE<ValueType> const&>(other);
@ -502,6 +524,8 @@ namespace storm {
return 0; return 0;
} }
bool isTypeEqualTo(DFTElement<ValueType> const& other) const override { bool isTypeEqualTo(DFTElement<ValueType> const& other) const override {
if(!DFTElement<ValueType>::isTypeEqualTo(other)) return false; if(!DFTElement<ValueType>::isTypeEqualTo(other)) return false;
DFTConst<ValueType> const& otherCNST = static_cast<DFTConst<ValueType> const&>(other); DFTConst<ValueType> const& otherCNST = static_cast<DFTConst<ValueType> const&>(other);
@ -589,6 +613,23 @@ namespace storm {
return std::vector<size_t>(unit.begin(), unit.end()); return std::vector<size_t>(unit.begin(), unit.end());
} }
virtual void extendSubDft(std::set<size_t>& elemsInSubtree, std::vector<size_t> const& parentsOfSubRoot) const override {
if(elemsInSubtree.count(this->id())) return;
DFTElement<ValueType>::extendSubDft(elemsInSubtree, parentsOfSubRoot);
if(elemsInSubtree.empty()) {
// Parent in the subdft, ie it is *not* a subdft
return;
}
mDependentEvent->extendSubDft(elemsInSubtree, parentsOfSubRoot);
if(elemsInSubtree.empty()) {
// Parent in the subdft, ie it is *not* a subdft
return;
}
mTriggerEvent->extendSubDft(elemsInSubtree, parentsOfSubRoot);
}
virtual std::string toString() const override { virtual std::string toString() const override {
std::stringstream stream; std::stringstream stream;
bool fdep = storm::utility::isOne(mProbability); bool fdep = storm::utility::isOne(mProbability);

Loading…
Cancel
Save