Storm 1.14.0.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 <map>
4#include <unordered_map>
5
8
9// Forward declaration
10namespace storm::storage {
11template<typename ValueType>
12class DFT;
13} // namespace storm::storage
14
15namespace storm::dft {
16namespace builder {
17
18template<typename ValueType>
20 using DFTElementPointer = std::shared_ptr<storm::dft::storage::elements::DFTElement<ValueType>>;
21 using DFTElementCPointer = std::shared_ptr<storm::dft::storage::elements::DFTElement<ValueType> const>;
22 using DFTElementVector = std::vector<DFTElementPointer>;
23 using DFTBEPointer = std::shared_ptr<storm::dft::storage::elements::DFTBE<ValueType>>;
24 using DFTChildrenCPointer = std::shared_ptr<storm::dft::storage::elements::DFTChildren<ValueType> const>;
25 using DFTGatePointer = std::shared_ptr<storm::dft::storage::elements::DFTGate<ValueType>>;
26 using DFTDependencyPointer = std::shared_ptr<storm::dft::storage::elements::DFTDependency<ValueType>>;
27 using DFTRestrictionPointer = std::shared_ptr<storm::dft::storage::elements::DFTRestriction<ValueType>>;
28
29 private:
30 std::size_t mNextId;
31 std::string mTopLevelName;
32 std::unordered_map<std::string, DFTElementPointer> mElements;
33 std::unordered_map<DFTElementPointer, std::vector<std::string>> mChildNames;
34 std::unordered_map<DFTRestrictionPointer, std::vector<std::string>> mRestrictionChildNames;
35 std::unordered_map<DFTDependencyPointer, std::vector<std::string>> mDependencyChildNames;
36 std::unordered_map<std::string, storm::dft::storage::DFTLayoutInfo> mLayoutInfo;
37
38 public:
42 DFTBuilder();
43
49 void addBasicElementConst(std::string const& name, bool failed);
50
58 void addBasicElementProbability(std::string const& name, ValueType probability, ValueType dormancyFactor);
59
67 void addBasicElementExponential(std::string const& name, ValueType rate, ValueType dormancyFactor, bool transient = false);
68
76 void addBasicElementErlang(std::string const& name, ValueType rate, unsigned phases, ValueType dormancyFactor);
77
84 void addBasicElementWeibull(std::string const& name, ValueType shape, ValueType rate);
85
92 void addBasicElementLogNormal(std::string const& name, ValueType mean, ValueType standardDeviation);
93
99 void addBasicElementSamples(std::string const& name, std::map<ValueType, ValueType> const& activeSamples);
100
106 void addAndGate(std::string const& name, std::vector<std::string> const& children);
107
113 void addOrGate(std::string const& name, std::vector<std::string> const& children);
114
121 void addVotingGate(std::string const& name, unsigned threshold, std::vector<std::string> const& children);
122
129 void addPandGate(std::string const& name, std::vector<std::string> const& children, bool inclusive = true);
130
137 void addPorGate(std::string const& name, std::vector<std::string> const& children, bool inclusive = true);
138
144 void addSpareGate(std::string const& name, std::vector<std::string> const& children);
145
151 void addSequenceEnforcer(std::string const& name, std::vector<std::string> const& children);
152
158 void addMutex(std::string const& name, std::vector<std::string> const& children);
159
166 void addPdep(std::string const& name, std::vector<std::string> const& children, ValueType probability);
167
172 void setTopLevel(std::string const& tle);
173
180 void addLayoutInfo(std::string const& name, double x, double y);
181
188
194 void cloneElement(DFTElementCPointer element);
195
202 void cloneElementWithNewChildren(DFTChildrenCPointer elemWithChildren, std::vector<std::string> const& children);
203
204 private:
209 void addElement(DFTElementPointer element);
210
216 void addGate(DFTGatePointer gate, std::vector<std::string> const& children);
217
223 void addDependency(DFTDependencyPointer dependency, std::vector<std::string> const& children);
224
230 void addRestriction(DFTRestrictionPointer restriction, std::vector<std::string> const& children);
231
237 bool nameInUse(std::string const& name) const;
238
244 bool isValidProbability(ValueType value) const;
245
252 enum class topoSortColour { WHITE, BLACK, GREY };
253
260 void topologicalVisit(DFTElementPointer const& element,
261 std::map<DFTElementPointer, topoSortColour, storm::dft::storage::OrderElementsById<ValueType>>& visited,
262 DFTElementVector& visitedElements);
263
268 DFTElementVector sortTopological();
269
277 size_t computeRank(DFTElementPointer const& elem);
278};
279
280} // namespace builder
281} // 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:49