Browse Source

Removed mChildren in DFTGate

tempestpy_adaptions
Matthias Volk 6 years ago
parent
commit
723caeb56e
  1. 2
      src/storm-dft/storage/dft/elements/DFTAnd.h
  2. 11
      src/storm-dft/storage/dft/elements/DFTGate.h
  3. 2
      src/storm-dft/storage/dft/elements/DFTOr.h
  4. 2
      src/storm-dft/storage/dft/elements/DFTPand.h
  5. 6
      src/storm-dft/storage/dft/elements/DFTPor.h
  6. 54
      src/storm-dft/storage/dft/elements/DFTSpare.h
  7. 4
      src/storm-dft/storage/dft/elements/DFTVot.h

2
src/storm-dft/storage/dft/elements/DFTAnd.h

@ -29,7 +29,7 @@ namespace storm {
void checkFails(storm::storage::DFTState<ValueType>& state, DFTStateSpaceGenerationQueues<ValueType>& queues) const override {
if (state.isOperational(this->mId)) {
for (auto const& child : this->mChildren) {
for (auto const& child : this->children()) {
if (!state.hasFailed(child->id())) {
return;
}

11
src/storm-dft/storage/dft/elements/DFTGate.h

@ -14,9 +14,6 @@ namespace storm {
using DFTElementPointer = std::shared_ptr<DFTElement<ValueType>>;
using DFTElementVector = std::vector<DFTElementPointer>;
protected:
DFTElementVector mChildren;
public:
/*!
* Constructor.
@ -50,7 +47,7 @@ namespace storm {
virtual void extendSpareModule(std::set<size_t>& elementsInSpareModule) const override {
if (!this->isSpareGate()) {
DFTElement<ValueType>::extendSpareModule(elementsInSpareModule);
for (auto const& child : mChildren) {
for (auto const& child : this->children()) {
if (elementsInSpareModule.count(child->id()) == 0) {
elementsInSpareModule.insert(child->id());
child->extendSpareModule(elementsInSpareModule);
@ -70,7 +67,7 @@ namespace storm {
protected:
void fail(DFTState<ValueType>& state, DFTStateSpaceGenerationQueues<ValueType>& queues) const {
virtual void fail(DFTState<ValueType>& state, DFTStateSpaceGenerationQueues<ValueType>& queues) const {
for (std::shared_ptr<DFTGate> parent : this->mParents) {
if (state.isOperational(parent->id())) {
queues.propagateFailure(parent);
@ -83,7 +80,7 @@ namespace storm {
this->childrenDontCare(state, queues);
}
void failsafe(DFTState<ValueType>& state, DFTStateSpaceGenerationQueues<ValueType>& queues) const {
virtual void failsafe(DFTState<ValueType>& state, DFTStateSpaceGenerationQueues<ValueType>& queues) const {
for (std::shared_ptr<DFTGate> parent : this->mParents) {
if (state.isOperational(parent->id())) {
queues.propagateFailsafe(parent);
@ -94,7 +91,7 @@ namespace storm {
}
void childrenDontCare(DFTState<ValueType>& state, DFTStateSpaceGenerationQueues<ValueType>& queues) const {
queues.propagateDontCare(mChildren);
queues.propagateDontCare(this->children());
}
};

2
src/storm-dft/storage/dft/elements/DFTOr.h

@ -35,7 +35,7 @@ namespace storm {
}
void checkFailsafe(storm::storage::DFTState<ValueType>& state, DFTStateSpaceGenerationQueues<ValueType>& queues) const override {
for (auto const& child : this->mChildren) {
for (auto const& child : this->children()) {
if (!state.isFailsafe(child->id())) {
return;
}

2
src/storm-dft/storage/dft/elements/DFTPand.h

@ -47,7 +47,7 @@ namespace storm {
STORM_LOG_ASSERT(isInclusive(), "Exclusive PAND not supported.");
if (state.isOperational(this->mId)) {
bool childOperationalBefore = false;
for (auto const& child : this->mChildren) {
for (auto const& child : this->children()) {
if (!state.hasFailed(child->id())) {
childOperationalBefore = true;
} else if (childOperationalBefore && state.hasFailed(child->id())) {

6
src/storm-dft/storage/dft/elements/DFTPor.h

@ -45,14 +45,14 @@ namespace storm {
void checkFails(storm::storage::DFTState<ValueType>& state, DFTStateSpaceGenerationQueues<ValueType>& queues) const override {
STORM_LOG_ASSERT(isInclusive(), "Exclusive POR not supported.");
if (state.isOperational(this->mId)) {
auto childIter = this->mChildren.begin();
auto childIter = this->children().begin();
if (state.hasFailed((*childIter)->id())) {
// First child has failed before others
this->fail(state, queues);
return;
}
// Iterate over other children
for (; childIter != this->mChildren.end(); ++childIter) {
for (; childIter != this->children().end(); ++childIter) {
if (state.hasFailed((*childIter)->id())) {
// Child has failed before first child
this->failsafe(state, queues);
@ -65,7 +65,7 @@ namespace storm {
void checkFailsafe(storm::storage::DFTState<ValueType>& state, DFTStateSpaceGenerationQueues<ValueType>& queues) const override {
STORM_LOG_ASSERT(isInclusive(), "Exclusive POR not supported.");
// If first child is not failsafe, it could still fail.
if (state.isFailsafe(this->mChildren.front()->id())) {
if (state.isFailsafe(this->children().front()->id())) {
this->failsafe(state, queues);
this->childrenDontCare(state, queues);
}

54
src/storm-dft/storage/dft/elements/DFTSpare.h

@ -1,24 +1,28 @@
#pragma once
#include "DFTGate.h"
namespace storm {
namespace storage {
/*!
* SPARE gate.
*/
template<typename ValueType>
class DFTSpare : public DFTGate<ValueType> {
public:
DFTSpare(size_t id, std::string const& name, std::vector<std::shared_ptr<DFTElement<ValueType>>> const& children = {}) :
DFTGate<ValueType>(id, name, children)
{}
std::string typestring() const override {
return "SPARE";
/*!
* Constructor.
* @param id Id.
* @param name Name.
* @param children Children.
*/
DFTSpare(size_t id, std::string const& name, std::vector<std::shared_ptr<DFTElement<ValueType>>> const& children = {}) : DFTGate<ValueType>(id, name, children) {
// Intentionally left empty.
}
virtual DFTElementType type() const override {
DFTElementType type() const override {
return DFTElementType::SPARE;
}
@ -26,12 +30,12 @@ namespace storm {
return true;
}
void fail(DFTState<ValueType>& state, DFTStateSpaceGenerationQueues<ValueType>& queues) const {
void fail(DFTState<ValueType>& state, DFTStateSpaceGenerationQueues<ValueType>& queues) const override {
DFTGate<ValueType>::fail(state, queues);
state.finalizeUses(this->mId);
}
void failsafe(DFTState<ValueType>& state, DFTStateSpaceGenerationQueues<ValueType>& queues) const {
void failsafe(DFTState<ValueType>& state, DFTStateSpaceGenerationQueues<ValueType>& queues) const override {
DFTGate<ValueType>::failsafe(state, queues);
state.finalizeUses(this->mId);
}
@ -45,11 +49,11 @@ namespace storm {
}
void checkFails(storm::storage::DFTState<ValueType>& state, DFTStateSpaceGenerationQueues<ValueType>& queues) const override {
if(state.isOperational(this->mId)) {
if (state.isOperational(this->mId)) {
size_t uses = state.uses(this->mId);
if(!state.isOperational(uses)) {
bool claimingSuccessful = state.claimNew(this->mId, uses, this->mChildren);
if(!claimingSuccessful) {
if (!state.isOperational(uses)) {
bool claimingSuccessful = state.claimNew(this->mId, uses, this->children());
if (!claimingSuccessful) {
this->fail(state, queues);
}
}
@ -57,8 +61,8 @@ namespace storm {
}
void checkFailsafe(storm::storage::DFTState<ValueType>& state, DFTStateSpaceGenerationQueues<ValueType>& queues) const override {
if(state.isOperational(this->mId)) {
if(state.isFailsafe(state.uses(this->mId))) {
if (state.isOperational(this->mId)) {
if (state.isFailsafe(state.uses(this->mId))) {
this->failsafe(state, queues);
this->childrenDontCare(state, queues);
}
@ -67,16 +71,16 @@ namespace storm {
std::vector<size_t> independentSubDft(bool blockParents, bool sparesAsLeaves = false) const override {
auto prelRes = DFTElement<ValueType>::independentSubDft(blockParents);
if(prelRes.empty()) {
if (prelRes.empty()) {
// No elements (especially not this->id) in the prelimanry result, so we know already that it is not a subdft.
return prelRes;
}
std::set<size_t> unit(prelRes.begin(), prelRes.end());
std::vector<size_t> pids = this->parentIds();
if (!sparesAsLeaves) {
for(auto const& child : this->mChildren) {
for (auto const& child : this->children()) {
child->extendSubDft(unit, pids, blockParents, sparesAsLeaves);
if(unit.empty()) {
if (unit.empty()) {
// Parent in the subdft, ie it is *not* a subdft
break;
}
@ -86,24 +90,22 @@ namespace storm {
}
void extendSubDft(std::set<size_t>& elemsInSubtree, std::vector<size_t> const& parentsOfSubRoot, bool blockParents, bool sparesAsLeaves) const override {
if(elemsInSubtree.count(this->id()) > 0) return;
if (elemsInSubtree.count(this->id()) > 0) return;
DFTElement<ValueType>::extendSubDft(elemsInSubtree, parentsOfSubRoot, blockParents, sparesAsLeaves);
if(elemsInSubtree.empty()) {
if (elemsInSubtree.empty()) {
// Parent in the subdft, ie it is *not* a subdft
return;
}
if (!sparesAsLeaves) {
for(auto const& child : this->mChildren) {
for (auto const& child : this->children()) {
child->extendSubDft(elemsInSubtree, parentsOfSubRoot, blockParents, sparesAsLeaves);
if(elemsInSubtree.empty()) {
if (elemsInSubtree.empty()) {
// Parent in the subdft, ie it is *not* a subdft
return;
}
}
}
}
};
}

4
src/storm-dft/storage/dft/elements/DFTVot.h

@ -44,7 +44,7 @@ namespace storm {
void checkFails(storm::storage::DFTState<ValueType>& state, DFTStateSpaceGenerationQueues<ValueType>& queues) const override {
if (state.isOperational(this->mId)) {
unsigned nrFailedChildren = 0;
for (auto const& child : this->mChildren) {
for (auto const& child : this->children()) {
if (state.hasFailed(child->id())) {
++nrFailedChildren;
if (nrFailedChildren >= mThreshold) {
@ -61,7 +61,7 @@ namespace storm {
STORM_LOG_ASSERT(this->hasFailsafeChild(state), "No failsafe child.");
if (state.isOperational(this->mId)) {
unsigned nrFailsafeChildren = 0;
for (auto const& child : this->mChildren) {
for (auto const& child : this->children()) {
if (state.isFailsafe(child->id())) {
++nrFailsafeChildren;
if (nrFailsafeChildren > this->nrChildren() - mThreshold) {

Loading…
Cancel
Save