You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

103 lines
3.6 KiB

#pragma once
#include "DFTBE.h"
namespace storm {
namespace storage {
/*!
* BE with exponential failure rate.
*/
template<typename ValueType>
class BEExponential : public DFTBE<ValueType> {
public:
/*!
* Constructor.
* @param id Id.
* @param name Name.
* @param failureRate Active failure rate.
* @param dormancyFactor Dormancy factor.
* @param transient True iff the BE experiences transient failures.
*/
BEExponential(size_t id, std::string const& name, ValueType failureRate, ValueType dormancyFactor, bool transient = false) :
DFTBE<ValueType>(id, name), mActiveFailureRate(failureRate), mPassiveFailureRate(dormancyFactor * failureRate), mTransient(transient) {
STORM_LOG_ASSERT(!storm::utility::isZero<ValueType>(failureRate), "Exponential failure rate should not be zero.");
}
DFTElementType type() const override {
return DFTElementType::BE_EXP;
}
/*!
* Return failure rate in active state.
* @return Active failure rate.
*/
ValueType const& activeFailureRate() const {
return mActiveFailureRate;
}
/*!
* Return failure rate in passive state.
* @return Passive failure rate.
*/
ValueType const& passiveFailureRate() const {
return mPassiveFailureRate;
}
/*!
* Return dormancy factor given by passive_failure_rate/active_failure_rate.
* @return Dormancy factor.
*/
ValueType dormancyFactor() const {
if (storm::utility::isZero<ValueType>(this->activeFailureRate())) {
// Return default value of 1
return storm::utility::one<ValueType>();
} else {
return this->passiveFailureRate() / this->activeFailureRate();
}
}
/*!
* Return whether the BE experiences transient failures.
* @return True iff BE is transient.
*/
bool isTransient() const {
return mTransient;
}
bool canFail() const override {
return !storm::utility::isZero(this->activeFailureRate());
}
/*!
* Return whether the BE is a cold BE, i.e., passive failure rate = 0.
* @return True iff BE is cold BE.
*/
bool isColdBasicElement() const {
return storm::utility::isZero(this->passiveFailureRate());
}
bool isTypeEqualTo(DFTElement <ValueType> const& other) const override {
if (!DFTElement<ValueType>::isTypeEqualTo(other)) {
return false;
}
auto& otherBE = static_cast<BEExponential<ValueType> const&>(other);
return (this->activeFailureRate() == otherBE.activeFailureRate()) && (this->passiveFailureRate() == otherBE.passiveFailureRate());
}
std::string toString() const override {
std::stringstream stream;
stream << "{" << this->name() << "} BE exp(" << this->activeFailureRate() << ", " << this->passiveFailureRate() << ")";
return stream.str();
}
private:
ValueType mActiveFailureRate;
ValueType mPassiveFailureRate;
bool mTransient;
};
}
}