100 for (; iterFailable != this->state->getFailableElements().end(!exploreDependencies); ++iterFailable) {
101 DFTStatePointer newState;
102 if (iterFailable.isFailureDueToDependency()) {
104 STORM_LOG_ASSERT(exploreDependencies,
"Failure should be due to dependency.");
105 std::shared_ptr<storm::dft::storage::elements::DFTDependency<ValueType>
const> dependency = iterFailable.asDependency(mDft);
109 auto [newStateId, shouldStop] = getNewStateId(newState, stateToIdCallback);
114 "Self loop was added for " << newStateId <<
" and successful trigger of " << dependency->name());
117 ValueType probability = dependency->probability();
118 choice.addProbability(newStateId, probability);
119 STORM_LOG_TRACE(
"Added transition to " << newStateId <<
" with probability " << probability);
125 StateType unsuccessfulStateId = stateToIdCallback(unsuccessfulState);
127 choice.addProbability(unsuccessfulStateId, remainingProbability);
128 STORM_LOG_TRACE(
"Added transition to " << unsuccessfulStateId <<
" with remaining probability " << remainingProbability);
130 "Self loop was added for " << unsuccessfulStateId <<
" and unsuccessful trigger of " << dependency->name());
137 if (!iterFailable.isConflictingDependency()) {
141 if (takeFirstDependency) {
146 STORM_LOG_ASSERT(!exploreDependencies,
"Failure due to dependency should not be possible.");
149 std::shared_ptr<storm::dft::storage::elements::DFTBE<ValueType>
const> nextBE = iterFailable.asBE(mDft);
153 auto [newStateId, shouldStop] = getNewStateId(newState, stateToIdCallback);
157 STORM_LOG_ASSERT(newStateId != this->state->getId(),
"Self loop was added for " << newStateId <<
" and failure of " << nextBE->name());
160 ValueType rate = this->state->getBERate(nextBE->id());
162 choice.addProbability(newStateId, rate);
163 STORM_LOG_TRACE(
"Added transition to " << newStateId <<
" with failure rate " << rate);
168 if (exploreDependencies) {
169 if (result.
empty()) {
171 return exploreState(stateToIdCallback,
false, takeFirstDependency);
174 if (choice.size() == 0) {
181 STORM_LOG_ASSERT(choice.size() > 0,
"At least one choice should have been generated.");
186 STORM_LOG_TRACE(
"Finished exploring state: " << mDft.getStateString(state));
191template<
typename ValueType,
typename StateType>
192std::pair<StateType, bool> DftNextStateGenerator<ValueType, StateType>::getNewStateId(DFTStatePointer newState,
193 StateToIdCallback
const& stateToIdCallback)
const {
194 if (newState->isInvalid() || newState->isTransient()) {
195 STORM_LOG_TRACE(
"State is ignored because " << (newState->isInvalid() ?
"it is invalid" :
"the transient fault is ignored"));
196 return std::make_pair(0,
true);
199 if (newState->hasFailed(mDft.getTopLevelIndex()) && uniqueFailedState) {
201 return std::make_pair(0,
false);
204 return std::make_pair(stateToIdCallback(newState),
false);
208template<
typename ValueType,
typename StateType>
211 bool dependencySuccessful)
const {
213 DFTStatePointer newState = origState->copy();
215 if (dependencySuccessful) {
217 STORM_LOG_TRACE(
"With the successful triggering of PDEP " << dependency->name() <<
" [" << dependency->id() <<
"]" <<
" in "
218 << mDft.getStateString(origState));
219 newState->letDependencyTrigger(dependency,
true);
220 STORM_LOG_ASSERT(dependency->dependentEvents().size() == 1,
"Dependency " << dependency->name() <<
" does not have unique dependent event.");
222 "Trigger event " << dependency->dependentEvents().front()->name() <<
" is not a BE.");
223 auto trigger = std::static_pointer_cast<storm::dft::storage::elements::DFTBE<ValueType>
const>(dependency->dependentEvents().front());
227 STORM_LOG_TRACE(
"With the unsuccessful triggering of PDEP " << dependency->name() <<
" [" << dependency->id() <<
"]" <<
" in "
228 << mDft.getStateString(origState));
229 newState->letDependencyTrigger(dependency,
false);
234template<
typename ValueType,
typename StateType>
238 DFTStatePointer newState = origState->copy();
240 STORM_LOG_TRACE(
"With the failure of " << be->name() <<
" [" << be->id() <<
"]" <<
" in " << mDft.getStateString(origState));
241 newState->letBEFail(be);
250 auto beExp = std::static_pointer_cast<storm::dft::storage::elements::BEExponential<ValueType>
const>(be);
251 if (beExp->isTransient() && !newState->hasFailed(mDft.getTopLevelIndex())) {
252 newState->markAsTransient();
257 bool discardFailSafe =
false;
258 discardFailSafe |= newState->isInvalid();
259 discardFailSafe |= newState->isTransient();
260 discardFailSafe |= (newState->hasFailed(mDft.getTopLevelIndex()) && uniqueFailedState);
263 if (!discardFailSafe) {
267 newState->updateFailableDependencies(be->id());
268 newState->updateDontCareDependencies(be->id());
269 newState->updateFailableInRestrictions(be->id());
274template<
typename ValueType,
typename StateType>
279 for (DFTGatePointer parent : nextBE->parents()) {
280 if (newState->isOperational(parent->id())) {
287 next->checkFails(*newState, queues);
288 newState->updateFailableDependencies(next->id());
289 newState->updateFailableInRestrictions(next->id());
293 for (DFTRestrictionPointer restr : nextBE->restrictions()) {
299 next->checkFails(*newState, queues);
300 newState->updateFailableDependencies(next->id());
301 newState->updateFailableInRestrictions(next->id());
305template<
typename ValueType,
typename StateType>
312 next->checkFailsafe(*newState, queues);
319 next->checkDontCareAnymore(*newState, queues);