6namespace transformations {
11template<
typename ValueType>
16template<
typename ValueType>
18 bool mergeDCFailed,
bool extendPriorities) {
19 this->priorities = priorities;
20 this->dontCareElements = dontCareElements;
22 this->mergedDCFailed = mergeDCFailed;
23 this->dontCarePriority = 1;
24 this->extendedPriorities = extendPriorities;
25 builder.setGspnName(
"DftToGspnTransformation");
28 translateGSPNElements();
34template<
typename ValueType>
36 std::map<uint64_t, uint64_t> priorities;
39 uint64_t dependency_priority = 2;
40 for (std::size_t i = 0; i < mDft.nrElements(); i++) {
42 priorities[i] = dependency_priority;
44 priorities[i] = (-(mDft.getElement(i)->rank()) + mDft.maxRank()) * 2 + 5;
48 u_int64_t maxNrOfChildren = 0;
49 u_int64_t maxNrDependentEvents = 0;
51 std::list<size_t> elementList;
52 for (std::size_t i = 0; i < mDft.nrElements(); i++) {
55 auto dependency = std::static_pointer_cast<storm::dft::storage::elements::DFTDependency<ValueType>
const>(mDft.getElement(i));
56 uint64_t nrDependentEvents = (dependency->dependentEvents()).size();
57 if (nrDependentEvents > maxNrDependentEvents) {
58 maxNrDependentEvents = nrDependentEvents;
63 u_int64_t nrChildren = mDft.getElement(i)->nrChildren();
67 if (maxNrOfChildren < nrChildren) {
68 maxNrOfChildren = nrChildren;
71 if (!elementList.empty()) {
72 std::list<size_t>::iterator it = elementList.begin();
74 while ((mDft.getElement(*it)->rank()) < (mDft.getElement(i)->rank()) ||
78 elementList.insert(it, i);
80 elementList.push_back(i);
85 u_int64_t priorityIntervalLength = std::max(maxNrDependentEvents, maxNrOfChildren) + 4;
89 u_int64_t currentPrio = mDft.nrElements() + priorityIntervalLength;
91 for (std::list<size_t>::iterator it = elementList.begin(); it != elementList.end(); ++it) {
92 priorities[*it] = currentPrio;
93 currentPrio += priorityIntervalLength;
100template<
typename ValueType>
102 STORM_LOG_ASSERT(failedPlaces.size() > mDft.getTopLevelIndex(),
"Failed place for top level element does not exist.");
103 return failedPlaces.at(mDft.getTopLevelIndex());
106template<
typename ValueType>
108 return builder.buildGspn();
111template<
typename ValueType>
114 for (std::size_t i = 0; i < mDft.nrElements(); i++) {
115 auto dftElement = mDft.getElement(i);
118 switch (dftElement->type()) {
149 STORM_LOG_THROW(
false, storm::exceptions::InvalidArgumentException,
"DFT type '" << dftElement->type() <<
"' not known.");
155template<
typename ValueType>
157 switch (dftBE->beType()) {
165 STORM_LOG_THROW(
false, storm::exceptions::InvalidArgumentException,
"BE type '" << dftBE->beType() <<
"' not known.");
170template<
typename ValueType>
172 double xcenter = mDft.getElementLayoutInfo(dftBE->id()).x;
173 double ycenter = mDft.getElementLayoutInfo(dftBE->id()).y;
177 uint64_t activePlace = builder.addPlace(
defaultCapacity, isActiveInitially(dftBE) ? 1 : 0, dftBE->name() + STR_ACTIVATED);
178 activePlaces.emplace(dftBE->id(), activePlace);
180 uint64_t tActive = builder.addTimedTransition(getFailPriority(dftBE), dftBE->activeFailureRate(), dftBE->name() +
"_activeFailing");
182 builder.addInputArc(activePlace, tActive);
183 builder.addInhibitionArc(failedPlace, tActive);
184 builder.addOutputArc(tActive, activePlace);
185 builder.addOutputArc(tActive, failedPlace);
187 uint64_t tPassive = builder.addTimedTransition(getFailPriority(dftBE), dftBE->passiveFailureRate(), dftBE->name() +
"_passiveFailing");
189 builder.addInhibitionArc(activePlace, tPassive);
190 builder.addInhibitionArc(failedPlace, tPassive);
191 builder.addOutputArc(tPassive, failedPlace);
193 if (dontCareElements.count(dftBE->id()) && dftBE->id() != mDft.getTopLevelIndex()) {
195 if (!mergedDCFailed) {
196 uint64_t dontCarePlace = builder.addPlace(1, 0, dftBE->name() + STR_DONTCARE);
198 builder.addInhibitionArc(dontCarePlace, tDontCare);
199 builder.addOutputArc(tDontCare, dontCarePlace);
201 builder.addInhibitionArc(dontCarePlace, tActive);
202 builder.addInhibitionArc(dontCarePlace, tPassive);
205 if (!smart || dftBE->hasIngoingDependencies()) {
206 uint64_t dependencyPropagationPlace = builder.addPlace(1, 0, dftBE->name() +
"_dependency_prop");
207 dependencyPropagationPlaces.emplace(dftBE->id(), dependencyPropagationPlace);
208 builder.setPlaceLayoutInfo(dependencyPropagationPlace,
storm::gspn::LayoutInfo(xcenter + 10.0, ycenter - 5.0));
209 uint64_t tPropagationFailed = builder.addImmediateTransition(dontCarePriority, 0.0, dftBE->name() +
"_prop_fail");
211 builder.addInhibitionArc(dependencyPropagationPlace, tPropagationFailed);
212 builder.addInputArc(failedPlace, tPropagationFailed);
213 builder.addOutputArc(tPropagationFailed, failedPlace);
214 builder.addOutputArc(tPropagationFailed, dependencyPropagationPlace);
215 uint64_t tPropagationDontCare = builder.addImmediateTransition(dontCarePriority, 0.0, dftBE->name() +
"_prop_dontCare");
217 builder.addInhibitionArc(dependencyPropagationPlace, tPropagationDontCare);
218 builder.addInputArc(dependencyPropagationPlace, tPropagationDontCare);
219 builder.addOutputArc(tPropagationDontCare, dontCarePlace);
220 builder.addOutputArc(tPropagationDontCare, dependencyPropagationPlace);
223 builder.addInhibitionArc(failedPlace, tDontCare);
224 builder.addOutputArc(tDontCare, failedPlace);
228 if (!smart || dftBE->nrRestrictions() > 0) {
230 builder.addInhibitionArc(disabledPlace, tActive);
231 builder.addInhibitionArc(disabledPlace, tPassive);
234 if (!smart || mDft.isRepresentative(dftBE->id())) {
236 builder.addOutputArc(tActive, unavailablePlace);
237 builder.addOutputArc(tPassive, unavailablePlace);
240 if (extendedPriorities)
244template<
typename ValueType>
246 double xcenter = mDft.getElementLayoutInfo(dftConst->id()).x;
247 double ycenter = mDft.getElementLayoutInfo(dftConst->id()).y;
249 if (dftConst->failed()) {
253 if (!smart || mDft.isRepresentative(dftConst->id())) {
259 uint64_t failedPlace = builder.addPlace(capacity, 0, dftConst->name() + STR_FAILED);
260 assert(failedPlaces.size() == dftConst->id());
261 failedPlaces.push_back(failedPlace);
264 if (!smart || mDft.isRepresentative(dftConst->id())) {
265 uint64_t unavailablePlace = builder.addPlace(capacity, 0, dftConst->name() +
"_unavail");
266 unavailablePlaces.emplace(dftConst->id(), unavailablePlace);
272template<
typename ValueType>
274 double xcenter = mDft.getElementLayoutInfo(dftAnd->id()).x;
275 double ycenter = mDft.getElementLayoutInfo(dftAnd->id()).y;
279 uint64_t tFailed = builder.addImmediateTransition(getFailPriority(dftAnd), 0.0, dftAnd->name() + STR_FAILING);
281 builder.addInhibitionArc(failedPlace, tFailed);
282 builder.addOutputArc(tFailed, failedPlace);
284 if (dontCareElements.count(dftAnd->id())) {
285 if (dftAnd->id() != mDft.getTopLevelIndex()) {
287 if (!mergedDCFailed) {
288 uint64_t dontCarePlace = builder.addPlace(1, 0, dftAnd->name() + STR_DONTCARE);
290 builder.addInhibitionArc(dontCarePlace, tDontCare);
291 builder.addOutputArc(tDontCare, dontCarePlace);
293 uint64_t propagationPlace = builder.addPlace(1, 0, dftAnd->name() +
"_prop");
295 uint64_t tPropagationFailed = builder.addImmediateTransition(dontCarePriority, 0.0, dftAnd->name() +
"_prop_fail");
297 builder.addInhibitionArc(propagationPlace, tPropagationFailed);
298 builder.addInputArc(failedPlace, tPropagationFailed);
299 builder.addOutputArc(tPropagationFailed, failedPlace);
300 builder.addOutputArc(tPropagationFailed, propagationPlace);
301 uint64_t tPropagationDontCare = builder.addImmediateTransition(dontCarePriority, 0.0, dftAnd->name() +
"_prop_dontCare");
303 builder.addInhibitionArc(propagationPlace, tPropagationDontCare);
304 builder.addInputArc(dontCarePlace, tPropagationDontCare);
305 builder.addOutputArc(tPropagationDontCare, dontCarePlace);
306 builder.addOutputArc(tPropagationDontCare, propagationPlace);
307 for (
auto const &child : dftAnd->children()) {
308 if (dontCareElements.count(child->id())) {
309 u_int64_t childDontCare = dontcareTransitions.at(child->id());
310 builder.addInputArc(propagationPlace, childDontCare);
311 builder.addOutputArc(childDontCare, propagationPlace);
315 builder.addInhibitionArc(failedPlace, tDontCare);
316 builder.addOutputArc(tDontCare, failedPlace);
317 for (
auto const &child : dftAnd->children()) {
318 if (dontCareElements.count(child->id())) {
319 u_int64_t childDontCare = dontcareTransitions.at(child->id());
320 builder.addInputArc(failedPlace, childDontCare);
321 builder.addOutputArc(childDontCare, failedPlace);
327 for (
auto const &child : dftAnd->children()) {
328 if (dontCareElements.count(child->id())) {
329 u_int64_t childDontCare = dontcareTransitions.at(child->id());
330 builder.addInputArc(failedPlace, childDontCare);
331 builder.addOutputArc(childDontCare, failedPlace);
337 if (!smart || mDft.isRepresentative(dftAnd->id())) {
338 uint64_t unavailablePlace = addUnavailablePlace(dftAnd,
storm::gspn::LayoutInfo(xcenter + 6.0, ycenter - 3.0));
339 builder.addOutputArc(tFailed, unavailablePlace);
342 for (
auto const &child : dftAnd->children()) {
343 builder.addInputArc(getFailedPlace(child), tFailed);
344 builder.addOutputArc(tFailed, getFailedPlace(child));
346 if (extendedPriorities)
350template<
typename ValueType>
352 double xcenter = mDft.getElementLayoutInfo(dftOr->id()).x;
353 double ycenter = mDft.getElementLayoutInfo(dftOr->id()).y;
357 if (dontCareElements.count(dftOr->id())) {
358 if (dftOr->id() != mDft.getTopLevelIndex()) {
360 if (!mergedDCFailed) {
361 uint64_t dontCarePlace = builder.addPlace(1, 0, dftOr->name() + STR_DONTCARE);
363 builder.addInhibitionArc(dontCarePlace, tDontCare);
364 builder.addOutputArc(tDontCare, dontCarePlace);
366 uint64_t propagationPlace = builder.addPlace(1, 0, dftOr->name() +
"_prop");
368 uint64_t tPropagationFailed = builder.addImmediateTransition(dontCarePriority, 0.0, dftOr->name() +
"_prop_fail");
370 builder.addInhibitionArc(propagationPlace, tPropagationFailed);
371 builder.addInputArc(failedPlace, tPropagationFailed);
372 builder.addOutputArc(tPropagationFailed, failedPlace);
373 builder.addOutputArc(tPropagationFailed, propagationPlace);
374 uint64_t tPropagationDontCare = builder.addImmediateTransition(dontCarePriority, 0.0, dftOr->name() +
"_prop_dontCare");
376 builder.addInhibitionArc(propagationPlace, tPropagationDontCare);
377 builder.addInputArc(dontCarePlace, tPropagationDontCare);
378 builder.addOutputArc(tPropagationDontCare, dontCarePlace);
379 builder.addOutputArc(tPropagationDontCare, propagationPlace);
380 for (
auto const &child : dftOr->children()) {
381 if (dontCareElements.count(child->id())) {
382 u_int64_t childDontCare = dontcareTransitions.at(child->id());
383 builder.addInputArc(propagationPlace, childDontCare);
384 builder.addOutputArc(childDontCare, propagationPlace);
388 builder.addInhibitionArc(failedPlace, tDontCare);
389 builder.addOutputArc(tDontCare, failedPlace);
390 for (
auto const &child : dftOr->children()) {
391 if (dontCareElements.count(child->id())) {
392 u_int64_t childDontCare = dontcareTransitions.at(child->id());
393 builder.addInputArc(failedPlace, childDontCare);
394 builder.addOutputArc(childDontCare, failedPlace);
400 for (
auto const &child : dftOr->children()) {
401 if (dontCareElements.count(child->id())) {
402 u_int64_t childDontCare = dontcareTransitions.at(child->id());
403 builder.addInputArc(failedPlace, childDontCare);
404 builder.addOutputArc(childDontCare, failedPlace);
410 bool isRepresentative = mDft.isRepresentative(dftOr->id());
411 uint64_t unavailablePlace = 0;
412 if (!smart || isRepresentative) {
416 for (
size_t i = 0;
i < dftOr->nrChildren(); ++
i) {
417 auto const &child = dftOr->children().at(i);
418 uint64_t tFailed = 0;
419 if (extendedPriorities)
420 tFailed = builder.addImmediateTransition(getFailPriority(dftOr) + i, 0.0, dftOr->name() + STR_FAILING + std::to_string(i));
422 tFailed = builder.addImmediateTransition(getFailPriority(dftOr), 0.0, dftOr->name() + STR_FAILING + std::to_string(i));
424 builder.addInhibitionArc(failedPlace, tFailed);
425 builder.addOutputArc(tFailed, failedPlace);
426 if (!smart || isRepresentative) {
427 builder.addOutputArc(tFailed, unavailablePlace);
429 builder.addInputArc(getFailedPlace(child), tFailed);
430 builder.addOutputArc(tFailed, getFailedPlace(child));
432 if (extendedPriorities)
436template<
typename ValueType>
440 double xcenter = mDft.getElementLayoutInfo(dftVot->id()).x;
441 double ycenter = mDft.getElementLayoutInfo(dftVot->id()).y;
445 uint64_t tFailed = builder.addImmediateTransition(getFailPriority(dftVot), 0.0, dftVot->name() + STR_FAILING);
446 builder.addOutputArc(tFailed, failedPlace);
447 builder.addInhibitionArc(failedPlace, tFailed);
449 if (!smart || mDft.isRepresentative(dftVot->id())) {
450 uint64_t unavailablePlace = addUnavailablePlace(dftVot,
storm::gspn::LayoutInfo(xcenter + 6.0, ycenter - 3.0));
451 builder.addOutputArc(tFailed, unavailablePlace);
454 uint64_t collectorPlace = builder.addPlace(dftVot->nrChildren(), 0, dftVot->name() +
"_collector");
456 builder.addInputArc(collectorPlace, tFailed, dftVot->threshold());
458 for (
size_t i = 0;
i < dftVot->nrChildren(); ++
i) {
459 auto const &child = dftVot->children().at(i);
460 uint64_t childNextPlace = builder.addPlace(
defaultCapacity, 1, dftVot->name() +
"_child_next" + std::to_string(i));
462 if (extendedPriorities)
463 tCollect = builder.addImmediateTransition(getFailPriority(dftVot) + i, 0.0, dftVot->name() +
"_child_collect" + std::to_string(i));
465 tCollect = builder.addImmediateTransition(getFailPriority(dftVot), 0.0, dftVot->name() +
"_child_collect" + std::to_string(i));
466 builder.addOutputArc(tCollect, collectorPlace);
467 builder.addInputArc(childNextPlace, tCollect);
468 builder.addInputArc(getFailedPlace(child), tCollect);
469 builder.addOutputArc(tCollect, getFailedPlace(child));
472 if (dontCareElements.count(dftVot->id())) {
473 if (dftVot->id() != mDft.getTopLevelIndex()) {
475 if (!mergedDCFailed) {
476 uint64_t dontCarePlace = builder.addPlace(1, 0, dftVot->name() + STR_DONTCARE);
478 builder.addInhibitionArc(dontCarePlace, tDontCare);
479 builder.addOutputArc(tDontCare, dontCarePlace);
481 uint64_t propagationPlace = builder.addPlace(1, 0, dftVot->name() +
"_prop");
483 uint64_t tPropagationFailed = builder.addImmediateTransition(dontCarePriority, 0.0, dftVot->name() +
"_prop_fail");
485 builder.addInhibitionArc(propagationPlace, tPropagationFailed);
486 builder.addInputArc(failedPlace, tPropagationFailed);
487 builder.addOutputArc(tPropagationFailed, failedPlace);
488 builder.addOutputArc(tPropagationFailed, propagationPlace);
489 uint64_t tPropagationDontCare = builder.addImmediateTransition(dontCarePriority, 0.0, dftVot->name() +
"_prop_dontCare");
491 builder.addInhibitionArc(propagationPlace, tPropagationDontCare);
492 builder.addInputArc(dontCarePlace, tPropagationDontCare);
493 builder.addOutputArc(tPropagationDontCare, dontCarePlace);
494 builder.addOutputArc(tPropagationDontCare, propagationPlace);
495 for (
auto const &child : dftVot->children()) {
496 if (dontCareElements.count(child->id())) {
497 u_int64_t childDontCare = dontcareTransitions.at(child->id());
498 builder.addInputArc(propagationPlace, childDontCare);
499 builder.addOutputArc(childDontCare, propagationPlace);
503 builder.addInhibitionArc(failedPlace, tDontCare);
504 builder.addOutputArc(tDontCare, failedPlace);
505 for (
auto const &child : dftVot->children()) {
506 if (dontCareElements.count(child->id())) {
507 u_int64_t childDontCare = dontcareTransitions.at(child->id());
508 builder.addInputArc(failedPlace, childDontCare);
509 builder.addOutputArc(childDontCare, failedPlace);
515 for (
auto const &child : dftVot->children()) {
516 if (dontCareElements.count(child->id())) {
517 u_int64_t childDontCare = dontcareTransitions.at(child->id());
518 builder.addInputArc(failedPlace, childDontCare);
519 builder.addOutputArc(childDontCare, failedPlace);
524 if (extendedPriorities)
528template<
typename ValueType>
531 double xcenter = mDft.getElementLayoutInfo(dftPand->id()).x;
532 double ycenter = mDft.getElementLayoutInfo(dftPand->id()).y;
537 uint64_t tFailed = builder.addImmediateTransition(
538 getFailPriority(dftPand) - 1, 0.0, dftPand->name() + STR_FAILING);
540 builder.addInhibitionArc(failedPlace, tFailed);
541 builder.addOutputArc(tFailed, failedPlace);
543 if (!smart || mDft.isRepresentative(dftPand->id())) {
544 uint64_t unavailablePlace = addUnavailablePlace(dftPand,
storm::gspn::LayoutInfo(xcenter + 9.0, ycenter - 3.0));
545 builder.addOutputArc(tFailed, unavailablePlace);
548 uint64_t failSafePlace = builder.addPlace(
defaultCapacity, 0, dftPand->name() + STR_FAILSAVE);
551 builder.addInhibitionArc(failSafePlace, tFailed);
554 for (
auto const &child : dftPand->children()) {
555 builder.addInputArc(getFailedPlace(child), tFailed);
556 builder.addOutputArc(tFailed, getFailedPlace(child));
559 for (uint64_t i = 1;
i < dftPand->nrChildren(); ++
i) {
560 auto const &child = dftPand->children().at(i);
561 uint64_t tFailSafe = builder.addImmediateTransition(getFailPriority(dftPand), 0.0, dftPand->name() + STR_FAILSAVING + std::to_string(i));
565 builder.addInputArc(getFailedPlace(child), tFailSafe);
566 builder.addOutputArc(tFailSafe, getFailedPlace(child));
567 builder.addInhibitionArc(getFailedPlace(dftPand->children().at(i - 1)), tFailSafe);
568 builder.addOutputArc(tFailSafe, failSafePlace);
569 builder.addInhibitionArc(failSafePlace, tFailSafe);
572 auto const &previousChild = dftPand->children().at(i - 1);
573 uint64_t delayPlace = builder.addPlace(1, 0, dftPand->name() +
"_delay_" + previousChild->name());
576 uint64_t tDelay = builder.addImmediateTransition(getFailPriority(dftPand) - 1, 0.0, child->name() +
"_" + dftPand->name() +
"_delayTransition");
577 builder.setTransitionLayoutInfo(tDelay,
storm::gspn::LayoutInfo(xcenter - 5.0 + (i - 1) * 3.0, ycenter + 3.0));
578 builder.addInputArc(getFailedPlace(previousChild), tDelay);
579 builder.addOutputArc(tDelay, getFailedPlace(dftPand->children().at(i - 1)));
580 builder.addOutputArc(tDelay, delayPlace);
581 builder.addInhibitionArc(delayPlace, tDelay);
583 builder.addInputArc(getFailedPlace(child), tFailSafe);
584 builder.addOutputArc(tFailSafe, getFailedPlace(child));
585 builder.addInhibitionArc(delayPlace, tFailSafe);
586 builder.addOutputArc(tFailSafe, failSafePlace);
587 builder.addInhibitionArc(failSafePlace, tFailSafe);
591 if (dontCareElements.count(dftPand->id())) {
593 uint64_t propagationPlace = builder.addPlace(1, 0, dftPand->name() +
"_prop");
595 uint64_t tPropagationFailed = builder.addImmediateTransition(dontCarePriority, 0.0, dftPand->name() +
"_prop_fail");
597 uint64_t tPropagationFailsafe = builder.addImmediateTransition(dontCarePriority, 0.0, dftPand->name() +
"_prop_failsafe");
599 builder.addInhibitionArc(propagationPlace, tPropagationFailed);
600 builder.addInputArc(failedPlace, tPropagationFailed);
601 builder.addOutputArc(tPropagationFailed, failedPlace);
602 builder.addOutputArc(tPropagationFailed, propagationPlace);
604 builder.addInhibitionArc(propagationPlace, tPropagationFailsafe);
605 builder.addInputArc(failSafePlace, tPropagationFailsafe);
606 builder.addOutputArc(tPropagationFailsafe, failSafePlace);
607 builder.addOutputArc(tPropagationFailsafe, propagationPlace);
610 for (
auto const &child : dftPand->children()) {
611 if (dontCareElements.count(child->id())) {
612 u_int64_t childDontCare = dontcareTransitions.at(child->id());
613 builder.addInputArc(propagationPlace, childDontCare);
614 builder.addOutputArc(childDontCare, propagationPlace);
618 if (dftPand->id() != mDft.getTopLevelIndex()) {
620 if (!mergedDCFailed) {
621 uint64_t dontCarePlace = builder.addPlace(1, 0, dftPand->name() + STR_DONTCARE);
623 builder.addInhibitionArc(dontCarePlace, tDontCare);
624 builder.addOutputArc(tDontCare, dontCarePlace);
625 uint64_t tPropagationDontCare = builder.addImmediateTransition(dontCarePriority, 0.0, dftPand->name() +
"_prop_dontCare");
627 builder.addInhibitionArc(propagationPlace, tPropagationDontCare);
628 builder.addInputArc(dontCarePlace, tPropagationDontCare);
629 builder.addOutputArc(tPropagationDontCare, dontCarePlace);
630 builder.addOutputArc(tPropagationDontCare, propagationPlace);
633 builder.addInhibitionArc(failedPlace, tDontCare);
634 builder.addOutputArc(tDontCare, failedPlace);
638 if (extendedPriorities)
642template<
typename ValueType>
644 double xcenter = mDft.getElementLayoutInfo(dftPor->id()).x;
645 double ycenter = mDft.getElementLayoutInfo(dftPor->id()).y;
647 uint64_t delayPlace = 0;
652 uint64_t tFailed = builder.addImmediateTransition(
653 getFailPriority(dftPor) - 1, 0.0, dftPor->name() + STR_FAILING);
655 builder.addOutputArc(tFailed, failedPlace);
656 builder.addInhibitionArc(failedPlace, tFailed);
659 builder.addInputArc(getFailedPlace(dftPor->children().front()), tFailed);
660 builder.addOutputArc(tFailed, getFailedPlace(dftPor->children().front()));
662 if (!smart || mDft.isRepresentative(dftPor->id())) {
663 uint64_t unavailablePlace = addUnavailablePlace(dftPor,
storm::gspn::LayoutInfo(xcenter + 9.0, ycenter - 3.0));
664 builder.addOutputArc(tFailed, unavailablePlace);
667 uint64_t failSafePlace = builder.addPlace(
defaultCapacity, 0, dftPor->name() + STR_FAILSAVE);
670 builder.addInhibitionArc(failSafePlace, tFailed);
674 delayPlace = builder.addPlace(1, 0, dftPor->name() +
"_delay");
678 uint64_t tDelay = builder.addImmediateTransition(getFailPriority(dftPor) - 1, 0.0, dftPor->name() +
"_delayTransition");
681 builder.addInputArc(getFailedPlace(dftPor->children().front()), tDelay);
682 builder.addOutputArc(tDelay, getFailedPlace(dftPor->children().front()));
683 builder.addOutputArc(tDelay, delayPlace);
684 builder.addInhibitionArc(delayPlace, tDelay);
688 for (
size_t i = 1;
i < dftPor->nrChildren(); ++
i) {
689 auto const &child = dftPor->children().at(i);
690 uint64_t tFailSafe = builder.addImmediateTransition(getFailPriority(dftPor), 0.0, dftPor->name() + STR_FAILSAVING + std::to_string(i));
693 builder.addInputArc(getFailedPlace(child), tFailSafe);
694 builder.addOutputArc(tFailSafe, getFailedPlace(child));
695 builder.addOutputArc(tFailSafe, failSafePlace);
696 builder.addInhibitionArc(failSafePlace, tFailSafe);
698 builder.addInhibitionArc(getFailedPlace(dftPor->children().front()), tFailSafe);
700 builder.addInhibitionArc(delayPlace, tFailSafe);
705 if (dontCareElements.count(dftPor->id())) {
707 uint64_t propagationPlace = builder.addPlace(1, 0, dftPor->name() +
"_prop");
709 uint64_t tPropagationFailed = builder.addImmediateTransition(dontCarePriority, 0.0, dftPor->name() +
"_prop_fail");
711 uint64_t tPropagationFailsafe = builder.addImmediateTransition(dontCarePriority, 0.0, dftPor->name() +
"_prop_failsafe");
713 builder.addInhibitionArc(propagationPlace, tPropagationFailed);
714 builder.addInputArc(failedPlace, tPropagationFailed);
715 builder.addOutputArc(tPropagationFailed, failedPlace);
716 builder.addOutputArc(tPropagationFailed, propagationPlace);
718 builder.addInhibitionArc(propagationPlace, tPropagationFailsafe);
719 builder.addInputArc(failSafePlace, tPropagationFailsafe);
720 builder.addOutputArc(tPropagationFailsafe, failSafePlace);
721 builder.addOutputArc(tPropagationFailsafe, propagationPlace);
724 for (
auto const &child : dftPor->children()) {
725 if (dontCareElements.count(child->id())) {
726 u_int64_t childDontCare = dontcareTransitions.at(child->id());
727 builder.addInputArc(propagationPlace, childDontCare);
728 builder.addOutputArc(childDontCare, propagationPlace);
732 if (dftPor->id() != mDft.getTopLevelIndex()) {
734 if (!mergedDCFailed) {
735 uint64_t dontCarePlace = builder.addPlace(1, 0, dftPor->name() + STR_DONTCARE);
737 builder.addInhibitionArc(dontCarePlace, tDontCare);
738 builder.addOutputArc(tDontCare, dontCarePlace);
739 uint64_t tPropagationDontCare = builder.addImmediateTransition(dontCarePriority, 0.0, dftPor->name() +
"_prop_dontCare");
741 builder.addInhibitionArc(propagationPlace, tPropagationDontCare);
742 builder.addInputArc(dontCarePlace, tPropagationDontCare);
743 builder.addOutputArc(tPropagationDontCare, dontCarePlace);
744 builder.addOutputArc(tPropagationDontCare, propagationPlace);
747 builder.addInhibitionArc(failedPlace, tDontCare);
748 builder.addOutputArc(tDontCare, failedPlace);
752 if (extendedPriorities)
756template<
typename ValueType>
758 double xcenter = mDft.getElementLayoutInfo(dftSpare->id()).x;
759 double ycenter = mDft.getElementLayoutInfo(dftSpare->id()).y;
761 u_int64_t prio = getFailPriority(dftSpare);
765 bool isRepresentative = mDft.isRepresentative(dftSpare->id());
766 uint64_t unavailablePlace = 0;
767 if (!smart || isRepresentative) {
771 uint64_t activePlace = builder.addPlace(
defaultCapacity, isActiveInitially(dftSpare) ? 1 : 0, dftSpare->name() + STR_ACTIVATED);
773 activePlaces.emplace(dftSpare->id(), activePlace);
775 std::vector<uint64_t> tNextClaims;
776 std::vector<uint64_t> tNextConsiders;
777 for (
size_t i = 0;
i < dftSpare->nrChildren(); ++
i) {
778 auto const &child = dftSpare->children().at(i);
780 size_t considerPlace = builder.addPlace(
defaultCapacity, i == 0 ? 1 : 0, dftSpare->name() +
"_consider_" + child->name());
785 builder.addOutputArc(tNextClaims.back(), considerPlace);
787 builder.addOutputArc(tNextConsiders.back(), considerPlace);
791 uint64_t tConsiderNext = builder.addImmediateTransition(prio, 0.0, dftSpare->name() +
"_cannot_claim_" + child->name());
793 builder.setTransitionLayoutInfo(tConsiderNext,
storm::gspn::LayoutInfo(xcenter - 7.0 + i * 14.0, ycenter - 8.0));
794 builder.addInputArc(considerPlace, tConsiderNext);
795 builder.addInputArc(unavailablePlaces.at(child->id()), tConsiderNext);
796 builder.addOutputArc(tConsiderNext, unavailablePlaces.at(child->id()));
797 tNextConsiders.push_back(tConsiderNext);
800 size_t claimedPlace = builder.addPlace(
defaultCapacity, 0, dftSpare->name() +
"_claimed_" + child->name());
802 uint64_t tClaim = builder.addImmediateTransition(prio, 0.0, dftSpare->name() +
"_claim_" + child->name());
805 builder.addInhibitionArc(unavailablePlaces.at(child->id()), tClaim);
806 builder.addInputArc(considerPlace, tClaim);
807 builder.addOutputArc(tClaim, claimedPlace);
808 builder.addOutputArc(tClaim, unavailablePlaces.at(child->id()));
811 uint64_t tClaimNext = builder.addImmediateTransition(prio, 0.0, dftSpare->name() +
"_next_claim_" + std::to_string(i));
814 builder.addInputArc(claimedPlace, tClaimNext);
815 builder.addInputArc(getFailedPlace(child), tClaimNext);
816 builder.addOutputArc(tClaimNext, getFailedPlace(child));
817 tNextClaims.push_back(tClaimNext);
821 for (uint64_t k : mDft.module(child->id()).getElements()) {
822 uint64_t tActivate = builder.addImmediateTransition(prio, 0.0, dftSpare->name() +
"_activate_" + std::to_string(i) +
"_" + std::to_string(k));
824 builder.setTransitionLayoutInfo(tActivate,
storm::gspn::LayoutInfo(xcenter - 18.0 + (i + l) * 3, ycenter - 12.0));
825 builder.addInhibitionArc(activePlaces.at(k), tActivate);
826 builder.addInputArc(claimedPlace, tActivate);
827 builder.addInputArc(activePlace, tActivate);
828 builder.addOutputArc(tActivate, claimedPlace);
829 builder.addOutputArc(tActivate, activePlace);
830 builder.addOutputArc(tActivate, activePlaces.at(k));
836 builder.addOutputArc(tNextConsiders.back(), failedPlace);
837 builder.addOutputArc(tNextClaims.back(), failedPlace);
838 builder.addInhibitionArc(failedPlace, tNextConsiders.back());
839 builder.addInhibitionArc(failedPlace, tNextClaims.back());
842 if (dontCareElements.count(dftSpare->id())) {
843 if (dftSpare->id() != mDft.getTopLevelIndex()) {
845 if (!mergedDCFailed) {
846 uint64_t dontCarePlace = builder.addPlace(1, 0, dftSpare->name() + STR_DONTCARE);
848 builder.addInhibitionArc(dontCarePlace, tDontCare);
849 builder.addOutputArc(tDontCare, dontCarePlace);
851 uint64_t propagationPlace = builder.addPlace(1, 0, dftSpare->name() +
"_prop");
853 uint64_t tPropagationFailed = builder.addImmediateTransition(dontCarePriority, 0.0, dftSpare->name() +
"_prop_fail");
855 builder.addInhibitionArc(propagationPlace, tPropagationFailed);
856 builder.addInputArc(failedPlace, tPropagationFailed);
857 builder.addOutputArc(tPropagationFailed, failedPlace);
858 builder.addOutputArc(tPropagationFailed, propagationPlace);
859 uint64_t tPropagationDontCare = builder.addImmediateTransition(dontCarePriority, 0.0, dftSpare->name() +
"_prop_dontCare");
861 builder.addInhibitionArc(propagationPlace, tPropagationDontCare);
862 builder.addInputArc(dontCarePlace, tPropagationDontCare);
863 builder.addOutputArc(tPropagationDontCare, dontCarePlace);
864 builder.addOutputArc(tPropagationDontCare, propagationPlace);
865 for (
auto const &child : dftSpare->children()) {
866 if (dontCareElements.count(child->id())) {
867 u_int64_t childDontCare = dontcareTransitions.at(child->id());
868 builder.addInputArc(propagationPlace, childDontCare);
869 builder.addOutputArc(childDontCare, propagationPlace);
873 builder.addInhibitionArc(failedPlace, tDontCare);
874 builder.addOutputArc(tDontCare, failedPlace);
875 for (
auto const &child : dftSpare->children()) {
876 if (dontCareElements.count(child->id())) {
877 u_int64_t childDontCare = dontcareTransitions.at(child->id());
878 builder.addInputArc(failedPlace, childDontCare);
879 builder.addOutputArc(childDontCare, failedPlace);
885 for (
auto const &child : dftSpare->children()) {
886 if (dontCareElements.count(child->id())) {
887 u_int64_t childDontCare = dontcareTransitions.at(child->id());
888 builder.addInputArc(failedPlace, childDontCare);
889 builder.addOutputArc(childDontCare, failedPlace);
895 if (!smart || isRepresentative) {
896 builder.addOutputArc(tNextConsiders.back(), unavailablePlace);
897 builder.addOutputArc(tNextClaims.back(), unavailablePlace);
899 if (extendedPriorities)
903template<
typename ValueType>
905 double xcenter = mDft.getElementLayoutInfo(dftDependency->id()).x;
906 double ycenter = mDft.getElementLayoutInfo(dftDependency->id()).y;
908 uint64_t failedPlace = 0;
914 uint64_t forwardPlace = 0;
915 if (dftDependency->probability() < 1.0) {
917 forwardPlace = builder.addPlace(
defaultCapacity, 0, dftDependency->name() +
"_forward");
920 uint64_t coinPlace = builder.addPlace(
defaultCapacity, 1, dftDependency->name() +
"_coin");
923 uint64_t tStartFlip = builder.addImmediateTransition(getFailPriority(dftDependency), 0.0, dftDependency->name() +
"_start_flip");
924 builder.addInputArc(coinPlace, tStartFlip);
925 builder.addInputArc(getFailedPlace(dftDependency->triggerEvent()), tStartFlip);
926 builder.addOutputArc(tStartFlip, getFailedPlace(dftDependency->triggerEvent()));
928 uint64_t flipPlace = builder.addPlace(
defaultCapacity, 0, dftDependency->name() +
"_flip");
930 builder.addOutputArc(tStartFlip, flipPlace);
933 builder.addImmediateTransition(getFailPriority(dftDependency) + 1, dftDependency->probability(), dftDependency->name() +
"_win_flip");
934 builder.addInputArc(flipPlace, tWinFlip);
935 builder.addOutputArc(tWinFlip, forwardPlace);
937 uint64_t tLooseFlip = builder.addImmediateTransition(
938 getFailPriority(dftDependency) + 1, storm::utility::one<ValueType>() - dftDependency->probability(), dftDependency->name() +
"_lose_flip");
939 builder.addInputArc(flipPlace, tLooseFlip);
942 forwardPlace = getFailedPlace(dftDependency->triggerEvent());
946 uint64_t propagationPriority = getFailPriority(dftDependency);
947 for (
auto const &child : dftDependency->dependentEvents()) {
948 uint64_t tForwardFailure = builder.addImmediateTransition(propagationPriority, 0.0, dftDependency->name() +
"_propagate_" + child->name());
950 builder.addInputArc(forwardPlace, tForwardFailure);
951 builder.addOutputArc(tForwardFailure, forwardPlace);
952 builder.addOutputArc(tForwardFailure, getFailedPlace(child));
953 builder.addInhibitionArc(getFailedPlace(child), tForwardFailure);
954 if (!smart || child->nrRestrictions() > 0) {
955 builder.addInhibitionArc(disabledPlaces.at(child->id()), tForwardFailure);
957 if (!smart || mDft.isRepresentative(child->id())) {
958 builder.addOutputArc(tForwardFailure, unavailablePlaces.at(child->id()));
960 propagationPriority--;
964 if (dontCareElements.count(dftDependency->id())) {
966 if (!mergedDCFailed) {
967 u_int64_t dontCarePlace = builder.addPlace(1, 0, dftDependency->name() + STR_DONTCARE);
969 builder.addInhibitionArc(dontCarePlace, tDontCare);
970 builder.addOutputArc(tDontCare, dontCarePlace);
972 for (
auto const &dependentEvent : dftDependency->dependentEvents()) {
973 if (dontCareElements.count(dependentEvent->id())) {
974 u_int64_t dependentEventPropagation = dependencyPropagationPlaces.at(dependentEvent->id());
975 builder.addInputArc(dependentEventPropagation, tDontCare);
976 builder.addOutputArc(tDontCare, dependentEventPropagation);
980 uint64_t triggerDontCare = dontcareTransitions.at(dftDependency->triggerEvent()->id());
981 builder.addInputArc(dontCarePlace, triggerDontCare);
982 builder.addOutputArc(triggerDontCare, dontCarePlace);
984 if (failedPlace == 0) {
987 builder.addInhibitionArc(failedPlace, tDontCare);
988 builder.addOutputArc(tDontCare, failedPlace);
991 for (
auto const &dependentEvent : dftDependency->dependentEvents()) {
992 if (dontCareElements.count(dependentEvent->id())) {
993 u_int64_t dependentEventFailed = failedPlaces.at(dependentEvent->id());
994 builder.addInputArc(dependentEventFailed, tDontCare);
995 builder.addOutputArc(tDontCare, dependentEventFailed);
999 uint64_t triggerDontCare = dontcareTransitions.at(dftDependency->triggerEvent()->id());
1000 builder.addInputArc(failedPlace, triggerDontCare);
1001 builder.addOutputArc(triggerDontCare, failedPlace);
1004 if (failedPlace == 0) {
1005 failedPlaces.push_back(failedPlace);
1007 if (extendedPriorities)
1011template<
typename ValueType>
1013 STORM_LOG_THROW(dftSeq->allChildrenBEs(), storm::exceptions::NotImplementedException,
1014 "Sequence enforcers with gates as children are currently not supported");
1015 double xcenter = mDft.getElementLayoutInfo(dftSeq->id()).x;
1016 double ycenter = mDft.getElementLayoutInfo(dftSeq->id()).y;
1017 u_int64_t failedPlace = 0;
1023 uint64_t tEnable = 0;
1024 uint64_t nextPlace = 0;
1025 for (
size_t i = 0;
i < dftSeq->nrChildren(); ++
i) {
1026 auto const &child = dftSeq->children().at(i);
1028 nextPlace = builder.addPlace(
defaultCapacity, i == 0 ? 1 : 0, dftSeq->name() +
"_next_" + child->name());
1032 builder.addOutputArc(tEnable, nextPlace);
1034 tEnable = builder.addImmediateTransition(getFailPriority(dftSeq), 0.0, dftSeq->name() +
"_unblock_" + child->name());
1036 builder.addInputArc(nextPlace, tEnable);
1037 builder.addInputArc(disabledPlaces.at(child->id()), tEnable);
1039 builder.addInputArc(getFailedPlace(dftSeq->children().at(i - 1)), tEnable);
1043 if (dontCareElements.count(dftSeq->id())) {
1044 if (!mergedDCFailed) {
1045 u_int64_t dontCarePlace = builder.addPlace(1, 0, dftSeq->name() + STR_DONTCARE);
1047 for (
auto const &child : dftSeq->children()) {
1048 if (dontCareElements.count(child->id())) {
1049 u_int64_t childDontCare = dontcareTransitions.at(child->id());
1050 builder.addInputArc(dontCarePlace, childDontCare);
1054 if (failedPlace == 0) {
1057 for (
auto const &child : dftSeq->children()) {
1058 if (dontCareElements.count(child->id())) {
1059 u_int64_t childDontCare = dontcareTransitions.at(child->id());
1060 builder.addInputArc(failedPlace, childDontCare);
1067template<
typename ValueType>
1070 uint64_t failedPlace = builder.addPlace(
defaultCapacity, initialFailed ? 1 : 0, dftElement->name() + STR_FAILED);
1071 assert(failedPlaces.size() == dftElement->id());
1072 failedPlaces.push_back(failedPlace);
1073 builder.setPlaceLayoutInfo(failedPlace, layoutInfo);
1077template<
typename ValueType>
1080 unsigned int capacity = 2;
1081 uint64_t unavailablePlace = builder.addPlace(capacity, initialAvailable ? 0 : 1, dftElement->name() +
"_unavail");
1082 unavailablePlaces.emplace(dftElement->id(), unavailablePlace);
1083 builder.setPlaceLayoutInfo(unavailablePlace, layoutInfo);
1084 return unavailablePlace;
1087template<
typename ValueType>
1090 uint64_t disabledPlace = builder.addPlace(dftBe->nrRestrictions(), dftBe->nrRestrictions(), dftBe->name() +
"_dabled");
1091 disabledPlaces.emplace(dftBe->id(), disabledPlace);
1092 builder.setPlaceLayoutInfo(disabledPlace, layoutInfo);
1093 return disabledPlace;
1096template<
typename ValueType>
1099 uint64_t dontcareTransition;
1100 dontcareTransition = builder.addImmediateTransition(dontCarePriority, 0.0, dftElement->name() + STR_DONTCARE +
"_transition");
1101 dontcareTransitions.emplace(dftElement->id(), dontcareTransition);
1102 builder.setTransitionLayoutInfo(dontcareTransition, layoutInfo);
1103 return dontcareTransition;
1106template<
typename ValueType>
1109 return !mDft.hasRepresentant(dftElement->id());
1112template<
typename ValueType>
1115 return priorities.at(dftElement->id());
1119template class DftToGspnTransformator<double>;
Represents a Dynamic Fault Tree.
BE which is either constant failed or constant failsafe.
BE with exponential failure distribution.
Abstract base class for basic events (BEs) in DFTs.
Dependency gate with probability p.
Abstract base class for DFT elements.
Priority AND (PAND) gate.
VOT gate with threshold k.
#define STORM_LOG_ASSERT(cond, message)
#define STORM_LOG_THROW(cond, exception, message)