Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
DftToGspnTransformator.cpp
Go to the documentation of this file.
2#include <memory>
4
5namespace storm::dft {
6namespace transformations {
7
8// Prevent some magic constants
9static constexpr uint64_t defaultCapacity = 1;
10
11template<typename ValueType>
15
16template<typename ValueType>
17void DftToGspnTransformator<ValueType>::transform(std::map<uint64_t, uint64_t> const &priorities, std::set<uint64_t> const &dontCareElements, bool smart,
18 bool mergeDCFailed, bool extendPriorities) {
19 this->priorities = priorities;
20 this->dontCareElements = dontCareElements;
21 this->smart = smart;
22 this->mergedDCFailed = mergeDCFailed;
23 this->dontCarePriority = 1;
24 this->extendedPriorities = extendPriorities;
25 builder.setGspnName("DftToGspnTransformation");
26
27 // Translate all GSPN elements
28 translateGSPNElements();
29
30 // Create initial template
31 // TODO
32}
33
34template<typename ValueType>
35std::map<uint64_t, uint64_t> DftToGspnTransformator<ValueType>::computePriorities(bool extendedPrio) {
36 std::map<uint64_t, uint64_t> priorities;
37 if (!extendedPrio) {
38 // Set priority for PDEP and FDEP according to Monolithic MA semantics
39 uint64_t dependency_priority = 2;
40 for (std::size_t i = 0; i < mDft.nrElements(); i++) {
41 if (mDft.getElement(i)->type() == storm::dft::storage::elements::DFTElementType::PDEP) {
42 priorities[i] = dependency_priority;
43 } else {
44 priorities[i] = (-(mDft.getElement(i)->rank()) + mDft.maxRank()) * 2 + 5;
45 }
46 }
47 } else {
48 // Define some variables
49 uint64_t maxNrOfChildren = 0;
50 uint64_t maxNrDependentEvents = 0;
51 // Iterate over all elements of the DFT and sort them into the list
52 std::list<size_t> elementList;
53 for (std::size_t i = 0; i < mDft.nrElements(); i++) {
54 if (mDft.getElement(i)->type() == storm::dft::storage::elements::DFTElementType::PDEP) {
55 // For dependencies, get the maximal number of dependent events
56 auto dependency = std::static_pointer_cast<storm::dft::storage::elements::DFTDependency<ValueType> const>(mDft.getElement(i));
57 uint64_t nrDependentEvents = (dependency->dependentEvents()).size();
58 if (nrDependentEvents > maxNrDependentEvents) {
59 maxNrDependentEvents = nrDependentEvents;
60 }
61 }
62 // Get the maximum number of children/ SPAREs need additional transitions
63
64 uint64_t nrChildren = mDft.getElement(i)->nrChildren();
65 if (mDft.getElement(i)->type() == storm::dft::storage::elements::DFTElementType::SPARE) {
66 nrChildren *= 4;
67 }
68 if (maxNrOfChildren < nrChildren) {
69 maxNrOfChildren = nrChildren;
70 }
71 // Organize the elements according to their rank
72 if (!elementList.empty()) {
73 std::list<size_t>::iterator it = elementList.begin();
74 // Make sure dependencies are always in the front
75 while ((mDft.getElement(*it)->rank()) < (mDft.getElement(i)->rank()) ||
76 mDft.getElement(*it)->type() == storm::dft::storage::elements::DFTElementType::PDEP) {
77 it++;
78 }
79 elementList.insert(it, i);
80 } else {
81 elementList.push_back(i);
82 }
83 }
84 // Get the necessary length for priority intervals
85 // Note that additional priorities are necessary
86 uint64_t priorityIntervalLength = std::max(maxNrDependentEvents, maxNrOfChildren) + 4;
87
88 // Define a running variable for the current priority
89 // Initialize it with an offset for the DC priorities + first interval length as prios give upper interval limit
90 uint64_t currentPrio = mDft.nrElements() + priorityIntervalLength;
91 // TODO Dependencies have to have same priority
92 for (std::list<size_t>::iterator it = elementList.begin(); it != elementList.end(); ++it) {
93 priorities[*it] = currentPrio;
94 currentPrio += priorityIntervalLength;
95 }
96 }
97
98 return priorities;
99}
100
101template<typename ValueType>
103 STORM_LOG_ASSERT(failedPlaces.size() > mDft.getTopLevelIndex(), "Failed place for top level element does not exist.");
104 return failedPlaces.at(mDft.getTopLevelIndex());
105}
106
107template<typename ValueType>
109 return builder.buildGspn();
110}
111
112template<typename ValueType>
113void DftToGspnTransformator<ValueType>::translateGSPNElements() {
114 // Loop through every DFT element and create its corresponding GSPN template.
115 for (std::size_t i = 0; i < mDft.nrElements(); i++) {
116 auto dftElement = mDft.getElement(i);
117
118 // Check which type the element is and call the corresponding translate-function.
119 switch (dftElement->type()) {
121 translateBE(std::static_pointer_cast<storm::dft::storage::elements::DFTBE<ValueType> const>(dftElement));
122 break;
124 translateAND(std::static_pointer_cast<storm::dft::storage::elements::DFTAnd<ValueType> const>(dftElement));
125 break;
127 translateOR(std::static_pointer_cast<storm::dft::storage::elements::DFTOr<ValueType> const>(dftElement));
128 break;
130 translateVOT(std::static_pointer_cast<storm::dft::storage::elements::DFTVot<ValueType> const>(dftElement));
131 break;
133 translatePAND(std::static_pointer_cast<storm::dft::storage::elements::DFTPand<ValueType> const>(dftElement),
134 std::static_pointer_cast<storm::dft::storage::elements::DFTPand<ValueType> const>(dftElement)->isInclusive());
135 break;
137 translatePOR(std::static_pointer_cast<storm::dft::storage::elements::DFTPor<ValueType> const>(dftElement),
138 std::static_pointer_cast<storm::dft::storage::elements::DFTPor<ValueType> const>(dftElement)->isInclusive());
139 break;
141 translateSPARE(std::static_pointer_cast<storm::dft::storage::elements::DFTSpare<ValueType> const>(dftElement));
142 break;
144 translatePDEP(std::static_pointer_cast<storm::dft::storage::elements::DFTDependency<ValueType> const>(dftElement));
145 break;
147 translateSeq(std::static_pointer_cast<storm::dft::storage::elements::DFTSeq<ValueType> const>(dftElement));
148 break;
149 default:
150 STORM_LOG_THROW(false, storm::exceptions::InvalidArgumentException, "DFT type '" << dftElement->type() << "' not known.");
151 break;
152 }
153 }
154}
155
156template<typename ValueType>
157void DftToGspnTransformator<ValueType>::translateBE(std::shared_ptr<storm::dft::storage::elements::DFTBE<ValueType> const> dftBE) {
158 switch (dftBE->beType()) {
160 translateBEConst(std::static_pointer_cast<storm::dft::storage::elements::BEConst<ValueType> const>(dftBE));
161 break;
163 translateBEExponential(std::static_pointer_cast<storm::dft::storage::elements::BEExponential<ValueType> const>(dftBE));
164 break;
165 default:
166 STORM_LOG_THROW(false, storm::exceptions::InvalidArgumentException, "BE type '" << dftBE->beType() << "' not known.");
167 break;
168 }
169}
170
171template<typename ValueType>
172void DftToGspnTransformator<ValueType>::translateBEExponential(std::shared_ptr<storm::dft::storage::elements::BEExponential<ValueType> const> dftBE) {
173 double xcenter = mDft.getElementLayoutInfo(dftBE->id()).x;
174 double ycenter = mDft.getElementLayoutInfo(dftBE->id()).y;
175
176 uint64_t failedPlace = addFailedPlace(dftBE, storm::gspn::LayoutInfo(xcenter + 3.0, ycenter));
177
178 uint64_t activePlace = builder.addPlace(defaultCapacity, isActiveInitially(dftBE) ? 1 : 0, dftBE->name() + STR_ACTIVATED);
179 activePlaces.emplace(dftBE->id(), activePlace);
180 builder.setPlaceLayoutInfo(activePlace, storm::gspn::LayoutInfo(xcenter - 3.0, ycenter));
181 uint64_t tActive = builder.addTimedTransition(getFailPriority(dftBE), dftBE->activeFailureRate(), dftBE->name() + "_activeFailing");
182 builder.setTransitionLayoutInfo(tActive, storm::gspn::LayoutInfo(xcenter, ycenter + 3.0));
183 builder.addInputArc(activePlace, tActive);
184 builder.addInhibitionArc(failedPlace, tActive);
185 builder.addOutputArc(tActive, activePlace);
186 builder.addOutputArc(tActive, failedPlace);
187
188 uint64_t tPassive = builder.addTimedTransition(getFailPriority(dftBE), dftBE->passiveFailureRate(), dftBE->name() + "_passiveFailing");
189 builder.setTransitionLayoutInfo(tPassive, storm::gspn::LayoutInfo(xcenter, ycenter - 3.0));
190 builder.addInhibitionArc(activePlace, tPassive);
191 builder.addInhibitionArc(failedPlace, tPassive);
192 builder.addOutputArc(tPassive, failedPlace);
193
194 if (dontCareElements.count(dftBE->id()) && dftBE->id() != mDft.getTopLevelIndex()) {
195 uint64_t tDontCare = addDontcareTransition(dftBE, storm::gspn::LayoutInfo(xcenter + 12.0, ycenter));
196 if (!mergedDCFailed) {
197 uint64_t dontCarePlace = builder.addPlace(1, 0, dftBE->name() + STR_DONTCARE);
198 builder.setPlaceLayoutInfo(dontCarePlace, storm::gspn::LayoutInfo(xcenter + 12.0, ycenter + 5.0));
199 builder.addInhibitionArc(dontCarePlace, tDontCare);
200 builder.addOutputArc(tDontCare, dontCarePlace);
201
202 builder.addInhibitionArc(dontCarePlace, tActive);
203 builder.addInhibitionArc(dontCarePlace, tPassive);
204
205 // Propagation for dependencies
206 if (!smart || dftBE->hasIngoingDependencies()) {
207 uint64_t dependencyPropagationPlace = builder.addPlace(1, 0, dftBE->name() + "_dependency_prop");
208 dependencyPropagationPlaces.emplace(dftBE->id(), dependencyPropagationPlace);
209 builder.setPlaceLayoutInfo(dependencyPropagationPlace, storm::gspn::LayoutInfo(xcenter + 10.0, ycenter - 5.0));
210 uint64_t tPropagationFailed = builder.addImmediateTransition(dontCarePriority, 0.0, dftBE->name() + "_prop_fail");
211 builder.setTransitionLayoutInfo(tPropagationFailed, storm::gspn::LayoutInfo(xcenter + 8.0, ycenter));
212 builder.addInhibitionArc(dependencyPropagationPlace, tPropagationFailed);
213 builder.addInputArc(failedPlace, tPropagationFailed);
214 builder.addOutputArc(tPropagationFailed, failedPlace);
215 builder.addOutputArc(tPropagationFailed, dependencyPropagationPlace);
216 uint64_t tPropagationDontCare = builder.addImmediateTransition(dontCarePriority, 0.0, dftBE->name() + "_prop_dontCare");
217 builder.setTransitionLayoutInfo(tPropagationDontCare, storm::gspn::LayoutInfo(xcenter + 10.0, ycenter));
218 builder.addInhibitionArc(dependencyPropagationPlace, tPropagationDontCare);
219 builder.addInputArc(dependencyPropagationPlace, tPropagationDontCare);
220 builder.addOutputArc(tPropagationDontCare, dontCarePlace);
221 builder.addOutputArc(tPropagationDontCare, dependencyPropagationPlace);
222 }
223 } else {
224 builder.addInhibitionArc(failedPlace, tDontCare);
225 builder.addOutputArc(tDontCare, failedPlace);
226 }
227 }
228
229 if (!smart || dftBE->nrRestrictions() > 0) {
230 uint64_t disabledPlace = addDisabledPlace(dftBE, storm::gspn::LayoutInfo(xcenter - 9.0, ycenter));
231 builder.addInhibitionArc(disabledPlace, tActive);
232 builder.addInhibitionArc(disabledPlace, tPassive);
233 }
234
235 if (!smart || mDft.isRepresentative(dftBE->id())) {
236 uint64_t unavailablePlace = addUnavailablePlace(dftBE, storm::gspn::LayoutInfo(xcenter + 9.0, ycenter));
237 builder.addOutputArc(tActive, unavailablePlace);
238 builder.addOutputArc(tPassive, unavailablePlace);
239 }
240
241 if (extendedPriorities) {
242 dontCarePriority++;
243 }
244}
245
246template<typename ValueType>
247void DftToGspnTransformator<ValueType>::translateBEConst(std::shared_ptr<storm::dft::storage::elements::BEConst<ValueType> const> dftConst) {
248 double xcenter = mDft.getElementLayoutInfo(dftConst->id()).x;
249 double ycenter = mDft.getElementLayoutInfo(dftConst->id()).y;
250
251 if (dftConst->failed()) {
252 // Constant failed BE
253 addFailedPlace(dftConst, storm::gspn::LayoutInfo(xcenter, ycenter - 3.0), true);
254
255 if (!smart || mDft.isRepresentative(dftConst->id())) {
256 addUnavailablePlace(dftConst, storm::gspn::LayoutInfo(xcenter, ycenter + 3.0), false);
257 }
258 } else {
259 // Constant failsafe BE
260 size_t capacity = 0; // It cannot contain a token, because it cannot fail.
261 uint64_t failedPlace = builder.addPlace(capacity, 0, dftConst->name() + STR_FAILED);
262 STORM_LOG_ASSERT(failedPlaces.size() == dftConst->id(), "Failed place index mismatch.");
263 failedPlaces.push_back(failedPlace);
264 builder.setPlaceLayoutInfo(failedPlace, storm::gspn::LayoutInfo(xcenter, ycenter - 3.0));
265
266 if (!smart || mDft.isRepresentative(dftConst->id())) {
267 uint64_t unavailablePlace = builder.addPlace(capacity, 0, dftConst->name() + "_unavail");
268 unavailablePlaces.emplace(dftConst->id(), unavailablePlace);
269 builder.setPlaceLayoutInfo(unavailablePlace, storm::gspn::LayoutInfo(xcenter, ycenter + 3.0));
270 }
271 }
272}
273
274template<typename ValueType>
275void DftToGspnTransformator<ValueType>::translateAND(std::shared_ptr<storm::dft::storage::elements::DFTAnd<ValueType> const> dftAnd) {
276 double xcenter = mDft.getElementLayoutInfo(dftAnd->id()).x;
277 double ycenter = mDft.getElementLayoutInfo(dftAnd->id()).y;
278
279 uint64_t failedPlace = addFailedPlace(dftAnd, storm::gspn::LayoutInfo(xcenter, ycenter - 3.0));
280
281 uint64_t tFailed = builder.addImmediateTransition(getFailPriority(dftAnd), 0.0, dftAnd->name() + STR_FAILING);
282 builder.setTransitionLayoutInfo(tFailed, storm::gspn::LayoutInfo(xcenter, ycenter + 3.0));
283 builder.addInhibitionArc(failedPlace, tFailed);
284 builder.addOutputArc(tFailed, failedPlace);
285
286 if (dontCareElements.count(dftAnd->id())) {
287 if (dftAnd->id() != mDft.getTopLevelIndex()) {
288 uint64_t tDontCare = addDontcareTransition(dftAnd, storm::gspn::LayoutInfo(xcenter + 16.0, ycenter));
289 if (!mergedDCFailed) {
290 uint64_t dontCarePlace = builder.addPlace(1, 0, dftAnd->name() + STR_DONTCARE);
291 builder.setPlaceLayoutInfo(dontCarePlace, storm::gspn::LayoutInfo(xcenter + 16.0, ycenter + 4.0));
292 builder.addInhibitionArc(dontCarePlace, tDontCare);
293 builder.addOutputArc(tDontCare, dontCarePlace);
294 // Propagation
295 uint64_t propagationPlace = builder.addPlace(1, 0, dftAnd->name() + "_prop");
296 builder.setPlaceLayoutInfo(propagationPlace, storm::gspn::LayoutInfo(xcenter + 12.0, ycenter + 8.0));
297 uint64_t tPropagationFailed = builder.addImmediateTransition(dontCarePriority, 0.0, dftAnd->name() + "_prop_fail");
298 builder.setTransitionLayoutInfo(tPropagationFailed, storm::gspn::LayoutInfo(xcenter + 10.0, ycenter + 6.0));
299 builder.addInhibitionArc(propagationPlace, tPropagationFailed);
300 builder.addInputArc(failedPlace, tPropagationFailed);
301 builder.addOutputArc(tPropagationFailed, failedPlace);
302 builder.addOutputArc(tPropagationFailed, propagationPlace);
303 uint64_t tPropagationDontCare = builder.addImmediateTransition(dontCarePriority, 0.0, dftAnd->name() + "_prop_dontCare");
304 builder.setTransitionLayoutInfo(tPropagationDontCare, storm::gspn::LayoutInfo(xcenter + 14.0, ycenter + 6.0));
305 builder.addInhibitionArc(propagationPlace, tPropagationDontCare);
306 builder.addInputArc(dontCarePlace, tPropagationDontCare);
307 builder.addOutputArc(tPropagationDontCare, dontCarePlace);
308 builder.addOutputArc(tPropagationDontCare, propagationPlace);
309 for (auto const &child : dftAnd->children()) {
310 if (dontCareElements.count(child->id())) {
311 uint64_t childDontCare = dontcareTransitions.at(child->id());
312 builder.addInputArc(propagationPlace, childDontCare);
313 builder.addOutputArc(childDontCare, propagationPlace);
314 }
315 }
316 } else {
317 builder.addInhibitionArc(failedPlace, tDontCare);
318 builder.addOutputArc(tDontCare, failedPlace);
319 for (auto const &child : dftAnd->children()) {
320 if (dontCareElements.count(child->id())) {
321 uint64_t childDontCare = dontcareTransitions.at(child->id());
322 builder.addInputArc(failedPlace, childDontCare);
323 builder.addOutputArc(childDontCare, failedPlace);
324 }
325 }
326 }
327 } else {
328 // If AND is TLE, simple failure propagation suffices
329 for (auto const &child : dftAnd->children()) {
330 if (dontCareElements.count(child->id())) {
331 uint64_t childDontCare = dontcareTransitions.at(child->id());
332 builder.addInputArc(failedPlace, childDontCare);
333 builder.addOutputArc(childDontCare, failedPlace);
334 }
335 }
336 }
337 }
338
339 if (!smart || mDft.isRepresentative(dftAnd->id())) {
340 uint64_t unavailablePlace = addUnavailablePlace(dftAnd, storm::gspn::LayoutInfo(xcenter + 6.0, ycenter - 3.0));
341 builder.addOutputArc(tFailed, unavailablePlace);
342 }
343
344 for (auto const &child : dftAnd->children()) {
345 builder.addInputArc(getFailedPlace(child), tFailed);
346 builder.addOutputArc(tFailed, getFailedPlace(child));
347 }
348 if (extendedPriorities) {
349 dontCarePriority++;
350 }
351}
352
353template<typename ValueType>
354void DftToGspnTransformator<ValueType>::translateOR(std::shared_ptr<storm::dft::storage::elements::DFTOr<ValueType> const> dftOr) {
355 double xcenter = mDft.getElementLayoutInfo(dftOr->id()).x;
356 double ycenter = mDft.getElementLayoutInfo(dftOr->id()).y;
357
358 uint64_t failedPlace = addFailedPlace(dftOr, storm::gspn::LayoutInfo(xcenter, ycenter - 3.0));
359
360 if (dontCareElements.count(dftOr->id())) {
361 if (dftOr->id() != mDft.getTopLevelIndex()) {
362 uint64_t tDontCare = addDontcareTransition(dftOr, storm::gspn::LayoutInfo(xcenter + 16.0, ycenter));
363 if (!mergedDCFailed) {
364 uint64_t dontCarePlace = builder.addPlace(1, 0, dftOr->name() + STR_DONTCARE);
365 builder.setPlaceLayoutInfo(dontCarePlace, storm::gspn::LayoutInfo(xcenter + 16.0, ycenter + 4.0));
366 builder.addInhibitionArc(dontCarePlace, tDontCare);
367 builder.addOutputArc(tDontCare, dontCarePlace);
368 // Propagation
369 uint64_t propagationPlace = builder.addPlace(1, 0, dftOr->name() + "_prop");
370 builder.setPlaceLayoutInfo(propagationPlace, storm::gspn::LayoutInfo(xcenter + 12.0, ycenter + 8.0));
371 uint64_t tPropagationFailed = builder.addImmediateTransition(dontCarePriority, 0.0, dftOr->name() + "_prop_fail");
372 builder.setTransitionLayoutInfo(tPropagationFailed, storm::gspn::LayoutInfo(xcenter + 10.0, ycenter + 6.0));
373 builder.addInhibitionArc(propagationPlace, tPropagationFailed);
374 builder.addInputArc(failedPlace, tPropagationFailed);
375 builder.addOutputArc(tPropagationFailed, failedPlace);
376 builder.addOutputArc(tPropagationFailed, propagationPlace);
377 uint64_t tPropagationDontCare = builder.addImmediateTransition(dontCarePriority, 0.0, dftOr->name() + "_prop_dontCare");
378 builder.setTransitionLayoutInfo(tPropagationDontCare, storm::gspn::LayoutInfo(xcenter + 14.0, ycenter + 6.0));
379 builder.addInhibitionArc(propagationPlace, tPropagationDontCare);
380 builder.addInputArc(dontCarePlace, tPropagationDontCare);
381 builder.addOutputArc(tPropagationDontCare, dontCarePlace);
382 builder.addOutputArc(tPropagationDontCare, propagationPlace);
383 for (auto const &child : dftOr->children()) {
384 if (dontCareElements.count(child->id())) {
385 uint64_t childDontCare = dontcareTransitions.at(child->id());
386 builder.addInputArc(propagationPlace, childDontCare);
387 builder.addOutputArc(childDontCare, propagationPlace);
388 }
389 }
390 } else {
391 builder.addInhibitionArc(failedPlace, tDontCare);
392 builder.addOutputArc(tDontCare, failedPlace);
393 for (auto const &child : dftOr->children()) {
394 if (dontCareElements.count(child->id())) {
395 uint64_t childDontCare = dontcareTransitions.at(child->id());
396 builder.addInputArc(failedPlace, childDontCare);
397 builder.addOutputArc(childDontCare, failedPlace);
398 }
399 }
400 }
401 } else {
402 // If OR is TLE, simple failure propagation suffices
403 for (auto const &child : dftOr->children()) {
404 if (dontCareElements.count(child->id())) {
405 uint64_t childDontCare = dontcareTransitions.at(child->id());
406 builder.addInputArc(failedPlace, childDontCare);
407 builder.addOutputArc(childDontCare, failedPlace);
408 }
409 }
410 }
411 }
412
413 bool isRepresentative = mDft.isRepresentative(dftOr->id());
414 uint64_t unavailablePlace = 0;
415 if (!smart || isRepresentative) {
416 unavailablePlace = addUnavailablePlace(dftOr, storm::gspn::LayoutInfo(xcenter + 6.0, ycenter - 3.0));
417 }
418
419 for (size_t i = 0; i < dftOr->nrChildren(); ++i) {
420 auto const &child = dftOr->children().at(i);
421 uint64_t tFailed = 0;
422 if (extendedPriorities) {
423 tFailed = builder.addImmediateTransition(getFailPriority(dftOr) + i, 0.0, dftOr->name() + STR_FAILING + std::to_string(i));
424 } else {
425 tFailed = builder.addImmediateTransition(getFailPriority(dftOr), 0.0, dftOr->name() + STR_FAILING + std::to_string(i));
426 }
427 builder.setTransitionLayoutInfo(tFailed, storm::gspn::LayoutInfo(xcenter - 5.0 + i * 3.0, ycenter + 3.0));
428 builder.addInhibitionArc(failedPlace, tFailed);
429 builder.addOutputArc(tFailed, failedPlace);
430 if (!smart || isRepresentative) {
431 builder.addOutputArc(tFailed, unavailablePlace);
432 }
433 builder.addInputArc(getFailedPlace(child), tFailed);
434 builder.addOutputArc(tFailed, getFailedPlace(child));
435 }
436 if (extendedPriorities) {
437 dontCarePriority++;
438 }
439}
440
441template<typename ValueType>
442void DftToGspnTransformator<ValueType>::translateVOT(std::shared_ptr<storm::dft::storage::elements::DFTVot<ValueType> const> dftVot) {
443 // TODO: finish layouting
444
445 double xcenter = mDft.getElementLayoutInfo(dftVot->id()).x;
446 double ycenter = mDft.getElementLayoutInfo(dftVot->id()).y;
447
448 uint64_t failedPlace = addFailedPlace(dftVot, storm::gspn::LayoutInfo(xcenter, ycenter - 3.0));
449
450 uint64_t tFailed = builder.addImmediateTransition(getFailPriority(dftVot), 0.0, dftVot->name() + STR_FAILING);
451 builder.addOutputArc(tFailed, failedPlace);
452 builder.addInhibitionArc(failedPlace, tFailed);
453
454 if (!smart || mDft.isRepresentative(dftVot->id())) {
455 uint64_t unavailablePlace = addUnavailablePlace(dftVot, storm::gspn::LayoutInfo(xcenter + 6.0, ycenter - 3.0));
456 builder.addOutputArc(tFailed, unavailablePlace);
457 }
458
459 uint64_t collectorPlace = builder.addPlace(dftVot->nrChildren(), 0, dftVot->name() + "_collector");
460 builder.setPlaceLayoutInfo(collectorPlace, storm::gspn::LayoutInfo(xcenter, ycenter));
461 builder.addInputArc(collectorPlace, tFailed, dftVot->threshold());
462
463 for (size_t i = 0; i < dftVot->nrChildren(); ++i) {
464 auto const &child = dftVot->children().at(i);
465 uint64_t childNextPlace = builder.addPlace(defaultCapacity, 1, dftVot->name() + "_child_next" + std::to_string(i));
466 uint64_t tCollect;
467 if (extendedPriorities) {
468 tCollect = builder.addImmediateTransition(getFailPriority(dftVot) + i, 0.0, dftVot->name() + "_child_collect" + std::to_string(i));
469 } else {
470 tCollect = builder.addImmediateTransition(getFailPriority(dftVot), 0.0, dftVot->name() + "_child_collect" + std::to_string(i));
471 }
472 builder.addOutputArc(tCollect, collectorPlace);
473 builder.addInputArc(childNextPlace, tCollect);
474 builder.addInputArc(getFailedPlace(child), tCollect);
475 builder.addOutputArc(tCollect, getFailedPlace(child));
476 }
477
478 if (dontCareElements.count(dftVot->id())) {
479 if (dftVot->id() != mDft.getTopLevelIndex()) {
480 uint64_t tDontCare = addDontcareTransition(dftVot, storm::gspn::LayoutInfo(xcenter + 16.0, ycenter));
481 if (!mergedDCFailed) {
482 uint64_t dontCarePlace = builder.addPlace(1, 0, dftVot->name() + STR_DONTCARE);
483 builder.setPlaceLayoutInfo(dontCarePlace, storm::gspn::LayoutInfo(xcenter + 16.0, ycenter + 4.0));
484 builder.addInhibitionArc(dontCarePlace, tDontCare);
485 builder.addOutputArc(tDontCare, dontCarePlace);
486 // Propagation
487 uint64_t propagationPlace = builder.addPlace(1, 0, dftVot->name() + "_prop");
488 builder.setPlaceLayoutInfo(propagationPlace, storm::gspn::LayoutInfo(xcenter + 12.0, ycenter + 8.0));
489 uint64_t tPropagationFailed = builder.addImmediateTransition(dontCarePriority, 0.0, dftVot->name() + "_prop_fail");
490 builder.setTransitionLayoutInfo(tPropagationFailed, storm::gspn::LayoutInfo(xcenter + 10.0, ycenter + 6.0));
491 builder.addInhibitionArc(propagationPlace, tPropagationFailed);
492 builder.addInputArc(failedPlace, tPropagationFailed);
493 builder.addOutputArc(tPropagationFailed, failedPlace);
494 builder.addOutputArc(tPropagationFailed, propagationPlace);
495 uint64_t tPropagationDontCare = builder.addImmediateTransition(dontCarePriority, 0.0, dftVot->name() + "_prop_dontCare");
496 builder.setTransitionLayoutInfo(tPropagationDontCare, storm::gspn::LayoutInfo(xcenter + 14.0, ycenter + 6.0));
497 builder.addInhibitionArc(propagationPlace, tPropagationDontCare);
498 builder.addInputArc(dontCarePlace, tPropagationDontCare);
499 builder.addOutputArc(tPropagationDontCare, dontCarePlace);
500 builder.addOutputArc(tPropagationDontCare, propagationPlace);
501 for (auto const &child : dftVot->children()) {
502 if (dontCareElements.count(child->id())) {
503 uint64_t childDontCare = dontcareTransitions.at(child->id());
504 builder.addInputArc(propagationPlace, childDontCare);
505 builder.addOutputArc(childDontCare, propagationPlace);
506 }
507 }
508 } else {
509 builder.addInhibitionArc(failedPlace, tDontCare);
510 builder.addOutputArc(tDontCare, failedPlace);
511 for (auto const &child : dftVot->children()) {
512 if (dontCareElements.count(child->id())) {
513 uint64_t childDontCare = dontcareTransitions.at(child->id());
514 builder.addInputArc(failedPlace, childDontCare);
515 builder.addOutputArc(childDontCare, failedPlace);
516 }
517 }
518 }
519 } else {
520 // If VOT is TLE, simple failure propagation suffices
521 for (auto const &child : dftVot->children()) {
522 if (dontCareElements.count(child->id())) {
523 uint64_t childDontCare = dontcareTransitions.at(child->id());
524 builder.addInputArc(failedPlace, childDontCare);
525 builder.addOutputArc(childDontCare, failedPlace);
526 }
527 }
528 }
529 }
530 if (extendedPriorities) {
531 dontCarePriority++;
532 }
533}
534
535template<typename ValueType>
536void DftToGspnTransformator<ValueType>::translatePAND(std::shared_ptr<storm::dft::storage::elements::DFTPand<ValueType> const> dftPand, bool inclusive) {
537 // TODO Layouting
538 double xcenter = mDft.getElementLayoutInfo(dftPand->id()).x;
539 double ycenter = mDft.getElementLayoutInfo(dftPand->id()).y;
540
541 uint64_t failedPlace = addFailedPlace(dftPand, storm::gspn::LayoutInfo(xcenter + 3.0, ycenter - 3.0));
542
543 // Set priority lower if the PAND is exclusive
544 uint64_t tFailed = builder.addImmediateTransition(
545 /*inclusive ? getFailPriority(dftPand) : */ getFailPriority(dftPand) - 1, 0.0, dftPand->name() + STR_FAILING);
546 builder.setTransitionLayoutInfo(tFailed, storm::gspn::LayoutInfo(xcenter + 3.0, ycenter + 3.0));
547 builder.addInhibitionArc(failedPlace, tFailed);
548 builder.addOutputArc(tFailed, failedPlace);
549
550 if (!smart || mDft.isRepresentative(dftPand->id())) {
551 uint64_t unavailablePlace = addUnavailablePlace(dftPand, storm::gspn::LayoutInfo(xcenter + 9.0, ycenter - 3.0));
552 builder.addOutputArc(tFailed, unavailablePlace);
553 }
554
555 uint64_t failSafePlace = builder.addPlace(defaultCapacity, 0, dftPand->name() + STR_FAILSAVE);
556 builder.setPlaceLayoutInfo(failSafePlace, storm::gspn::LayoutInfo(xcenter - 3.0, ycenter - 3.0));
557
558 builder.addInhibitionArc(failSafePlace, tFailed);
559
560 // Transitions for failed place
561 for (auto const &child : dftPand->children()) {
562 builder.addInputArc(getFailedPlace(child), tFailed);
563 builder.addOutputArc(tFailed, getFailedPlace(child));
564 }
565 // Transitions for fail-safe place
566 for (uint64_t i = 1; i < dftPand->nrChildren(); ++i) {
567 auto const &child = dftPand->children().at(i);
568 uint64_t tFailSafe = builder.addImmediateTransition(getFailPriority(dftPand), 0.0, dftPand->name() + STR_FAILSAVING + std::to_string(i));
569 builder.setTransitionLayoutInfo(tFailSafe, storm::gspn::LayoutInfo(xcenter - 6.0 + i * 3.0, ycenter + 3.0));
570
571 if (inclusive) {
572 builder.addInputArc(getFailedPlace(child), tFailSafe);
573 builder.addOutputArc(tFailSafe, getFailedPlace(child));
574 builder.addInhibitionArc(getFailedPlace(dftPand->children().at(i - 1)), tFailSafe);
575 builder.addOutputArc(tFailSafe, failSafePlace);
576 builder.addInhibitionArc(failSafePlace, tFailSafe);
577 } else {
578 // Delay mechanism for exclusive PAND
579 auto const &previousChild = dftPand->children().at(i - 1);
580 uint64_t delayPlace = builder.addPlace(1, 0, dftPand->name() + "_delay_" + previousChild->name());
581 builder.setPlaceLayoutInfo(delayPlace, storm::gspn::LayoutInfo(xcenter - 5.0 + (i - 1) * 3.0, ycenter + 5.0));
582 // Priority of delayTransitions needs to be lower than for failsafeTransitions
583 uint64_t tDelay = builder.addImmediateTransition(getFailPriority(dftPand) - 1, 0.0, child->name() + "_" + dftPand->name() + "_delayTransition");
584 builder.setTransitionLayoutInfo(tDelay, storm::gspn::LayoutInfo(xcenter - 5.0 + (i - 1) * 3.0, ycenter + 3.0));
585 builder.addInputArc(getFailedPlace(previousChild), tDelay);
586 builder.addOutputArc(tDelay, getFailedPlace(dftPand->children().at(i - 1)));
587 builder.addOutputArc(tDelay, delayPlace);
588 builder.addInhibitionArc(delayPlace, tDelay);
589
590 builder.addInputArc(getFailedPlace(child), tFailSafe);
591 builder.addOutputArc(tFailSafe, getFailedPlace(child));
592 builder.addInhibitionArc(delayPlace, tFailSafe);
593 builder.addOutputArc(tFailSafe, failSafePlace);
594 builder.addInhibitionArc(failSafePlace, tFailSafe);
595 }
596 }
597 // Dont Care
598 if (dontCareElements.count(dftPand->id())) {
599 // Propagation
600 uint64_t propagationPlace = builder.addPlace(1, 0, dftPand->name() + "_prop");
601 builder.setPlaceLayoutInfo(propagationPlace, storm::gspn::LayoutInfo(xcenter + 12.0, ycenter + 8.0));
602 uint64_t tPropagationFailed = builder.addImmediateTransition(dontCarePriority, 0.0, dftPand->name() + "_prop_fail");
603 builder.setTransitionLayoutInfo(tPropagationFailed, storm::gspn::LayoutInfo(xcenter + 10.0, ycenter + 6.0));
604 uint64_t tPropagationFailsafe = builder.addImmediateTransition(dontCarePriority, 0.0, dftPand->name() + "_prop_failsafe");
605 builder.setTransitionLayoutInfo(tPropagationFailsafe, storm::gspn::LayoutInfo(xcenter + 8.0, ycenter + 6.0));
606 builder.addInhibitionArc(propagationPlace, tPropagationFailed);
607 builder.addInputArc(failedPlace, tPropagationFailed);
608 builder.addOutputArc(tPropagationFailed, failedPlace);
609 builder.addOutputArc(tPropagationFailed, propagationPlace);
610
611 builder.addInhibitionArc(propagationPlace, tPropagationFailsafe);
612 builder.addInputArc(failSafePlace, tPropagationFailsafe);
613 builder.addOutputArc(tPropagationFailsafe, failSafePlace);
614 builder.addOutputArc(tPropagationFailsafe, propagationPlace);
615
616 // Connect children to propagation place
617 for (auto const &child : dftPand->children()) {
618 if (dontCareElements.count(child->id())) {
619 uint64_t childDontCare = dontcareTransitions.at(child->id());
620 builder.addInputArc(propagationPlace, childDontCare);
621 builder.addOutputArc(childDontCare, propagationPlace);
622 }
623 }
624
625 if (dftPand->id() != mDft.getTopLevelIndex()) {
626 uint64_t tDontCare = addDontcareTransition(dftPand, storm::gspn::LayoutInfo(xcenter + 16.0, ycenter));
627 if (!mergedDCFailed) {
628 uint64_t dontCarePlace = builder.addPlace(1, 0, dftPand->name() + STR_DONTCARE);
629 builder.setPlaceLayoutInfo(dontCarePlace, storm::gspn::LayoutInfo(xcenter + 16.0, ycenter + 4.0));
630 builder.addInhibitionArc(dontCarePlace, tDontCare);
631 builder.addOutputArc(tDontCare, dontCarePlace);
632 uint64_t tPropagationDontCare = builder.addImmediateTransition(dontCarePriority, 0.0, dftPand->name() + "_prop_dontCare");
633 builder.setTransitionLayoutInfo(tPropagationDontCare, storm::gspn::LayoutInfo(xcenter + 14.0, ycenter + 6.0));
634 builder.addInhibitionArc(propagationPlace, tPropagationDontCare);
635 builder.addInputArc(dontCarePlace, tPropagationDontCare);
636 builder.addOutputArc(tPropagationDontCare, dontCarePlace);
637 builder.addOutputArc(tPropagationDontCare, propagationPlace);
638
639 } else {
640 builder.addInhibitionArc(failedPlace, tDontCare);
641 builder.addOutputArc(tDontCare, failedPlace);
642 }
643 }
644 }
645 if (extendedPriorities) {
646 dontCarePriority++;
647 }
648}
649
650template<typename ValueType>
651void DftToGspnTransformator<ValueType>::translatePOR(std::shared_ptr<storm::dft::storage::elements::DFTPor<ValueType> const> dftPor, bool inclusive) {
652 double xcenter = mDft.getElementLayoutInfo(dftPor->id()).x;
653 double ycenter = mDft.getElementLayoutInfo(dftPor->id()).y;
654
655 uint64_t delayPlace = 0;
656
657 uint64_t failedPlace = addFailedPlace(dftPor, storm::gspn::LayoutInfo(xcenter + 3.0, ycenter - 3.0));
658
659 // Set priority lower if the POR is exclusive
660 uint64_t tFailed = builder.addImmediateTransition(
661 /*inclusive ? getFailPriority(dftPor) : */ getFailPriority(dftPor) - 1, 0.0, dftPor->name() + STR_FAILING);
662 builder.setTransitionLayoutInfo(tFailed, storm::gspn::LayoutInfo(xcenter + 3.0, ycenter + 3.0));
663 builder.addOutputArc(tFailed, failedPlace);
664 builder.addInhibitionArc(failedPlace, tFailed);
665
666 // Arcs from first child
667 builder.addInputArc(getFailedPlace(dftPor->children().front()), tFailed);
668 builder.addOutputArc(tFailed, getFailedPlace(dftPor->children().front()));
669
670 if (!smart || mDft.isRepresentative(dftPor->id())) {
671 uint64_t unavailablePlace = addUnavailablePlace(dftPor, storm::gspn::LayoutInfo(xcenter + 9.0, ycenter - 3.0));
672 builder.addOutputArc(tFailed, unavailablePlace);
673 }
674
675 uint64_t failSafePlace = builder.addPlace(defaultCapacity, 0, dftPor->name() + STR_FAILSAVE);
676 builder.setPlaceLayoutInfo(failSafePlace, storm::gspn::LayoutInfo(xcenter - 3.0, ycenter - 3.0));
677
678 builder.addInhibitionArc(failSafePlace, tFailed);
679
680 if (!inclusive) {
681 // Setup delay mechanism if necessary
682 delayPlace = builder.addPlace(1, 0, dftPor->name() + "_delay");
683 builder.setPlaceLayoutInfo(delayPlace, storm::gspn::LayoutInfo(xcenter - 5.0, ycenter + 5.0));
684
685 // priority of delayTransition has to be lower than other priorities
686 uint64_t tDelay = builder.addImmediateTransition(getFailPriority(dftPor) - 1, 0.0, dftPor->name() + "_delayTransition");
687 builder.setTransitionLayoutInfo(tDelay, storm::gspn::LayoutInfo(xcenter - 5.0, ycenter + 3.0));
688
689 builder.addInputArc(getFailedPlace(dftPor->children().front()), tDelay);
690 builder.addOutputArc(tDelay, getFailedPlace(dftPor->children().front()));
691 builder.addOutputArc(tDelay, delayPlace);
692 builder.addInhibitionArc(delayPlace, tDelay);
693 }
694
695 // For all children except the first one
696 for (size_t i = 1; i < dftPor->nrChildren(); ++i) {
697 auto const &child = dftPor->children().at(i);
698 uint64_t tFailSafe = builder.addImmediateTransition(getFailPriority(dftPor), 0.0, dftPor->name() + STR_FAILSAVING + std::to_string(i));
699 builder.setTransitionLayoutInfo(tFailSafe, storm::gspn::LayoutInfo(xcenter - 3.0 + i * 3.0, ycenter + 3.0));
700
701 builder.addInputArc(getFailedPlace(child), tFailSafe);
702 builder.addOutputArc(tFailSafe, getFailedPlace(child));
703 builder.addOutputArc(tFailSafe, failSafePlace);
704 builder.addInhibitionArc(failSafePlace, tFailSafe);
705 if (inclusive) {
706 builder.addInhibitionArc(getFailedPlace(dftPor->children().front()), tFailSafe);
707 } else {
708 builder.addInhibitionArc(delayPlace, tFailSafe);
709 }
710 }
711
712 // Dont Care
713 if (dontCareElements.count(dftPor->id())) {
714 // Propagation
715 uint64_t propagationPlace = builder.addPlace(1, 0, dftPor->name() + "_prop");
716 builder.setPlaceLayoutInfo(propagationPlace, storm::gspn::LayoutInfo(xcenter + 12.0, ycenter + 8.0));
717 uint64_t tPropagationFailed = builder.addImmediateTransition(dontCarePriority, 0.0, dftPor->name() + "_prop_fail");
718 builder.setTransitionLayoutInfo(tPropagationFailed, storm::gspn::LayoutInfo(xcenter + 10.0, ycenter + 6.0));
719 uint64_t tPropagationFailsafe = builder.addImmediateTransition(dontCarePriority, 0.0, dftPor->name() + "_prop_failsafe");
720 builder.setTransitionLayoutInfo(tPropagationFailsafe, storm::gspn::LayoutInfo(xcenter + 8.0, ycenter + 6.0));
721 builder.addInhibitionArc(propagationPlace, tPropagationFailed);
722 builder.addInputArc(failedPlace, tPropagationFailed);
723 builder.addOutputArc(tPropagationFailed, failedPlace);
724 builder.addOutputArc(tPropagationFailed, propagationPlace);
725
726 builder.addInhibitionArc(propagationPlace, tPropagationFailsafe);
727 builder.addInputArc(failSafePlace, tPropagationFailsafe);
728 builder.addOutputArc(tPropagationFailsafe, failSafePlace);
729 builder.addOutputArc(tPropagationFailsafe, propagationPlace);
730
731 // Connect children to propagation place
732 for (auto const &child : dftPor->children()) {
733 if (dontCareElements.count(child->id())) {
734 uint64_t childDontCare = dontcareTransitions.at(child->id());
735 builder.addInputArc(propagationPlace, childDontCare);
736 builder.addOutputArc(childDontCare, propagationPlace);
737 }
738 }
739
740 if (dftPor->id() != mDft.getTopLevelIndex()) {
741 uint64_t tDontCare = addDontcareTransition(dftPor, storm::gspn::LayoutInfo(xcenter + 16.0, ycenter));
742 if (!mergedDCFailed) {
743 uint64_t dontCarePlace = builder.addPlace(1, 0, dftPor->name() + STR_DONTCARE);
744 builder.setPlaceLayoutInfo(dontCarePlace, storm::gspn::LayoutInfo(xcenter + 16.0, ycenter + 4.0));
745 builder.addInhibitionArc(dontCarePlace, tDontCare);
746 builder.addOutputArc(tDontCare, dontCarePlace);
747 uint64_t tPropagationDontCare = builder.addImmediateTransition(dontCarePriority, 0.0, dftPor->name() + "_prop_dontCare");
748 builder.setTransitionLayoutInfo(tPropagationDontCare, storm::gspn::LayoutInfo(xcenter + 14.0, ycenter + 6.0));
749 builder.addInhibitionArc(propagationPlace, tPropagationDontCare);
750 builder.addInputArc(dontCarePlace, tPropagationDontCare);
751 builder.addOutputArc(tPropagationDontCare, dontCarePlace);
752 builder.addOutputArc(tPropagationDontCare, propagationPlace);
753
754 } else {
755 builder.addInhibitionArc(failedPlace, tDontCare);
756 builder.addOutputArc(tDontCare, failedPlace);
757 }
758 }
759 }
760 if (extendedPriorities) {
761 dontCarePriority++;
762 }
763}
764
765template<typename ValueType>
766void DftToGspnTransformator<ValueType>::translateSPARE(std::shared_ptr<storm::dft::storage::elements::DFTSpare<ValueType> const> dftSpare) {
767 double xcenter = mDft.getElementLayoutInfo(dftSpare->id()).x;
768 double ycenter = mDft.getElementLayoutInfo(dftSpare->id()).y;
769
770 uint64_t prio = getFailPriority(dftSpare);
771
772 uint64_t failedPlace = addFailedPlace(dftSpare, storm::gspn::LayoutInfo(xcenter + 10.0, ycenter - 8.0));
773
774 bool isRepresentative = mDft.isRepresentative(dftSpare->id());
775 uint64_t unavailablePlace = 0;
776 if (!smart || isRepresentative) {
777 unavailablePlace = addUnavailablePlace(dftSpare, storm::gspn::LayoutInfo(xcenter + 16.0, ycenter - 8.0));
778 }
779
780 uint64_t activePlace = builder.addPlace(defaultCapacity, isActiveInitially(dftSpare) ? 1 : 0, dftSpare->name() + STR_ACTIVATED);
781 builder.setPlaceLayoutInfo(activePlace, storm::gspn::LayoutInfo(xcenter - 20.0, ycenter - 12.0));
782 activePlaces.emplace(dftSpare->id(), activePlace);
783
784 std::vector<uint64_t> tNextClaims;
785 std::vector<uint64_t> tNextConsiders;
786 for (size_t i = 0; i < dftSpare->nrChildren(); ++i) {
787 auto const &child = dftSpare->children().at(i);
788 // Consider next child
789 size_t considerPlace = builder.addPlace(defaultCapacity, i == 0 ? 1 : 0, dftSpare->name() + "_consider_" + child->name());
790 builder.setPlaceLayoutInfo(considerPlace, storm::gspn::LayoutInfo(xcenter - 15.0 + i * 14.0, ycenter - 8.0));
791
792 if (i > 0) {
793 // Set output transition from previous next_claim
794 builder.addOutputArc(tNextClaims.back(), considerPlace);
795 // Set output transition from previous cannot_claim
796 builder.addOutputArc(tNextConsiders.back(), considerPlace);
797 }
798
799 // Cannot claim child
800 uint64_t tConsiderNext = builder.addImmediateTransition(prio, 0.0, dftSpare->name() + "_cannot_claim_" + child->name());
801 prio++;
802 builder.setTransitionLayoutInfo(tConsiderNext, storm::gspn::LayoutInfo(xcenter - 7.0 + i * 14.0, ycenter - 8.0));
803 builder.addInputArc(considerPlace, tConsiderNext);
804 builder.addInputArc(unavailablePlaces.at(child->id()), tConsiderNext);
805 builder.addOutputArc(tConsiderNext, unavailablePlaces.at(child->id()));
806 tNextConsiders.push_back(tConsiderNext);
807
808 // Claimed child
809 size_t claimedPlace = builder.addPlace(defaultCapacity, 0, dftSpare->name() + "_claimed_" + child->name());
810 builder.setPlaceLayoutInfo(claimedPlace, storm::gspn::LayoutInfo(xcenter - 15.0 + i * 14.0, ycenter + 5.0));
811 uint64_t tClaim = builder.addImmediateTransition(prio, 0.0, dftSpare->name() + "_claim_" + child->name());
812 prio++;
813 builder.setTransitionLayoutInfo(tClaim, storm::gspn::LayoutInfo(xcenter - 15.0 + i * 14.0, ycenter));
814 builder.addInhibitionArc(unavailablePlaces.at(child->id()), tClaim);
815 builder.addInputArc(considerPlace, tClaim);
816 builder.addOutputArc(tClaim, claimedPlace);
817 builder.addOutputArc(tClaim, unavailablePlaces.at(child->id()));
818
819 // Claim next
820 uint64_t tClaimNext = builder.addImmediateTransition(prio, 0.0, dftSpare->name() + "_next_claim_" + std::to_string(i));
821 prio++;
822 builder.setTransitionLayoutInfo(tClaimNext, storm::gspn::LayoutInfo(xcenter - 7.0 + i * 14.0, ycenter + 5.0));
823 builder.addInputArc(claimedPlace, tClaimNext);
824 builder.addInputArc(getFailedPlace(child), tClaimNext);
825 builder.addOutputArc(tClaimNext, getFailedPlace(child));
826 tNextClaims.push_back(tClaimNext);
827
828 // Activate all elements in spare module
829 uint64_t l = 0;
830 for (uint64_t k : mDft.module(child->id()).getElements()) {
831 uint64_t tActivate = builder.addImmediateTransition(prio, 0.0, dftSpare->name() + "_activate_" + std::to_string(i) + "_" + std::to_string(k));
832 prio++;
833 builder.setTransitionLayoutInfo(tActivate, storm::gspn::LayoutInfo(xcenter - 18.0 + (i + l) * 3, ycenter - 12.0));
834 builder.addInhibitionArc(activePlaces.at(k), tActivate);
835 builder.addInputArc(claimedPlace, tActivate);
836 builder.addInputArc(activePlace, tActivate);
837 builder.addOutputArc(tActivate, claimedPlace);
838 builder.addOutputArc(tActivate, activePlace);
839 builder.addOutputArc(tActivate, activePlaces.at(k));
840 ++l;
841 }
842 }
843
844 // Set arcs to failed
845 builder.addOutputArc(tNextConsiders.back(), failedPlace);
846 builder.addOutputArc(tNextClaims.back(), failedPlace);
847 builder.addInhibitionArc(failedPlace, tNextConsiders.back());
848 builder.addInhibitionArc(failedPlace, tNextClaims.back());
849
850 // Don't Care Mechanism
851 if (dontCareElements.count(dftSpare->id())) {
852 if (dftSpare->id() != mDft.getTopLevelIndex()) {
853 uint64_t tDontCare = addDontcareTransition(dftSpare, storm::gspn::LayoutInfo(xcenter + 16.0, ycenter));
854 if (!mergedDCFailed) {
855 uint64_t dontCarePlace = builder.addPlace(1, 0, dftSpare->name() + STR_DONTCARE);
856 builder.setPlaceLayoutInfo(dontCarePlace, storm::gspn::LayoutInfo(xcenter + 16.0, ycenter + 4.0));
857 builder.addInhibitionArc(dontCarePlace, tDontCare);
858 builder.addOutputArc(tDontCare, dontCarePlace);
859 // Propagation
860 uint64_t propagationPlace = builder.addPlace(1, 0, dftSpare->name() + "_prop");
861 builder.setPlaceLayoutInfo(propagationPlace, storm::gspn::LayoutInfo(xcenter + 12.0, ycenter + 8.0));
862 uint64_t tPropagationFailed = builder.addImmediateTransition(dontCarePriority, 0.0, dftSpare->name() + "_prop_fail");
863 builder.setTransitionLayoutInfo(tPropagationFailed, storm::gspn::LayoutInfo(xcenter + 10.0, ycenter + 6.0));
864 builder.addInhibitionArc(propagationPlace, tPropagationFailed);
865 builder.addInputArc(failedPlace, tPropagationFailed);
866 builder.addOutputArc(tPropagationFailed, failedPlace);
867 builder.addOutputArc(tPropagationFailed, propagationPlace);
868 uint64_t tPropagationDontCare = builder.addImmediateTransition(dontCarePriority, 0.0, dftSpare->name() + "_prop_dontCare");
869 builder.setTransitionLayoutInfo(tPropagationDontCare, storm::gspn::LayoutInfo(xcenter + 14.0, ycenter + 6.0));
870 builder.addInhibitionArc(propagationPlace, tPropagationDontCare);
871 builder.addInputArc(dontCarePlace, tPropagationDontCare);
872 builder.addOutputArc(tPropagationDontCare, dontCarePlace);
873 builder.addOutputArc(tPropagationDontCare, propagationPlace);
874 for (auto const &child : dftSpare->children()) {
875 if (dontCareElements.count(child->id())) {
876 uint64_t childDontCare = dontcareTransitions.at(child->id());
877 builder.addInputArc(propagationPlace, childDontCare);
878 builder.addOutputArc(childDontCare, propagationPlace);
879 }
880 }
881 } else {
882 builder.addInhibitionArc(failedPlace, tDontCare);
883 builder.addOutputArc(tDontCare, failedPlace);
884 for (auto const &child : dftSpare->children()) {
885 if (dontCareElements.count(child->id())) {
886 uint64_t childDontCare = dontcareTransitions.at(child->id());
887 builder.addInputArc(failedPlace, childDontCare);
888 builder.addOutputArc(childDontCare, failedPlace);
889 }
890 }
891 }
892 } else {
893 // If SPARE is TLE, simple failure propagation suffices
894 for (auto const &child : dftSpare->children()) {
895 if (dontCareElements.count(child->id())) {
896 uint64_t childDontCare = dontcareTransitions.at(child->id());
897 builder.addInputArc(failedPlace, childDontCare);
898 builder.addOutputArc(childDontCare, failedPlace);
899 }
900 }
901 }
902 }
903
904 if (!smart || isRepresentative) {
905 builder.addOutputArc(tNextConsiders.back(), unavailablePlace);
906 builder.addOutputArc(tNextClaims.back(), unavailablePlace);
907 }
908 if (extendedPriorities) {
909 dontCarePriority++;
910 }
911}
912
913template<typename ValueType>
914void DftToGspnTransformator<ValueType>::translatePDEP(std::shared_ptr<storm::dft::storage::elements::DFTDependency<ValueType> const> dftDependency) {
915 double xcenter = mDft.getElementLayoutInfo(dftDependency->id()).x;
916 double ycenter = mDft.getElementLayoutInfo(dftDependency->id()).y;
917
918 uint64_t failedPlace = 0;
919 if (!smart) {
920 failedPlace = addFailedPlace(dftDependency, storm::gspn::LayoutInfo(xcenter + 10.0, ycenter - 8.0));
921 addUnavailablePlace(dftDependency, storm::gspn::LayoutInfo(xcenter + 16.0, ycenter - 8.0));
922 }
923
924 uint64_t forwardPlace = 0;
925 if (dftDependency->probability() < 1.0) {
926 // PDEP
927 forwardPlace = builder.addPlace(defaultCapacity, 0, dftDependency->name() + "_forward");
928 builder.setPlaceLayoutInfo(forwardPlace, storm::gspn::LayoutInfo(xcenter + 1.0, ycenter + 2.0));
929
930 uint64_t coinPlace = builder.addPlace(defaultCapacity, 1, dftDependency->name() + "_coin");
931 builder.setPlaceLayoutInfo(coinPlace, storm::gspn::LayoutInfo(xcenter - 5.0, ycenter + 2.0));
932
933 uint64_t tStartFlip = builder.addImmediateTransition(getFailPriority(dftDependency), 0.0, dftDependency->name() + "_start_flip");
934 builder.addInputArc(coinPlace, tStartFlip);
935 builder.addInputArc(getFailedPlace(dftDependency->triggerEvent()), tStartFlip);
936 builder.addOutputArc(tStartFlip, getFailedPlace(dftDependency->triggerEvent()));
937
938 uint64_t flipPlace = builder.addPlace(defaultCapacity, 0, dftDependency->name() + "_flip");
939 builder.setPlaceLayoutInfo(flipPlace, storm::gspn::LayoutInfo(xcenter - 2.0, ycenter + 2.0));
940 builder.addOutputArc(tStartFlip, flipPlace);
941
942 uint64_t tWinFlip =
943 builder.addImmediateTransition(getFailPriority(dftDependency) + 1, dftDependency->probability(), dftDependency->name() + "_win_flip");
944 builder.addInputArc(flipPlace, tWinFlip);
945 builder.addOutputArc(tWinFlip, forwardPlace);
946
947 uint64_t tLooseFlip = builder.addImmediateTransition(
948 getFailPriority(dftDependency) + 1, storm::utility::one<ValueType>() - dftDependency->probability(), dftDependency->name() + "_lose_flip");
949 builder.addInputArc(flipPlace, tLooseFlip);
950 } else {
951 // FDEP
952 forwardPlace = getFailedPlace(dftDependency->triggerEvent());
953 }
954
955 // if the extended priorities option is set, set the priority for the forwarding transitions uniquely
956 uint64_t propagationPriority = getFailPriority(dftDependency);
957 for (auto const &child : dftDependency->dependentEvents()) {
958 uint64_t tForwardFailure = builder.addImmediateTransition(propagationPriority, 0.0, dftDependency->name() + "_propagate_" + child->name());
959
960 builder.addInputArc(forwardPlace, tForwardFailure);
961 builder.addOutputArc(tForwardFailure, forwardPlace);
962 builder.addOutputArc(tForwardFailure, getFailedPlace(child));
963 builder.addInhibitionArc(getFailedPlace(child), tForwardFailure);
964 if (!smart || child->nrRestrictions() > 0) {
965 builder.addInhibitionArc(disabledPlaces.at(child->id()), tForwardFailure);
966 }
967 if (!smart || mDft.isRepresentative(child->id())) {
968 builder.addOutputArc(tForwardFailure, unavailablePlaces.at(child->id()));
969 }
970 propagationPriority--;
971 }
972
973 // Don't Care
974 if (dontCareElements.count(dftDependency->id())) {
975 uint64_t tDontCare = addDontcareTransition(dftDependency, storm::gspn::LayoutInfo(xcenter + 3.0, ycenter));
976 if (!mergedDCFailed) {
977 uint64_t dontCarePlace = builder.addPlace(1, 0, dftDependency->name() + STR_DONTCARE);
978 builder.setPlaceLayoutInfo(dontCarePlace, storm::gspn::LayoutInfo(xcenter + 4.0, ycenter));
979 builder.addInhibitionArc(dontCarePlace, tDontCare);
980 builder.addOutputArc(tDontCare, dontCarePlace);
981 // Add the arcs for the dependent events
982 for (auto const &dependentEvent : dftDependency->dependentEvents()) {
983 if (dontCareElements.count(dependentEvent->id())) {
984 uint64_t dependentEventPropagation = dependencyPropagationPlaces.at(dependentEvent->id());
985 builder.addInputArc(dependentEventPropagation, tDontCare);
986 builder.addOutputArc(tDontCare, dependentEventPropagation);
987 }
988 }
989 // Add the arcs for the trigger
990 uint64_t triggerDontCare = dontcareTransitions.at(dftDependency->triggerEvent()->id());
991 builder.addInputArc(dontCarePlace, triggerDontCare);
992 builder.addOutputArc(triggerDontCare, dontCarePlace);
993 } else {
994 if (failedPlace == 0) {
995 failedPlace = addFailedPlace(dftDependency, storm::gspn::LayoutInfo(xcenter + 4.0, ycenter));
996 }
997 builder.addInhibitionArc(failedPlace, tDontCare);
998 builder.addOutputArc(tDontCare, failedPlace);
999
1000 // Add the arcs for the dependent events
1001 for (auto const &dependentEvent : dftDependency->dependentEvents()) {
1002 if (dontCareElements.count(dependentEvent->id())) {
1003 uint64_t dependentEventFailed = failedPlaces.at(dependentEvent->id());
1004 builder.addInputArc(dependentEventFailed, tDontCare);
1005 builder.addOutputArc(tDontCare, dependentEventFailed);
1006 }
1007 }
1008 // Add the arcs for the trigger
1009 uint64_t triggerDontCare = dontcareTransitions.at(dftDependency->triggerEvent()->id());
1010 builder.addInputArc(failedPlace, triggerDontCare);
1011 builder.addOutputArc(triggerDontCare, failedPlace);
1012 }
1013 }
1014 if (failedPlace == 0) {
1015 failedPlaces.push_back(failedPlace);
1016 }
1017 if (extendedPriorities) {
1018 dontCarePriority++;
1019 }
1020}
1021
1022template<typename ValueType>
1023void DftToGspnTransformator<ValueType>::translateSeq(std::shared_ptr<storm::dft::storage::elements::DFTSeq<ValueType> const> dftSeq) {
1024 STORM_LOG_THROW(dftSeq->allChildrenBEs(), storm::exceptions::NotImplementedException,
1025 "Sequence enforcers with gates as children are currently not supported.");
1026 double xcenter = mDft.getElementLayoutInfo(dftSeq->id()).x;
1027 double ycenter = mDft.getElementLayoutInfo(dftSeq->id()).y;
1028 uint64_t failedPlace = 0;
1029 if (!smart) {
1030 failedPlace = addFailedPlace(dftSeq, storm::gspn::LayoutInfo(xcenter + 10.0, ycenter - 8.0));
1031 addUnavailablePlace(dftSeq, storm::gspn::LayoutInfo(xcenter + 16.0, ycenter - 8.0));
1032 }
1033
1034 uint64_t tEnable = 0;
1035 uint64_t nextPlace = 0;
1036 for (size_t i = 0; i < dftSeq->nrChildren(); ++i) {
1037 auto const &child = dftSeq->children().at(i);
1038
1039 nextPlace = builder.addPlace(defaultCapacity, i == 0 ? 1 : 0, dftSeq->name() + "_next_" + child->name());
1040 builder.setPlaceLayoutInfo(nextPlace, storm::gspn::LayoutInfo(xcenter - 5.0 + i * 3.0, ycenter - 3.0));
1041
1042 if (i > 0) {
1043 builder.addOutputArc(tEnable, nextPlace);
1044 }
1045 tEnable = builder.addImmediateTransition(getFailPriority(dftSeq), 0.0, dftSeq->name() + "_unblock_" + child->name());
1046 builder.setTransitionLayoutInfo(tEnable, storm::gspn::LayoutInfo(xcenter - 5.0 + i * 3.0, ycenter + 3.0));
1047 builder.addInputArc(nextPlace, tEnable);
1048 builder.addInputArc(disabledPlaces.at(child->id()), tEnable);
1049 if (i > 0) {
1050 builder.addInputArc(getFailedPlace(dftSeq->children().at(i - 1)), tEnable);
1051 }
1052 }
1053 // Dont Care
1054 if (dontCareElements.count(dftSeq->id())) {
1055 if (!mergedDCFailed) {
1056 uint64_t dontCarePlace = builder.addPlace(1, 0, dftSeq->name() + STR_DONTCARE);
1057 builder.setPlaceLayoutInfo(dontCarePlace, storm::gspn::LayoutInfo(xcenter + 10.0, ycenter - 8.0));
1058 for (auto const &child : dftSeq->children()) {
1059 if (dontCareElements.count(child->id())) {
1060 uint64_t childDontCare = dontcareTransitions.at(child->id());
1061 builder.addInputArc(dontCarePlace, childDontCare);
1062 }
1063 }
1064 } else {
1065 if (failedPlace == 0) {
1066 failedPlace = addFailedPlace(dftSeq, storm::gspn::LayoutInfo(xcenter + 10.0, ycenter - 8.0));
1067 }
1068 for (auto const &child : dftSeq->children()) {
1069 if (dontCareElements.count(child->id())) {
1070 uint64_t childDontCare = dontcareTransitions.at(child->id());
1071 builder.addInputArc(failedPlace, childDontCare);
1072 }
1073 }
1074 }
1075 }
1076}
1077
1078template<typename ValueType>
1079uint64_t DftToGspnTransformator<ValueType>::addFailedPlace(std::shared_ptr<storm::dft::storage::elements::DFTElement<ValueType> const> dftElement,
1080 storm::gspn::LayoutInfo const &layoutInfo, bool initialFailed) {
1081 uint64_t failedPlace = builder.addPlace(defaultCapacity, initialFailed ? 1 : 0, dftElement->name() + STR_FAILED);
1082 STORM_LOG_ASSERT(failedPlaces.size() == dftElement->id(), "Failed place index mismatch.");
1083 failedPlaces.push_back(failedPlace);
1084 builder.setPlaceLayoutInfo(failedPlace, layoutInfo);
1085 return failedPlace;
1086}
1087
1088template<typename ValueType>
1089uint64_t DftToGspnTransformator<ValueType>::addUnavailablePlace(std::shared_ptr<storm::dft::storage::elements::DFTElement<ValueType> const> dftElement,
1090 storm::gspn::LayoutInfo const &layoutInfo, bool initialAvailable) {
1091 unsigned int capacity = 2; // Unavailable place has capacity 2
1092 uint64_t unavailablePlace = builder.addPlace(capacity, initialAvailable ? 0 : 1, dftElement->name() + "_unavail");
1093 unavailablePlaces.emplace(dftElement->id(), unavailablePlace);
1094 builder.setPlaceLayoutInfo(unavailablePlace, layoutInfo);
1095 return unavailablePlace;
1096}
1097
1098template<typename ValueType>
1099uint64_t DftToGspnTransformator<ValueType>::addDisabledPlace(std::shared_ptr<const storm::dft::storage::elements::DFTBE<ValueType>> dftBe,
1100 storm::gspn::LayoutInfo const &layoutInfo) {
1101 uint64_t disabledPlace = builder.addPlace(dftBe->nrRestrictions(), dftBe->nrRestrictions(), dftBe->name() + "_dabled");
1102 disabledPlaces.emplace(dftBe->id(), disabledPlace);
1103 builder.setPlaceLayoutInfo(disabledPlace, layoutInfo);
1104 return disabledPlace;
1105}
1106
1107template<typename ValueType>
1108uint64_t DftToGspnTransformator<ValueType>::addDontcareTransition(std::shared_ptr<const storm::dft::storage::elements::DFTElement<ValueType>> dftElement,
1109 storm::gspn::LayoutInfo const &layoutInfo) {
1110 uint64_t dontcareTransition;
1111 dontcareTransition = builder.addImmediateTransition(dontCarePriority, 0.0, dftElement->name() + STR_DONTCARE + "_transition");
1112 dontcareTransitions.emplace(dftElement->id(), dontcareTransition);
1113 builder.setTransitionLayoutInfo(dontcareTransition, layoutInfo);
1114 return dontcareTransition;
1115}
1116
1117template<typename ValueType>
1118bool DftToGspnTransformator<ValueType>::isActiveInitially(std::shared_ptr<storm::dft::storage::elements::DFTElement<ValueType> const> dftElement) {
1119 // If element is in the top module, return true.
1120 return !mDft.hasRepresentant(dftElement->id());
1121}
1122
1123template<typename ValueType>
1124uint64_t DftToGspnTransformator<ValueType>::getFailPriority(std::shared_ptr<storm::dft::storage::elements::DFTElement<ValueType> const> dftElement) {
1125 // Return the value given in the field
1126 return priorities.at(dftElement->id());
1127}
1128
1129// Explicitly instantiate the class.
1130template class DftToGspnTransformator<double>;
1131
1132// template class DftToGspnTransformator<storm::RationalFunction>;
1133
1134} // namespace transformations
1135} // namespace storm::dft
Represents a Dynamic Fault Tree.
Definition DFT.h:49
BE which is either constant failed or constant failsafe.
Definition BEConst.h:14
BE with exponential failure distribution.
Abstract base class for basic events (BEs) in DFTs.
Definition DFTBE.h:14
Dependency gate with probability p.
Priority AND (PAND) gate.
Definition DFTPand.h:17
Priority OR (POR) gate.
Definition DFTPor.h:17
Sequence enforcer (SEQ).
Definition DFTSeq.h:15
VOT gate with threshold k.
Definition DFTVot.h:14
void transform(std::map< uint64_t, uint64_t > const &priorities, std::set< uint64_t > const &dontCareElements, bool smart=true, bool mergeDCFailed=true, bool extendPriorities=false)
Transform the DFT to a GSPN.
uint64_t toplevelFailedPlaceId()
Get failed place id of top level element.
DftToGspnTransformator(storm::dft::storage::DFT< ValueType > const &dft)
Constructor.
std::map< uint64_t, uint64_t > computePriorities(bool extendedPrio)
Compute priorities used for GSPN transformation.
#define STORM_LOG_ASSERT(cond, message)
Definition macros.h:9
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:28
static constexpr uint64_t defaultCapacity
ValueType one()
Definition constants.cpp:19