Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
BESamples.h
Go to the documentation of this file.
1#pragma once
2
3#include "DFTBE.h"
4
5#include <map>
6
7namespace storm::dft {
8namespace storage {
9namespace elements {
10
15template<typename ValueType>
16class BESamples : public DFTBE<ValueType> {
17 public:
24 BESamples(size_t id, std::string const& name, std::map<ValueType, ValueType> activeSamples) : DFTBE<ValueType>(id, name), mActiveSamples(activeSamples) {
25 STORM_LOG_ASSERT(activeSamples.size() > 0, "At least one sample should be given.");
26 STORM_LOG_ASSERT(this->canFail(), "At least one sample should have a non-zero probability.");
27 }
28
29 std::shared_ptr<DFTElement<ValueType>> clone() const override {
30 return std::shared_ptr<DFTElement<ValueType>>(new BESamples<ValueType>(this->id(), this->name(), this->activeSamples()));
31 }
32
36
41 std::map<ValueType, ValueType> const& activeSamples() const {
42 return mActiveSamples;
43 }
44
45 ValueType getUnreliability(ValueType time) const override;
46
47 bool canFail() const override {
48 // At least one sample is not zero
49 for (auto const& sample : mActiveSamples) {
50 if (!storm::utility::isZero(sample.second)) {
51 return true;
52 }
53 }
54 return false;
55 }
56
57 std::string distributionString() const override {
58 std::stringstream stream;
59 stream << "samples " << this->activeSamples().size();
60 return stream.str();
61 }
62
63 private:
64 std::map<ValueType, ValueType> mActiveSamples;
65};
66
67} // namespace elements
68} // namespace storage
69} // namespace storm::dft
BE where the failure distribution is defined by samples.
Definition BESamples.h:16
bool canFail() const override
Return whether the BE can fail.
Definition BESamples.h:47
ValueType getUnreliability(ValueType time) const override
Return the unreliability of the BE up to the given time point.
Definition BESamples.cpp:10
storm::dft::storage::elements::BEType beType() const override
Get type of BE (constant, exponential, etc.).
Definition BESamples.h:33
std::map< ValueType, ValueType > const & activeSamples() const
Return samples defining unreliability in active state.
Definition BESamples.h:41
std::string distributionString() const override
Print information about failure distribution to string.
Definition BESamples.h:57
std::shared_ptr< DFTElement< ValueType > > clone() const override
Create a shallow copy of the element.
Definition BESamples.h:29
BESamples(size_t id, std::string const &name, std::map< ValueType, ValueType > activeSamples)
Constructor.
Definition BESamples.h:24
Abstract base class for basic events (BEs) in DFTs.
Definition DFTBE.h:14
virtual size_t id() const
Get id.
Definition DFTElement.h:73
virtual std::string const & name() const
Get name.
Definition DFTElement.h:89
#define STORM_LOG_ASSERT(cond, message)
Definition macros.h:11
bool isZero(ValueType const &a)
Definition constants.cpp:41