Storm 1.11.1.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
DFTBuilder.h
Go to the documentation of this file.
1#pragma once
2
3#include <iostream>
4#include <map>
5#include <unordered_map>
6
10
14
15namespace storm::storage {
16// Forward declaration
17template<typename ValueType>
18class DFT;
19} // namespace storm::storage
20
21namespace storm::dft {
22namespace builder {
23
24template<typename ValueType>
26 using DFTElementPointer = std::shared_ptr<storm::dft::storage::elements::DFTElement<ValueType>>;
27 using DFTElementCPointer = std::shared_ptr<storm::dft::storage::elements::DFTElement<ValueType> const>;
28 using DFTElementVector = std::vector<DFTElementPointer>;
29 using DFTBEPointer = std::shared_ptr<storm::dft::storage::elements::DFTBE<ValueType>>;
30 using DFTChildrenCPointer = std::shared_ptr<storm::dft::storage::elements::DFTChildren<ValueType> const>;
31 using DFTGatePointer = std::shared_ptr<storm::dft::storage::elements::DFTGate<ValueType>>;
32 using DFTDependencyPointer = std::shared_ptr<storm::dft::storage::elements::DFTDependency<ValueType>>;
33 using DFTRestrictionPointer = std::shared_ptr<storm::dft::storage::elements::DFTRestriction<ValueType>>;
34
35 private:
36 std::size_t mNextId;
37 std::string mTopLevelName;
38 std::unordered_map<std::string, DFTElementPointer> mElements;
39 std::unordered_map<DFTElementPointer, std::vector<std::string>> mChildNames;
40 std::unordered_map<DFTRestrictionPointer, std::vector<std::string>> mRestrictionChildNames;
41 std::unordered_map<DFTDependencyPointer, std::vector<std::string>> mDependencyChildNames;
42 std::unordered_map<std::string, storm::dft::storage::DFTLayoutInfo> mLayoutInfo;
43
44 public:
48 DFTBuilder();
49
55 void addBasicElementConst(std::string const& name, bool failed);
56
64 void addBasicElementProbability(std::string const& name, ValueType probability, ValueType dormancyFactor);
65
73 void addBasicElementExponential(std::string const& name, ValueType rate, ValueType dormancyFactor, bool transient = false);
74
82 void addBasicElementErlang(std::string const& name, ValueType rate, unsigned phases, ValueType dormancyFactor);
83
90 void addBasicElementWeibull(std::string const& name, ValueType shape, ValueType rate);
91
98 void addBasicElementLogNormal(std::string const& name, ValueType mean, ValueType standardDeviation);
99
105 void addBasicElementSamples(std::string const& name, std::map<ValueType, ValueType> const& activeSamples);
106
112 void addAndGate(std::string const& name, std::vector<std::string> const& children);
113
119 void addOrGate(std::string const& name, std::vector<std::string> const& children);
120
127 void addVotingGate(std::string const& name, unsigned threshold, std::vector<std::string> const& children);
128
135 void addPandGate(std::string const& name, std::vector<std::string> const& children, bool inclusive = true);
136
143 void addPorGate(std::string const& name, std::vector<std::string> const& children, bool inclusive = true);
144
150 void addSpareGate(std::string const& name, std::vector<std::string> const& children);
151
157 void addSequenceEnforcer(std::string const& name, std::vector<std::string> const& children);
158
164 void addMutex(std::string const& name, std::vector<std::string> const& children);
165
172 void addPdep(std::string const& name, std::vector<std::string> const& children, ValueType probability);
173
178 void setTopLevel(std::string const& tle);
179
186 void addLayoutInfo(std::string const& name, double x, double y);
187
194
200 void cloneElement(DFTElementCPointer element);
201
208 void cloneElementWithNewChildren(DFTChildrenCPointer elemWithChildren, std::vector<std::string> const& children);
209
210 private:
215 void addElement(DFTElementPointer element);
216
222 void addGate(DFTGatePointer gate, std::vector<std::string> const& children);
223
229 void addDependency(DFTDependencyPointer dependency, std::vector<std::string> const& children);
230
236 void addRestriction(DFTRestrictionPointer restriction, std::vector<std::string> const& children);
237
243 bool nameInUse(std::string const& name) const;
244
250 bool isValidProbability(ValueType value) const;
251
258 enum class topoSortColour { WHITE, BLACK, GREY };
259
266 void topologicalVisit(DFTElementPointer const& element,
267 std::map<DFTElementPointer, topoSortColour, storm::dft::storage::OrderElementsById<ValueType>>& visited,
268 DFTElementVector& visitedElements);
269
274 DFTElementVector sortTopological();
275
283 size_t computeRank(DFTElementPointer const& elem);
284};
285
286} // namespace builder
287} // namespace storm::dft
void addPdep(std::string const &name, std::vector< std::string > const &children, ValueType probability)
Create (probabilistic) dependency (PDEP) and add it to DFT.
void addOrGate(std::string const &name, std::vector< std::string > const &children)
Create OR-gate and add it to DFT.
void addVotingGate(std::string const &name, unsigned threshold, std::vector< std::string > const &children)
Create VOTing-gate and add it to DFT.
void addBasicElementSamples(std::string const &name, std::map< ValueType, ValueType > const &activeSamples)
Create BE with distribution given by sample points and add it to DFT.
void addBasicElementErlang(std::string const &name, ValueType rate, unsigned phases, ValueType dormancyFactor)
Create BE with Erlang distribution and add it to DFT.
void addLayoutInfo(std::string const &name, double x, double y)
Add layout information for DFT element.
void addSpareGate(std::string const &name, std::vector< std::string > const &children)
Create SPARE-gate and add it to DFT.
void addBasicElementConst(std::string const &name, bool failed)
Create BE which is constant failed or constant failsafe and add it to DFT.
storm::dft::storage::DFT< ValueType > build()
Create DFT.
void addAndGate(std::string const &name, std::vector< std::string > const &children)
Create AND-gate and add it to DFT.
void addBasicElementProbability(std::string const &name, ValueType probability, ValueType dormancyFactor)
Create BE with constant (Bernoulli) distribution and add it to DFT.
void cloneElement(DFTElementCPointer element)
Clone element and add it via the builder.
void setTopLevel(std::string const &tle)
Set top level element.
void cloneElementWithNewChildren(DFTChildrenCPointer elemWithChildren, std::vector< std::string > const &children)
Clone element, replace its children with the given children and add it via the builder.
void addBasicElementExponential(std::string const &name, ValueType rate, ValueType dormancyFactor, bool transient=false)
Create BE with exponential distribution and add it to DFT.
void addPorGate(std::string const &name, std::vector< std::string > const &children, bool inclusive=true)
Create POR-gate and add it to DFT.
void addSequenceEnforcer(std::string const &name, std::vector< std::string > const &children)
Create sequence enforcer (SEQ) and add it to DFT.
void addPandGate(std::string const &name, std::vector< std::string > const &children, bool inclusive=true)
Create PAND-gate and add it to DFT.
void addBasicElementWeibull(std::string const &name, ValueType shape, ValueType rate)
Create BE with Weibull distribution and add it to DFT.
void addBasicElementLogNormal(std::string const &name, ValueType mean, ValueType standardDeviation)
Create BE with log-normal distribution and add it to DFT.
void addMutex(std::string const &name, std::vector< std::string > const &children)
Create mutual exclusion-gate (MUTEX) and add it to DFT.
Represents a Dynamic Fault Tree.
Definition DFT.h:52