Matthias Volk
5 years ago
No known key found for this signature in database
GPG Key ID: 83A57678F739FCD3
8 changed files with 119 additions and 24 deletions
-
16src/storm-dft/storage/dft/elements/BEConst.cpp
-
2src/storm-dft/storage/dft/elements/BEConst.h
-
24src/storm-dft/storage/dft/elements/BEExponential.cpp
-
10src/storm-dft/storage/dft/elements/BEExponential.h
-
33src/storm-dft/storage/dft/elements/DFTBE.cpp
-
27src/storm-dft/storage/dft/elements/DFTBE.h
-
2src/test/storm-dft/CMakeLists.txt
-
29src/test/storm-dft/storage/DftBETest.cpp
@ -0,0 +1,16 @@ |
|||
#include "BEConst.h"
|
|||
|
|||
namespace storm { |
|||
namespace storage { |
|||
|
|||
template <typename ValueType> |
|||
ValueType BEConst<ValueType>::getUnreliability(ValueType time) const { |
|||
return failed() ? storm::utility::one<ValueType>() : storm::utility::zero<ValueType>(); |
|||
} |
|||
|
|||
// Explicitly instantiate the class.
|
|||
template class BEConst<double>; |
|||
template class BEConst<RationalFunction>; |
|||
|
|||
} // namespace storage
|
|||
} // namespace storm
|
@ -0,0 +1,24 @@ |
|||
#include "BEExponential.h"
|
|||
|
|||
#include "storm/exceptions/NotSupportedException.h"
|
|||
|
|||
namespace storm { |
|||
namespace storage { |
|||
|
|||
template <> |
|||
double BEExponential<double>::getUnreliability(double time) const { |
|||
// 1 - e^(-lambda * t)
|
|||
return 1 - exp(-this->activeFailureRate() * time); |
|||
} |
|||
|
|||
template <typename ValueType> |
|||
ValueType BEExponential<ValueType>::getUnreliability(ValueType time) const { |
|||
STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Computing cumulative failure probability not supported for this data type."); |
|||
} |
|||
|
|||
// Explicitly instantiate the class.
|
|||
template class BEExponential<double>; |
|||
template class BEExponential<RationalFunction>; |
|||
|
|||
} |
|||
} |
@ -0,0 +1,33 @@ |
|||
#include "DFTBE.h"
|
|||
|
|||
#include "storm-dft/storage/dft/elements/DFTGate.h"
|
|||
#include "storm-dft/storage/dft/elements/DFTDependency.h"
|
|||
|
|||
namespace storm { |
|||
namespace storage { |
|||
|
|||
template <typename ValueType> |
|||
void DFTBE<ValueType>::extendSubDft(std::set<size_t>& elemsInSubtree, std::vector<size_t> const& parentsOfSubRoot, bool blockParents, bool sparesAsLeaves) const { |
|||
if (elemsInSubtree.count(this->id())) { |
|||
return; |
|||
} |
|||
DFTElement<ValueType>::extendSubDft(elemsInSubtree, parentsOfSubRoot, blockParents, sparesAsLeaves); |
|||
if (elemsInSubtree.empty()) { |
|||
// Parent in the subDFT, i.e., it is *not* a subDFT
|
|||
return; |
|||
} |
|||
for (auto const& inDep : ingoingDependencies()) { |
|||
inDep->extendSubDft(elemsInSubtree, parentsOfSubRoot, blockParents, sparesAsLeaves); |
|||
if (elemsInSubtree.empty()) { |
|||
// Parent in the subDFT, i.e., it is *not* a subDFT
|
|||
return; |
|||
} |
|||
} |
|||
} |
|||
|
|||
// Explicitly instantiate the class.
|
|||
template class DFTBE<double>; |
|||
template class DFTBE<RationalFunction>; |
|||
|
|||
} |
|||
} |
@ -0,0 +1,29 @@ |
|||
#include "test/storm_gtest.h"
|
|||
#include "storm-config.h"
|
|||
|
|||
#include "storm-dft/storage/dft/DFTElements.h"
|
|||
|
|||
namespace { |
|||
|
|||
TEST(DftBETest, FailureConstant) { |
|||
storm::storage::BEConst<double> be(0, "Test", true); |
|||
EXPECT_TRUE(be.failed()); |
|||
EXPECT_TRUE(be.canFail()); |
|||
|
|||
EXPECT_EQ(1, be.getUnreliability(0)); |
|||
EXPECT_EQ(1, be.getUnreliability(10)); |
|||
} |
|||
|
|||
TEST(DftBETest, FailureExponential) { |
|||
storm::storage::BEExponential<double> be(0, "Test", 3, 0.5); |
|||
|
|||
EXPECT_TRUE(be.canFail()); |
|||
EXPECT_EQ(1.5, be.passiveFailureRate()); |
|||
|
|||
EXPECT_EQ(0, be.getUnreliability(0)); |
|||
EXPECT_FLOAT_EQ(0.7768698399, be.getUnreliability(0.5)); |
|||
EXPECT_FLOAT_EQ(0.9502129316, be.getUnreliability(1)); |
|||
EXPECT_FLOAT_EQ(0.9975212478, be.getUnreliability(2)); |
|||
} |
|||
|
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue