6#include <unordered_map> 
    9#include <boost/iterator/counting_iterator.hpp> 
   36template<
typename ValueType>
 
   40        if (a->rank() == 0 && b->rank() == 0) {
 
   41            return a->isConstant();
 
   43            return a->rank() < b->rank();
 
 
 
   51template<
typename ValueType>
 
   53    using DFTElementPointer = std::shared_ptr<storm::dft::storage::elements::DFTElement<ValueType>>;
 
   54    using DFTElementCPointer = std::shared_ptr<storm::dft::storage::elements::DFTElement<ValueType> 
const>;
 
   55    using DFTElementVector = std::vector<DFTElementPointer>;
 
   56    using DFTGatePointer = std::shared_ptr<storm::dft::storage::elements::DFTGate<ValueType>>;
 
   57    using DFTGateVector = std::vector<DFTGatePointer>;
 
   58    using DFTStatePointer = std::shared_ptr<storm::dft::storage::DFTState<ValueType>>;
 
   61    DFTElementVector mElements;
 
   64    size_t mNrRepresentatives;
 
   65    size_t mTopLevelIndex;
 
   66    size_t mStateVectorSize;
 
   67    size_t mMaxSpareChildCount;
 
   68    std::map<size_t, storm::dft::storage::DftModule> mModules;
 
   69    std::vector<size_t> mBEs;
 
   70    std::vector<size_t> mDependencies;
 
   71    std::map<size_t, size_t> mRepresentants;  
 
   72    std::map<size_t, DFTLayoutInfo> mLayoutInfo;
 
   73    mutable std::vector<size_t> mRelevantEvents;
 
   74    std::map<size_t, bool> mDependencyInConflict;
 
   77    DFT(DFTElementVector 
const& elements, DFTElementPointer 
const& tle);
 
   84                                         size_t stateIndex) 
const;
 
   92        return (mStateVectorSize / 64 + (mStateVectorSize % 64 != 0)) * 64;
 
 
   96        return mElements.size();
 
 
  108        return mTopLevelIndex;
 
 
  116        return mMaxSpareChildCount;
 
 
  120        std::vector<size_t> indices;
 
  121        for (
auto const& elem : mElements) {
 
  122            if (elem->isSpareGate()) {
 
  123                indices.push_back(elem->id());
 
 
  130        STORM_LOG_ASSERT(mModules.count(representativeId) > 0, 
"Representative not found.");
 
  131        return mModules.at(representativeId);
 
 
  135        std::vector<storm::dft::storage::DftModule> spareModules;
 
  136        for (
auto const& pair : mModules) {
 
  137            if (pair.first != mTopLevelIndex) {
 
  138                spareModules.push_back(pair.second);
 
 
  146        return mDependencyInConflict.at(
id);
 
 
  151        mDependencyInConflict.at(
id) = 
false;
 
 
  155        return mDependencies;
 
 
  159        std::vector<size_t> result;
 
  160        for (DFTElementPointer elem : mElements) {
 
  161            if (elem->isBasicElement()) {
 
  162                std::shared_ptr<storm::dft::storage::elements::DFTBE<ValueType>> be =
 
  163                    std::static_pointer_cast<storm::dft::storage::elements::DFTBE<ValueType>>(elem);
 
  165                    switch (be->beType()) {
 
  167                            result.push_back(be->id());
 
  170                            auto beExp = std::static_pointer_cast<storm::dft::storage::elements::BEExponential<ValueType>>(be);
 
  171                            if (!beExp->isColdBasicElement()) {
 
  172                                result.push_back(be->id());
 
  177                            STORM_LOG_THROW(
false, storm::exceptions::NotSupportedException, 
"BE type '" << be->beType() << 
"' is not supported.");
 
 
  191        return mElements[index];
 
 
  210    std::shared_ptr<storm::dft::storage::elements::DFTBE<ValueType> 
const> 
getBasicElement(
size_t index)
 const {
 
  212        return std::static_pointer_cast<storm::dft::storage::elements::DFTBE<ValueType> 
const>(mElements[index]);
 
 
  219    std::shared_ptr<storm::dft::storage::elements::DFTGate<ValueType> 
const> 
getGate(
size_t index)
 const {
 
  221        return std::static_pointer_cast<storm::dft::storage::elements::DFTGate<ValueType> 
const>(mElements[index]);
 
 
  224    std::shared_ptr<storm::dft::storage::elements::DFTDependency<ValueType> 
const> 
getDependency(
size_t index)
 const {
 
  226        return std::static_pointer_cast<storm::dft::storage::elements::DFTDependency<ValueType> 
const>(mElements[index]);
 
 
  229    std::shared_ptr<storm::dft::storage::elements::DFTRestriction<ValueType> 
const> 
getRestriction(
size_t index)
 const {
 
  231        return std::static_pointer_cast<storm::dft::storage::elements::DFTRestriction<ValueType> 
const>(mElements[index]);
 
 
  242        STORM_LOG_ASSERT(std::all_of(bes.begin(), bes.end(), [
this](
size_t id) { return this->getElement(id)->isBasicElement(); }),
 
  243                         "All elements must be BEs.");
 
 
  252    std::vector<std::shared_ptr<storm::dft::storage::elements::DFTBE<ValueType> 
const>> 
getBasicElements()
 const {
 
  253        std::vector<std::shared_ptr<storm::dft::storage::elements::DFTBE<ValueType> 
const>> elements;
 
  254        for (
size_t id : mBEs) {
 
 
  269        for (
auto const& parent : 
getElement(
id)->parents()) {
 
  270            if (parent->isSpareGate()) {
 
 
  278        return mRepresentants.find(
id) != mRepresentants.end();
 
 
  283        return mRepresentants.find(
id)->second;
 
 
  287        return state->hasFailed(mTopLevelIndex);
 
 
  295        return state->isFailsafe(mTopLevelIndex);
 
 
  320    size_t getChild(
size_t spareId, 
size_t nrUsedChild) 
const;
 
  322    size_t getNrChild(
size_t spareId, 
size_t childId) 
const;
 
  341        mLayoutInfo[id] = layoutInfo;
 
 
  345        return mLayoutInfo.at(
id);
 
 
  361    bool existsName(std::string 
const& name) 
const;
 
  368    size_t getIndex(std::string 
const& name) 
const;
 
  390    bool elementIndicesCorrect()
 const {
 
  391        for (
size_t i = 0; i < mElements.size(); ++i) {
 
  392            if (mElements[i]->
id() != i)
 
 
  404std::set<storm::RationalFunctionVariable> 
getParameters(DFT<storm::RationalFunction> 
const& dft);
 
Represents a Dynamic Fault Tree.
size_t nrBasicElements() const
bool hasFailed(DFTStatePointer const &state) const
std::vector< size_t > nonColdBEs() const
size_t getTopLevelIndex() const
bool isRepresentative(size_t id) const
void setBEOrder(std::vector< size_t > const &bes)
Set order of BEs.
std::string getRelevantEventsString() const
Get a string containing the list of all relevant events.
std::shared_ptr< storm::dft::storage::elements::DFTDependency< ValueType > const > getDependency(size_t index) const
void setRelevantEvents(storm::dft::utility::RelevantEvents const &relevantEvents, bool const allowDCForRelevant) const
Set the relevance flag for all elements according to the given relevant events.
std::shared_ptr< storm::dft::storage::elements::DFTBE< ValueType > const > getBasicElement(size_t index) const
size_t nrDynamicElements() const
size_t getNrChild(size_t spareId, size_t childId) const
DFTLayoutInfo const & getElementLayoutInfo(size_t id) const
std::string getModulesString() const
std::set< size_t > getAllIds() const
Get Ids of all elements.
bool hasRepresentant(size_t id) const
std::vector< size_t > findModularisationRewrite() const
void setDependencyNotInConflict(size_t id)
DFTElementCPointer getElement(size_t index) const
Get a pointer to an element in the DFT.
void setElementLayoutInfo(size_t id, DFTLayoutInfo const &layoutInfo)
void writeStatsToStream(std::ostream &stream) const
storm::dft::storage::elements::DFTElementType getTopLevelType() const
std::string getElementsWithStateString(DFTStatePointer const &state) const
DFTElementCPointer getTopLevelElement() const
std::vector< size_t > const & getDependencies() const
bool existsName(std::string const &name) const
Check whether an element with the given name exists.
size_t nrElements() const
std::shared_ptr< storm::dft::storage::elements::DFTGate< ValueType > const > getGate(size_t index) const
std::string getStateString(DFTStatePointer const &state) const
size_t stateBitVectorSize() const
size_t uses(storm::storage::BitVector const &state, DFTStateGenerationInfo const &stateGenerationInfo, size_t id) const
Return id of used child for a given spare gate.
std::string getInfoString() const
bool isDependencyInConflict(size_t id) const
size_t getRepresentant(size_t id) const
size_t generateStateInfo(DFTStateGenerationInfo &generationInfo, size_t id, storm::storage::BitVector &visited, size_t stateIndex) const
bool isDependency(size_t index) const
DFTStateGenerationInfo buildStateGenerationInfo(storm::dft::storage::DftSymmetries const &symmetries) const
bool isGate(size_t index) const
std::shared_ptr< storm::dft::storage::elements::DFTRestriction< ValueType > const > getRestriction(size_t index) const
size_t nrStaticElements() const
bool hasFailed(storm::storage::BitVector const &state, DFTStateGenerationInfo const &stateGenerationInfo) const
std::vector< size_t > const & getRelevantEvents() const
Get all relevant events.
std::vector< std::shared_ptr< storm::dft::storage::elements::DFTBE< ValueType > const > > getBasicElements() const
Return list of basic elements.
size_t getIndex(std::string const &name) const
Get id for the given element name.
std::vector< size_t > getSpareIndices() const
bool isRestriction(size_t index) const
size_t performStateGenerationInfoDFS(DFTStateGenerationInfo &generationInfo, std::queue< size_t > &visitQueue, storm::storage::BitVector &visited, size_t stateIndex) const
bool isFailsafe(storm::storage::BitVector const &state, DFTStateGenerationInfo const &stateGenerationInfo) const
void copyElements(std::vector< size_t > elements, storm::dft::builder::DFTBuilder< ValueType > builder) const
bool canHaveNondeterminism() const
size_t getMaxSpareChildCount() const
std::vector< size_t > immediateFailureCauses(size_t index) const
size_t getChild(size_t spareId, size_t nrUsedChild) const
std::vector< storm::dft::storage::DftModule > getSpareModules() const
std::string getElementsString() const
storm::dft::storage::DftModule const & module(size_t representativeId) const
std::vector< DFT< ValueType > > topModularisation() const
DFT< ValueType > optimize() const
bool isFailsafe(DFTStatePointer const &state) const
bool isBasicElement(size_t index) const
size_t getStateIndex(size_t id) const
bool hasFailed(size_t id) const
bool isFailsafe(size_t id) const
static uint_fast64_t usesIndex(storm::storage::BitVector const &state, DFTStateGenerationInfo const &stateGenerationInfo, size_t id)
Returns the index of the used child for a spare gate.
Represents a module/subtree in a DFT.
Abstract base class for basic events (BEs) in DFTs.
Abstract base class for DFT elements.
A bit vector that is internally represented as a vector of 64-bit values.
#define STORM_LOG_ASSERT(cond, message)
#define STORM_LOG_THROW(cond, exception, message)
DFTElementType
Element types in a DFT.
std::set< storm::RationalFunctionVariable > getParameters(DFT< storm::RationalFunction > const &dft)
Get all rate/probability parameters occurring in the DFT.
bool operator()(std::shared_ptr< storm::dft::storage::elements::DFTElement< ValueType > > const &a, std::shared_ptr< storm::dft::storage::elements::DFTElement< ValueType > > const &b) const