Browse Source

Use passive failure rate if BE is not used

Former-commit-id: fdc4a6687b
tempestpy_adaptions
Mavo 9 years ago
parent
commit
a781df35c2
  1. 21
      src/builder/ExplicitDFTModelBuilder.cpp
  2. 9
      src/storage/dft/DFT.cpp
  3. 9
      src/storage/dft/DFT.h

21
src/builder/ExplicitDFTModelBuilder.cpp

@ -127,31 +127,36 @@ namespace storm {
next->checkDontCareAnymore(newState, queues); next->checkDontCareAnymore(newState, queues);
} }
auto it = mStates.find(newState);
if (it == mStates.end()) {
auto itState = mStates.find(newState);
if (itState == mStates.end()) {
// New state // New state
newState.setId(newIndex++); newState.setId(newIndex++);
auto itInsert = mStates.insert(newState); auto itInsert = mStates.insert(newState);
assert(itInsert.second); assert(itInsert.second);
it = itInsert.first;
itState = itInsert.first;
STORM_LOG_TRACE("New state " << mDft.getStateString(newState)); STORM_LOG_TRACE("New state " << mDft.getStateString(newState));
// Add state to search // Add state to search
stateQueue.push(newState); stateQueue.push(newState);
} else { } else {
// State already exists // State already exists
STORM_LOG_TRACE("State " << mDft.getStateString(*it) << " already exists");
STORM_LOG_TRACE("State " << mDft.getStateString(*itState) << " already exists");
} }
// Set transition
ValueType rate = nextBE->activeFailureRate();
auto resultFind = outgoingTransitions.find(it->getId());
// Set failure rate according to usage
bool isUsed = true;
if (mDft.hasRepresentant(nextBE->id())) {
isUsed = newState.isUsed(nextBE->id());
}
STORM_LOG_TRACE("BE " << nextBE->name() << " is " << (isUsed ? "used" : "not used"));
ValueType rate = isUsed ? nextBE->activeFailureRate() : nextBE->passiveFailureRate();
auto resultFind = outgoingTransitions.find(itState->getId());
if (resultFind != outgoingTransitions.end()) { if (resultFind != outgoingTransitions.end()) {
// Add to existing transition // Add to existing transition
resultFind->second += rate; resultFind->second += rate;
} else { } else {
// Insert new transition // Insert new transition
outgoingTransitions.insert(std::make_pair(it->getId(), rate));
outgoingTransitions.insert(std::make_pair(itState->getId(), rate));
} }
sum += rate; sum += rate;
} // end while failing BE } // end while failing BE

9
src/storage/dft/DFT.cpp

@ -29,6 +29,7 @@ namespace storm {
for(auto const& modelem : module) { for(auto const& modelem : module) {
if(mElements[modelem]->isSpareGate() || mElements[modelem]->isBasicElement()) { if(mElements[modelem]->isSpareGate() || mElements[modelem]->isBasicElement()) {
sparesAndBes.push_back(modelem); sparesAndBes.push_back(modelem);
mRepresentants.insert(std::make_pair(modelem, spareReprs->id()));
} }
} }
mSpareModules.insert(std::make_pair(spareReprs->id(), sparesAndBes)); mSpareModules.insert(std::make_pair(spareReprs->id(), sparesAndBes));
@ -131,12 +132,12 @@ namespace storm {
stream << "(" << state.getId() << ") "; stream << "(" << state.getId() << ") ";
for (auto const& elem : mElements) { for (auto const& elem : mElements) {
stream << state.getElementStateInt(elem->id()); stream << state.getElementStateInt(elem->id());
/*if(elem->isSpareGate()) {
if(elem->isSpareGate()) {
if(state.isActiveSpare(elem->id())) { if(state.isActiveSpare(elem->id())) {
os << " actively";
stream << " actively";
} }
os << " using " << state.uses(elem->id());
}*/
stream << " using " << state.uses(elem->id());
}
} }
return stream.str(); return stream.str();
} }

9
src/storage/dft/DFT.h

@ -50,6 +50,7 @@ namespace storm {
std::vector<size_t> mTopModule; std::vector<size_t> mTopModule;
std::vector<size_t> mIdToFailureIndex; std::vector<size_t> mIdToFailureIndex;
std::map<size_t, size_t> mUsageIndex; std::map<size_t, size_t> mUsageIndex;
std::map<size_t, size_t> mRepresentants;
public: public:
DFT(DFTElementVector const& elements, DFTElementPointer const& tle); DFT(DFTElementVector const& elements, DFTElementPointer const& tle);
@ -154,6 +155,14 @@ namespace storm {
return elements; return elements;
} }
bool hasRepresentant(size_t id) const {
return mRepresentants.find(id) != mRepresentants.end();
}
DFTElementPointer getRepresentant(size_t id) const {
assert(hasRepresentant(id));
return getElement(mRepresentants.find(id)->second);
}
bool hasFailed(DFTState<ValueType> const& state) const { bool hasFailed(DFTState<ValueType> const& state) const {
return state.hasFailed(mTopLevelIndex); return state.hasFailed(mTopLevelIndex);

Loading…
Cancel
Save