From faee1dfeeeeec169f023b314448de27e9703c3dc Mon Sep 17 00:00:00 2001
From: Sebastian Junges <sebastian.junges@rwth-aachen.de>
Date: Mon, 21 Nov 2016 22:05:10 +0100
Subject: [PATCH 01/47] updated dft->gspn translation to now have basis support
 for spares

---
 src/storm-dft-cli/storm-dyftee.cpp            |   6 +
 .../dft/DftToGspnTransformator.cpp            | 923 ++++++++++++++++++
 .../dft/DftToGspnTransformator.h              | 174 ++++
 3 files changed, 1103 insertions(+)
 create mode 100644 src/storm/transformations/dft/DftToGspnTransformator.cpp
 create mode 100644 src/storm/transformations/dft/DftToGspnTransformator.h

diff --git a/src/storm-dft-cli/storm-dyftee.cpp b/src/storm-dft-cli/storm-dyftee.cpp
index 6ed375d79..71f5cea86 100644
--- a/src/storm-dft-cli/storm-dyftee.cpp
+++ b/src/storm-dft-cli/storm-dyftee.cpp
@@ -4,6 +4,7 @@
 #include "storm/cli/cli.h"
 #include "storm/exceptions/BaseException.h"
 #include "storm/utility/macros.h"
+#include "storm/transformations/dft/DftToGspnTransformator.h"
 
 #include "storm/settings/modules/GeneralSettings.h"
 #include "storm/settings/modules/CoreSettings.h"
@@ -78,6 +79,11 @@ template <typename ValueType>
 storm::gspn::GSPN transformDFT(std::string filename) {
     storm::parser::DFTGalileoParser<ValueType> parser;
     storm::storage::DFT<ValueType> dft = parser.parseDFT(filename);
+<<<<<<< f8986fe6139bddaf5068477b0f70ac1f806f8576:src/storm-dft-cli/storm-dyftee.cpp
+=======
+    storm::transformations::dft::DftToGspnTransformator<ValueType> gspnTransformator(dft);
+    gspnTransformator.transform();
+>>>>>>> updated dft->gspn translation to now have basis support for spares:src/storm/storm-dyftee.cpp
 }
 
 /*!
diff --git a/src/storm/transformations/dft/DftToGspnTransformator.cpp b/src/storm/transformations/dft/DftToGspnTransformator.cpp
new file mode 100644
index 000000000..4331e0c62
--- /dev/null
+++ b/src/storm/transformations/dft/DftToGspnTransformator.cpp
@@ -0,0 +1,923 @@
+#include "DftToGspnTransformator.h"
+#include "storm/exceptions/NotImplementedException.h"
+#include <memory>
+
+namespace storm {
+    namespace transformations {
+        namespace dft {
+            
+            // Prevent some magic constants
+            static constexpr const uint64_t defaultPriority = 0;
+            static constexpr const uint64_t defaultCapacity = 0;
+
+            template <typename ValueType>
+            DftToGspnTransformator<ValueType>::DftToGspnTransformator(storm::storage::DFT<ValueType> const& dft) : mDft(dft) {
+                // Intentionally left empty.
+            }
+
+            template <typename ValueType>
+            void DftToGspnTransformator<ValueType>::transform() {
+				
+                builder.setGspnName("DftToGspnTransformation");
+				
+				// Loop through every DFT element and draw them as a GSPN.
+				drawGSPNElements();
+				
+				// When all DFT elements are drawn, draw the connections between them.
+				drawGSPNConnections();
+				
+				// Draw functional/probability dependencies into the GSPN.
+				drawGSPNDependencies();
+				
+				// Draw restrictions into the GSPN (i.e. SEQ or MUTEX).
+				drawGSPNRestrictions(); 
+		
+				// Write GSPN to file.
+				writeGspn(true);
+            }
+            
+			template <typename ValueType>
+            void DftToGspnTransformator<ValueType>::drawGSPNElements() {
+                
+                
+				// Loop through every DFT element and draw them as a GSPN.
+				for (std::size_t i = 0; i < mDft.nrElements(); i++) {
+					auto dftElement = mDft.getElement(i);
+                    bool isRepresentative = mDft.isRepresentative(i);
+                    
+					// Check which type the element is and call the corresponding drawing-function.
+					switch (dftElement->type()) {
+						case storm::storage::DFTElementType::AND:
+							drawAND(std::static_pointer_cast<storm::storage::DFTAnd<ValueType> const>(dftElement), isRepresentative);
+							break;
+						case storm::storage::DFTElementType::OR:
+							drawOR(std::static_pointer_cast<storm::storage::DFTOr<ValueType> const>(dftElement), isRepresentative);
+							break;
+						case storm::storage::DFTElementType::VOT:
+							drawVOT(std::static_pointer_cast<storm::storage::DFTVot<ValueType> const>(dftElement), isRepresentative);
+							break;
+						case storm::storage::DFTElementType::PAND:
+							drawPAND(std::static_pointer_cast<storm::storage::DFTPand<ValueType> const>(dftElement), isRepresentative);
+							break;
+						case storm::storage::DFTElementType::SPARE:
+							drawSPARE(std::static_pointer_cast<storm::storage::DFTSpare<ValueType> const>(dftElement), isRepresentative);
+							break;
+						case storm::storage::DFTElementType::POR:
+							drawPOR(std::static_pointer_cast<storm::storage::DFTPor<ValueType> const>(dftElement), isRepresentative);
+							break;
+						case storm::storage::DFTElementType::SEQ:
+							// No method call needed here. SEQ only consists of restrictions, which are handled later.
+							break;
+						case storm::storage::DFTElementType::MUTEX:
+							// No method call needed here. MUTEX only consists of restrictions, which are handled later.
+							break;
+						case storm::storage::DFTElementType::BE:
+							drawBE(std::static_pointer_cast<storm::storage::DFTBE<ValueType> const>(dftElement), isRepresentative);
+							break;
+						case storm::storage::DFTElementType::CONSTF:
+							drawCONSTF(dftElement, isRepresentative);
+							break;
+						case storm::storage::DFTElementType::CONSTS:
+							drawCONSTS(dftElement, isRepresentative);
+							break;
+						case storm::storage::DFTElementType::PDEP:
+							drawPDEP(std::static_pointer_cast<storm::storage::DFTDependency<ValueType> const>(dftElement), isRepresentative);
+							break;
+						default:
+							STORM_LOG_ASSERT(false, "DFT type unknown.");
+							break;
+					}
+				}
+                
+			}
+            
+            template <typename ValueType>
+            void DftToGspnTransformator<ValueType>::drawBE(std::shared_ptr<storm::storage::DFTBE<ValueType> const> dftBE, bool isRepresentative) {
+                
+				uint64_t beActive = builder.addPlace(defaultCapacity, isBEActive(dftBE) ? 1 : 0, dftBE->name() + STR_ACTIVATED);
+                activeNodes.emplace(dftBE->id(), beActive);
+                uint64_t beFailed = builder.addPlace(defaultCapacity, 0, dftBE->name() + STR_FAILED);
+                
+                uint64_t unavailableNode = 0;
+                if (isRepresentative) {
+                    unavailableNode = addUnavailableNode(dftBE);
+                }
+                
+                assert(failedNodes.size() == dftBE->id());
+                failedNodes.push_back(beFailed);
+                uint64_t tActive = builder.addTimedTransition(defaultPriority, dftBE->activeFailureRate(), dftBE->name() + "_activeFailing");
+                builder.addInputArc(beActive, tActive);
+                builder.addInhibitionArc(beFailed, tActive);
+                builder.addOutputArc(tActive, beActive);
+                builder.addOutputArc(tActive, beFailed);
+                uint64_t tPassive = builder.addTimedTransition(defaultPriority, dftBE->passiveFailureRate(), dftBE->name() + "_passiveFailing");
+                builder.addInhibitionArc(beActive, tPassive);
+                builder.addInhibitionArc(beFailed, tPassive);
+                builder.addOutputArc(tPassive, beFailed);
+                
+                if (isRepresentative) {
+                    builder.addOutputArc(tActive, unavailableNode);
+                    builder.addOutputArc(tPassive, unavailableNode);
+                }
+            }
+			
+			template <typename ValueType>
+            void DftToGspnTransformator<ValueType>::drawAND(std::shared_ptr<storm::storage::DFTAnd<ValueType> const> dftAnd, bool isRepresentative) {
+                uint64_t nodeFailed = builder.addPlace(defaultCapacity, 0, dftAnd->name() + STR_FAILED);
+                assert(failedNodes.size() == dftAnd->id());
+                failedNodes.push_back(nodeFailed);
+                
+                uint64_t unavailableNode = 0;
+                if (isRepresentative) {
+                    unavailableNode = addUnavailableNode(dftAnd);
+                }
+
+                
+                uint64_t tAndFailed = builder.addImmediateTransition( getFailPriority(dftAnd)  , 0.0, dftAnd->name() + STR_FAILING );
+                builder.addInhibitionArc(nodeFailed, tAndFailed);
+                builder.addOutputArc(tAndFailed, nodeFailed);
+                if (isRepresentative) {
+                    builder.addOutputArc(tAndFailed, unavailableNode);
+                }
+                for(auto const& child : dftAnd->children()) {
+                    assert(failedNodes.size() > child->id());
+                    builder.addInputArc(failedNodes[child->id()], tAndFailed);
+                }
+                
+			}
+
+			template <typename ValueType>
+            void DftToGspnTransformator<ValueType>::drawOR(std::shared_ptr<storm::storage::DFTOr<ValueType> const> dftOr, bool isRepresentative) {
+                uint64_t nodeFailed = builder.addPlace(defaultCapacity, 0, dftOr->name() + STR_FAILED);
+                assert(failedNodes.size() == dftOr->id());
+                failedNodes.push_back(nodeFailed);
+                uint64_t unavailableNode = 0;
+                if (isRepresentative) {
+                    unavailableNode = addUnavailableNode(dftOr);
+                }
+                
+                uint64_t i = 0;
+                for (auto const& child : dftOr->children()) {
+                    uint64_t tNodeFailed = builder.addImmediateTransition( getFailPriority(dftOr)  , 0.0, dftOr->name() + STR_FAILING + std::to_string(i) );
+                    builder.addInhibitionArc(nodeFailed, tNodeFailed);
+                    builder.addOutputArc(tNodeFailed, nodeFailed);
+                    if (isRepresentative) {
+                        builder.addOutputArc(tNodeFailed, unavailableNode);
+                    }
+                    assert(failedNodes.size() > child->id());
+                    builder.addInputArc(failedNodes[child->id()], tNodeFailed);
+                    ++i;
+                }
+			}
+			
+			template <typename ValueType>
+            void DftToGspnTransformator<ValueType>::drawVOT(std::shared_ptr<storm::storage::DFTVot<ValueType> const> dftVot, bool isRepresentative) {
+                uint64_t nodeFailed = builder.addPlace(defaultCapacity, 0, dftVot->name() + STR_FAILED);
+                assert(failedNodes.size() == dftVot->id());
+                failedNodes.push_back(nodeFailed);
+                uint64_t unavailableNode = 0;
+                if (isRepresentative) {
+                    unavailableNode = addUnavailableNode(dftVot);
+                }
+                
+                uint64_t nodeCollector = builder.addPlace(dftVot->nrChildren(), 0, dftVot->name() + "_collector");
+                uint64_t tNodeFailed = builder.addImmediateTransition(getFailPriority(dftVot), 0.0, dftVot->name() + STR_FAILING);
+                builder.addOutputArc(tNodeFailed, nodeFailed);
+                if (isRepresentative) {
+                    builder.addOutputArc(tNodeFailed, unavailableNode);
+                }
+                builder.addInhibitionArc(nodeFailed, tNodeFailed);
+                builder.addInputArc(nodeCollector, tNodeFailed, dftVot->threshold());
+                builder.addOutputArc(tNodeFailed, nodeCollector, dftVot->threshold());
+                uint64_t i = 0;
+                for (auto const& child : dftVot->children()) {
+                    uint64_t childInhibPlace = builder.addPlace(1, 0, dftVot->name() + "_child_fail_inhib" + std::to_string(i));
+                    uint64_t tCollect = builder.addImmediateTransition(getFailPriority(dftVot), 0.0, dftVot->name() + "_child_collect" + std::to_string(i));
+                    builder.addOutputArc(tCollect, nodeCollector);
+                    builder.addOutputArc(tCollect, childInhibPlace);
+                    builder.addInhibitionArc(childInhibPlace, tCollect);
+                    builder.addInputArc(failedNodes[child->id()], tCollect);
+                    ++i;
+                }
+			}
+
+			template <typename ValueType>
+            void DftToGspnTransformator<ValueType>::drawPAND(std::shared_ptr<storm::storage::DFTPand<ValueType> const> dftPand, bool isRepresentative) {
+                uint64_t nodeFailed = builder.addPlace(defaultCapacity, 0, dftPand->name()  + STR_FAILED);
+                assert(failedNodes.size() == dftPand->id());
+                failedNodes.push_back(nodeFailed);
+                uint64_t unavailableNode = 0;
+                if (isRepresentative) {
+                    unavailableNode = addUnavailableNode(dftPand);
+                }
+
+                uint64_t nodeFS = builder.addPlace(defaultCapacity, 0, dftPand->name() + STR_FAILSAVE);
+                uint64_t tNodeFailed = builder.addImmediateTransition(getFailPriority(dftPand), 0.0,  dftPand->name() + STR_FAILING);
+                builder.addInhibitionArc(nodeFailed, tNodeFailed);
+                builder.addInhibitionArc(nodeFS, tNodeFailed);
+                builder.addOutputArc(tNodeFailed, nodeFailed);
+                if (isRepresentative) {
+                    builder.addOutputArc(tNodeFailed, nodeFailed);
+                }
+                for(auto const& child : dftPand->children()) {
+                    builder.addInputArc(failedNodes[child->id()], tNodeFailed);
+                }
+                for (uint64_t j = 1; j < dftPand->nrChildren(); ++j) {
+                    uint64_t tfs = builder.addImmediateTransition(getFailPriority(dftPand), 0.0, dftPand->name() + STR_FAILSAVING + std::to_string(j));
+                    builder.addInputArc(failedNodes[dftPand->children().at(j)->id()], tfs);
+                    builder.addInhibitionArc(failedNodes[dftPand->children().at(j-1)->id()], tfs);
+                    builder.addOutputArc(tfs, nodeFS);
+                    
+                }
+            }
+//			
+			template <typename ValueType>
+            void DftToGspnTransformator<ValueType>::drawSPARE(std::shared_ptr<storm::storage::DFTSpare<ValueType> const> dftSpare, bool isRepresentative) {
+                
+                uint64_t nodeFailed = builder.addPlace(defaultCapacity, 0, dftSpare->name() + STR_FAILED);
+                failedNodes.push_back(nodeFailed);
+                uint64_t unavailableNode = 0;
+                if (isRepresentative) {
+                    unavailableNode = addUnavailableNode(dftSpare);
+                }
+                uint64_t spareActive = builder.addPlace(defaultCapacity, 0, dftSpare->name() + STR_ACTIVATED);
+                activeNodes.emplace(dftBE->id(), beActive);
+
+                
+                std::vector<uint64_t> cucNodes;
+                std::vector<uint64_t> nextClaimNodes;
+                std::vector<uint64_t> nextclTransitions;
+                std::vector<uint64_t> nextconsiderTransitions;
+                uint64_t j = 0;
+                for(auto const& child : dftSpare->children()) {
+                    if (j > 0) {
+                        nextClaimNodes.push_back(builder.addPlace(defaultCapacity, 0, dftSpare->name()+ "_consider_" + child->name()));
+                        
+                        builder.addOutputArc(nextclTransitions.back(), nextClaimNodes.back(), 1);
+                        if (j > 1) {
+                            builder.addOutputArc(nextconsiderTransitions.back(), nextClaimNodes.back());
+                        }
+                        
+                        uint64_t tnextconsider = builder.addImmediateTransition(getFailPriority(dftSpare), 0.0, dftSpare->name() + "_cannot_claim_" + child->name());
+                        builder.addInputArc(nextClaimNodes.back(), tnextconsider);
+                        builder.addInputArc(unavailableNodes.at(child->id()), tnextconsider);
+                        nextconsiderTransitions.push_back(tnextconsider);
+                        
+                    }
+                    cucNodes.push_back(builder.addPlace(defaultCapacity, j == 0 ? 1 : 0, dftSpare->name() + "_claimed_" + child->name()));
+                    if (j > 0) {
+                        uint64 tclaim = builder.addImmediateTransition(getFailPriority(dftSpare), 0.0, dftSpare->name() + "_claim_" + child->name());
+                        builder.addInhibitionArc(unavailableNodes.at(child->id()), tclaim);
+                        builder.addInputArc(nextClaimNodes.back(), tclaim);
+                        builder.addOutputArc(tclaim, cucNodes.back());
+                    }
+                    uint64_t tnextcl = builder.addImmediateTransition(getFailPriority(dftSpare), 0.0, dftSpare->name() + "_next_claim_" + std::to_string(j));
+                    builder.addInputArc(cucNodes.back(), tnextcl);
+                    builder.addOutputArc(tnextcl, cucNodes.back());
+                    builder.addInputArc(failedNodes.at(child->id()), tnextcl);
+                    builder.addOutputArc(tnextcl, failedNodes.at(child->id()));
+                    nextclTransitions.push_back(tnextcl);
+                    
+                    
+                    ++j;
+                }
+                builder.addOutputArc(nextconsiderTransitions.back(), nodeFailed);
+                builder.addOutputArc(nextclTransitions.back(), nodeFailed);
+                
+                if (isRepresentative) {
+                    builder.addOutputArc(nextconsiderTransitions.back(), unavailableNode);
+                    builder.addOutputArc(nextclTransitions.back(), unavailableNode);
+                }
+                
+                
+//				uint_fast64_t priority = getPriority(0, dftSpare);
+//				
+//				// This codeblock can be removed later, when I am 100% sure it is not needed anymore.
+//				/*
+//				storm::gspn::Place placeSPAREActivated;
+//				placeSPAREActivated.setName(dftSpare->name() + STR_ACTIVATED);
+//				placeSPAREActivated.setNumberOfInitialTokens(isBEActive(dftSpare));
+//				mGspn.addPlace(placeSPAREActivated);
+//				
+//				storm::gspn::ImmediateTransition<storm::gspn::GSPN::WeightType> immediateTransitionPCActivating;
+//				immediateTransitionPCActivating.setName(dftSpare->children()[0]->name() + STR_ACTIVATING);
+//				immediateTransitionPCActivating.setPriority(priority);
+//				immediateTransitionPCActivating.setWeight(0.0);
+//				immediateTransitionPCActivating.setInputArcMultiplicity(placeSPAREActivated, 1);
+//				immediateTransitionPCActivating.setOutputArcMultiplicity(placeSPAREActivated, 1);
+//				mGspn.addImmediateTransition(immediateTransitionPCActivating);
+//				*/
+//				
+//				auto children = dftSpare->children();
+//				
+//				// Draw places and transitions that belong to each spare child.
+//				for (std::size_t i = 1; i < children.size(); i++) {
+//					auto placeChildClaimedPreexist = mGspn.getPlace(children[i]->name() + "_claimed");
+//					
+//					if (!placeChildClaimedPreexist.first) { // Only draw this place if it doesn't exist jet.
+//						storm::gspn::Place placeChildClaimed;
+//						placeChildClaimed.setName(children[i]->name() + "_claimed");
+//						placeChildClaimed.setNumberOfInitialTokens(0);
+//						mGspn.addPlace(placeChildClaimed);
+//						
+//						storm::gspn::ImmediateTransition<storm::gspn::GSPN::WeightType> immediateTransitionSpareChildActivating;
+//						immediateTransitionSpareChildActivating.setName(children[i]->name() + STR_ACTIVATING);
+//						immediateTransitionSpareChildActivating.setPriority(priority);
+//						immediateTransitionSpareChildActivating.setWeight(0.0);
+//						immediateTransitionSpareChildActivating.setInputArcMultiplicity(placeChildClaimed, 1);
+//						immediateTransitionSpareChildActivating.setOutputArcMultiplicity(placeChildClaimed, 1);
+//						mGspn.addImmediateTransition(immediateTransitionSpareChildActivating);
+//					}
+//					
+//					auto placeChildClaimedExist = mGspn.getPlace(children[i]->name() + "_claimed");
+//					
+//					storm::gspn::Place placeSPAREClaimedChild;
+//					placeSPAREClaimedChild.setName(dftSpare->name() + "_claimed_" + children[i]->name());
+//					placeSPAREClaimedChild.setNumberOfInitialTokens(0);
+//					mGspn.addPlace(placeSPAREClaimedChild);
+//					
+//					storm::gspn::ImmediateTransition<storm::gspn::GSPN::WeightType> immediateTransitionChildClaiming;
+//					immediateTransitionChildClaiming.setName(dftSpare->name() + "_claiming_" + children[i]->name());
+//					immediateTransitionChildClaiming.setPriority(priority + 1); // Higher priority needed!
+//					immediateTransitionChildClaiming.setWeight(0.0);
+//					immediateTransitionChildClaiming.setInhibitionArcMultiplicity(placeChildClaimedExist.second, 1);
+//					immediateTransitionChildClaiming.setOutputArcMultiplicity(placeChildClaimedExist.second, 1);
+//					immediateTransitionChildClaiming.setOutputArcMultiplicity(placeSPAREClaimedChild, 1);
+//					mGspn.addImmediateTransition(immediateTransitionChildClaiming);
+//					
+//					storm::gspn::Place placeSPAREChildConsumed;
+//					if (i < children.size() - 1) {
+//						placeSPAREChildConsumed.setName(dftSpare->name() + "_" + children[i]->name() + "_consumed");
+//					}
+//					else {
+//						placeSPAREChildConsumed.setName(dftSpare->name() + STR_FAILED);
+//					}
+//					placeSPAREChildConsumed.setNumberOfInitialTokens(0);
+//					mGspn.addPlace(placeSPAREChildConsumed);
+//					
+//					storm::gspn::ImmediateTransition<storm::gspn::GSPN::WeightType> immediateTransitionChildConsuming1;
+//					immediateTransitionChildConsuming1.setName(dftSpare->name() + "_" + children[i]->name() + "_consuming1");
+//					immediateTransitionChildConsuming1.setPriority(priority);
+//					immediateTransitionChildConsuming1.setWeight(0.0);
+//					immediateTransitionChildConsuming1.setOutputArcMultiplicity(placeSPAREChildConsumed, 1);
+//					immediateTransitionChildConsuming1.setInhibitionArcMultiplicity(placeSPAREChildConsumed, 1);
+//					immediateTransitionChildConsuming1.setInhibitionArcMultiplicity(placeSPAREClaimedChild, 1);
+//					mGspn.addImmediateTransition(immediateTransitionChildConsuming1);
+//					
+//					storm::gspn::ImmediateTransition<storm::gspn::GSPN::WeightType> immediateTransitionChildConsuming2;
+//					immediateTransitionChildConsuming2.setName(dftSpare->name() + "_" + children[i]->name() + "_consuming2");
+//					immediateTransitionChildConsuming2.setPriority(priority);
+//					immediateTransitionChildConsuming2.setWeight(0.0);
+//					immediateTransitionChildConsuming2.setOutputArcMultiplicity(placeSPAREChildConsumed, 1);
+//					immediateTransitionChildConsuming2.setInhibitionArcMultiplicity(placeSPAREChildConsumed, 1);
+//					immediateTransitionChildConsuming2.setOutputArcMultiplicity(placeSPAREClaimedChild, 1);
+//					immediateTransitionChildConsuming2.setInputArcMultiplicity(placeSPAREClaimedChild, 1);
+//					mGspn.addImmediateTransition(immediateTransitionChildConsuming2);
+//				}
+//				
+//				// Draw connections between all spare childs.
+//				for (std::size_t i = 1; i < children.size() - 1; i++) {
+//					auto placeSPAREChildConsumed = mGspn.getPlace(dftSpare->name() + "_" + children[i]->name() + "_consumed");
+//					auto immediateTransitionChildClaiming = mGspn.getImmediateTransition(dftSpare->name() + "_claiming_" + children[i + 1]->name());
+//					auto immediateTransitionChildConsuming1 = mGspn.getImmediateTransition(dftSpare->name() + "_" + children[i + 1]->name() + "_consuming1");
+//					
+//					immediateTransitionChildClaiming.second->setOutputArcMultiplicity(placeSPAREChildConsumed.second, 1);
+//					immediateTransitionChildClaiming.second->setInputArcMultiplicity(placeSPAREChildConsumed.second, 1);
+//					
+//					immediateTransitionChildConsuming1.second->setOutputArcMultiplicity(placeSPAREChildConsumed.second, 1);
+//					immediateTransitionChildConsuming1.second->setInputArcMultiplicity(placeSPAREChildConsumed.second, 1);
+//				}
+			}
+//			
+			template <typename ValueType>
+            void DftToGspnTransformator<ValueType>::drawPOR(std::shared_ptr<storm::storage::DFTPor<ValueType> const> dftPor, bool isRepresentative) {
+                uint64_t nodeFailed = builder.addPlace(defaultCapacity, 0, dftPor->name() + STR_FAILED);
+                uint64_t nodeFS = builder.addPlace(defaultCapacity, 0, dftPor->name() + STR_FAILSAVE);
+                
+                
+                uint64_t tfail = builder.addImmediateTransition(getFailPriority(dftPor), 0.0, dftPor->name() + STR_FAILING);
+                builder.addInhibitionArc(nodeFS, tfail);
+                builder.addInputArc(failedNodes.at(dftPor->children().front()->id()), tfail);
+                builder.addOutputArc(tfail, failedNodes.at(dftPor->children().front()->id()));
+                builder.addOutputArc(tfail, nodeFailed);
+                builder.addInhibitionArc(nodeFailed, tfail);
+                uint64_t j = 0;
+                for (auto const& child : dftPor->children()) {
+                    uint64_t tfailsf = builder.addImmediateTransition(getFailPriority(dftPor), 0.0, dftPor->name() + STR_FAILSAVING + std::to_string(j));
+                    builder.addInputArc(failedNodes.at(child->id()), tfailsf);
+                    builder.addOutputArc(tfailsf, failedNodes.at(child->id()));
+                    // TODO
+//                    builder.addInhibitionArc(<#const uint_fast64_t &from#>, <#const uint_fast64_t &to#>)
+                    ++j;
+                }
+			}
+            
+//			
+			template <typename ValueType>
+            void DftToGspnTransformator<ValueType>::drawCONSTF(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dftConstF, bool isRepresentative) {
+//				storm::gspn::Place placeCONSTFFailed;
+//				placeCONSTFFailed.setName(dftConstF->name() + STR_FAILED);
+//				placeCONSTFFailed.setNumberOfInitialTokens(1);
+//				mGspn.addPlace(placeCONSTFFailed);
+			}
+//			
+			template <typename ValueType>
+            void DftToGspnTransformator<ValueType>::drawCONSTS(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dftConstS, bool isRepresentative) {
+//				storm::gspn::Place placeCONSTSFailed;
+//				placeCONSTSFailed.setName(dftConstS->name() + STR_FAILED);
+//				placeCONSTSFailed.setNumberOfInitialTokens(0);
+//				placeCONSTSFailed.setCapacity(0); // It cannot contain a token, because it cannot fail.
+//				mGspn.addPlace(placeCONSTSFailed);
+			}
+//			
+			template <typename ValueType>
+            void DftToGspnTransformator<ValueType>::drawPDEP(std::shared_ptr<storm::storage::DFTDependency<ValueType> const> dftDependency, bool isRepresentative) {
+//				// Only draw dependency, if it wasn't drawn before.
+//				std::string gateName = dftDependency->name().substr(0, dftDependency->name().find("_"));
+//				auto exists = mGspn.getPlace(gateName + STR_FAILED);
+//				if (!exists.first) {
+//					storm::gspn::Place placeDEPFailed;
+//					placeDEPFailed.setName(gateName + STR_FAILED);
+//					placeDEPFailed.setNumberOfInitialTokens(0);
+//					mGspn.addPlace(placeDEPFailed);
+//					
+//					storm::gspn::TimedTransition<double> timedTransitionDEPFailure;
+//					timedTransitionDEPFailure.setName(gateName + STR_FAILING);
+//					timedTransitionDEPFailure.setPriority(getPriority(0, dftDependency));
+//					timedTransitionDEPFailure.setRate(dftDependency->probability());
+//					timedTransitionDEPFailure.setOutputArcMultiplicity(placeDEPFailed, 1);
+//					timedTransitionDEPFailure.setInhibitionArcMultiplicity(placeDEPFailed, 1);
+//					mGspn.addTimedTransition(timedTransitionDEPFailure);
+//				}
+			}
+            
+            template<typename ValueType>
+            uint64_t DftToGspnTransformator<ValueType>::addUnavailableNode(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dftElement) {
+                uint64_t unavailableNode = builder.addPlace(defaultCapacity, 1, dftElement->name() + "_unavailable");
+                assert(unavailableNode != 0);
+                unavailableNodes.emplace(dftElement->id(), unavailableNode);
+                return unavailableNode;
+            }
+//			
+			template <typename ValueType>
+            void DftToGspnTransformator<ValueType>::drawGSPNConnections() {
+//				// Check for every element, if they have parents (all will have at least 1, except the top event). 
+//				for (std::size_t i = 0; i < mDft.nrElements(); i++) {
+//					auto child = mDft.getElement(i);
+//					auto parents = child->parentIds();
+//					
+//					// Draw a connection to every parent.
+//					for (std::size_t j = 0; j < parents.size(); j++) {	
+//						// Check the type of the parent and act accordingly (every parent gate has different entry points...).
+//						switch (mDft.getElement(parents[j])->type()) {
+//							case storm::storage::DFTElementType::AND:
+//							{
+//								auto andEntry = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + STR_FAILING);
+//								auto childExit = mGspn.getPlace(child->name() + STR_FAILED);
+//								if (andEntry.first && childExit.first) { // Only add arcs if the objects have been found.
+//									andEntry.second->setInputArcMultiplicity(childExit.second, 1);
+//									andEntry.second->setOutputArcMultiplicity(childExit.second, 1);
+//								}
+//								break;
+//							}
+//							case storm::storage::DFTElementType::OR:
+//							{
+//								auto orEntry = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + "_" + child->name() + STR_FAILING);
+//								auto childExit = mGspn.getPlace(child->name() + STR_FAILED);
+//								if (orEntry.first && childExit.first) { // Only add arcs if the objects have been found.
+//									orEntry.second->setInputArcMultiplicity(childExit.second, 1);
+//									orEntry.second->setOutputArcMultiplicity(childExit.second, 1);
+//								}
+//								break;
+//							}
+//							case storm::storage::DFTElementType::VOT:
+//							{
+//								auto childExit = mGspn.getPlace(child->name() + STR_FAILED);
+//								auto parentEntry = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + "_" + child->name() + "_collecting");
+//								
+//								if (childExit.first && parentEntry.first) { // Only add arcs if the objects have been found.
+//									parentEntry.second->setInputArcMultiplicity(childExit.second, 1);
+//									parentEntry.second->setOutputArcMultiplicity(childExit.second, 1);
+//								}
+//								
+//								break;
+//							}
+//							case storm::storage::DFTElementType::PAND:
+//							{
+//								auto children =  std::static_pointer_cast<storm::storage::DFTPand<ValueType> const>(mDft.getElement(parents[j]))->children();
+//								auto childExit = mGspn.getPlace(child->name() + STR_FAILED);
+//								auto pandEntry = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + STR_FAILING);
+//								
+//								if (childExit.first && pandEntry.first) { // Only add arcs if the objects have been found.
+//									pandEntry.second->setInputArcMultiplicity(childExit.second, 1);
+//									pandEntry.second->setOutputArcMultiplicity(childExit.second, 1);
+//									
+//									if (children[0] == child) { // Current element is primary child.
+//										auto pandEntry2 = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + "_0" + STR_FAILSAVING);
+//										
+//										if (pandEntry2.first) {
+//											pandEntry2.second->setInhibitionArcMultiplicity(childExit.second, 1);
+//										}
+//									}
+//									else { // Current element is not the primary child.
+//										for (std::size_t k = 1; k < children.size(); k++) {
+//											if (children[k] == child) {
+//												auto pandEntry2 = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + "_" + std::to_string((k - 1)) + STR_FAILSAVING);
+//												auto pandEntry3 = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + "_" + std::to_string((k)) + STR_FAILSAVING);
+//												
+//												if (pandEntry2.first) {
+//													pandEntry2.second->setInputArcMultiplicity(childExit.second, 1);
+//													pandEntry2.second->setOutputArcMultiplicity(childExit.second, 1);
+//												}
+//												
+//												if (pandEntry3.first) {
+//													pandEntry3.second->setInhibitionArcMultiplicity(childExit.second, 1);
+//												}
+//												
+//												continue;
+//											}
+//										}
+//									}
+//								}
+//								
+//								break;
+//							}
+//							case storm::storage::DFTElementType::SPARE:
+//							{
+//								// Check if current child is a primary or spare child.
+//								auto children =  std::static_pointer_cast<storm::storage::DFTSpare<ValueType> const>(mDft.getElement(parents[j]))->children();
+//								
+//								if (child == children[0]) { // Primary child.
+//									auto spareExit = mGspn.getImmediateTransition(child->name() + STR_ACTIVATING);
+//									
+//									std::vector<int> ids = getAllBEIDsOfElement(child);
+//									for (std::size_t k = 0; k < ids.size(); k++) {
+//										auto childEntry = mGspn.getPlace(mDft.getElement(ids[k])->name() + STR_ACTIVATED);
+//										
+//										if (spareExit.first && childEntry.first) { // Only add arcs if the objects have been found.
+//											spareExit.second->setInhibitionArcMultiplicity(childEntry.second, 1);
+//											spareExit.second->setOutputArcMultiplicity(childEntry.second, 1);
+//										}
+//									}
+//									
+//									// Draw lines from "primary child_failed" to SPARE.
+//									auto childExit = mGspn.getPlace(child->name() + STR_FAILED);
+//									auto spareEntry = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + "_claiming_" + children[1]->name());
+//									auto spareEntry2 = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + "_" + children[1]->name() + "_consuming1");
+//									
+//									if (childExit.first && spareEntry.first && spareEntry2.first) { // Only add arcs if the objects have been found.
+//										spareEntry.second->setInputArcMultiplicity(childExit.second, 1);
+//										spareEntry.second->setOutputArcMultiplicity(childExit.second, 1);
+//										
+//										spareEntry2.second->setInputArcMultiplicity(childExit.second, 1);
+//										spareEntry2.second->setOutputArcMultiplicity(childExit.second, 1);
+//									}
+//								}
+//								else { // A spare child.
+//									auto spareExit = mGspn.getImmediateTransition(child->name() + STR_ACTIVATING);
+//									auto spareExit2 = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + "_claiming_" + child->name());
+//									
+//									std::vector<int> ids = getAllBEIDsOfElement(child);
+//									for (std::size_t k = 0; k < ids.size(); k++) {
+//										auto childEntry = mGspn.getPlace(mDft.getElement(ids[k])->name() + STR_ACTIVATED);
+//										
+//										if (spareExit.first && spareExit2.first && childEntry.first) { // Only add arcs if the objects have been found.
+//											if (!spareExit.second->existsInhibitionArc(childEntry.second)) {
+//												spareExit.second->setInhibitionArcMultiplicity(childEntry.second, 1);
+//											}
+//											if (!spareExit.second->existsOutputArc(childEntry.second)) {
+//												spareExit.second->setOutputArcMultiplicity(childEntry.second, 1);
+//											}
+//											if (!spareExit2.second->existsInhibitionArc(childEntry.second)) {
+//												spareExit2.second->setInhibitionArcMultiplicity(childEntry.second, 1);
+//											}
+//										}
+//									}
+//									
+//									auto childExit = mGspn.getPlace(child->name() + STR_FAILED);
+//									auto spareEntry = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + "_claiming_" + child->name());
+//									auto spareEntry2 = mGspn.getImmediateTransition(child->name() + STR_ACTIVATING);
+//									auto spareEntry3 = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + "_" + child->name() + "_consuming2");
+//									
+//									if (childExit.first && spareEntry.first && spareEntry2.first && spareEntry3.first) { // Only add arcs if the objects have been found.
+//										spareEntry.second->setInhibitionArcMultiplicity(childExit.second, 1);
+//										
+//										if (!spareEntry2.second->existsInhibitionArc(childExit.second)) {
+//											spareEntry2.second->setInhibitionArcMultiplicity(childExit.second, 1);
+//										}
+//										
+//										spareEntry3.second->setInputArcMultiplicity(childExit.second, 1);
+//										spareEntry3.second->setOutputArcMultiplicity(childExit.second, 1);
+//									}
+//								}
+//								
+//								break;
+//							}
+//							case storm::storage::DFTElementType::POR:
+//							{
+//								auto children =  std::static_pointer_cast<storm::storage::DFTPand<ValueType> const>(mDft.getElement(parents[j]))->children();
+//								auto porEntry = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + STR_FAILING);
+//								auto porEntry2 = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + STR_FAILSAVING);
+//								auto childExit = mGspn.getPlace(child->name() + STR_FAILED);
+//								
+//								if (porEntry.first && porEntry2.first && childExit.first) { // Only add arcs if the objects have been found.
+//									if (children[0] == child) { // Current element is primary child.
+//										porEntry.second->setInputArcMultiplicity(childExit.second, 1);
+//										porEntry.second->setOutputArcMultiplicity(childExit.second, 1);
+//										porEntry2.second->setInhibitionArcMultiplicity(childExit.second, 1);
+//										
+//									}
+//									else { // Current element is not the primary child.
+//										porEntry2.second->setInputArcMultiplicity(childExit.second, 1);
+//										porEntry2.second->setOutputArcMultiplicity(childExit.second, 1);
+//									}
+//								}
+//								
+//								break;
+//							}
+//							case storm::storage::DFTElementType::SEQ:
+//							{
+//								// Sequences are realized with restrictions. Nothing to do here.
+//								break;
+//							}
+//							case storm::storage::DFTElementType::MUTEX:
+//							{
+//								// MUTEX are realized with restrictions. Nothing to do here.
+//								break;
+//							}
+//							case storm::storage::DFTElementType::BE:
+//							{
+//								// The parent is never a Basic Event.
+//								break;
+//							}
+//							case storm::storage::DFTElementType::CONSTF:
+//							{
+//								// The parent is never a Basic Event.
+//								break;
+//							}
+//							case storm::storage::DFTElementType::CONSTS:
+//							{
+//								// The parent is never a Basic Event.
+//								break;
+//							}
+//							case storm::storage::DFTElementType::PDEP:
+//							{
+//								// The parent is never a DEP. Hence the connections must be drawn somewhere else.
+//								break;
+//							}
+//							default:
+//							{
+//								STORM_LOG_ASSERT(false, "DFT type unknown.");
+//								break;
+//							}
+//						}
+//					}
+//				}
+			}
+			
+			template <typename ValueType>
+            bool DftToGspnTransformator<ValueType>::isBEActive(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dftElement)
+			{
+				// If element is the top element, return true.
+				if (dftElement->id() == mDft.getTopLevelIndex()) {
+					return true;
+				}
+				else { // Else look at all parents.
+					auto parents = dftElement->parents();
+					std::vector<bool> pathValidities;
+					
+					for (std::size_t i = 0; i < parents.size(); i++) {
+						// Add all parents to the vector, except if the parent is a SPARE and the current element is an inactive child of the SPARE.
+						if (parents[i]->type() == storm::storage::DFTElementType::SPARE) {
+							auto children = std::static_pointer_cast<storm::storage::DFTSpare<ValueType> const>(parents[i])->children();
+							if (children[0]->id() != dftElement->id()) {
+								continue;
+							}
+						}
+						
+						pathValidities.push_back(isBEActive(parents[i]));
+					}
+					
+					// Check all vector entries. If one is true, a "valid" path has been found.
+					for (std::size_t i = 0; i < pathValidities.size(); i++) {
+						if (pathValidities[i]) {
+							return true;
+						}
+					}
+				}
+				
+				// No "valid" path found. BE is inactive.
+				return false;
+			}
+			
+			template <typename ValueType>
+            uint64_t DftToGspnTransformator<ValueType>::getFailPriority(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dftElement)
+			{
+                return mDft.maxRank() - dftElement->rank();
+			}
+			
+			template <typename ValueType>
+            void DftToGspnTransformator<ValueType>::drawGSPNDependencies() {
+//				for (std::size_t i = 0; i < mDft.nrElements(); i++) {
+//					auto dftElement = mDft.getElement(i);
+//					
+//					if (dftElement->isDependency()) {
+//						std::string gateName = dftElement->name().substr(0, dftElement->name().find("_"));
+//						auto depEntry = mGspn.getTimedTransition(gateName + STR_FAILING);
+//						auto trigger = mGspn.getPlace(std::static_pointer_cast<storm::storage::DFTDependency<ValueType> const>(dftElement)->nameTrigger() + STR_FAILED);
+//						
+//						if (depEntry.first && trigger.first) { // Only add arcs if the objects have been found.
+//							if (!depEntry.second->existsInputArc(trigger.second)) {
+//								depEntry.second->setInputArcMultiplicity(trigger.second, 1);
+//							}
+//							if (!depEntry.second->existsOutputArc(trigger.second)){
+//								depEntry.second->setOutputArcMultiplicity(trigger.second, 1);
+//							}
+//						}
+//						
+//						auto dependent = mGspn.getPlace(std::static_pointer_cast<storm::storage::DFTDependency<ValueType> const>(dftElement)->nameDependent() + STR_FAILED);
+//						
+//						if (dependent.first) { // Only add arcs if the objects have been found.
+//							depEntry.second->setOutputArcMultiplicity(dependent.second, 1);
+//						}
+//					}
+//				}
+			}
+			
+			template <typename ValueType>
+            void DftToGspnTransformator<ValueType>::drawGSPNRestrictions() {
+//				for (std::size_t i = 0; i < mDft.nrElements(); i++) {
+//					auto dftElement = mDft.getElement(i);
+//					
+//					if (dftElement->isRestriction()) {
+//						switch (dftElement->type()) {
+//							case storm::storage::DFTElementType::SEQ:
+//							{
+//								auto children = mDft.getRestriction(i)->children();
+//								
+//								for (std::size_t j = 0; j < children.size() - 1; j++) {
+//									auto suppressor = mGspn.getPlace(children[j]->name() + STR_FAILED);
+//									
+//									switch (children[j + 1]->type()) {
+//										case storm::storage::DFTElementType::BE: // If suppressed is a BE, add 2 arcs to timed transitions.
+//										{
+//											auto suppressedActive = mGspn.getTimedTransition(children[j + 1]->name() + "_activeFailing");
+//											auto suppressedPassive = mGspn.getTimedTransition(children[j + 1]->name() + "_passiveFailing");
+//											
+//											if (suppressor.first && suppressedActive.first && suppressedPassive.first) { // Only add arcs if the objects have been found.
+//												suppressedActive.second->setInputArcMultiplicity(suppressor.second, 1);
+//												suppressedActive.second->setOutputArcMultiplicity(suppressor.second, 1);
+//												suppressedPassive.second->setInputArcMultiplicity(suppressor.second, 1);
+//												suppressedPassive.second->setOutputArcMultiplicity(suppressor.second, 1);
+//											}
+//											break;
+//										}
+//										default: // If supressed is not a BE, add single arc to immediate transition.
+//										{
+//											auto suppressed = mGspn.getImmediateTransition(children[j + 1]->name() + STR_FAILING);
+//											
+//											if (suppressor.first && suppressed.first) { // Only add arcs if the objects have been found.
+//												suppressed.second->setInputArcMultiplicity(suppressor.second, 1);
+//												suppressed.second->setOutputArcMultiplicity(suppressor.second, 1);
+//											}
+//											break;
+//										}
+//									}
+//								}
+//								break;
+//							}
+//							case storm::storage::DFTElementType::MUTEX:
+//							{
+//								// MUTEX is not implemented by the DFTGalileoParser yet. Nothing to do here.
+//								STORM_LOG_ASSERT(false, "MUTEX is not supported by DftToGspnTransformator.");
+//								break;
+//							}
+//							default:
+//							{
+//								break;
+//							}
+//						}
+//					}
+//				}
+			}
+			
+			template <typename ValueType>
+            std::vector<int> DftToGspnTransformator<ValueType>::getAllBEIDsOfElement(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dftElement) {
+//				std::vector<int> ids;
+//				
+//				switch (dftElement->type()) {
+//					case storm::storage::DFTElementType::AND:
+//					{
+//						auto children = std::static_pointer_cast<storm::storage::DFTAnd<ValueType> const>(dftElement)->children();
+//						
+//						for (std::size_t i = 0; i < children.size(); i++) {
+//							std::vector<int> newIds = getAllBEIDsOfElement(children[i]);
+//							ids.insert(ids.end(), newIds.begin(), newIds.end());
+//						}
+//						break;
+//					}
+//					case storm::storage::DFTElementType::OR:
+//					{
+//						auto children = std::static_pointer_cast<storm::storage::DFTOr<ValueType> const>(dftElement)->children();
+//						
+//						for (std::size_t i = 0; i < children.size(); i++) {
+//							std::vector<int> newIds = getAllBEIDsOfElement(children[i]);
+//							ids.insert(ids.end(), newIds.begin(), newIds.end());
+//						}
+//						break;
+//					}
+//					case storm::storage::DFTElementType::VOT:
+//					{
+//						auto children = std::static_pointer_cast<storm::storage::DFTVot<ValueType> const>(dftElement)->children();
+//						
+//						for (std::size_t i = 0; i < children.size(); i++) {
+//							std::vector<int> newIds = getAllBEIDsOfElement(children[i]);
+//							ids.insert(ids.end(), newIds.begin(), newIds.end());
+//						}
+//						break;
+//					}
+//					case storm::storage::DFTElementType::PAND:
+//					{
+//						auto children = std::static_pointer_cast<storm::storage::DFTPand<ValueType> const>(dftElement)->children();
+//						
+//						for (std::size_t i = 0; i < children.size(); i++) {
+//							std::vector<int> newIds = getAllBEIDsOfElement(children[i]);
+//							ids.insert(ids.end(), newIds.begin(), newIds.end());
+//						}
+//						break;
+//					}
+//					case storm::storage::DFTElementType::SPARE:
+//					{								
+//						auto children = std::static_pointer_cast<storm::storage::DFTSpare<ValueType> const>(dftElement)->children();
+//						
+//						// Only regard the primary child of a SPARE. The spare childs are not allowed to be listed here.
+//						for (std::size_t i = 0; i < 1; i++) {
+//							std::vector<int> newIds = getAllBEIDsOfElement(children[i]);
+//							ids.insert(ids.end(), newIds.begin(), newIds.end());
+//						}
+//						break;
+//					}
+//					case storm::storage::DFTElementType::POR:
+//					{
+//						auto children = std::static_pointer_cast<storm::storage::DFTPor<ValueType> const>(dftElement)->children();
+//						
+//						for (std::size_t i = 0; i < children.size(); i++) {
+//							std::vector<int> newIds = getAllBEIDsOfElement(children[i]);
+//							ids.insert(ids.end(), newIds.begin(), newIds.end());
+//						}
+//						break;
+//					}
+//					case storm::storage::DFTElementType::BE:
+//					case storm::storage::DFTElementType::CONSTF:
+//					case storm::storage::DFTElementType::CONSTS:
+//					{
+//						ids.push_back(dftElement->id());
+//						break;
+//					}
+//					case storm::storage::DFTElementType::SEQ:
+//					case storm::storage::DFTElementType::MUTEX:
+//					case storm::storage::DFTElementType::PDEP:
+//					{
+//						break;
+//					}
+//					default:
+//					{
+//						STORM_LOG_ASSERT(false, "DFT type unknown.");
+//						break;
+//					}
+//				}
+//				
+//				return ids;
+			}
+			
+			template <typename ValueType>
+            void DftToGspnTransformator<ValueType>::writeGspn(bool toFile) {
+                if (toFile) {
+                    // Writing to file
+                    std::ofstream file;
+                    file.open("gspn.dot");
+                    storm::gspn::GSPN* gspn = builder.buildGspn();
+                    gspn->writeDotToStream(file);
+                    delete gspn;
+                    file.close();
+                } else {
+                    // Writing to console
+                    storm::gspn::GSPN* gspn = builder.buildGspn();
+                    gspn->writeDotToStream(std::cout);
+                    delete gspn;
+                }
+            }
+			
+            // Explicitly instantiate the class.
+            template class DftToGspnTransformator<double>;
+            
+
+    #ifdef STORM_HAVE_CARL
+            // template class DftToGspnTransformator<storm::RationalFunction>;
+    #endif
+
+        } // namespace dft
+    } // namespace transformations
+} // namespace storm
+
+
diff --git a/src/storm/transformations/dft/DftToGspnTransformator.h b/src/storm/transformations/dft/DftToGspnTransformator.h
new file mode 100644
index 000000000..76250bfbf
--- /dev/null
+++ b/src/storm/transformations/dft/DftToGspnTransformator.h
@@ -0,0 +1,174 @@
+#pragma once
+
+#include "storm/storage/dft/DFT.h"
+#include "storm/storage/gspn/GSPN.h"
+#include "storm/storage/gspn/GspnBuilder.h"
+
+namespace storm {
+    namespace transformations {
+        namespace dft {
+
+            /*!
+             * Transformator for DFT -> GSPN.
+             */
+            template<typename ValueType>
+            class DftToGspnTransformator {
+
+            public:
+                /*!
+                 * Constructor.
+                 *
+                 * @param dft DFT
+                 */
+                DftToGspnTransformator(storm::storage::DFT<ValueType> const& dft);
+
+                /*!
+                 * Transform the DFT to a GSPN.
+                 */
+                void transform();
+
+            private:
+                /*!
+                 * Write Gspn to file or console.
+                 *
+                 * @param toFile If true, the GSPN will be written to a file, otherwise it will
+                                 be written to the console.
+                 */
+                void writeGspn(bool toFile);
+				
+				/*
+				 * Draw all elements of the GSPN.
+				 */
+				void drawGSPNElements();
+				
+				/*
+				 * Draw the connections between the elements of the GSPN.
+				 */
+				void drawGSPNConnections();
+				
+				/*
+				 * Draw functional/probability dependencies into the GSPN.
+				 */
+				void drawGSPNDependencies();
+				
+				/*
+				 * Draw restrictions between the elements of the GSPN (i.e. SEQ or MUTEX).
+				 */
+				void drawGSPNRestrictions();
+				
+				/*
+				 * Draw a Petri net Basic Event.
+				 * 
+				 * @param dftBE The Basic Event.
+				 */
+				void drawBE(std::shared_ptr<storm::storage::DFTBE<ValueType> const> dftBE, bool isRepresentative);
+				
+				/*
+				 * Draw a Petri net AND.
+				 * 
+				 * @param dftAnd The AND gate.
+				 */
+				void drawAND(std::shared_ptr<storm::storage::DFTAnd<ValueType> const> dftAnd, bool isRepresentative);
+				
+				/*
+				 * Draw a Petri net OR.
+				 * 
+				 * @param dftOr The OR gate.
+				 */
+				void drawOR(std::shared_ptr<storm::storage::DFTOr<ValueType> const> dftOr, bool isRepresentative);
+				
+				/*
+				 * Draw a Petri net VOT.
+				 * 
+				 * @param dftVot The VOT gate.
+				 */
+				void drawVOT(std::shared_ptr<storm::storage::DFTVot<ValueType> const> dftVot, bool isRepresentative);
+				
+				/*
+				 * Draw a Petri net PAND. 
+				 * This PAND is inklusive (children are allowed to fail simultaneously and the PAND will fail nevertheless).
+				 * 
+				 * @param dftPand The PAND gate.
+				 */
+				void drawPAND(std::shared_ptr<storm::storage::DFTPand<ValueType> const> dftPand, bool isRepresentative);
+				
+				/*
+				 * Draw a Petri net SPARE.
+				 * 
+				 * @param dftSpare The SPARE gate.
+				 */
+				void drawSPARE(std::shared_ptr<storm::storage::DFTSpare<ValueType> const> dftSpare, bool isRepresentative);
+				
+				/*
+				 * Draw a Petri net POR.
+				 * This POR is inklusive (children are allowed to fail simultaneously and the POR will fail nevertheless).
+				 * 
+				 * @param dftPor The POR gate.
+				 */
+				void drawPOR(std::shared_ptr<storm::storage::DFTPor<ValueType> const> dftPor, bool isRepresentative);
+				
+				/*
+				 * Draw a Petri net CONSTF (Constant Failure, a Basic Event that has already failed).
+				 * 
+				 * @param dftPor The CONSTF Basic Event.
+				 */
+				void drawCONSTF(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dftConstF, bool isRepresentative);
+				
+				/*
+				 * Draw a Petri net CONSTS (Constant Save, a Basic Event that cannot fail).
+				 * 
+				 * @param dftPor The CONSTS Basic Event.
+				 */
+				void drawCONSTS(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dftConstS, bool isRepresentative);
+				
+				/*
+				 * Draw a Petri net PDEP (FDEP is included with a firerate of 1).
+				 */
+				void drawPDEP(std::shared_ptr<storm::storage::DFTDependency<ValueType> const> dftDependency, bool isRepresentative);
+				
+				 /*
+				  * Return true if BE is active (corresponding place contains one initial token) or false if BE is inactive (corresponding place contains no initial token).
+				  * 
+				  * @param dFTElement DFT element.
+				  */
+				 bool isBEActive(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dFTElement);
+				 
+				 /*
+				  * Get the priority of the element.
+				  * The priority is two times the length of the shortest path to the top event.
+				  * 
+				  * @param priority The priority of the gate. Top Event has priority 0,  its children 2, its grandchildren 4, ...
+				  * 
+				  * @param dftElement The element whose priority shall be determined.
+				  */
+				 uint64_t getFailPriority(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dFTElement);
+				 
+				 /*
+				  * Return all ids of BEs, that are successors of the given element and that are not the spare childs of a SPARE.
+				  * 
+				  * @param dftElement The element which 
+				  */
+				 std::vector<int> getAllBEIDsOfElement(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dftElement);
+                
+                
+                uint64_t addUnavailableNode(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dftElement);
+                
+                storm::storage::DFT<ValueType> const& mDft;
+                storm::gspn::GspnBuilder builder;
+                std::vector<uint64_t> failedNodes;
+                std::map<uint64_t, uint64_t> unavailableNodes;
+                std::map<uint64_t, uint64_t> activeNodes;
+                
+                static constexpr const char* STR_FAILING = "_failing";			// Name standard for transitions that point towards a place, which in turn indicates the failure of a gate.
+                static constexpr const char* STR_FAILED = "_failed";			// Name standard for place which indicates the failure of a gate.
+                static constexpr const char* STR_FAILSAVING = "_failsaving";	// Name standard for transition that point towards a place, which in turn indicates the failsave state of a gate.
+                static constexpr const char* STR_FAILSAVE = "_failsave";		// Name standard for place which indicates the failsave state of a gate.
+                static constexpr const char* STR_ACTIVATED = "_activated";		// Name standard for place which indicates the activity.
+                static constexpr const char* STR_ACTIVATING = "_activating";	// Name standard for transition that point towards a place, which in turn indicates its activity.
+                
+
+            };
+        }
+    }
+}
+

From 297f3ff48076dbf9b67056c82bc97409ef9fd445 Mon Sep 17 00:00:00 2001
From: sjunges <sebastian.junges@gmail.com>
Date: Tue, 22 Nov 2016 09:56:00 +0100
Subject: [PATCH 02/47] some cleaning and minor additions to dft->gspn
 translation

---
 .../dft/DftToGspnTransformator.cpp            | 468 +-----------------
 .../dft/DftToGspnTransformator.h              |  22 +-
 2 files changed, 18 insertions(+), 472 deletions(-)

diff --git a/src/storm/transformations/dft/DftToGspnTransformator.cpp b/src/storm/transformations/dft/DftToGspnTransformator.cpp
index 4331e0c62..730656b35 100644
--- a/src/storm/transformations/dft/DftToGspnTransformator.cpp
+++ b/src/storm/transformations/dft/DftToGspnTransformator.cpp
@@ -22,16 +22,10 @@ namespace storm {
 				
 				// Loop through every DFT element and draw them as a GSPN.
 				drawGSPNElements();
-				
-				// When all DFT elements are drawn, draw the connections between them.
-				drawGSPNConnections();
-				
-				// Draw functional/probability dependencies into the GSPN.
-				drawGSPNDependencies();
-				
+
 				// Draw restrictions into the GSPN (i.e. SEQ or MUTEX).
-				drawGSPNRestrictions(); 
-		
+				//drawGSPNRestrictions();
+
 				// Write GSPN to file.
 				writeGspn(true);
             }
@@ -227,7 +221,6 @@ namespace storm {
                     builder.addInputArc(failedNodes[dftPand->children().at(j)->id()], tfs);
                     builder.addInhibitionArc(failedNodes[dftPand->children().at(j-1)->id()], tfs);
                     builder.addOutputArc(tfs, nodeFS);
-                    
                 }
             }
 //			
@@ -241,7 +234,7 @@ namespace storm {
                     unavailableNode = addUnavailableNode(dftSpare);
                 }
                 uint64_t spareActive = builder.addPlace(defaultCapacity, 0, dftSpare->name() + STR_ACTIVATED);
-                activeNodes.emplace(dftBE->id(), beActive);
+                activeNodes.emplace(dftSpare->id(), spareActive);
 
                 
                 std::vector<uint64_t> cucNodes;
@@ -277,116 +270,16 @@ namespace storm {
                     builder.addInputArc(failedNodes.at(child->id()), tnextcl);
                     builder.addOutputArc(tnextcl, failedNodes.at(child->id()));
                     nextclTransitions.push_back(tnextcl);
-                    
-                    
+
                     ++j;
                 }
                 builder.addOutputArc(nextconsiderTransitions.back(), nodeFailed);
                 builder.addOutputArc(nextclTransitions.back(), nodeFailed);
-                
+
                 if (isRepresentative) {
                     builder.addOutputArc(nextconsiderTransitions.back(), unavailableNode);
                     builder.addOutputArc(nextclTransitions.back(), unavailableNode);
                 }
-                
-                
-//				uint_fast64_t priority = getPriority(0, dftSpare);
-//				
-//				// This codeblock can be removed later, when I am 100% sure it is not needed anymore.
-//				/*
-//				storm::gspn::Place placeSPAREActivated;
-//				placeSPAREActivated.setName(dftSpare->name() + STR_ACTIVATED);
-//				placeSPAREActivated.setNumberOfInitialTokens(isBEActive(dftSpare));
-//				mGspn.addPlace(placeSPAREActivated);
-//				
-//				storm::gspn::ImmediateTransition<storm::gspn::GSPN::WeightType> immediateTransitionPCActivating;
-//				immediateTransitionPCActivating.setName(dftSpare->children()[0]->name() + STR_ACTIVATING);
-//				immediateTransitionPCActivating.setPriority(priority);
-//				immediateTransitionPCActivating.setWeight(0.0);
-//				immediateTransitionPCActivating.setInputArcMultiplicity(placeSPAREActivated, 1);
-//				immediateTransitionPCActivating.setOutputArcMultiplicity(placeSPAREActivated, 1);
-//				mGspn.addImmediateTransition(immediateTransitionPCActivating);
-//				*/
-//				
-//				auto children = dftSpare->children();
-//				
-//				// Draw places and transitions that belong to each spare child.
-//				for (std::size_t i = 1; i < children.size(); i++) {
-//					auto placeChildClaimedPreexist = mGspn.getPlace(children[i]->name() + "_claimed");
-//					
-//					if (!placeChildClaimedPreexist.first) { // Only draw this place if it doesn't exist jet.
-//						storm::gspn::Place placeChildClaimed;
-//						placeChildClaimed.setName(children[i]->name() + "_claimed");
-//						placeChildClaimed.setNumberOfInitialTokens(0);
-//						mGspn.addPlace(placeChildClaimed);
-//						
-//						storm::gspn::ImmediateTransition<storm::gspn::GSPN::WeightType> immediateTransitionSpareChildActivating;
-//						immediateTransitionSpareChildActivating.setName(children[i]->name() + STR_ACTIVATING);
-//						immediateTransitionSpareChildActivating.setPriority(priority);
-//						immediateTransitionSpareChildActivating.setWeight(0.0);
-//						immediateTransitionSpareChildActivating.setInputArcMultiplicity(placeChildClaimed, 1);
-//						immediateTransitionSpareChildActivating.setOutputArcMultiplicity(placeChildClaimed, 1);
-//						mGspn.addImmediateTransition(immediateTransitionSpareChildActivating);
-//					}
-//					
-//					auto placeChildClaimedExist = mGspn.getPlace(children[i]->name() + "_claimed");
-//					
-//					storm::gspn::Place placeSPAREClaimedChild;
-//					placeSPAREClaimedChild.setName(dftSpare->name() + "_claimed_" + children[i]->name());
-//					placeSPAREClaimedChild.setNumberOfInitialTokens(0);
-//					mGspn.addPlace(placeSPAREClaimedChild);
-//					
-//					storm::gspn::ImmediateTransition<storm::gspn::GSPN::WeightType> immediateTransitionChildClaiming;
-//					immediateTransitionChildClaiming.setName(dftSpare->name() + "_claiming_" + children[i]->name());
-//					immediateTransitionChildClaiming.setPriority(priority + 1); // Higher priority needed!
-//					immediateTransitionChildClaiming.setWeight(0.0);
-//					immediateTransitionChildClaiming.setInhibitionArcMultiplicity(placeChildClaimedExist.second, 1);
-//					immediateTransitionChildClaiming.setOutputArcMultiplicity(placeChildClaimedExist.second, 1);
-//					immediateTransitionChildClaiming.setOutputArcMultiplicity(placeSPAREClaimedChild, 1);
-//					mGspn.addImmediateTransition(immediateTransitionChildClaiming);
-//					
-//					storm::gspn::Place placeSPAREChildConsumed;
-//					if (i < children.size() - 1) {
-//						placeSPAREChildConsumed.setName(dftSpare->name() + "_" + children[i]->name() + "_consumed");
-//					}
-//					else {
-//						placeSPAREChildConsumed.setName(dftSpare->name() + STR_FAILED);
-//					}
-//					placeSPAREChildConsumed.setNumberOfInitialTokens(0);
-//					mGspn.addPlace(placeSPAREChildConsumed);
-//					
-//					storm::gspn::ImmediateTransition<storm::gspn::GSPN::WeightType> immediateTransitionChildConsuming1;
-//					immediateTransitionChildConsuming1.setName(dftSpare->name() + "_" + children[i]->name() + "_consuming1");
-//					immediateTransitionChildConsuming1.setPriority(priority);
-//					immediateTransitionChildConsuming1.setWeight(0.0);
-//					immediateTransitionChildConsuming1.setOutputArcMultiplicity(placeSPAREChildConsumed, 1);
-//					immediateTransitionChildConsuming1.setInhibitionArcMultiplicity(placeSPAREChildConsumed, 1);
-//					immediateTransitionChildConsuming1.setInhibitionArcMultiplicity(placeSPAREClaimedChild, 1);
-//					mGspn.addImmediateTransition(immediateTransitionChildConsuming1);
-//					
-//					storm::gspn::ImmediateTransition<storm::gspn::GSPN::WeightType> immediateTransitionChildConsuming2;
-//					immediateTransitionChildConsuming2.setName(dftSpare->name() + "_" + children[i]->name() + "_consuming2");
-//					immediateTransitionChildConsuming2.setPriority(priority);
-//					immediateTransitionChildConsuming2.setWeight(0.0);
-//					immediateTransitionChildConsuming2.setOutputArcMultiplicity(placeSPAREChildConsumed, 1);
-//					immediateTransitionChildConsuming2.setInhibitionArcMultiplicity(placeSPAREChildConsumed, 1);
-//					immediateTransitionChildConsuming2.setOutputArcMultiplicity(placeSPAREClaimedChild, 1);
-//					immediateTransitionChildConsuming2.setInputArcMultiplicity(placeSPAREClaimedChild, 1);
-//					mGspn.addImmediateTransition(immediateTransitionChildConsuming2);
-//				}
-//				
-//				// Draw connections between all spare childs.
-//				for (std::size_t i = 1; i < children.size() - 1; i++) {
-//					auto placeSPAREChildConsumed = mGspn.getPlace(dftSpare->name() + "_" + children[i]->name() + "_consumed");
-//					auto immediateTransitionChildClaiming = mGspn.getImmediateTransition(dftSpare->name() + "_claiming_" + children[i + 1]->name());
-//					auto immediateTransitionChildConsuming1 = mGspn.getImmediateTransition(dftSpare->name() + "_" + children[i + 1]->name() + "_consuming1");
-//					
-//					immediateTransitionChildClaiming.second->setOutputArcMultiplicity(placeSPAREChildConsumed.second, 1);
-//					immediateTransitionChildClaiming.second->setInputArcMultiplicity(placeSPAREChildConsumed.second, 1);
-//					
-//					immediateTransitionChildConsuming1.second->setOutputArcMultiplicity(placeSPAREChildConsumed.second, 1);
-//					immediateTransitionChildConsuming1.second->setInputArcMultiplicity(placeSPAREChildConsumed.second, 1);
-//				}
 			}
 //			
 			template <typename ValueType>
@@ -415,10 +308,11 @@ namespace storm {
 //			
 			template <typename ValueType>
             void DftToGspnTransformator<ValueType>::drawCONSTF(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dftConstF, bool isRepresentative) {
-//				storm::gspn::Place placeCONSTFFailed;
-//				placeCONSTFFailed.setName(dftConstF->name() + STR_FAILED);
-//				placeCONSTFFailed.setNumberOfInitialTokens(1);
-//				mGspn.addPlace(placeCONSTFFailed);
+			    failedNodes.push_back(builder.addPlace(defaultCapacity, 1, dftConstF->name() + STR_FAILED));
+                uint64_t unavailableNode = 0;
+                if (isRepresentative) {
+                    unavailableNode = addUnavailableNode(dftConstF, false);
+                }
 			}
 //			
 			template <typename ValueType>
@@ -452,228 +346,14 @@ namespace storm {
 			}
             
             template<typename ValueType>
-            uint64_t DftToGspnTransformator<ValueType>::addUnavailableNode(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dftElement) {
-                uint64_t unavailableNode = builder.addPlace(defaultCapacity, 1, dftElement->name() + "_unavailable");
+            uint64_t DftToGspnTransformator<ValueType>::addUnavailableNode(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dftElement, bool initialAvailable) {
+                uint64_t unavailableNode = builder.addPlace(defaultCapacity, initialAvailable ? 0 : 1, dftElement->name() + "_unavailable");
                 assert(unavailableNode != 0);
                 unavailableNodes.emplace(dftElement->id(), unavailableNode);
                 return unavailableNode;
             }
 //			
-			template <typename ValueType>
-            void DftToGspnTransformator<ValueType>::drawGSPNConnections() {
-//				// Check for every element, if they have parents (all will have at least 1, except the top event). 
-//				for (std::size_t i = 0; i < mDft.nrElements(); i++) {
-//					auto child = mDft.getElement(i);
-//					auto parents = child->parentIds();
-//					
-//					// Draw a connection to every parent.
-//					for (std::size_t j = 0; j < parents.size(); j++) {	
-//						// Check the type of the parent and act accordingly (every parent gate has different entry points...).
-//						switch (mDft.getElement(parents[j])->type()) {
-//							case storm::storage::DFTElementType::AND:
-//							{
-//								auto andEntry = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + STR_FAILING);
-//								auto childExit = mGspn.getPlace(child->name() + STR_FAILED);
-//								if (andEntry.first && childExit.first) { // Only add arcs if the objects have been found.
-//									andEntry.second->setInputArcMultiplicity(childExit.second, 1);
-//									andEntry.second->setOutputArcMultiplicity(childExit.second, 1);
-//								}
-//								break;
-//							}
-//							case storm::storage::DFTElementType::OR:
-//							{
-//								auto orEntry = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + "_" + child->name() + STR_FAILING);
-//								auto childExit = mGspn.getPlace(child->name() + STR_FAILED);
-//								if (orEntry.first && childExit.first) { // Only add arcs if the objects have been found.
-//									orEntry.second->setInputArcMultiplicity(childExit.second, 1);
-//									orEntry.second->setOutputArcMultiplicity(childExit.second, 1);
-//								}
-//								break;
-//							}
-//							case storm::storage::DFTElementType::VOT:
-//							{
-//								auto childExit = mGspn.getPlace(child->name() + STR_FAILED);
-//								auto parentEntry = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + "_" + child->name() + "_collecting");
-//								
-//								if (childExit.first && parentEntry.first) { // Only add arcs if the objects have been found.
-//									parentEntry.second->setInputArcMultiplicity(childExit.second, 1);
-//									parentEntry.second->setOutputArcMultiplicity(childExit.second, 1);
-//								}
-//								
-//								break;
-//							}
-//							case storm::storage::DFTElementType::PAND:
-//							{
-//								auto children =  std::static_pointer_cast<storm::storage::DFTPand<ValueType> const>(mDft.getElement(parents[j]))->children();
-//								auto childExit = mGspn.getPlace(child->name() + STR_FAILED);
-//								auto pandEntry = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + STR_FAILING);
-//								
-//								if (childExit.first && pandEntry.first) { // Only add arcs if the objects have been found.
-//									pandEntry.second->setInputArcMultiplicity(childExit.second, 1);
-//									pandEntry.second->setOutputArcMultiplicity(childExit.second, 1);
-//									
-//									if (children[0] == child) { // Current element is primary child.
-//										auto pandEntry2 = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + "_0" + STR_FAILSAVING);
-//										
-//										if (pandEntry2.first) {
-//											pandEntry2.second->setInhibitionArcMultiplicity(childExit.second, 1);
-//										}
-//									}
-//									else { // Current element is not the primary child.
-//										for (std::size_t k = 1; k < children.size(); k++) {
-//											if (children[k] == child) {
-//												auto pandEntry2 = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + "_" + std::to_string((k - 1)) + STR_FAILSAVING);
-//												auto pandEntry3 = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + "_" + std::to_string((k)) + STR_FAILSAVING);
-//												
-//												if (pandEntry2.first) {
-//													pandEntry2.second->setInputArcMultiplicity(childExit.second, 1);
-//													pandEntry2.second->setOutputArcMultiplicity(childExit.second, 1);
-//												}
-//												
-//												if (pandEntry3.first) {
-//													pandEntry3.second->setInhibitionArcMultiplicity(childExit.second, 1);
-//												}
-//												
-//												continue;
-//											}
-//										}
-//									}
-//								}
-//								
-//								break;
-//							}
-//							case storm::storage::DFTElementType::SPARE:
-//							{
-//								// Check if current child is a primary or spare child.
-//								auto children =  std::static_pointer_cast<storm::storage::DFTSpare<ValueType> const>(mDft.getElement(parents[j]))->children();
-//								
-//								if (child == children[0]) { // Primary child.
-//									auto spareExit = mGspn.getImmediateTransition(child->name() + STR_ACTIVATING);
-//									
-//									std::vector<int> ids = getAllBEIDsOfElement(child);
-//									for (std::size_t k = 0; k < ids.size(); k++) {
-//										auto childEntry = mGspn.getPlace(mDft.getElement(ids[k])->name() + STR_ACTIVATED);
-//										
-//										if (spareExit.first && childEntry.first) { // Only add arcs if the objects have been found.
-//											spareExit.second->setInhibitionArcMultiplicity(childEntry.second, 1);
-//											spareExit.second->setOutputArcMultiplicity(childEntry.second, 1);
-//										}
-//									}
-//									
-//									// Draw lines from "primary child_failed" to SPARE.
-//									auto childExit = mGspn.getPlace(child->name() + STR_FAILED);
-//									auto spareEntry = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + "_claiming_" + children[1]->name());
-//									auto spareEntry2 = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + "_" + children[1]->name() + "_consuming1");
-//									
-//									if (childExit.first && spareEntry.first && spareEntry2.first) { // Only add arcs if the objects have been found.
-//										spareEntry.second->setInputArcMultiplicity(childExit.second, 1);
-//										spareEntry.second->setOutputArcMultiplicity(childExit.second, 1);
-//										
-//										spareEntry2.second->setInputArcMultiplicity(childExit.second, 1);
-//										spareEntry2.second->setOutputArcMultiplicity(childExit.second, 1);
-//									}
-//								}
-//								else { // A spare child.
-//									auto spareExit = mGspn.getImmediateTransition(child->name() + STR_ACTIVATING);
-//									auto spareExit2 = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + "_claiming_" + child->name());
-//									
-//									std::vector<int> ids = getAllBEIDsOfElement(child);
-//									for (std::size_t k = 0; k < ids.size(); k++) {
-//										auto childEntry = mGspn.getPlace(mDft.getElement(ids[k])->name() + STR_ACTIVATED);
-//										
-//										if (spareExit.first && spareExit2.first && childEntry.first) { // Only add arcs if the objects have been found.
-//											if (!spareExit.second->existsInhibitionArc(childEntry.second)) {
-//												spareExit.second->setInhibitionArcMultiplicity(childEntry.second, 1);
-//											}
-//											if (!spareExit.second->existsOutputArc(childEntry.second)) {
-//												spareExit.second->setOutputArcMultiplicity(childEntry.second, 1);
-//											}
-//											if (!spareExit2.second->existsInhibitionArc(childEntry.second)) {
-//												spareExit2.second->setInhibitionArcMultiplicity(childEntry.second, 1);
-//											}
-//										}
-//									}
-//									
-//									auto childExit = mGspn.getPlace(child->name() + STR_FAILED);
-//									auto spareEntry = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + "_claiming_" + child->name());
-//									auto spareEntry2 = mGspn.getImmediateTransition(child->name() + STR_ACTIVATING);
-//									auto spareEntry3 = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + "_" + child->name() + "_consuming2");
-//									
-//									if (childExit.first && spareEntry.first && spareEntry2.first && spareEntry3.first) { // Only add arcs if the objects have been found.
-//										spareEntry.second->setInhibitionArcMultiplicity(childExit.second, 1);
-//										
-//										if (!spareEntry2.second->existsInhibitionArc(childExit.second)) {
-//											spareEntry2.second->setInhibitionArcMultiplicity(childExit.second, 1);
-//										}
-//										
-//										spareEntry3.second->setInputArcMultiplicity(childExit.second, 1);
-//										spareEntry3.second->setOutputArcMultiplicity(childExit.second, 1);
-//									}
-//								}
-//								
-//								break;
-//							}
-//							case storm::storage::DFTElementType::POR:
-//							{
-//								auto children =  std::static_pointer_cast<storm::storage::DFTPand<ValueType> const>(mDft.getElement(parents[j]))->children();
-//								auto porEntry = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + STR_FAILING);
-//								auto porEntry2 = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + STR_FAILSAVING);
-//								auto childExit = mGspn.getPlace(child->name() + STR_FAILED);
-//								
-//								if (porEntry.first && porEntry2.first && childExit.first) { // Only add arcs if the objects have been found.
-//									if (children[0] == child) { // Current element is primary child.
-//										porEntry.second->setInputArcMultiplicity(childExit.second, 1);
-//										porEntry.second->setOutputArcMultiplicity(childExit.second, 1);
-//										porEntry2.second->setInhibitionArcMultiplicity(childExit.second, 1);
-//										
-//									}
-//									else { // Current element is not the primary child.
-//										porEntry2.second->setInputArcMultiplicity(childExit.second, 1);
-//										porEntry2.second->setOutputArcMultiplicity(childExit.second, 1);
-//									}
-//								}
-//								
-//								break;
-//							}
-//							case storm::storage::DFTElementType::SEQ:
-//							{
-//								// Sequences are realized with restrictions. Nothing to do here.
-//								break;
-//							}
-//							case storm::storage::DFTElementType::MUTEX:
-//							{
-//								// MUTEX are realized with restrictions. Nothing to do here.
-//								break;
-//							}
-//							case storm::storage::DFTElementType::BE:
-//							{
-//								// The parent is never a Basic Event.
-//								break;
-//							}
-//							case storm::storage::DFTElementType::CONSTF:
-//							{
-//								// The parent is never a Basic Event.
-//								break;
-//							}
-//							case storm::storage::DFTElementType::CONSTS:
-//							{
-//								// The parent is never a Basic Event.
-//								break;
-//							}
-//							case storm::storage::DFTElementType::PDEP:
-//							{
-//								// The parent is never a DEP. Hence the connections must be drawn somewhere else.
-//								break;
-//							}
-//							default:
-//							{
-//								STORM_LOG_ASSERT(false, "DFT type unknown.");
-//								break;
-//							}
-//						}
-//					}
-//				}
-			}
+
 			
 			template <typename ValueType>
             bool DftToGspnTransformator<ValueType>::isBEActive(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dftElement)
@@ -715,34 +395,7 @@ namespace storm {
 			{
                 return mDft.maxRank() - dftElement->rank();
 			}
-			
-			template <typename ValueType>
-            void DftToGspnTransformator<ValueType>::drawGSPNDependencies() {
-//				for (std::size_t i = 0; i < mDft.nrElements(); i++) {
-//					auto dftElement = mDft.getElement(i);
-//					
-//					if (dftElement->isDependency()) {
-//						std::string gateName = dftElement->name().substr(0, dftElement->name().find("_"));
-//						auto depEntry = mGspn.getTimedTransition(gateName + STR_FAILING);
-//						auto trigger = mGspn.getPlace(std::static_pointer_cast<storm::storage::DFTDependency<ValueType> const>(dftElement)->nameTrigger() + STR_FAILED);
-//						
-//						if (depEntry.first && trigger.first) { // Only add arcs if the objects have been found.
-//							if (!depEntry.second->existsInputArc(trigger.second)) {
-//								depEntry.second->setInputArcMultiplicity(trigger.second, 1);
-//							}
-//							if (!depEntry.second->existsOutputArc(trigger.second)){
-//								depEntry.second->setOutputArcMultiplicity(trigger.second, 1);
-//							}
-//						}
-//						
-//						auto dependent = mGspn.getPlace(std::static_pointer_cast<storm::storage::DFTDependency<ValueType> const>(dftElement)->nameDependent() + STR_FAILED);
-//						
-//						if (dependent.first) { // Only add arcs if the objects have been found.
-//							depEntry.second->setOutputArcMultiplicity(dependent.second, 1);
-//						}
-//					}
-//				}
-			}
+
 			
 			template <typename ValueType>
             void DftToGspnTransformator<ValueType>::drawGSPNRestrictions() {
@@ -800,96 +453,7 @@ namespace storm {
 //					}
 //				}
 			}
-			
-			template <typename ValueType>
-            std::vector<int> DftToGspnTransformator<ValueType>::getAllBEIDsOfElement(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dftElement) {
-//				std::vector<int> ids;
-//				
-//				switch (dftElement->type()) {
-//					case storm::storage::DFTElementType::AND:
-//					{
-//						auto children = std::static_pointer_cast<storm::storage::DFTAnd<ValueType> const>(dftElement)->children();
-//						
-//						for (std::size_t i = 0; i < children.size(); i++) {
-//							std::vector<int> newIds = getAllBEIDsOfElement(children[i]);
-//							ids.insert(ids.end(), newIds.begin(), newIds.end());
-//						}
-//						break;
-//					}
-//					case storm::storage::DFTElementType::OR:
-//					{
-//						auto children = std::static_pointer_cast<storm::storage::DFTOr<ValueType> const>(dftElement)->children();
-//						
-//						for (std::size_t i = 0; i < children.size(); i++) {
-//							std::vector<int> newIds = getAllBEIDsOfElement(children[i]);
-//							ids.insert(ids.end(), newIds.begin(), newIds.end());
-//						}
-//						break;
-//					}
-//					case storm::storage::DFTElementType::VOT:
-//					{
-//						auto children = std::static_pointer_cast<storm::storage::DFTVot<ValueType> const>(dftElement)->children();
-//						
-//						for (std::size_t i = 0; i < children.size(); i++) {
-//							std::vector<int> newIds = getAllBEIDsOfElement(children[i]);
-//							ids.insert(ids.end(), newIds.begin(), newIds.end());
-//						}
-//						break;
-//					}
-//					case storm::storage::DFTElementType::PAND:
-//					{
-//						auto children = std::static_pointer_cast<storm::storage::DFTPand<ValueType> const>(dftElement)->children();
-//						
-//						for (std::size_t i = 0; i < children.size(); i++) {
-//							std::vector<int> newIds = getAllBEIDsOfElement(children[i]);
-//							ids.insert(ids.end(), newIds.begin(), newIds.end());
-//						}
-//						break;
-//					}
-//					case storm::storage::DFTElementType::SPARE:
-//					{								
-//						auto children = std::static_pointer_cast<storm::storage::DFTSpare<ValueType> const>(dftElement)->children();
-//						
-//						// Only regard the primary child of a SPARE. The spare childs are not allowed to be listed here.
-//						for (std::size_t i = 0; i < 1; i++) {
-//							std::vector<int> newIds = getAllBEIDsOfElement(children[i]);
-//							ids.insert(ids.end(), newIds.begin(), newIds.end());
-//						}
-//						break;
-//					}
-//					case storm::storage::DFTElementType::POR:
-//					{
-//						auto children = std::static_pointer_cast<storm::storage::DFTPor<ValueType> const>(dftElement)->children();
-//						
-//						for (std::size_t i = 0; i < children.size(); i++) {
-//							std::vector<int> newIds = getAllBEIDsOfElement(children[i]);
-//							ids.insert(ids.end(), newIds.begin(), newIds.end());
-//						}
-//						break;
-//					}
-//					case storm::storage::DFTElementType::BE:
-//					case storm::storage::DFTElementType::CONSTF:
-//					case storm::storage::DFTElementType::CONSTS:
-//					{
-//						ids.push_back(dftElement->id());
-//						break;
-//					}
-//					case storm::storage::DFTElementType::SEQ:
-//					case storm::storage::DFTElementType::MUTEX:
-//					case storm::storage::DFTElementType::PDEP:
-//					{
-//						break;
-//					}
-//					default:
-//					{
-//						STORM_LOG_ASSERT(false, "DFT type unknown.");
-//						break;
-//					}
-//				}
-//				
-//				return ids;
-			}
-			
+
 			template <typename ValueType>
             void DftToGspnTransformator<ValueType>::writeGspn(bool toFile) {
                 if (toFile) {
diff --git a/src/storm/transformations/dft/DftToGspnTransformator.h b/src/storm/transformations/dft/DftToGspnTransformator.h
index 76250bfbf..1e0d3eb69 100644
--- a/src/storm/transformations/dft/DftToGspnTransformator.h
+++ b/src/storm/transformations/dft/DftToGspnTransformator.h
@@ -40,17 +40,6 @@ namespace storm {
 				 * Draw all elements of the GSPN.
 				 */
 				void drawGSPNElements();
-				
-				/*
-				 * Draw the connections between the elements of the GSPN.
-				 */
-				void drawGSPNConnections();
-				
-				/*
-				 * Draw functional/probability dependencies into the GSPN.
-				 */
-				void drawGSPNDependencies();
-				
 				/*
 				 * Draw restrictions between the elements of the GSPN (i.e. SEQ or MUTEX).
 				 */
@@ -142,16 +131,9 @@ namespace storm {
 				  * @param dftElement The element whose priority shall be determined.
 				  */
 				 uint64_t getFailPriority(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dFTElement);
-				 
-				 /*
-				  * Return all ids of BEs, that are successors of the given element and that are not the spare childs of a SPARE.
-				  * 
-				  * @param dftElement The element which 
-				  */
-				 std::vector<int> getAllBEIDsOfElement(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dftElement);
-                
+
                 
-                uint64_t addUnavailableNode(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dftElement);
+                uint64_t addUnavailableNode(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dftElement, bool initialAvailable = true);
                 
                 storm::storage::DFT<ValueType> const& mDft;
                 storm::gspn::GspnBuilder builder;

From b2b04fa76bc2715842670f082974f38d97be5d88 Mon Sep 17 00:00:00 2001
From: sjunges <sebastian.junges@gmail.com>
Date: Fri, 25 Nov 2016 00:35:25 +0100
Subject: [PATCH 03/47] moving dfts to their own lib and cli

---
 src/storm-dft-cli/storm-dyftee.cpp                 | 5 ++---
 src/storm-dft/modelchecker/dft/DFTModelChecker.cpp | 7 +++++++
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/storm-dft-cli/storm-dyftee.cpp b/src/storm-dft-cli/storm-dyftee.cpp
index 71f5cea86..c0b0b58b2 100644
--- a/src/storm-dft-cli/storm-dyftee.cpp
+++ b/src/storm-dft-cli/storm-dyftee.cpp
@@ -6,6 +6,7 @@
 #include "storm/utility/macros.h"
 #include "storm/transformations/dft/DftToGspnTransformator.h"
 
+
 #include "storm/settings/modules/GeneralSettings.h"
 #include "storm/settings/modules/CoreSettings.h"
 #include "storm/settings/modules/DebugSettings.h"
@@ -17,6 +18,7 @@
 #include "storm-dft/parser/DFTGalileoParser.h"
 #include "storm-dft/modelchecker/dft/DFTModelChecker.h"
 #include "storm-dft/modelchecker/dft/DFTASFChecker.h"
+#include "storm-dft/transformations/dft/DftToGspnTransformator.h"
 
 #include "storm-dft/settings/modules/DFTSettings.h"
 
@@ -79,11 +81,8 @@ template <typename ValueType>
 storm::gspn::GSPN transformDFT(std::string filename) {
     storm::parser::DFTGalileoParser<ValueType> parser;
     storm::storage::DFT<ValueType> dft = parser.parseDFT(filename);
-<<<<<<< f8986fe6139bddaf5068477b0f70ac1f806f8576:src/storm-dft-cli/storm-dyftee.cpp
-=======
     storm::transformations::dft::DftToGspnTransformator<ValueType> gspnTransformator(dft);
     gspnTransformator.transform();
->>>>>>> updated dft->gspn translation to now have basis support for spares:src/storm/storm-dyftee.cpp
 }
 
 /*!
diff --git a/src/storm-dft/modelchecker/dft/DFTModelChecker.cpp b/src/storm-dft/modelchecker/dft/DFTModelChecker.cpp
index ae4144ee7..6c1834d78 100644
--- a/src/storm-dft/modelchecker/dft/DFTModelChecker.cpp
+++ b/src/storm-dft/modelchecker/dft/DFTModelChecker.cpp
@@ -1,12 +1,19 @@
 #include "DFTModelChecker.h"
 
 #include "storm/builder/ParallelCompositionBuilder.h"
+<<<<<<< 297f3ff48076dbf9b67056c82bc97409ef9fd445:src/storm-dft/modelchecker/dft/DFTModelChecker.cpp
+=======
+#include "storm/settings/modules/DFTSettings.h"
+>>>>>>> moving dfts to their own lib and cli:src/storm-dft/modelchecker/dft/DFTModelChecker.cpp
 #include "storm/utility/bitoperations.h"
 
 #include "storm-dft/builder/ExplicitDFTModelBuilder.h"
 #include "storm-dft/builder/ExplicitDFTModelBuilderApprox.h"
 #include "storm-dft/storage/dft/DFTIsomorphism.h"
+<<<<<<< 297f3ff48076dbf9b67056c82bc97409ef9fd445:src/storm-dft/modelchecker/dft/DFTModelChecker.cpp
 #include "storm-dft/settings/modules/DFTSettings.h"
+=======
+>>>>>>> moving dfts to their own lib and cli:src/storm-dft/modelchecker/dft/DFTModelChecker.cpp
 
 namespace storm {
     namespace modelchecker {

From 2b7610244d759ecb4742361e5d1de801f4315b9a Mon Sep 17 00:00:00 2001
From: Sebastian Junges <sebastian.junges@rwth-aachen.de>
Date: Fri, 25 Nov 2016 11:27:25 +0100
Subject: [PATCH 04/47] storm-dft running again

---
 src/storm-dft/modelchecker/dft/DFTModelChecker.cpp | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/src/storm-dft/modelchecker/dft/DFTModelChecker.cpp b/src/storm-dft/modelchecker/dft/DFTModelChecker.cpp
index 6c1834d78..2de46e599 100644
--- a/src/storm-dft/modelchecker/dft/DFTModelChecker.cpp
+++ b/src/storm-dft/modelchecker/dft/DFTModelChecker.cpp
@@ -1,19 +1,13 @@
 #include "DFTModelChecker.h"
 
 #include "storm/builder/ParallelCompositionBuilder.h"
-<<<<<<< 297f3ff48076dbf9b67056c82bc97409ef9fd445:src/storm-dft/modelchecker/dft/DFTModelChecker.cpp
-=======
-#include "storm/settings/modules/DFTSettings.h"
->>>>>>> moving dfts to their own lib and cli:src/storm-dft/modelchecker/dft/DFTModelChecker.cpp
 #include "storm/utility/bitoperations.h"
 
 #include "storm-dft/builder/ExplicitDFTModelBuilder.h"
 #include "storm-dft/builder/ExplicitDFTModelBuilderApprox.h"
 #include "storm-dft/storage/dft/DFTIsomorphism.h"
-<<<<<<< 297f3ff48076dbf9b67056c82bc97409ef9fd445:src/storm-dft/modelchecker/dft/DFTModelChecker.cpp
 #include "storm-dft/settings/modules/DFTSettings.h"
-=======
->>>>>>> moving dfts to their own lib and cli:src/storm-dft/modelchecker/dft/DFTModelChecker.cpp
+
 
 namespace storm {
     namespace modelchecker {

From 0fa736d4588650eee8d3cddd597a427682d760bd Mon Sep 17 00:00:00 2001
From: Sebastian Junges <sebastian.junges@rwth-aachen.de>
Date: Mon, 21 Nov 2016 22:05:10 +0100
Subject: [PATCH 05/47] updated dft->gspn translation to now have basis support
 for spares

---
 .../dft/DftToGspnTransformator.cpp            | 473 ++++++++++++++++++
 1 file changed, 473 insertions(+)

diff --git a/src/storm/transformations/dft/DftToGspnTransformator.cpp b/src/storm/transformations/dft/DftToGspnTransformator.cpp
index 730656b35..f63e80f0a 100644
--- a/src/storm/transformations/dft/DftToGspnTransformator.cpp
+++ b/src/storm/transformations/dft/DftToGspnTransformator.cpp
@@ -221,6 +221,10 @@ namespace storm {
                     builder.addInputArc(failedNodes[dftPand->children().at(j)->id()], tfs);
                     builder.addInhibitionArc(failedNodes[dftPand->children().at(j-1)->id()], tfs);
                     builder.addOutputArc(tfs, nodeFS);
+<<<<<<< fcc5d69a44cb202290c4db3c5b2062ff35da5791
+=======
+                    
+>>>>>>> updated dft->gspn translation to now have basis support for spares
                 }
             }
 //			
@@ -234,7 +238,11 @@ namespace storm {
                     unavailableNode = addUnavailableNode(dftSpare);
                 }
                 uint64_t spareActive = builder.addPlace(defaultCapacity, 0, dftSpare->name() + STR_ACTIVATED);
+<<<<<<< fcc5d69a44cb202290c4db3c5b2062ff35da5791
                 activeNodes.emplace(dftSpare->id(), spareActive);
+=======
+                activeNodes.emplace(dftBE->id(), beActive);
+>>>>>>> updated dft->gspn translation to now have basis support for spares
 
                 
                 std::vector<uint64_t> cucNodes;
@@ -270,16 +278,127 @@ namespace storm {
                     builder.addInputArc(failedNodes.at(child->id()), tnextcl);
                     builder.addOutputArc(tnextcl, failedNodes.at(child->id()));
                     nextclTransitions.push_back(tnextcl);
+<<<<<<< fcc5d69a44cb202290c4db3c5b2062ff35da5791
 
+=======
+                    
+                    
+>>>>>>> updated dft->gspn translation to now have basis support for spares
                     ++j;
                 }
                 builder.addOutputArc(nextconsiderTransitions.back(), nodeFailed);
                 builder.addOutputArc(nextclTransitions.back(), nodeFailed);
+<<<<<<< fcc5d69a44cb202290c4db3c5b2062ff35da5791
 
+=======
+                
+>>>>>>> updated dft->gspn translation to now have basis support for spares
                 if (isRepresentative) {
                     builder.addOutputArc(nextconsiderTransitions.back(), unavailableNode);
                     builder.addOutputArc(nextclTransitions.back(), unavailableNode);
                 }
+<<<<<<< fcc5d69a44cb202290c4db3c5b2062ff35da5791
+=======
+                
+                
+//				uint_fast64_t priority = getPriority(0, dftSpare);
+//				
+//				// This codeblock can be removed later, when I am 100% sure it is not needed anymore.
+//				/*
+//				storm::gspn::Place placeSPAREActivated;
+//				placeSPAREActivated.setName(dftSpare->name() + STR_ACTIVATED);
+//				placeSPAREActivated.setNumberOfInitialTokens(isBEActive(dftSpare));
+//				mGspn.addPlace(placeSPAREActivated);
+//				
+//				storm::gspn::ImmediateTransition<storm::gspn::GSPN::WeightType> immediateTransitionPCActivating;
+//				immediateTransitionPCActivating.setName(dftSpare->children()[0]->name() + STR_ACTIVATING);
+//				immediateTransitionPCActivating.setPriority(priority);
+//				immediateTransitionPCActivating.setWeight(0.0);
+//				immediateTransitionPCActivating.setInputArcMultiplicity(placeSPAREActivated, 1);
+//				immediateTransitionPCActivating.setOutputArcMultiplicity(placeSPAREActivated, 1);
+//				mGspn.addImmediateTransition(immediateTransitionPCActivating);
+//				*/
+//				
+//				auto children = dftSpare->children();
+//				
+//				// Draw places and transitions that belong to each spare child.
+//				for (std::size_t i = 1; i < children.size(); i++) {
+//					auto placeChildClaimedPreexist = mGspn.getPlace(children[i]->name() + "_claimed");
+//					
+//					if (!placeChildClaimedPreexist.first) { // Only draw this place if it doesn't exist jet.
+//						storm::gspn::Place placeChildClaimed;
+//						placeChildClaimed.setName(children[i]->name() + "_claimed");
+//						placeChildClaimed.setNumberOfInitialTokens(0);
+//						mGspn.addPlace(placeChildClaimed);
+//						
+//						storm::gspn::ImmediateTransition<storm::gspn::GSPN::WeightType> immediateTransitionSpareChildActivating;
+//						immediateTransitionSpareChildActivating.setName(children[i]->name() + STR_ACTIVATING);
+//						immediateTransitionSpareChildActivating.setPriority(priority);
+//						immediateTransitionSpareChildActivating.setWeight(0.0);
+//						immediateTransitionSpareChildActivating.setInputArcMultiplicity(placeChildClaimed, 1);
+//						immediateTransitionSpareChildActivating.setOutputArcMultiplicity(placeChildClaimed, 1);
+//						mGspn.addImmediateTransition(immediateTransitionSpareChildActivating);
+//					}
+//					
+//					auto placeChildClaimedExist = mGspn.getPlace(children[i]->name() + "_claimed");
+//					
+//					storm::gspn::Place placeSPAREClaimedChild;
+//					placeSPAREClaimedChild.setName(dftSpare->name() + "_claimed_" + children[i]->name());
+//					placeSPAREClaimedChild.setNumberOfInitialTokens(0);
+//					mGspn.addPlace(placeSPAREClaimedChild);
+//					
+//					storm::gspn::ImmediateTransition<storm::gspn::GSPN::WeightType> immediateTransitionChildClaiming;
+//					immediateTransitionChildClaiming.setName(dftSpare->name() + "_claiming_" + children[i]->name());
+//					immediateTransitionChildClaiming.setPriority(priority + 1); // Higher priority needed!
+//					immediateTransitionChildClaiming.setWeight(0.0);
+//					immediateTransitionChildClaiming.setInhibitionArcMultiplicity(placeChildClaimedExist.second, 1);
+//					immediateTransitionChildClaiming.setOutputArcMultiplicity(placeChildClaimedExist.second, 1);
+//					immediateTransitionChildClaiming.setOutputArcMultiplicity(placeSPAREClaimedChild, 1);
+//					mGspn.addImmediateTransition(immediateTransitionChildClaiming);
+//					
+//					storm::gspn::Place placeSPAREChildConsumed;
+//					if (i < children.size() - 1) {
+//						placeSPAREChildConsumed.setName(dftSpare->name() + "_" + children[i]->name() + "_consumed");
+//					}
+//					else {
+//						placeSPAREChildConsumed.setName(dftSpare->name() + STR_FAILED);
+//					}
+//					placeSPAREChildConsumed.setNumberOfInitialTokens(0);
+//					mGspn.addPlace(placeSPAREChildConsumed);
+//					
+//					storm::gspn::ImmediateTransition<storm::gspn::GSPN::WeightType> immediateTransitionChildConsuming1;
+//					immediateTransitionChildConsuming1.setName(dftSpare->name() + "_" + children[i]->name() + "_consuming1");
+//					immediateTransitionChildConsuming1.setPriority(priority);
+//					immediateTransitionChildConsuming1.setWeight(0.0);
+//					immediateTransitionChildConsuming1.setOutputArcMultiplicity(placeSPAREChildConsumed, 1);
+//					immediateTransitionChildConsuming1.setInhibitionArcMultiplicity(placeSPAREChildConsumed, 1);
+//					immediateTransitionChildConsuming1.setInhibitionArcMultiplicity(placeSPAREClaimedChild, 1);
+//					mGspn.addImmediateTransition(immediateTransitionChildConsuming1);
+//					
+//					storm::gspn::ImmediateTransition<storm::gspn::GSPN::WeightType> immediateTransitionChildConsuming2;
+//					immediateTransitionChildConsuming2.setName(dftSpare->name() + "_" + children[i]->name() + "_consuming2");
+//					immediateTransitionChildConsuming2.setPriority(priority);
+//					immediateTransitionChildConsuming2.setWeight(0.0);
+//					immediateTransitionChildConsuming2.setOutputArcMultiplicity(placeSPAREChildConsumed, 1);
+//					immediateTransitionChildConsuming2.setInhibitionArcMultiplicity(placeSPAREChildConsumed, 1);
+//					immediateTransitionChildConsuming2.setOutputArcMultiplicity(placeSPAREClaimedChild, 1);
+//					immediateTransitionChildConsuming2.setInputArcMultiplicity(placeSPAREClaimedChild, 1);
+//					mGspn.addImmediateTransition(immediateTransitionChildConsuming2);
+//				}
+//				
+//				// Draw connections between all spare childs.
+//				for (std::size_t i = 1; i < children.size() - 1; i++) {
+//					auto placeSPAREChildConsumed = mGspn.getPlace(dftSpare->name() + "_" + children[i]->name() + "_consumed");
+//					auto immediateTransitionChildClaiming = mGspn.getImmediateTransition(dftSpare->name() + "_claiming_" + children[i + 1]->name());
+//					auto immediateTransitionChildConsuming1 = mGspn.getImmediateTransition(dftSpare->name() + "_" + children[i + 1]->name() + "_consuming1");
+//					
+//					immediateTransitionChildClaiming.second->setOutputArcMultiplicity(placeSPAREChildConsumed.second, 1);
+//					immediateTransitionChildClaiming.second->setInputArcMultiplicity(placeSPAREChildConsumed.second, 1);
+//					
+//					immediateTransitionChildConsuming1.second->setOutputArcMultiplicity(placeSPAREChildConsumed.second, 1);
+//					immediateTransitionChildConsuming1.second->setInputArcMultiplicity(placeSPAREChildConsumed.second, 1);
+//				}
+>>>>>>> updated dft->gspn translation to now have basis support for spares
 			}
 //			
 			template <typename ValueType>
@@ -308,11 +427,18 @@ namespace storm {
 //			
 			template <typename ValueType>
             void DftToGspnTransformator<ValueType>::drawCONSTF(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dftConstF, bool isRepresentative) {
+<<<<<<< fcc5d69a44cb202290c4db3c5b2062ff35da5791
 			    failedNodes.push_back(builder.addPlace(defaultCapacity, 1, dftConstF->name() + STR_FAILED));
                 uint64_t unavailableNode = 0;
                 if (isRepresentative) {
                     unavailableNode = addUnavailableNode(dftConstF, false);
                 }
+=======
+//				storm::gspn::Place placeCONSTFFailed;
+//				placeCONSTFFailed.setName(dftConstF->name() + STR_FAILED);
+//				placeCONSTFFailed.setNumberOfInitialTokens(1);
+//				mGspn.addPlace(placeCONSTFFailed);
+>>>>>>> updated dft->gspn translation to now have basis support for spares
 			}
 //			
 			template <typename ValueType>
@@ -346,14 +472,237 @@ namespace storm {
 			}
             
             template<typename ValueType>
+<<<<<<< fcc5d69a44cb202290c4db3c5b2062ff35da5791
             uint64_t DftToGspnTransformator<ValueType>::addUnavailableNode(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dftElement, bool initialAvailable) {
                 uint64_t unavailableNode = builder.addPlace(defaultCapacity, initialAvailable ? 0 : 1, dftElement->name() + "_unavailable");
+=======
+            uint64_t DftToGspnTransformator<ValueType>::addUnavailableNode(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dftElement) {
+                uint64_t unavailableNode = builder.addPlace(defaultCapacity, 1, dftElement->name() + "_unavailable");
+>>>>>>> updated dft->gspn translation to now have basis support for spares
                 assert(unavailableNode != 0);
                 unavailableNodes.emplace(dftElement->id(), unavailableNode);
                 return unavailableNode;
             }
 //			
+<<<<<<< fcc5d69a44cb202290c4db3c5b2062ff35da5791
 
+=======
+			template <typename ValueType>
+            void DftToGspnTransformator<ValueType>::drawGSPNConnections() {
+//				// Check for every element, if they have parents (all will have at least 1, except the top event). 
+//				for (std::size_t i = 0; i < mDft.nrElements(); i++) {
+//					auto child = mDft.getElement(i);
+//					auto parents = child->parentIds();
+//					
+//					// Draw a connection to every parent.
+//					for (std::size_t j = 0; j < parents.size(); j++) {	
+//						// Check the type of the parent and act accordingly (every parent gate has different entry points...).
+//						switch (mDft.getElement(parents[j])->type()) {
+//							case storm::storage::DFTElementType::AND:
+//							{
+//								auto andEntry = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + STR_FAILING);
+//								auto childExit = mGspn.getPlace(child->name() + STR_FAILED);
+//								if (andEntry.first && childExit.first) { // Only add arcs if the objects have been found.
+//									andEntry.second->setInputArcMultiplicity(childExit.second, 1);
+//									andEntry.second->setOutputArcMultiplicity(childExit.second, 1);
+//								}
+//								break;
+//							}
+//							case storm::storage::DFTElementType::OR:
+//							{
+//								auto orEntry = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + "_" + child->name() + STR_FAILING);
+//								auto childExit = mGspn.getPlace(child->name() + STR_FAILED);
+//								if (orEntry.first && childExit.first) { // Only add arcs if the objects have been found.
+//									orEntry.second->setInputArcMultiplicity(childExit.second, 1);
+//									orEntry.second->setOutputArcMultiplicity(childExit.second, 1);
+//								}
+//								break;
+//							}
+//							case storm::storage::DFTElementType::VOT:
+//							{
+//								auto childExit = mGspn.getPlace(child->name() + STR_FAILED);
+//								auto parentEntry = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + "_" + child->name() + "_collecting");
+//								
+//								if (childExit.first && parentEntry.first) { // Only add arcs if the objects have been found.
+//									parentEntry.second->setInputArcMultiplicity(childExit.second, 1);
+//									parentEntry.second->setOutputArcMultiplicity(childExit.second, 1);
+//								}
+//								
+//								break;
+//							}
+//							case storm::storage::DFTElementType::PAND:
+//							{
+//								auto children =  std::static_pointer_cast<storm::storage::DFTPand<ValueType> const>(mDft.getElement(parents[j]))->children();
+//								auto childExit = mGspn.getPlace(child->name() + STR_FAILED);
+//								auto pandEntry = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + STR_FAILING);
+//								
+//								if (childExit.first && pandEntry.first) { // Only add arcs if the objects have been found.
+//									pandEntry.second->setInputArcMultiplicity(childExit.second, 1);
+//									pandEntry.second->setOutputArcMultiplicity(childExit.second, 1);
+//									
+//									if (children[0] == child) { // Current element is primary child.
+//										auto pandEntry2 = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + "_0" + STR_FAILSAVING);
+//										
+//										if (pandEntry2.first) {
+//											pandEntry2.second->setInhibitionArcMultiplicity(childExit.second, 1);
+//										}
+//									}
+//									else { // Current element is not the primary child.
+//										for (std::size_t k = 1; k < children.size(); k++) {
+//											if (children[k] == child) {
+//												auto pandEntry2 = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + "_" + std::to_string((k - 1)) + STR_FAILSAVING);
+//												auto pandEntry3 = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + "_" + std::to_string((k)) + STR_FAILSAVING);
+//												
+//												if (pandEntry2.first) {
+//													pandEntry2.second->setInputArcMultiplicity(childExit.second, 1);
+//													pandEntry2.second->setOutputArcMultiplicity(childExit.second, 1);
+//												}
+//												
+//												if (pandEntry3.first) {
+//													pandEntry3.second->setInhibitionArcMultiplicity(childExit.second, 1);
+//												}
+//												
+//												continue;
+//											}
+//										}
+//									}
+//								}
+//								
+//								break;
+//							}
+//							case storm::storage::DFTElementType::SPARE:
+//							{
+//								// Check if current child is a primary or spare child.
+//								auto children =  std::static_pointer_cast<storm::storage::DFTSpare<ValueType> const>(mDft.getElement(parents[j]))->children();
+//								
+//								if (child == children[0]) { // Primary child.
+//									auto spareExit = mGspn.getImmediateTransition(child->name() + STR_ACTIVATING);
+//									
+//									std::vector<int> ids = getAllBEIDsOfElement(child);
+//									for (std::size_t k = 0; k < ids.size(); k++) {
+//										auto childEntry = mGspn.getPlace(mDft.getElement(ids[k])->name() + STR_ACTIVATED);
+//										
+//										if (spareExit.first && childEntry.first) { // Only add arcs if the objects have been found.
+//											spareExit.second->setInhibitionArcMultiplicity(childEntry.second, 1);
+//											spareExit.second->setOutputArcMultiplicity(childEntry.second, 1);
+//										}
+//									}
+//									
+//									// Draw lines from "primary child_failed" to SPARE.
+//									auto childExit = mGspn.getPlace(child->name() + STR_FAILED);
+//									auto spareEntry = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + "_claiming_" + children[1]->name());
+//									auto spareEntry2 = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + "_" + children[1]->name() + "_consuming1");
+//									
+//									if (childExit.first && spareEntry.first && spareEntry2.first) { // Only add arcs if the objects have been found.
+//										spareEntry.second->setInputArcMultiplicity(childExit.second, 1);
+//										spareEntry.second->setOutputArcMultiplicity(childExit.second, 1);
+//										
+//										spareEntry2.second->setInputArcMultiplicity(childExit.second, 1);
+//										spareEntry2.second->setOutputArcMultiplicity(childExit.second, 1);
+//									}
+//								}
+//								else { // A spare child.
+//									auto spareExit = mGspn.getImmediateTransition(child->name() + STR_ACTIVATING);
+//									auto spareExit2 = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + "_claiming_" + child->name());
+//									
+//									std::vector<int> ids = getAllBEIDsOfElement(child);
+//									for (std::size_t k = 0; k < ids.size(); k++) {
+//										auto childEntry = mGspn.getPlace(mDft.getElement(ids[k])->name() + STR_ACTIVATED);
+//										
+//										if (spareExit.first && spareExit2.first && childEntry.first) { // Only add arcs if the objects have been found.
+//											if (!spareExit.second->existsInhibitionArc(childEntry.second)) {
+//												spareExit.second->setInhibitionArcMultiplicity(childEntry.second, 1);
+//											}
+//											if (!spareExit.second->existsOutputArc(childEntry.second)) {
+//												spareExit.second->setOutputArcMultiplicity(childEntry.second, 1);
+//											}
+//											if (!spareExit2.second->existsInhibitionArc(childEntry.second)) {
+//												spareExit2.second->setInhibitionArcMultiplicity(childEntry.second, 1);
+//											}
+//										}
+//									}
+//									
+//									auto childExit = mGspn.getPlace(child->name() + STR_FAILED);
+//									auto spareEntry = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + "_claiming_" + child->name());
+//									auto spareEntry2 = mGspn.getImmediateTransition(child->name() + STR_ACTIVATING);
+//									auto spareEntry3 = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + "_" + child->name() + "_consuming2");
+//									
+//									if (childExit.first && spareEntry.first && spareEntry2.first && spareEntry3.first) { // Only add arcs if the objects have been found.
+//										spareEntry.second->setInhibitionArcMultiplicity(childExit.second, 1);
+//										
+//										if (!spareEntry2.second->existsInhibitionArc(childExit.second)) {
+//											spareEntry2.second->setInhibitionArcMultiplicity(childExit.second, 1);
+//										}
+//										
+//										spareEntry3.second->setInputArcMultiplicity(childExit.second, 1);
+//										spareEntry3.second->setOutputArcMultiplicity(childExit.second, 1);
+//									}
+//								}
+//								
+//								break;
+//							}
+//							case storm::storage::DFTElementType::POR:
+//							{
+//								auto children =  std::static_pointer_cast<storm::storage::DFTPand<ValueType> const>(mDft.getElement(parents[j]))->children();
+//								auto porEntry = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + STR_FAILING);
+//								auto porEntry2 = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + STR_FAILSAVING);
+//								auto childExit = mGspn.getPlace(child->name() + STR_FAILED);
+//								
+//								if (porEntry.first && porEntry2.first && childExit.first) { // Only add arcs if the objects have been found.
+//									if (children[0] == child) { // Current element is primary child.
+//										porEntry.second->setInputArcMultiplicity(childExit.second, 1);
+//										porEntry.second->setOutputArcMultiplicity(childExit.second, 1);
+//										porEntry2.second->setInhibitionArcMultiplicity(childExit.second, 1);
+//										
+//									}
+//									else { // Current element is not the primary child.
+//										porEntry2.second->setInputArcMultiplicity(childExit.second, 1);
+//										porEntry2.second->setOutputArcMultiplicity(childExit.second, 1);
+//									}
+//								}
+//								
+//								break;
+//							}
+//							case storm::storage::DFTElementType::SEQ:
+//							{
+//								// Sequences are realized with restrictions. Nothing to do here.
+//								break;
+//							}
+//							case storm::storage::DFTElementType::MUTEX:
+//							{
+//								// MUTEX are realized with restrictions. Nothing to do here.
+//								break;
+//							}
+//							case storm::storage::DFTElementType::BE:
+//							{
+//								// The parent is never a Basic Event.
+//								break;
+//							}
+//							case storm::storage::DFTElementType::CONSTF:
+//							{
+//								// The parent is never a Basic Event.
+//								break;
+//							}
+//							case storm::storage::DFTElementType::CONSTS:
+//							{
+//								// The parent is never a Basic Event.
+//								break;
+//							}
+//							case storm::storage::DFTElementType::PDEP:
+//							{
+//								// The parent is never a DEP. Hence the connections must be drawn somewhere else.
+//								break;
+//							}
+//							default:
+//							{
+//								STORM_LOG_ASSERT(false, "DFT type unknown.");
+//								break;
+//							}
+//						}
+//					}
+//				}
+			}
+>>>>>>> updated dft->gspn translation to now have basis support for spares
 			
 			template <typename ValueType>
             bool DftToGspnTransformator<ValueType>::isBEActive(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dftElement)
@@ -395,7 +744,38 @@ namespace storm {
 			{
                 return mDft.maxRank() - dftElement->rank();
 			}
+<<<<<<< fcc5d69a44cb202290c4db3c5b2062ff35da5791
 
+=======
+			
+			template <typename ValueType>
+            void DftToGspnTransformator<ValueType>::drawGSPNDependencies() {
+//				for (std::size_t i = 0; i < mDft.nrElements(); i++) {
+//					auto dftElement = mDft.getElement(i);
+//					
+//					if (dftElement->isDependency()) {
+//						std::string gateName = dftElement->name().substr(0, dftElement->name().find("_"));
+//						auto depEntry = mGspn.getTimedTransition(gateName + STR_FAILING);
+//						auto trigger = mGspn.getPlace(std::static_pointer_cast<storm::storage::DFTDependency<ValueType> const>(dftElement)->nameTrigger() + STR_FAILED);
+//						
+//						if (depEntry.first && trigger.first) { // Only add arcs if the objects have been found.
+//							if (!depEntry.second->existsInputArc(trigger.second)) {
+//								depEntry.second->setInputArcMultiplicity(trigger.second, 1);
+//							}
+//							if (!depEntry.second->existsOutputArc(trigger.second)){
+//								depEntry.second->setOutputArcMultiplicity(trigger.second, 1);
+//							}
+//						}
+//						
+//						auto dependent = mGspn.getPlace(std::static_pointer_cast<storm::storage::DFTDependency<ValueType> const>(dftElement)->nameDependent() + STR_FAILED);
+//						
+//						if (dependent.first) { // Only add arcs if the objects have been found.
+//							depEntry.second->setOutputArcMultiplicity(dependent.second, 1);
+//						}
+//					}
+//				}
+			}
+>>>>>>> updated dft->gspn translation to now have basis support for spares
 			
 			template <typename ValueType>
             void DftToGspnTransformator<ValueType>::drawGSPNRestrictions() {
@@ -453,7 +833,100 @@ namespace storm {
 //					}
 //				}
 			}
+<<<<<<< fcc5d69a44cb202290c4db3c5b2062ff35da5791
 
+=======
+			
+			template <typename ValueType>
+            std::vector<int> DftToGspnTransformator<ValueType>::getAllBEIDsOfElement(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dftElement) {
+//				std::vector<int> ids;
+//				
+//				switch (dftElement->type()) {
+//					case storm::storage::DFTElementType::AND:
+//					{
+//						auto children = std::static_pointer_cast<storm::storage::DFTAnd<ValueType> const>(dftElement)->children();
+//						
+//						for (std::size_t i = 0; i < children.size(); i++) {
+//							std::vector<int> newIds = getAllBEIDsOfElement(children[i]);
+//							ids.insert(ids.end(), newIds.begin(), newIds.end());
+//						}
+//						break;
+//					}
+//					case storm::storage::DFTElementType::OR:
+//					{
+//						auto children = std::static_pointer_cast<storm::storage::DFTOr<ValueType> const>(dftElement)->children();
+//						
+//						for (std::size_t i = 0; i < children.size(); i++) {
+//							std::vector<int> newIds = getAllBEIDsOfElement(children[i]);
+//							ids.insert(ids.end(), newIds.begin(), newIds.end());
+//						}
+//						break;
+//					}
+//					case storm::storage::DFTElementType::VOT:
+//					{
+//						auto children = std::static_pointer_cast<storm::storage::DFTVot<ValueType> const>(dftElement)->children();
+//						
+//						for (std::size_t i = 0; i < children.size(); i++) {
+//							std::vector<int> newIds = getAllBEIDsOfElement(children[i]);
+//							ids.insert(ids.end(), newIds.begin(), newIds.end());
+//						}
+//						break;
+//					}
+//					case storm::storage::DFTElementType::PAND:
+//					{
+//						auto children = std::static_pointer_cast<storm::storage::DFTPand<ValueType> const>(dftElement)->children();
+//						
+//						for (std::size_t i = 0; i < children.size(); i++) {
+//							std::vector<int> newIds = getAllBEIDsOfElement(children[i]);
+//							ids.insert(ids.end(), newIds.begin(), newIds.end());
+//						}
+//						break;
+//					}
+//					case storm::storage::DFTElementType::SPARE:
+//					{								
+//						auto children = std::static_pointer_cast<storm::storage::DFTSpare<ValueType> const>(dftElement)->children();
+//						
+//						// Only regard the primary child of a SPARE. The spare childs are not allowed to be listed here.
+//						for (std::size_t i = 0; i < 1; i++) {
+//							std::vector<int> newIds = getAllBEIDsOfElement(children[i]);
+//							ids.insert(ids.end(), newIds.begin(), newIds.end());
+//						}
+//						break;
+//					}
+//					case storm::storage::DFTElementType::POR:
+//					{
+//						auto children = std::static_pointer_cast<storm::storage::DFTPor<ValueType> const>(dftElement)->children();
+//						
+//						for (std::size_t i = 0; i < children.size(); i++) {
+//							std::vector<int> newIds = getAllBEIDsOfElement(children[i]);
+//							ids.insert(ids.end(), newIds.begin(), newIds.end());
+//						}
+//						break;
+//					}
+//					case storm::storage::DFTElementType::BE:
+//					case storm::storage::DFTElementType::CONSTF:
+//					case storm::storage::DFTElementType::CONSTS:
+//					{
+//						ids.push_back(dftElement->id());
+//						break;
+//					}
+//					case storm::storage::DFTElementType::SEQ:
+//					case storm::storage::DFTElementType::MUTEX:
+//					case storm::storage::DFTElementType::PDEP:
+//					{
+//						break;
+//					}
+//					default:
+//					{
+//						STORM_LOG_ASSERT(false, "DFT type unknown.");
+//						break;
+//					}
+//				}
+//				
+//				return ids;
+			}
+			
+>>>>>>> updated dft->gspn translation to now have basis support for spares
 			template <typename ValueType>
             void DftToGspnTransformator<ValueType>::writeGspn(bool toFile) {
                 if (toFile) {

From d4f7088cfd7d7dc07dea605e783690ebd619f599 Mon Sep 17 00:00:00 2001
From: Sebastian Junges <sebastian.junges@rwth-aachen.de>
Date: Fri, 2 Dec 2016 13:58:59 +0100
Subject: [PATCH 06/47] updates to dft->gspn

---
 src/storm-dft-cli/storm-dyftee.cpp                          | 5 ++---
 src/storm-dft/CMakeLists.txt                                | 2 +-
 .../transformations}/DftToGspnTransformator.cpp             | 0
 .../transformations}/DftToGspnTransformator.h               | 6 +++---
 4 files changed, 6 insertions(+), 7 deletions(-)
 rename src/{storm/transformations/dft => storm-dft/transformations}/DftToGspnTransformator.cpp (100%)
 rename src/{storm/transformations/dft => storm-dft/transformations}/DftToGspnTransformator.h (97%)

diff --git a/src/storm-dft-cli/storm-dyftee.cpp b/src/storm-dft-cli/storm-dyftee.cpp
index c0b0b58b2..3056cbdf1 100644
--- a/src/storm-dft-cli/storm-dyftee.cpp
+++ b/src/storm-dft-cli/storm-dyftee.cpp
@@ -3,8 +3,6 @@
 #include "storm/utility/storm.h"
 #include "storm/cli/cli.h"
 #include "storm/exceptions/BaseException.h"
-#include "storm/utility/macros.h"
-#include "storm/transformations/dft/DftToGspnTransformator.h"
 
 
 #include "storm/settings/modules/GeneralSettings.h"
@@ -18,7 +16,8 @@
 #include "storm-dft/parser/DFTGalileoParser.h"
 #include "storm-dft/modelchecker/dft/DFTModelChecker.h"
 #include "storm-dft/modelchecker/dft/DFTASFChecker.h"
-#include "storm-dft/transformations/dft/DftToGspnTransformator.h"
+#include "storm-dft/transformations/DftToGspnTransformator.h"
+
 
 #include "storm-dft/settings/modules/DFTSettings.h"
 
diff --git a/src/storm-dft/CMakeLists.txt b/src/storm-dft/CMakeLists.txt
index df0c067e0..10d9b8508 100644
--- a/src/storm-dft/CMakeLists.txt
+++ b/src/storm-dft/CMakeLists.txt
@@ -10,4 +10,4 @@ file(GLOB_RECURSE STORM_DFT_HEADERS ${PROJECT_SOURCE_DIR}/src/storm-dft/*/*.h)
 
 # Create storm-pgcl.
 add_library(storm-dft SHARED ${STORM_DFT_SOURCES} ${STORM_DFT_HEADERS})
-target_link_libraries(storm-dft storm ${STORM_DFT_LINK_LIBRARIES})
+target_link_libraries(storm-dft storm storm-gspn ${STORM_DFT_LINK_LIBRARIES})
diff --git a/src/storm/transformations/dft/DftToGspnTransformator.cpp b/src/storm-dft/transformations/DftToGspnTransformator.cpp
similarity index 100%
rename from src/storm/transformations/dft/DftToGspnTransformator.cpp
rename to src/storm-dft/transformations/DftToGspnTransformator.cpp
diff --git a/src/storm/transformations/dft/DftToGspnTransformator.h b/src/storm-dft/transformations/DftToGspnTransformator.h
similarity index 97%
rename from src/storm/transformations/dft/DftToGspnTransformator.h
rename to src/storm-dft/transformations/DftToGspnTransformator.h
index 1e0d3eb69..4d827e44b 100644
--- a/src/storm/transformations/dft/DftToGspnTransformator.h
+++ b/src/storm-dft/transformations/DftToGspnTransformator.h
@@ -1,8 +1,8 @@
 #pragma once
 
-#include "storm/storage/dft/DFT.h"
-#include "storm/storage/gspn/GSPN.h"
-#include "storm/storage/gspn/GspnBuilder.h"
+#include "storm-dft/storage/dft/DFT.h"
+#include "storm-gspn/storage/gspn/GSPN.h"
+#include "storm-gspn/storage/gspn/GspnBuilder.h"
 
 namespace storm {
     namespace transformations {

From f2a8c1be401c0e9a934f597e90220a02b57fd4bc Mon Sep 17 00:00:00 2001
From: Sebastian Junges <sebastian.junges@rwth-aachen.de>
Date: Fri, 2 Dec 2016 14:12:19 +0100
Subject: [PATCH 07/47] post-rebase fix

---
 .../DftToGspnTransformator.cpp                | 477 +-----------------
 1 file changed, 3 insertions(+), 474 deletions(-)

diff --git a/src/storm-dft/transformations/DftToGspnTransformator.cpp b/src/storm-dft/transformations/DftToGspnTransformator.cpp
index f63e80f0a..49f58707f 100644
--- a/src/storm-dft/transformations/DftToGspnTransformator.cpp
+++ b/src/storm-dft/transformations/DftToGspnTransformator.cpp
@@ -221,10 +221,7 @@ namespace storm {
                     builder.addInputArc(failedNodes[dftPand->children().at(j)->id()], tfs);
                     builder.addInhibitionArc(failedNodes[dftPand->children().at(j-1)->id()], tfs);
                     builder.addOutputArc(tfs, nodeFS);
-<<<<<<< fcc5d69a44cb202290c4db3c5b2062ff35da5791
-=======
-                    
->>>>>>> updated dft->gspn translation to now have basis support for spares
+
                 }
             }
 //			
@@ -238,11 +235,7 @@ namespace storm {
                     unavailableNode = addUnavailableNode(dftSpare);
                 }
                 uint64_t spareActive = builder.addPlace(defaultCapacity, 0, dftSpare->name() + STR_ACTIVATED);
-<<<<<<< fcc5d69a44cb202290c4db3c5b2062ff35da5791
                 activeNodes.emplace(dftSpare->id(), spareActive);
-=======
-                activeNodes.emplace(dftBE->id(), beActive);
->>>>>>> updated dft->gspn translation to now have basis support for spares
 
                 
                 std::vector<uint64_t> cucNodes;
@@ -278,127 +271,17 @@ namespace storm {
                     builder.addInputArc(failedNodes.at(child->id()), tnextcl);
                     builder.addOutputArc(tnextcl, failedNodes.at(child->id()));
                     nextclTransitions.push_back(tnextcl);
-<<<<<<< fcc5d69a44cb202290c4db3c5b2062ff35da5791
-
-=======
-                    
-                    
->>>>>>> updated dft->gspn translation to now have basis support for spares
                     ++j;
                 }
                 builder.addOutputArc(nextconsiderTransitions.back(), nodeFailed);
                 builder.addOutputArc(nextclTransitions.back(), nodeFailed);
-<<<<<<< fcc5d69a44cb202290c4db3c5b2062ff35da5791
 
-=======
-                
->>>>>>> updated dft->gspn translation to now have basis support for spares
                 if (isRepresentative) {
                     builder.addOutputArc(nextconsiderTransitions.back(), unavailableNode);
                     builder.addOutputArc(nextclTransitions.back(), unavailableNode);
                 }
-<<<<<<< fcc5d69a44cb202290c4db3c5b2062ff35da5791
-=======
-                
                 
-//				uint_fast64_t priority = getPriority(0, dftSpare);
-//				
-//				// This codeblock can be removed later, when I am 100% sure it is not needed anymore.
-//				/*
-//				storm::gspn::Place placeSPAREActivated;
-//				placeSPAREActivated.setName(dftSpare->name() + STR_ACTIVATED);
-//				placeSPAREActivated.setNumberOfInitialTokens(isBEActive(dftSpare));
-//				mGspn.addPlace(placeSPAREActivated);
-//				
-//				storm::gspn::ImmediateTransition<storm::gspn::GSPN::WeightType> immediateTransitionPCActivating;
-//				immediateTransitionPCActivating.setName(dftSpare->children()[0]->name() + STR_ACTIVATING);
-//				immediateTransitionPCActivating.setPriority(priority);
-//				immediateTransitionPCActivating.setWeight(0.0);
-//				immediateTransitionPCActivating.setInputArcMultiplicity(placeSPAREActivated, 1);
-//				immediateTransitionPCActivating.setOutputArcMultiplicity(placeSPAREActivated, 1);
-//				mGspn.addImmediateTransition(immediateTransitionPCActivating);
-//				*/
-//				
-//				auto children = dftSpare->children();
-//				
-//				// Draw places and transitions that belong to each spare child.
-//				for (std::size_t i = 1; i < children.size(); i++) {
-//					auto placeChildClaimedPreexist = mGspn.getPlace(children[i]->name() + "_claimed");
-//					
-//					if (!placeChildClaimedPreexist.first) { // Only draw this place if it doesn't exist jet.
-//						storm::gspn::Place placeChildClaimed;
-//						placeChildClaimed.setName(children[i]->name() + "_claimed");
-//						placeChildClaimed.setNumberOfInitialTokens(0);
-//						mGspn.addPlace(placeChildClaimed);
-//						
-//						storm::gspn::ImmediateTransition<storm::gspn::GSPN::WeightType> immediateTransitionSpareChildActivating;
-//						immediateTransitionSpareChildActivating.setName(children[i]->name() + STR_ACTIVATING);
-//						immediateTransitionSpareChildActivating.setPriority(priority);
-//						immediateTransitionSpareChildActivating.setWeight(0.0);
-//						immediateTransitionSpareChildActivating.setInputArcMultiplicity(placeChildClaimed, 1);
-//						immediateTransitionSpareChildActivating.setOutputArcMultiplicity(placeChildClaimed, 1);
-//						mGspn.addImmediateTransition(immediateTransitionSpareChildActivating);
-//					}
-//					
-//					auto placeChildClaimedExist = mGspn.getPlace(children[i]->name() + "_claimed");
-//					
-//					storm::gspn::Place placeSPAREClaimedChild;
-//					placeSPAREClaimedChild.setName(dftSpare->name() + "_claimed_" + children[i]->name());
-//					placeSPAREClaimedChild.setNumberOfInitialTokens(0);
-//					mGspn.addPlace(placeSPAREClaimedChild);
-//					
-//					storm::gspn::ImmediateTransition<storm::gspn::GSPN::WeightType> immediateTransitionChildClaiming;
-//					immediateTransitionChildClaiming.setName(dftSpare->name() + "_claiming_" + children[i]->name());
-//					immediateTransitionChildClaiming.setPriority(priority + 1); // Higher priority needed!
-//					immediateTransitionChildClaiming.setWeight(0.0);
-//					immediateTransitionChildClaiming.setInhibitionArcMultiplicity(placeChildClaimedExist.second, 1);
-//					immediateTransitionChildClaiming.setOutputArcMultiplicity(placeChildClaimedExist.second, 1);
-//					immediateTransitionChildClaiming.setOutputArcMultiplicity(placeSPAREClaimedChild, 1);
-//					mGspn.addImmediateTransition(immediateTransitionChildClaiming);
-//					
-//					storm::gspn::Place placeSPAREChildConsumed;
-//					if (i < children.size() - 1) {
-//						placeSPAREChildConsumed.setName(dftSpare->name() + "_" + children[i]->name() + "_consumed");
-//					}
-//					else {
-//						placeSPAREChildConsumed.setName(dftSpare->name() + STR_FAILED);
-//					}
-//					placeSPAREChildConsumed.setNumberOfInitialTokens(0);
-//					mGspn.addPlace(placeSPAREChildConsumed);
-//					
-//					storm::gspn::ImmediateTransition<storm::gspn::GSPN::WeightType> immediateTransitionChildConsuming1;
-//					immediateTransitionChildConsuming1.setName(dftSpare->name() + "_" + children[i]->name() + "_consuming1");
-//					immediateTransitionChildConsuming1.setPriority(priority);
-//					immediateTransitionChildConsuming1.setWeight(0.0);
-//					immediateTransitionChildConsuming1.setOutputArcMultiplicity(placeSPAREChildConsumed, 1);
-//					immediateTransitionChildConsuming1.setInhibitionArcMultiplicity(placeSPAREChildConsumed, 1);
-//					immediateTransitionChildConsuming1.setInhibitionArcMultiplicity(placeSPAREClaimedChild, 1);
-//					mGspn.addImmediateTransition(immediateTransitionChildConsuming1);
-//					
-//					storm::gspn::ImmediateTransition<storm::gspn::GSPN::WeightType> immediateTransitionChildConsuming2;
-//					immediateTransitionChildConsuming2.setName(dftSpare->name() + "_" + children[i]->name() + "_consuming2");
-//					immediateTransitionChildConsuming2.setPriority(priority);
-//					immediateTransitionChildConsuming2.setWeight(0.0);
-//					immediateTransitionChildConsuming2.setOutputArcMultiplicity(placeSPAREChildConsumed, 1);
-//					immediateTransitionChildConsuming2.setInhibitionArcMultiplicity(placeSPAREChildConsumed, 1);
-//					immediateTransitionChildConsuming2.setOutputArcMultiplicity(placeSPAREClaimedChild, 1);
-//					immediateTransitionChildConsuming2.setInputArcMultiplicity(placeSPAREClaimedChild, 1);
-//					mGspn.addImmediateTransition(immediateTransitionChildConsuming2);
-//				}
-//				
-//				// Draw connections between all spare childs.
-//				for (std::size_t i = 1; i < children.size() - 1; i++) {
-//					auto placeSPAREChildConsumed = mGspn.getPlace(dftSpare->name() + "_" + children[i]->name() + "_consumed");
-//					auto immediateTransitionChildClaiming = mGspn.getImmediateTransition(dftSpare->name() + "_claiming_" + children[i + 1]->name());
-//					auto immediateTransitionChildConsuming1 = mGspn.getImmediateTransition(dftSpare->name() + "_" + children[i + 1]->name() + "_consuming1");
-//					
-//					immediateTransitionChildClaiming.second->setOutputArcMultiplicity(placeSPAREChildConsumed.second, 1);
-//					immediateTransitionChildClaiming.second->setInputArcMultiplicity(placeSPAREChildConsumed.second, 1);
-//					
-//					immediateTransitionChildConsuming1.second->setOutputArcMultiplicity(placeSPAREChildConsumed.second, 1);
-//					immediateTransitionChildConsuming1.second->setInputArcMultiplicity(placeSPAREChildConsumed.second, 1);
-//				}
->>>>>>> updated dft->gspn translation to now have basis support for spares
+
 			}
 //			
 			template <typename ValueType>
@@ -427,18 +310,12 @@ namespace storm {
 //			
 			template <typename ValueType>
             void DftToGspnTransformator<ValueType>::drawCONSTF(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dftConstF, bool isRepresentative) {
-<<<<<<< fcc5d69a44cb202290c4db3c5b2062ff35da5791
 			    failedNodes.push_back(builder.addPlace(defaultCapacity, 1, dftConstF->name() + STR_FAILED));
                 uint64_t unavailableNode = 0;
                 if (isRepresentative) {
                     unavailableNode = addUnavailableNode(dftConstF, false);
                 }
-=======
-//				storm::gspn::Place placeCONSTFFailed;
-//				placeCONSTFFailed.setName(dftConstF->name() + STR_FAILED);
-//				placeCONSTFFailed.setNumberOfInitialTokens(1);
-//				mGspn.addPlace(placeCONSTFFailed);
->>>>>>> updated dft->gspn translation to now have basis support for spares
+
 			}
 //			
 			template <typename ValueType>
@@ -472,237 +349,13 @@ namespace storm {
 			}
             
             template<typename ValueType>
-<<<<<<< fcc5d69a44cb202290c4db3c5b2062ff35da5791
             uint64_t DftToGspnTransformator<ValueType>::addUnavailableNode(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dftElement, bool initialAvailable) {
                 uint64_t unavailableNode = builder.addPlace(defaultCapacity, initialAvailable ? 0 : 1, dftElement->name() + "_unavailable");
-=======
-            uint64_t DftToGspnTransformator<ValueType>::addUnavailableNode(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dftElement) {
-                uint64_t unavailableNode = builder.addPlace(defaultCapacity, 1, dftElement->name() + "_unavailable");
->>>>>>> updated dft->gspn translation to now have basis support for spares
                 assert(unavailableNode != 0);
                 unavailableNodes.emplace(dftElement->id(), unavailableNode);
                 return unavailableNode;
             }
 //			
-<<<<<<< fcc5d69a44cb202290c4db3c5b2062ff35da5791
-
-=======
-			template <typename ValueType>
-            void DftToGspnTransformator<ValueType>::drawGSPNConnections() {
-//				// Check for every element, if they have parents (all will have at least 1, except the top event). 
-//				for (std::size_t i = 0; i < mDft.nrElements(); i++) {
-//					auto child = mDft.getElement(i);
-//					auto parents = child->parentIds();
-//					
-//					// Draw a connection to every parent.
-//					for (std::size_t j = 0; j < parents.size(); j++) {	
-//						// Check the type of the parent and act accordingly (every parent gate has different entry points...).
-//						switch (mDft.getElement(parents[j])->type()) {
-//							case storm::storage::DFTElementType::AND:
-//							{
-//								auto andEntry = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + STR_FAILING);
-//								auto childExit = mGspn.getPlace(child->name() + STR_FAILED);
-//								if (andEntry.first && childExit.first) { // Only add arcs if the objects have been found.
-//									andEntry.second->setInputArcMultiplicity(childExit.second, 1);
-//									andEntry.second->setOutputArcMultiplicity(childExit.second, 1);
-//								}
-//								break;
-//							}
-//							case storm::storage::DFTElementType::OR:
-//							{
-//								auto orEntry = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + "_" + child->name() + STR_FAILING);
-//								auto childExit = mGspn.getPlace(child->name() + STR_FAILED);
-//								if (orEntry.first && childExit.first) { // Only add arcs if the objects have been found.
-//									orEntry.second->setInputArcMultiplicity(childExit.second, 1);
-//									orEntry.second->setOutputArcMultiplicity(childExit.second, 1);
-//								}
-//								break;
-//							}
-//							case storm::storage::DFTElementType::VOT:
-//							{
-//								auto childExit = mGspn.getPlace(child->name() + STR_FAILED);
-//								auto parentEntry = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + "_" + child->name() + "_collecting");
-//								
-//								if (childExit.first && parentEntry.first) { // Only add arcs if the objects have been found.
-//									parentEntry.second->setInputArcMultiplicity(childExit.second, 1);
-//									parentEntry.second->setOutputArcMultiplicity(childExit.second, 1);
-//								}
-//								
-//								break;
-//							}
-//							case storm::storage::DFTElementType::PAND:
-//							{
-//								auto children =  std::static_pointer_cast<storm::storage::DFTPand<ValueType> const>(mDft.getElement(parents[j]))->children();
-//								auto childExit = mGspn.getPlace(child->name() + STR_FAILED);
-//								auto pandEntry = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + STR_FAILING);
-//								
-//								if (childExit.first && pandEntry.first) { // Only add arcs if the objects have been found.
-//									pandEntry.second->setInputArcMultiplicity(childExit.second, 1);
-//									pandEntry.second->setOutputArcMultiplicity(childExit.second, 1);
-//									
-//									if (children[0] == child) { // Current element is primary child.
-//										auto pandEntry2 = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + "_0" + STR_FAILSAVING);
-//										
-//										if (pandEntry2.first) {
-//											pandEntry2.second->setInhibitionArcMultiplicity(childExit.second, 1);
-//										}
-//									}
-//									else { // Current element is not the primary child.
-//										for (std::size_t k = 1; k < children.size(); k++) {
-//											if (children[k] == child) {
-//												auto pandEntry2 = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + "_" + std::to_string((k - 1)) + STR_FAILSAVING);
-//												auto pandEntry3 = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + "_" + std::to_string((k)) + STR_FAILSAVING);
-//												
-//												if (pandEntry2.first) {
-//													pandEntry2.second->setInputArcMultiplicity(childExit.second, 1);
-//													pandEntry2.second->setOutputArcMultiplicity(childExit.second, 1);
-//												}
-//												
-//												if (pandEntry3.first) {
-//													pandEntry3.second->setInhibitionArcMultiplicity(childExit.second, 1);
-//												}
-//												
-//												continue;
-//											}
-//										}
-//									}
-//								}
-//								
-//								break;
-//							}
-//							case storm::storage::DFTElementType::SPARE:
-//							{
-//								// Check if current child is a primary or spare child.
-//								auto children =  std::static_pointer_cast<storm::storage::DFTSpare<ValueType> const>(mDft.getElement(parents[j]))->children();
-//								
-//								if (child == children[0]) { // Primary child.
-//									auto spareExit = mGspn.getImmediateTransition(child->name() + STR_ACTIVATING);
-//									
-//									std::vector<int> ids = getAllBEIDsOfElement(child);
-//									for (std::size_t k = 0; k < ids.size(); k++) {
-//										auto childEntry = mGspn.getPlace(mDft.getElement(ids[k])->name() + STR_ACTIVATED);
-//										
-//										if (spareExit.first && childEntry.first) { // Only add arcs if the objects have been found.
-//											spareExit.second->setInhibitionArcMultiplicity(childEntry.second, 1);
-//											spareExit.second->setOutputArcMultiplicity(childEntry.second, 1);
-//										}
-//									}
-//									
-//									// Draw lines from "primary child_failed" to SPARE.
-//									auto childExit = mGspn.getPlace(child->name() + STR_FAILED);
-//									auto spareEntry = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + "_claiming_" + children[1]->name());
-//									auto spareEntry2 = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + "_" + children[1]->name() + "_consuming1");
-//									
-//									if (childExit.first && spareEntry.first && spareEntry2.first) { // Only add arcs if the objects have been found.
-//										spareEntry.second->setInputArcMultiplicity(childExit.second, 1);
-//										spareEntry.second->setOutputArcMultiplicity(childExit.second, 1);
-//										
-//										spareEntry2.second->setInputArcMultiplicity(childExit.second, 1);
-//										spareEntry2.second->setOutputArcMultiplicity(childExit.second, 1);
-//									}
-//								}
-//								else { // A spare child.
-//									auto spareExit = mGspn.getImmediateTransition(child->name() + STR_ACTIVATING);
-//									auto spareExit2 = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + "_claiming_" + child->name());
-//									
-//									std::vector<int> ids = getAllBEIDsOfElement(child);
-//									for (std::size_t k = 0; k < ids.size(); k++) {
-//										auto childEntry = mGspn.getPlace(mDft.getElement(ids[k])->name() + STR_ACTIVATED);
-//										
-//										if (spareExit.first && spareExit2.first && childEntry.first) { // Only add arcs if the objects have been found.
-//											if (!spareExit.second->existsInhibitionArc(childEntry.second)) {
-//												spareExit.second->setInhibitionArcMultiplicity(childEntry.second, 1);
-//											}
-//											if (!spareExit.second->existsOutputArc(childEntry.second)) {
-//												spareExit.second->setOutputArcMultiplicity(childEntry.second, 1);
-//											}
-//											if (!spareExit2.second->existsInhibitionArc(childEntry.second)) {
-//												spareExit2.second->setInhibitionArcMultiplicity(childEntry.second, 1);
-//											}
-//										}
-//									}
-//									
-//									auto childExit = mGspn.getPlace(child->name() + STR_FAILED);
-//									auto spareEntry = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + "_claiming_" + child->name());
-//									auto spareEntry2 = mGspn.getImmediateTransition(child->name() + STR_ACTIVATING);
-//									auto spareEntry3 = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + "_" + child->name() + "_consuming2");
-//									
-//									if (childExit.first && spareEntry.first && spareEntry2.first && spareEntry3.first) { // Only add arcs if the objects have been found.
-//										spareEntry.second->setInhibitionArcMultiplicity(childExit.second, 1);
-//										
-//										if (!spareEntry2.second->existsInhibitionArc(childExit.second)) {
-//											spareEntry2.second->setInhibitionArcMultiplicity(childExit.second, 1);
-//										}
-//										
-//										spareEntry3.second->setInputArcMultiplicity(childExit.second, 1);
-//										spareEntry3.second->setOutputArcMultiplicity(childExit.second, 1);
-//									}
-//								}
-//								
-//								break;
-//							}
-//							case storm::storage::DFTElementType::POR:
-//							{
-//								auto children =  std::static_pointer_cast<storm::storage::DFTPand<ValueType> const>(mDft.getElement(parents[j]))->children();
-//								auto porEntry = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + STR_FAILING);
-//								auto porEntry2 = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + STR_FAILSAVING);
-//								auto childExit = mGspn.getPlace(child->name() + STR_FAILED);
-//								
-//								if (porEntry.first && porEntry2.first && childExit.first) { // Only add arcs if the objects have been found.
-//									if (children[0] == child) { // Current element is primary child.
-//										porEntry.second->setInputArcMultiplicity(childExit.second, 1);
-//										porEntry.second->setOutputArcMultiplicity(childExit.second, 1);
-//										porEntry2.second->setInhibitionArcMultiplicity(childExit.second, 1);
-//										
-//									}
-//									else { // Current element is not the primary child.
-//										porEntry2.second->setInputArcMultiplicity(childExit.second, 1);
-//										porEntry2.second->setOutputArcMultiplicity(childExit.second, 1);
-//									}
-//								}
-//								
-//								break;
-//							}
-//							case storm::storage::DFTElementType::SEQ:
-//							{
-//								// Sequences are realized with restrictions. Nothing to do here.
-//								break;
-//							}
-//							case storm::storage::DFTElementType::MUTEX:
-//							{
-//								// MUTEX are realized with restrictions. Nothing to do here.
-//								break;
-//							}
-//							case storm::storage::DFTElementType::BE:
-//							{
-//								// The parent is never a Basic Event.
-//								break;
-//							}
-//							case storm::storage::DFTElementType::CONSTF:
-//							{
-//								// The parent is never a Basic Event.
-//								break;
-//							}
-//							case storm::storage::DFTElementType::CONSTS:
-//							{
-//								// The parent is never a Basic Event.
-//								break;
-//							}
-//							case storm::storage::DFTElementType::PDEP:
-//							{
-//								// The parent is never a DEP. Hence the connections must be drawn somewhere else.
-//								break;
-//							}
-//							default:
-//							{
-//								STORM_LOG_ASSERT(false, "DFT type unknown.");
-//								break;
-//							}
-//						}
-//					}
-//				}
-			}
->>>>>>> updated dft->gspn translation to now have basis support for spares
 			
 			template <typename ValueType>
             bool DftToGspnTransformator<ValueType>::isBEActive(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dftElement)
@@ -744,38 +397,7 @@ namespace storm {
 			{
                 return mDft.maxRank() - dftElement->rank();
 			}
-<<<<<<< fcc5d69a44cb202290c4db3c5b2062ff35da5791
 
-=======
-			
-			template <typename ValueType>
-            void DftToGspnTransformator<ValueType>::drawGSPNDependencies() {
-//				for (std::size_t i = 0; i < mDft.nrElements(); i++) {
-//					auto dftElement = mDft.getElement(i);
-//					
-//					if (dftElement->isDependency()) {
-//						std::string gateName = dftElement->name().substr(0, dftElement->name().find("_"));
-//						auto depEntry = mGspn.getTimedTransition(gateName + STR_FAILING);
-//						auto trigger = mGspn.getPlace(std::static_pointer_cast<storm::storage::DFTDependency<ValueType> const>(dftElement)->nameTrigger() + STR_FAILED);
-//						
-//						if (depEntry.first && trigger.first) { // Only add arcs if the objects have been found.
-//							if (!depEntry.second->existsInputArc(trigger.second)) {
-//								depEntry.second->setInputArcMultiplicity(trigger.second, 1);
-//							}
-//							if (!depEntry.second->existsOutputArc(trigger.second)){
-//								depEntry.second->setOutputArcMultiplicity(trigger.second, 1);
-//							}
-//						}
-//						
-//						auto dependent = mGspn.getPlace(std::static_pointer_cast<storm::storage::DFTDependency<ValueType> const>(dftElement)->nameDependent() + STR_FAILED);
-//						
-//						if (dependent.first) { // Only add arcs if the objects have been found.
-//							depEntry.second->setOutputArcMultiplicity(dependent.second, 1);
-//						}
-//					}
-//				}
-			}
->>>>>>> updated dft->gspn translation to now have basis support for spares
 			
 			template <typename ValueType>
             void DftToGspnTransformator<ValueType>::drawGSPNRestrictions() {
@@ -833,100 +455,7 @@ namespace storm {
 //					}
 //				}
 			}
-<<<<<<< fcc5d69a44cb202290c4db3c5b2062ff35da5791
 
-=======
-			
-			template <typename ValueType>
-            std::vector<int> DftToGspnTransformator<ValueType>::getAllBEIDsOfElement(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dftElement) {
-//				std::vector<int> ids;
-//				
-//				switch (dftElement->type()) {
-//					case storm::storage::DFTElementType::AND:
-//					{
-//						auto children = std::static_pointer_cast<storm::storage::DFTAnd<ValueType> const>(dftElement)->children();
-//						
-//						for (std::size_t i = 0; i < children.size(); i++) {
-//							std::vector<int> newIds = getAllBEIDsOfElement(children[i]);
-//							ids.insert(ids.end(), newIds.begin(), newIds.end());
-//						}
-//						break;
-//					}
-//					case storm::storage::DFTElementType::OR:
-//					{
-//						auto children = std::static_pointer_cast<storm::storage::DFTOr<ValueType> const>(dftElement)->children();
-//						
-//						for (std::size_t i = 0; i < children.size(); i++) {
-//							std::vector<int> newIds = getAllBEIDsOfElement(children[i]);
-//							ids.insert(ids.end(), newIds.begin(), newIds.end());
-//						}
-//						break;
-//					}
-//					case storm::storage::DFTElementType::VOT:
-//					{
-//						auto children = std::static_pointer_cast<storm::storage::DFTVot<ValueType> const>(dftElement)->children();
-//						
-//						for (std::size_t i = 0; i < children.size(); i++) {
-//							std::vector<int> newIds = getAllBEIDsOfElement(children[i]);
-//							ids.insert(ids.end(), newIds.begin(), newIds.end());
-//						}
-//						break;
-//					}
-//					case storm::storage::DFTElementType::PAND:
-//					{
-//						auto children = std::static_pointer_cast<storm::storage::DFTPand<ValueType> const>(dftElement)->children();
-//						
-//						for (std::size_t i = 0; i < children.size(); i++) {
-//							std::vector<int> newIds = getAllBEIDsOfElement(children[i]);
-//							ids.insert(ids.end(), newIds.begin(), newIds.end());
-//						}
-//						break;
-//					}
-//					case storm::storage::DFTElementType::SPARE:
-//					{								
-//						auto children = std::static_pointer_cast<storm::storage::DFTSpare<ValueType> const>(dftElement)->children();
-//						
-//						// Only regard the primary child of a SPARE. The spare childs are not allowed to be listed here.
-//						for (std::size_t i = 0; i < 1; i++) {
-//							std::vector<int> newIds = getAllBEIDsOfElement(children[i]);
-//							ids.insert(ids.end(), newIds.begin(), newIds.end());
-//						}
-//						break;
-//					}
-//					case storm::storage::DFTElementType::POR:
-//					{
-//						auto children = std::static_pointer_cast<storm::storage::DFTPor<ValueType> const>(dftElement)->children();
-//						
-//						for (std::size_t i = 0; i < children.size(); i++) {
-//							std::vector<int> newIds = getAllBEIDsOfElement(children[i]);
-//							ids.insert(ids.end(), newIds.begin(), newIds.end());
-//						}
-//						break;
-//					}
-//					case storm::storage::DFTElementType::BE:
-//					case storm::storage::DFTElementType::CONSTF:
-//					case storm::storage::DFTElementType::CONSTS:
-//					{
-//						ids.push_back(dftElement->id());
-//						break;
-//					}
-//					case storm::storage::DFTElementType::SEQ:
-//					case storm::storage::DFTElementType::MUTEX:
-//					case storm::storage::DFTElementType::PDEP:
-//					{
-//						break;
-//					}
-//					default:
-//					{
-//						STORM_LOG_ASSERT(false, "DFT type unknown.");
-//						break;
-//					}
-//				}
-//				
-//				return ids;
-			}
-			
->>>>>>> updated dft->gspn translation to now have basis support for spares
 			template <typename ValueType>
             void DftToGspnTransformator<ValueType>::writeGspn(bool toFile) {
                 if (toFile) {

From b9e46cf8c1cda810e488f2b1136d8ea7ef7024bb Mon Sep 17 00:00:00 2001
From: Sebastian Junges <sebastian.junges@rwth-aachen.de>
Date: Mon, 12 Dec 2016 15:47:56 +0100
Subject: [PATCH 08/47] gspn transformation related changes

---
 src/storm-dft-cli/storm-dyftee.cpp            |  7 ++++---
 .../DftToGspnTransformator.cpp                | 20 ++-----------------
 .../transformations/DftToGspnTransformator.h  | 12 +++++------
 src/storm-gspn/storage/gspn/GspnBuilder.cpp   |  2 +-
 4 files changed, 12 insertions(+), 29 deletions(-)

diff --git a/src/storm-dft-cli/storm-dyftee.cpp b/src/storm-dft-cli/storm-dyftee.cpp
index 3056cbdf1..b785be6c3 100644
--- a/src/storm-dft-cli/storm-dyftee.cpp
+++ b/src/storm-dft-cli/storm-dyftee.cpp
@@ -77,11 +77,12 @@ void analyzeWithSMT(std::string filename) {
  *
  */
 template <typename ValueType>
-storm::gspn::GSPN transformDFT(std::string filename) {
+storm::gspn::GSPN* transformDFT(std::string filename) {
     storm::parser::DFTGalileoParser<ValueType> parser;
     storm::storage::DFT<ValueType> dft = parser.parseDFT(filename);
     storm::transformations::dft::DftToGspnTransformator<ValueType> gspnTransformator(dft);
     gspnTransformator.transform();
+    return gspnTransformator.obtainGSPN();
 }
 
 /*!
@@ -138,9 +139,9 @@ int main(const int argc, const char** argv) {
         }
 
         if (dftSettings.isTransformToGspn()) {
-            // For now we only transform the DFT to a GSPN and then exit
-            transformDFT<double>(dftSettings.getDftFilename());
+            storm::gspn::GSPN* gspn = transformDFT<double>(dftSettings.getDftFilename());
             
+            delete gspn;
             storm::utility::cleanUp();
             return 0;
         }
diff --git a/src/storm-dft/transformations/DftToGspnTransformator.cpp b/src/storm-dft/transformations/DftToGspnTransformator.cpp
index 49f58707f..5649754cd 100644
--- a/src/storm-dft/transformations/DftToGspnTransformator.cpp
+++ b/src/storm-dft/transformations/DftToGspnTransformator.cpp
@@ -25,9 +25,6 @@ namespace storm {
 
 				// Draw restrictions into the GSPN (i.e. SEQ or MUTEX).
 				//drawGSPNRestrictions();
-
-				// Write GSPN to file.
-				writeGspn(true);
             }
             
 			template <typename ValueType>
@@ -457,21 +454,8 @@ namespace storm {
 			}
 
 			template <typename ValueType>
-            void DftToGspnTransformator<ValueType>::writeGspn(bool toFile) {
-                if (toFile) {
-                    // Writing to file
-                    std::ofstream file;
-                    file.open("gspn.dot");
-                    storm::gspn::GSPN* gspn = builder.buildGspn();
-                    gspn->writeDotToStream(file);
-                    delete gspn;
-                    file.close();
-                } else {
-                    // Writing to console
-                    storm::gspn::GSPN* gspn = builder.buildGspn();
-                    gspn->writeDotToStream(std::cout);
-                    delete gspn;
-                }
+            gspn::GSPN* DftToGspnTransformator<ValueType>::obtainGSPN() {
+                return builder.buildGspn();
             }
 			
             // Explicitly instantiate the class.
diff --git a/src/storm-dft/transformations/DftToGspnTransformator.h b/src/storm-dft/transformations/DftToGspnTransformator.h
index 4d827e44b..e2812f738 100644
--- a/src/storm-dft/transformations/DftToGspnTransformator.h
+++ b/src/storm-dft/transformations/DftToGspnTransformator.h
@@ -27,16 +27,14 @@ namespace storm {
                  */
                 void transform();
 
-            private:
                 /*!
-                 * Write Gspn to file or console.
+                 * Extract Gspn by building
                  *
-                 * @param toFile If true, the GSPN will be written to a file, otherwise it will
-                                 be written to the console.
                  */
-                void writeGspn(bool toFile);
-				
-				/*
+                gspn::GSPN* obtainGSPN();
+                
+            private:
+                /*
 				 * Draw all elements of the GSPN.
 				 */
 				void drawGSPNElements();
diff --git a/src/storm-gspn/storage/gspn/GspnBuilder.cpp b/src/storm-gspn/storage/gspn/GspnBuilder.cpp
index 9cb662eb7..fa81444c3 100644
--- a/src/storm-gspn/storage/gspn/GspnBuilder.cpp
+++ b/src/storm-gspn/storage/gspn/GspnBuilder.cpp
@@ -35,7 +35,7 @@ namespace storm {
             if(partitions.count(priority) == 0) {
                 TransitionPartition newPart;
                 newPart.priority = priority;
-                partitions.at(priority).push_back(newPart);
+                partitions[priority].push_back(newPart);
             }
             
             if(storm::utility::isZero(weight)) {

From 88e17d423a8cf8073357d817b7a0d0cd62a4a6ae Mon Sep 17 00:00:00 2001
From: Sebastian Junges <sebastian.junges@rwth-aachen.de>
Date: Wed, 14 Dec 2016 01:03:42 +0100
Subject: [PATCH 09/47] updated dft->gspn->jani workflow

---
 src/storm-dft-cli/storm-dyftee.cpp            |  11 ++
 src/storm-gspn/builder/JaniGSPNBuilder.h      | 163 ++++++++----------
 src/storm-gspn/storm-gspn.h                   |  32 ++++
 src/storm/cli/cli.cpp                         |  11 +-
 .../settings/modules/GSPNExportSettings.h     |   2 +-
 src/storm/storage/jani/OrderedAssignments.cpp |   9 +
 src/storm/storage/jani/OrderedAssignments.h   |   2 +
 src/storm/utility/storm.cpp                   |  11 ++
 src/storm/utility/storm.h                     |  10 +-
 9 files changed, 151 insertions(+), 100 deletions(-)
 create mode 100644 src/storm-gspn/storm-gspn.h

diff --git a/src/storm-dft-cli/storm-dyftee.cpp b/src/storm-dft-cli/storm-dyftee.cpp
index b785be6c3..8ccdc12be 100644
--- a/src/storm-dft-cli/storm-dyftee.cpp
+++ b/src/storm-dft-cli/storm-dyftee.cpp
@@ -22,6 +22,7 @@
 #include "storm-dft/settings/modules/DFTSettings.h"
 
 #include "storm-gspn/storage/gspn/GSPN.h"
+#include "storm-gspn/storm-gspn.h"
 #include "storm/settings/modules/GSPNSettings.h"
 #include "storm/settings/modules/GSPNExportSettings.h"
 
@@ -112,6 +113,7 @@ void initializeSettings() {
     // For translation into JANI via GSPN.
     storm::settings::addModule<storm::settings::modules::GSPNSettings>();
     storm::settings::addModule<storm::settings::modules::GSPNExportSettings>();
+    storm::settings::addModule<storm::settings::modules::JaniExportSettings>();
 }
 
 /*!
@@ -140,7 +142,16 @@ int main(const int argc, const char** argv) {
 
         if (dftSettings.isTransformToGspn()) {
             storm::gspn::GSPN* gspn = transformDFT<double>(dftSettings.getDftFilename());
+            storm::handleGSPNExportSettings(*gspn);
             
+            storm::jani::Model* model = storm::buildJani(*gspn);
+            
+            storm::settings::modules::JaniExportSettings const& janiSettings = storm::settings::getModule<storm::settings::modules::JaniExportSettings>();
+            if (janiSettings.isJaniFileSet()) {
+                storm::exportJaniModel(*model, {}, janiSettings.getJaniFilename());
+            }
+            
+            delete model;
             delete gspn;
             storm::utility::cleanUp();
             return 0;
diff --git a/src/storm-gspn/builder/JaniGSPNBuilder.h b/src/storm-gspn/builder/JaniGSPNBuilder.h
index 76517a3a1..305fa0129 100644
--- a/src/storm-gspn/builder/JaniGSPNBuilder.h
+++ b/src/storm-gspn/builder/JaniGSPNBuilder.h
@@ -9,17 +9,15 @@ namespace storm {
         class JaniGSPNBuilder {
         public:
             JaniGSPNBuilder(storm::gspn::GSPN const& gspn, std::shared_ptr<storm::expressions::ExpressionManager> const& expManager) : gspn(gspn), expressionManager(expManager) {
-                gspn.writeDotToStream(std::cout);
+                
             }
             
             virtual ~JaniGSPNBuilder() {
-                for (auto const& varEntry : vars) {
-                    delete varEntry.second;
-                }
+                
             }
             
             void setIgnoreWeights(bool ignore = true)  {
-                ignoreWeights = ignore;
+                //ignoreWeights = ignore;
             }
             
             
@@ -46,8 +44,8 @@ namespace storm {
                     }
                     assert(janiVar != nullptr);
                     assert(vars.count(place.getID()) == 0);
-                    vars[place.getID()] = janiVar;
-                    model->addVariable(*janiVar);
+                    vars[place.getID()] = &model->addVariable(*janiVar);
+                    delete janiVar;
                 }
             }
             
@@ -59,95 +57,76 @@ namespace storm {
             
             void addEdges(storm::jani::Automaton& automaton, uint64_t locId) {
                 
-                storm::expressions::Expression guard = expressionManager->boolean(true);
-                for (auto const& trans : gspn.getImmediateTransitions()) {
-                    if (ignoreWeights || trans.noWeightAttached()) {
-                        std::vector<storm::jani::Assignment> assignments;
+                uint64_t lastPriority = -1;
+                storm::expressions::Expression lastPriorityGuard = expressionManager->boolean(false);
+                storm::expressions::Expression priorityGuard = expressionManager->boolean(true);
+                // TODO here there is something to fix if we add transition partitions.
+                
+                for (auto const& partition : gspn.getPartitions()) {
+                    storm::expressions::Expression guard = expressionManager->boolean(false);
+                    std::vector<storm::jani::EdgeDestination> weightedDestinations;
+                    
+                    assert(lastPriority >= partition.priority);
+                    if (lastPriority > partition.priority) {
+                        priorityGuard = priorityGuard && !lastPriorityGuard;
+                        lastPriority = partition.priority;
+                    } else {
+                        assert(lastPriority == partition.priority);
+                    }
+                    
+                    // Compute enabled weight expression.
+                    storm::expressions::Expression totalWeight = expressionManager->rational(0.0);
+                    for (auto const& transId : partition.transitions) {
+                        auto const& trans = gspn.getImmediateTransitions()[transId];
+                        if (trans.noWeightAttached()) {
+                            continue;
+                        }
+                        storm::expressions::Expression destguard = expressionManager->boolean(true);
                         for (auto const& inPlaceEntry : trans.getInputPlaces()) {
-                            guard = guard && (vars[inPlaceEntry.first]->getExpressionVariable() > inPlaceEntry.second);
-                            assignments.emplace_back( *vars[inPlaceEntry.first], (vars[inPlaceEntry.first])->getExpressionVariable() - inPlaceEntry.second);
+                            destguard = destguard && (vars[inPlaceEntry.first]->getExpressionVariable() >= inPlaceEntry.second);
                         }
                         for (auto const& inhibPlaceEntry : trans.getInhibitionPlaces()) {
-                            guard = guard && (vars[inhibPlaceEntry.first]->getExpressionVariable() > inhibPlaceEntry.second);
+                            destguard = destguard && (vars[inhibPlaceEntry.first]->getExpressionVariable() >= inhibPlaceEntry.second);
                         }
-                        for (auto const& outputPlaceEntry : trans.getOutputPlaces()) {
-                            assignments.emplace_back( *vars[outputPlaceEntry.first], (vars[outputPlaceEntry.first])->getExpressionVariable() + outputPlaceEntry.second );
-                        }
-                        storm::jani::OrderedAssignments oa(assignments);
-                        storm::jani::EdgeDestination dest(locId, expressionManager->integer(1), oa);
-                        storm::jani::Edge e(locId, storm::jani::Model::SILENT_ACTION_INDEX, boost::none, guard, {dest});
-                        automaton.addEdge(e);
+                        totalWeight = totalWeight + storm::expressions::ite(destguard, expressionManager->rational(trans.getWeight()), expressionManager->rational(0.0));
+                        
                     }
+                    totalWeight = totalWeight.simplify();
                     
-                }
-                if(!ignoreWeights) {
-                    uint64_t lastPriority;
-                    storm::expressions::Expression lastPriorityGuard = expressionManager->boolean(false);
-                    storm::expressions::Expression priorityGuard = expressionManager->boolean(true);
-                    // TODO here there is something to fix if we add transition partitions.
                     
-                    for (auto const& partition : gspn.getPartitions()) {
-                        storm::expressions::Expression guard = expressionManager->boolean(false);
-                        std::vector<storm::jani::EdgeDestination> weightedDestinations;
-                        
-                        
-                        assert(lastPriority <= partition.priority);
-                        if (lastPriority < partition.priority) {
-                            priorityGuard = priorityGuard && !lastPriorityGuard;
-                            lastPriority = partition.priority;
-                        } else {
-                            assert(lastPriority == partition.priority);
+                    for (auto const& transId : partition.transitions) {
+                        auto const& trans = gspn.getImmediateTransitions()[transId];
+                        if (trans.noWeightAttached()) {
+                            std::cout << "ERROR -- no weights attached at transition" << std::endl;
+                            continue;
                         }
-                        
-                        // Compute enabled weight expression.
-                        storm::expressions::Expression totalWeight = expressionManager->rational(0.0);
-                        for (auto const& transId : partition.transitions) {
-                            auto const& trans = gspn.getImmediateTransitions()[transId];
-                            if (trans.noWeightAttached()) {
-                                continue;
-                            }
-                            storm::expressions::Expression destguard = expressionManager->boolean(true);
-                            for (auto const& inPlaceEntry : trans.getInputPlaces()) {
-                                destguard = destguard && (vars[inPlaceEntry.first]->getExpressionVariable() > inPlaceEntry.second);
-                            }
-                            for (auto const& inhibPlaceEntry : trans.getInhibitionPlaces()) {
-                                destguard = destguard && (vars[inhibPlaceEntry.first]->getExpressionVariable() > inhibPlaceEntry.second);
+                        storm::expressions::Expression destguard = expressionManager->boolean(true);
+                        std::vector<storm::jani::Assignment> assignments;
+                        for (auto const& inPlaceEntry : trans.getInputPlaces()) {
+                            destguard = destguard && (vars[inPlaceEntry.first]->getExpressionVariable() > inPlaceEntry.second);
+                            if (trans.getOutputPlaces().count(inPlaceEntry.first) == 0) {
+                                assignments.emplace_back( *vars[inPlaceEntry.first], (vars[inPlaceEntry.first])->getExpressionVariable() - inPlaceEntry.second);
                             }
-                            totalWeight = totalWeight + storm::expressions::ite(destguard, expressionManager->rational(trans.getWeight()), expressionManager->rational(0.0));
-                            
                         }
-                        totalWeight = totalWeight.simplify();
-                        
-                        
-                        for (auto const& transId : partition.transitions) {
-                            auto const& trans = gspn.getImmediateTransitions()[transId];
-                            if (trans.noWeightAttached()) {
-                                continue;
-                            }
-                            storm::expressions::Expression destguard = expressionManager->boolean(true);
-                            std::vector<storm::jani::Assignment> assignments;
-                            for (auto const& inPlaceEntry : trans.getInputPlaces()) {
-                                destguard = destguard && (vars[inPlaceEntry.first]->getExpressionVariable() > inPlaceEntry.second);
-                                assignments.emplace_back( *vars[inPlaceEntry.first], (vars[inPlaceEntry.first]->getExpressionVariable() - inPlaceEntry.second) );
-                            }
-                            for (auto const& inhibPlaceEntry : trans.getInhibitionPlaces()) {
-                                destguard = destguard && (vars[inhibPlaceEntry.first]->getExpressionVariable() > inhibPlaceEntry.second);
-                            }
-                            for (auto const& outputPlaceEntry : trans.getOutputPlaces()) {
-                                assignments.emplace_back( *vars[outputPlaceEntry.first], (vars[outputPlaceEntry.first]->getExpressionVariable() + outputPlaceEntry.second) );
+                        for (auto const& inhibPlaceEntry : trans.getInhibitionPlaces()) {
+                            destguard = destguard && (vars[inhibPlaceEntry.first]->getExpressionVariable() > inhibPlaceEntry.second);
+                        }
+                        for (auto const& outputPlaceEntry : trans.getOutputPlaces()) {
+                            if (trans.getInputPlaces().count(outputPlaceEntry.first) == 0) {
+                                assignments.emplace_back( *vars[outputPlaceEntry.first], (vars[outputPlaceEntry.first])->getExpressionVariable() + outputPlaceEntry.second );
+                            } else {
+                                assignments.emplace_back( *vars[outputPlaceEntry.first], (vars[outputPlaceEntry.first])->getExpressionVariable() + outputPlaceEntry.second -  trans.getInputPlaces().at(outputPlaceEntry.first));
                             }
-                            destguard = destguard.simplify();
-                            guard = guard || destguard;
-                            storm::jani::OrderedAssignments oa(assignments);
-                            storm::jani::EdgeDestination dest(locId, storm::expressions::ite(destguard, (expressionManager->rational(trans.getWeight()) / totalWeight), expressionManager->rational(0.0)), oa);
-                            weightedDestinations.push_back(dest);
                         }
-                        storm::jani::Edge e(locId, storm::jani::Model::SILENT_ACTION_INDEX, boost::none, (priorityGuard && guard).simplify(), weightedDestinations);
-                        automaton.addEdge(e);
-                        lastPriorityGuard = lastPriorityGuard || guard;
+                        destguard = destguard.simplify();
+                        guard = guard || destguard;
+                        storm::jani::OrderedAssignments oa(assignments);
+                        storm::jani::EdgeDestination dest(locId, storm::expressions::ite(destguard, (expressionManager->rational(trans.getWeight()) / totalWeight), expressionManager->rational(0.0)), oa);
+                        weightedDestinations.push_back(dest);
                     }
-                    
-                    
+                    storm::jani::Edge e(locId, storm::jani::Model::SILENT_ACTION_INDEX, boost::none, (priorityGuard && guard).simplify(), weightedDestinations);
+                    automaton.addEdge(e);
+                    lastPriorityGuard = lastPriorityGuard || guard;
                     
                 }
                 for (auto const& trans : gspn.getTimedTransitions()) {
@@ -155,27 +134,33 @@ namespace storm {
                     
                     std::vector<storm::jani::Assignment> assignments;
                     for (auto const& inPlaceEntry : trans.getInputPlaces()) {
-                        guard = guard && (vars[inPlaceEntry.first]->getExpressionVariable() > inPlaceEntry.second);
-                        assignments.emplace_back( *vars[inPlaceEntry.first], (vars[inPlaceEntry.first]->getExpressionVariable() - inPlaceEntry.second) );
+                        guard = guard && (vars[inPlaceEntry.first]->getExpressionVariable() >= inPlaceEntry.second);
+                        if (trans.getOutputPlaces().count(inPlaceEntry.first) == 0) {
+                            assignments.emplace_back( *vars[inPlaceEntry.first], (vars[inPlaceEntry.first])->getExpressionVariable() - inPlaceEntry.second);
+                        }
                     }
                     for (auto const& inhibPlaceEntry : trans.getInhibitionPlaces()) {
-                        guard = guard && (vars[inhibPlaceEntry.first]->getExpressionVariable() > inhibPlaceEntry.second);
+                        guard = guard && (vars[inhibPlaceEntry.first]->getExpressionVariable() >= inhibPlaceEntry.second);
                     }
                     for (auto const& outputPlaceEntry : trans.getOutputPlaces()) {
-                        assignments.emplace_back( *vars[outputPlaceEntry.first], (vars[outputPlaceEntry.first]->getExpressionVariable() + outputPlaceEntry.second) );
+                        if (trans.getInputPlaces().count(outputPlaceEntry.first) == 0) {
+                            assignments.emplace_back( *vars[outputPlaceEntry.first], (vars[outputPlaceEntry.first])->getExpressionVariable() + outputPlaceEntry.second );
+                        } else {
+                            assignments.emplace_back( *vars[outputPlaceEntry.first], (vars[outputPlaceEntry.first])->getExpressionVariable() + outputPlaceEntry.second -  trans.getInputPlaces().at(outputPlaceEntry.first));
+                        }
                     }
                     storm::jani::OrderedAssignments oa(assignments);
                     storm::jani::EdgeDestination dest(locId, expressionManager->integer(1), oa);
                     storm::jani::Edge e(locId, storm::jani::Model::SILENT_ACTION_INDEX, expressionManager->rational(trans.getRate()), guard, {dest});
                     automaton.addEdge(e);
+                    
                 }
             }
             
         private:
-            bool ignoreWeights;
             const uint64_t janiVersion = 1;
             storm::gspn::GSPN const& gspn;
-            std::map<uint64_t, storm::jani::Variable*> vars;
+            std::map<uint64_t, storm::jani::Variable const*> vars;
             std::shared_ptr<storm::expressions::ExpressionManager> expressionManager;
             
         };
diff --git a/src/storm-gspn/storm-gspn.h b/src/storm-gspn/storm-gspn.h
new file mode 100644
index 000000000..3af59a9c1
--- /dev/null
+++ b/src/storm-gspn/storm-gspn.h
@@ -0,0 +1,32 @@
+#pragma once
+
+#include "storm/storage/jani/Model.h"
+
+#include "storm-gspn/builder/JaniGSPNBuilder.h"
+#include "storm-gspn/storage/gspn/Gspn.h"
+
+#include "storm/settings/modules/GSPNExportSettings.h"
+
+namespace storm {
+    /**
+     *    Builds JANI model from GSPN.
+     */
+    storm::jani::Model* buildJani(storm::gspn::GSPN const& gspn) {
+        std::shared_ptr<storm::expressions::ExpressionManager> exprManager(new storm::expressions::ExpressionManager());
+        storm::builder::JaniGSPNBuilder builder(gspn, exprManager);
+        return builder.build();
+    }
+    
+    void handleGSPNExportSettings(storm::gspn::GSPN const& gspn) {
+        storm::settings::modules::GSPNExportSettings const& exportSettings = storm::settings::getModule<storm::settings::modules::GSPNExportSettings>();
+        if (exportSettings.isWriteToDotSet()) {
+            std::ofstream fs;
+            fs.open(exportSettings.getWriteToDotFilename());
+            gspn.writeDotToStream(std::cout);
+            gspn.writeDotToStream(fs);
+            fs.close();
+        }
+        
+    }
+    
+}
\ No newline at end of file
diff --git a/src/storm/cli/cli.cpp b/src/storm/cli/cli.cpp
index 7ba6cc09e..cfa8c66d1 100644
--- a/src/storm/cli/cli.cpp
+++ b/src/storm/cli/cli.cpp
@@ -12,7 +12,7 @@
 #include "storm/settings/modules/JaniExportSettings.h"
 
 #include "storm/utility/storm-version.h"
-#include "storm/storage/jani/JSONExporter.h"
+
 
 
 // Includes for the linked libraries and versions header.
@@ -253,14 +253,7 @@ namespace storm {
                 }
                 
                 if (model.isJaniModel() && storm::settings::getModule<storm::settings::modules::JaniExportSettings>().isJaniFileSet()) {
-                    STORM_LOG_TRACE("Exporting JANI model.");
-                    if (storm::settings::getModule<storm::settings::modules::JaniExportSettings>().isExportAsStandardJaniSet()) {
-                        storm::jani::Model normalisedModel = storm::jani::Model(model.asJaniModel());
-                        normalisedModel.makeStandardJaniCompliant();
-                        storm::jani::JsonExporter::toFile(normalisedModel, formulasInProperties(properties), storm::settings::getModule<storm::settings::modules::JaniExportSettings>().getJaniFilename());
-                    } else {
-                        storm::jani::JsonExporter::toFile(model.asJaniModel(), formulasInProperties(properties), storm::settings::getModule<storm::settings::modules::JaniExportSettings>().getJaniFilename());
-                    }
+                    exportJaniModel(model.asJaniModel(), properties, storm::settings::getModule<storm::settings::modules::JaniExportSettings>().getJaniFilename());
                 }
                 
                 if (ioSettings.isNoBuildModelSet()) {
diff --git a/src/storm/settings/modules/GSPNExportSettings.h b/src/storm/settings/modules/GSPNExportSettings.h
index 3db836cf7..32ae422ba 100644
--- a/src/storm/settings/modules/GSPNExportSettings.h
+++ b/src/storm/settings/modules/GSPNExportSettings.h
@@ -15,7 +15,7 @@ namespace storm {
                 GSPNExportSettings();
                 
                 /**
-                 * Retrievew whether the pgcl file option was set
+                 * Retrieve whether the pgcl file option was set
                  */
                 bool isWriteToDotSet() const;
                 
diff --git a/src/storm/storage/jani/OrderedAssignments.cpp b/src/storm/storage/jani/OrderedAssignments.cpp
index 667952719..18f0aebae 100644
--- a/src/storm/storage/jani/OrderedAssignments.cpp
+++ b/src/storm/storage/jani/OrderedAssignments.cpp
@@ -141,5 +141,14 @@ namespace storm {
             return std::lower_bound(assignments.begin(), assignments.end(), assignment, storm::jani::AssignmentPartialOrderByLevelAndVariable());
         }
         
+        std::ostream& operator<<(std::ostream& stream, OrderedAssignments const& assignments) {
+            stream << "[";
+            for(auto const& e : assignments.allAssignments) {
+                stream << *e << std::endl;
+            }
+            stream << "]";
+            return stream;
+        }
+        
     }
 }
diff --git a/src/storm/storage/jani/OrderedAssignments.h b/src/storm/storage/jani/OrderedAssignments.h
index 789b1014a..999b9d95f 100644
--- a/src/storm/storage/jani/OrderedAssignments.h
+++ b/src/storm/storage/jani/OrderedAssignments.h
@@ -109,6 +109,8 @@ namespace storm {
              */
             void substitute(std::map<storm::expressions::Variable, storm::expressions::Expression> const& substitution);
 
+            friend std::ostream& operator<<(std::ostream& stream, OrderedAssignments const& assignments);
+            
         private:
             static std::vector<std::shared_ptr<Assignment>>::const_iterator lowerBound(Assignment const& assignment, std::vector<std::shared_ptr<Assignment>> const& assignments);
                         
diff --git a/src/storm/utility/storm.cpp b/src/storm/utility/storm.cpp
index 40ab41b91..62c499fbd 100644
--- a/src/storm/utility/storm.cpp
+++ b/src/storm/utility/storm.cpp
@@ -30,6 +30,17 @@ namespace storm{
         modelAndFormulae.first.checkValid();
         return modelAndFormulae;
     }
+    
+    void exportJaniModel(storm::jani::Model const& model, std::vector<storm::jani::Property> const& properties, std::string const& filepath) {
+        STORM_LOG_TRACE("Exporting JANI model.");
+        if (storm::settings::getModule<storm::settings::modules::JaniExportSettings>().isExportAsStandardJaniSet()) {
+            storm::jani::Model normalisedModel = model;
+            normalisedModel.makeStandardJaniCompliant();
+            storm::jani::JsonExporter::toFile(normalisedModel, formulasInProperties(properties), filepath);
+        } else {
+            storm::jani::JsonExporter::toFile(model, formulasInProperties(properties), filepath);
+        }
+    }
 
     /**
      * Helper
diff --git a/src/storm/utility/storm.h b/src/storm/utility/storm.h
index cee49998b..6657a7d6d 100644
--- a/src/storm/utility/storm.h
+++ b/src/storm/utility/storm.h
@@ -23,6 +23,7 @@
 #include "storm/settings/modules/RegionSettings.h"
 #include "storm/settings/modules/EliminationSettings.h"
 #include "storm/settings/modules/JitBuilderSettings.h"
+#include "storm/settings/modules/JaniExportSettings.h"
 
 // Formula headers.
 #include "storm/logic/Formulas.h"
@@ -55,6 +56,7 @@
 #include "storm/storage/bisimulation/NondeterministicModelBisimulationDecomposition.h"
 #include "storm/storage/ModelFormulasPair.h"
 #include "storm/storage/SymbolicModelDescription.h"
+#include "storm/storage/jani/JSONExporter.h"
 
 // Headers for model checking.
 #include "storm/modelchecker/prctl/SparseDtmcPrctlModelChecker.h"
@@ -575,7 +577,13 @@ namespace storm {
         }
         return result;
     }
-
+    
+    
+    /**
+     *
+     */
+    void exportJaniModel(storm::jani::Model const& model, std::vector<storm::jani::Property> const& properties, std::string const& filepath);
+    
     template<typename ValueType>
     void exportMatrixToFile(std::shared_ptr<storm::models::sparse::Model<ValueType>> model, std::string const& filepath) {
         STORM_LOG_THROW(model->getType() != storm::models::ModelType::Ctmc, storm::exceptions::NotImplementedException, "This functionality is not yet implemented." );

From 18383f5220dfb77bd615fd0cd6b3d2133ab9c1bc Mon Sep 17 00:00:00 2001
From: Sebastian Junges <sebastian.junges@rwth-aachen.de>
Date: Wed, 14 Dec 2016 15:46:13 +0100
Subject: [PATCH 10/47] several fixes in dft->gspn->jani code path: Most
 notably, mas are closed, successor nodes failed places keep intact and tb
 property is added

---
 src/storm-dft-cli/storm-dyftee.cpp            | 36 ++++++++++---------
 .../DftToGspnTransformator.cpp                | 14 +++++++-
 .../transformations/DftToGspnTransformator.h  |  3 ++
 src/storm-gspn-cli/storm-gspn.cpp             |  4 +--
 src/storm-gspn/builder/JaniGSPNBuilder.h      | 16 ++++-----
 src/storm/utility/storm.h                     |  1 +
 6 files changed, 45 insertions(+), 29 deletions(-)

diff --git a/src/storm-dft-cli/storm-dyftee.cpp b/src/storm-dft-cli/storm-dyftee.cpp
index 8ccdc12be..6c54dc226 100644
--- a/src/storm-dft-cli/storm-dyftee.cpp
+++ b/src/storm-dft-cli/storm-dyftee.cpp
@@ -4,6 +4,7 @@
 #include "storm/cli/cli.h"
 #include "storm/exceptions/BaseException.h"
 
+#include "storm/logic/Formula.h"
 
 #include "storm/settings/modules/GeneralSettings.h"
 #include "storm/settings/modules/CoreSettings.h"
@@ -71,20 +72,6 @@ void analyzeWithSMT(std::string filename) {
     //std::cout << "SMT result: " << sat << std::endl;
 }
 
-/*!
- * Load DFT from filename and transform into a GSPN.
- *
- * @param filename Path to DFT file in Galileo format.
- *
- */
-template <typename ValueType>
-storm::gspn::GSPN* transformDFT(std::string filename) {
-    storm::parser::DFTGalileoParser<ValueType> parser;
-    storm::storage::DFT<ValueType> dft = parser.parseDFT(filename);
-    storm::transformations::dft::DftToGspnTransformator<ValueType> gspnTransformator(dft);
-    gspnTransformator.transform();
-    return gspnTransformator.obtainGSPN();
-}
 
 /*!
  * Initialize the settings manager.
@@ -140,15 +127,30 @@ int main(const int argc, const char** argv) {
             STORM_LOG_THROW(false, storm::exceptions::InvalidSettingsException, "No input model.");
         }
 
+        
         if (dftSettings.isTransformToGspn()) {
-            storm::gspn::GSPN* gspn = transformDFT<double>(dftSettings.getDftFilename());
+            
+            storm::parser::DFTGalileoParser<double> parser;
+            storm::storage::DFT<double> dft = parser.parseDFT(dftSettings.getDftFilename());
+            storm::transformations::dft::DftToGspnTransformator<double> gspnTransformator(dft);
+            gspnTransformator.transform();
+            storm::gspn::GSPN* gspn = gspnTransformator.obtainGSPN();
+            uint64_t toplevelFailedPlace = gspnTransformator.toplevelFailedPlaceId();
             storm::handleGSPNExportSettings(*gspn);
             
-            storm::jani::Model* model = storm::buildJani(*gspn);
+            std::shared_ptr<storm::expressions::ExpressionManager> exprManager(new storm::expressions::ExpressionManager());
+            storm::builder::JaniGSPNBuilder builder(*gspn, exprManager);
+            storm::jani::Model* model =  builder.build();
+            storm::jani::Variable const& topfailedVar = builder.getPlaceVariable(toplevelFailedPlace);
+            
+            
+            auto evtlFormula = std::make_shared<storm::logic::AtomicExpressionFormula>(exprManager->integer(1) == topfailedVar.getExpressionVariable().getExpression());
+            auto tbFormula = std::make_shared<storm::logic::BoundedUntilFormula>(std::make_shared<storm::logic::BooleanLiteralFormula>(true), evtlFormula, 0.0, 10.0);
+            auto tbUntil = std::make_shared<storm::logic::ProbabilityOperatorFormula>(tbFormula);
             
             storm::settings::modules::JaniExportSettings const& janiSettings = storm::settings::getModule<storm::settings::modules::JaniExportSettings>();
             if (janiSettings.isJaniFileSet()) {
-                storm::exportJaniModel(*model, {}, janiSettings.getJaniFilename());
+                storm::exportJaniModel(*model, {storm::jani::Property("time-bounded", tbUntil)}, janiSettings.getJaniFilename());
             }
             
             delete model;
diff --git a/src/storm-dft/transformations/DftToGspnTransformator.cpp b/src/storm-dft/transformations/DftToGspnTransformator.cpp
index 5649754cd..355c6f440 100644
--- a/src/storm-dft/transformations/DftToGspnTransformator.cpp
+++ b/src/storm-dft/transformations/DftToGspnTransformator.cpp
@@ -8,7 +8,7 @@ namespace storm {
             
             // Prevent some magic constants
             static constexpr const uint64_t defaultPriority = 0;
-            static constexpr const uint64_t defaultCapacity = 0;
+            static constexpr const uint64_t defaultCapacity = 1;
 
             template <typename ValueType>
             DftToGspnTransformator<ValueType>::DftToGspnTransformator(storm::storage::DFT<ValueType> const& dft) : mDft(dft) {
@@ -27,6 +27,12 @@ namespace storm {
 				//drawGSPNRestrictions();
             }
             
+            template<typename ValueType>
+            uint64_t DftToGspnTransformator<ValueType>::toplevelFailedPlaceId() {
+                assert(failedNodes.size() > mDft.getTopLevelIndex());
+                return failedNodes[mDft.getTopLevelIndex()];
+            }
+            
 			template <typename ValueType>
             void DftToGspnTransformator<ValueType>::drawGSPNElements() {
                 
@@ -133,6 +139,7 @@ namespace storm {
                 for(auto const& child : dftAnd->children()) {
                     assert(failedNodes.size() > child->id());
                     builder.addInputArc(failedNodes[child->id()], tAndFailed);
+                    builder.addOutputArc(tAndFailed, failedNodes[child->id()]);
                 }
                 
 			}
@@ -157,6 +164,7 @@ namespace storm {
                     }
                     assert(failedNodes.size() > child->id());
                     builder.addInputArc(failedNodes[child->id()], tNodeFailed);
+                    builder.addOutputArc(tNodeFailed, failedNodes[child->id()]);
                     ++i;
                 }
 			}
@@ -188,6 +196,7 @@ namespace storm {
                     builder.addOutputArc(tCollect, childInhibPlace);
                     builder.addInhibitionArc(childInhibPlace, tCollect);
                     builder.addInputArc(failedNodes[child->id()], tCollect);
+                    builder.addOutputArc(tCollect, failedNodes[child->id()]);
                     ++i;
                 }
 			}
@@ -212,12 +221,15 @@ namespace storm {
                 }
                 for(auto const& child : dftPand->children()) {
                     builder.addInputArc(failedNodes[child->id()], tNodeFailed);
+                    builder.addOutputArc(tNodeFailed, failedNodes[child->id()]);
                 }
                 for (uint64_t j = 1; j < dftPand->nrChildren(); ++j) {
                     uint64_t tfs = builder.addImmediateTransition(getFailPriority(dftPand), 0.0, dftPand->name() + STR_FAILSAVING + std::to_string(j));
                     builder.addInputArc(failedNodes[dftPand->children().at(j)->id()], tfs);
+                    builder.addOutputArc(tfs, failedNodes[dftPand->children().at(j)->id()]);
                     builder.addInhibitionArc(failedNodes[dftPand->children().at(j-1)->id()], tfs);
                     builder.addOutputArc(tfs, nodeFS);
+                    builder.addInhibitionArc(nodeFS, tfs);
 
                 }
             }
diff --git a/src/storm-dft/transformations/DftToGspnTransformator.h b/src/storm-dft/transformations/DftToGspnTransformator.h
index e2812f738..2d763452d 100644
--- a/src/storm-dft/transformations/DftToGspnTransformator.h
+++ b/src/storm-dft/transformations/DftToGspnTransformator.h
@@ -33,6 +33,9 @@ namespace storm {
                  */
                 gspn::GSPN* obtainGSPN();
                 
+                
+                uint64_t toplevelFailedPlaceId();
+                
             private:
                 /*
 				 * Draw all elements of the GSPN.
diff --git a/src/storm-gspn-cli/storm-gspn.cpp b/src/storm-gspn-cli/storm-gspn.cpp
index b973d046d..17b45222d 100644
--- a/src/storm-gspn-cli/storm-gspn.cpp
+++ b/src/storm-gspn-cli/storm-gspn.cpp
@@ -66,9 +66,7 @@ std::unordered_map<std::string, uint64_t> parseCapacitiesList(std::string const&
 }
 
 void handleJani(storm::gspn::GSPN const& gspn) {
-    std::shared_ptr<storm::expressions::ExpressionManager> exprManager(new storm::expressions::ExpressionManager());
-    storm::builder::JaniGSPNBuilder builder(gspn, exprManager);
-    storm::jani::Model* model = builder.build();
+
     storm::jani::JsonExporter::toFile(*model, {}, storm::settings::getModule<storm::settings::modules::JaniExportSettings>().getJaniFilename());
     delete model;
 }
diff --git a/src/storm-gspn/builder/JaniGSPNBuilder.h b/src/storm-gspn/builder/JaniGSPNBuilder.h
index 305fa0129..196d29562 100644
--- a/src/storm-gspn/builder/JaniGSPNBuilder.h
+++ b/src/storm-gspn/builder/JaniGSPNBuilder.h
@@ -16,10 +16,6 @@ namespace storm {
                 
             }
             
-            void setIgnoreWeights(bool ignore = true)  {
-                //ignoreWeights = ignore;
-            }
-            
             
             storm::jani::Model* build() {
                 storm::jani::Model* model = new storm::jani::Model(gspn.getName(), storm::jani::ModelType::MA, janiVersion, expressionManager);
@@ -32,6 +28,10 @@ namespace storm {
                 return model;
             }
             
+            storm::jani::Variable const& getPlaceVariable(uint64_t placeId) {
+                return *vars.at(placeId);
+            }
+            
             void addVariables(storm::jani::Model* model) {
                 for (auto const& place : gspn.getPlaces()) {
                     storm::jani::Variable* janiVar = nullptr;
@@ -86,7 +86,7 @@ namespace storm {
                             destguard = destguard && (vars[inPlaceEntry.first]->getExpressionVariable() >= inPlaceEntry.second);
                         }
                         for (auto const& inhibPlaceEntry : trans.getInhibitionPlaces()) {
-                            destguard = destguard && (vars[inhibPlaceEntry.first]->getExpressionVariable() >= inhibPlaceEntry.second);
+                            destguard = destguard && (vars[inhibPlaceEntry.first]->getExpressionVariable() < inhibPlaceEntry.second);
                         }
                         totalWeight = totalWeight + storm::expressions::ite(destguard, expressionManager->rational(trans.getWeight()), expressionManager->rational(0.0));
                         
@@ -103,13 +103,13 @@ namespace storm {
                         storm::expressions::Expression destguard = expressionManager->boolean(true);
                         std::vector<storm::jani::Assignment> assignments;
                         for (auto const& inPlaceEntry : trans.getInputPlaces()) {
-                            destguard = destguard && (vars[inPlaceEntry.first]->getExpressionVariable() > inPlaceEntry.second);
+                            destguard = destguard && (vars[inPlaceEntry.first]->getExpressionVariable() >= inPlaceEntry.second);
                             if (trans.getOutputPlaces().count(inPlaceEntry.first) == 0) {
                                 assignments.emplace_back( *vars[inPlaceEntry.first], (vars[inPlaceEntry.first])->getExpressionVariable() - inPlaceEntry.second);
                             }
                         }
                         for (auto const& inhibPlaceEntry : trans.getInhibitionPlaces()) {
-                            destguard = destguard && (vars[inhibPlaceEntry.first]->getExpressionVariable() > inhibPlaceEntry.second);
+                            destguard = destguard && (vars[inhibPlaceEntry.first]->getExpressionVariable() < inhibPlaceEntry.second);
                         }
                         for (auto const& outputPlaceEntry : trans.getOutputPlaces()) {
                             if (trans.getInputPlaces().count(outputPlaceEntry.first) == 0) {
@@ -140,7 +140,7 @@ namespace storm {
                         }
                     }
                     for (auto const& inhibPlaceEntry : trans.getInhibitionPlaces()) {
-                        guard = guard && (vars[inhibPlaceEntry.first]->getExpressionVariable() >= inhibPlaceEntry.second);
+                        guard = guard && (vars[inhibPlaceEntry.first]->getExpressionVariable() < inhibPlaceEntry.second);
                     }
                     for (auto const& outputPlaceEntry : trans.getOutputPlaces()) {
                         if (trans.getInputPlaces().count(outputPlaceEntry.first) == 0) {
diff --git a/src/storm/utility/storm.h b/src/storm/utility/storm.h
index 6657a7d6d..343832e00 100644
--- a/src/storm/utility/storm.h
+++ b/src/storm/utility/storm.h
@@ -227,6 +227,7 @@ namespace storm {
     std::shared_ptr<storm::models::ModelBase> preprocessModel(std::shared_ptr<storm::models::ModelBase> model, std::vector<std::shared_ptr<storm::logic::Formula const>> const& formulas) {
         if (model->getType() == storm::models::ModelType::MarkovAutomaton && model->isSparseModel()) {
             std::shared_ptr<storm::models::sparse::MarkovAutomaton<typename ModelType::ValueType>> ma = model->template as<storm::models::sparse::MarkovAutomaton<typename ModelType::ValueType>>();
+            ma->close();
             if (ma->hasOnlyTrivialNondeterminism()) {
                 // Markov automaton can be converted into CTMC.
                 model = ma->convertToCTMC();

From 276261ae55041ab7f941684907dc18b262f0b5b3 Mon Sep 17 00:00:00 2001
From: Sebastian Junges <sebastian.junges@rwth-aachen.de>
Date: Wed, 14 Dec 2016 15:47:14 +0100
Subject: [PATCH 11/47] slightly more informative error message in
 out-of-bounds in bitvector

---
 src/storm/storage/BitVector.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/storm/storage/BitVector.cpp b/src/storm/storage/BitVector.cpp
index 89113d718..a0004263a 100644
--- a/src/storm/storage/BitVector.cpp
+++ b/src/storm/storage/BitVector.cpp
@@ -486,7 +486,7 @@ namespace storm {
         
         void BitVector::setFromInt(uint_fast64_t bitIndex, uint_fast64_t numberOfBits, uint64_t value) {
             STORM_LOG_ASSERT(numberOfBits <= 64, "Number of bits must be <= 64.");
-            STORM_LOG_ASSERT(numberOfBits == 64 || (value >> numberOfBits) == 0, "Integer value too large to fit in the given number of bits.");
+            STORM_LOG_ASSERT(numberOfBits == 64 || (value >> numberOfBits) == 0, "Integer value ("<< value << ") too large to fit in the given number of bits (" << numberOfBits << ").");
 
             uint64_t bucket = bitIndex >> 6;
             uint64_t bitIndexInBucket = bitIndex & mod64mask;

From 69cae73bce1ffea49987ad120cb05db9024cdd50 Mon Sep 17 00:00:00 2001
From: Sebastian Junges <sebastian.junges@rwth-aachen.de>
Date: Wed, 14 Dec 2016 16:50:07 +0100
Subject: [PATCH 12/47] fix in nextstate generator for MA

---
 src/storm/generator/NextStateGenerator.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/storm/generator/NextStateGenerator.cpp b/src/storm/generator/NextStateGenerator.cpp
index 588edb70a..7f931051f 100644
--- a/src/storm/generator/NextStateGenerator.cpp
+++ b/src/storm/generator/NextStateGenerator.cpp
@@ -119,7 +119,7 @@ namespace storm {
                             result.getChoices().front().add(choice);
                             
                             // Swap the choice to the end to indicate it can be removed (if it's not already there).
-                            if (index != result.getNumberOfChoices() - 1) {
+                            if (index != result.getNumberOfChoices() - 1 - numberOfChoicesToDelete) {
                                 choice = std::move(result.getChoices()[result.getNumberOfChoices() - 1 - numberOfChoicesToDelete]);
                             }
                             ++numberOfChoicesToDelete;

From 474eaa950a143140aa67f4e30c4933627370371a Mon Sep 17 00:00:00 2001
From: Sebastian Junges <sebastian.junges@rwth-aachen.de>
Date: Wed, 14 Dec 2016 16:50:49 +0100
Subject: [PATCH 13/47] primes in dft element names are replaced now

---
 src/storm-dft/parser/DFTGalileoParser.cpp | 10 ++++++++--
 src/storm-dft/parser/DFTGalileoParser.h   |  1 +
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/storm-dft/parser/DFTGalileoParser.cpp b/src/storm-dft/parser/DFTGalileoParser.cpp
index 776eb64d9..ec0b446d9 100644
--- a/src/storm-dft/parser/DFTGalileoParser.cpp
+++ b/src/storm-dft/parser/DFTGalileoParser.cpp
@@ -4,6 +4,7 @@
 #include <fstream>
 #include <boost/algorithm/string.hpp>
 #include <boost/lexical_cast.hpp>
+#include <boost/algorithm/string/replace.hpp>
 #include "storm/storage/expressions/ExpressionManager.h"
 #include "storm/exceptions/NotImplementedException.h"
 #include "storm/exceptions/FileIoException.h"
@@ -34,6 +35,11 @@ namespace storm {
                 return name.substr(firstQuots+1,secondQuots-1);
             }
         }
+        
+        template<typename ValueType>
+        std::string DFTGalileoParser<ValueType>::parseNodeIdentifier(std::string const& name) {
+            return boost::replace_all_copy(name, "'", "__prime__");
+        }
 
         template<typename ValueType>
         void DFTGalileoParser<ValueType>::readFile(const std::string& filename) {
@@ -84,11 +90,11 @@ namespace storm {
                 } else {
                     std::vector<std::string> tokens;
                     boost::split(tokens, line, boost::is_any_of(" "));
-                    std::string name(stripQuotsFromName(tokens[0]));
+                    std::string name(parseNodeIdentifier(stripQuotsFromName(tokens[0])));
 
                     std::vector<std::string> childNames;
                     for(unsigned i = 2; i < tokens.size(); ++i) {
-                        childNames.push_back(stripQuotsFromName(tokens[i]));
+                        childNames.push_back(parseNodeIdentifier(stripQuotsFromName(tokens[i])));
                     }
                     if(tokens[1] == "and") {
                         success = builder.addAndElement(name, childNames);
diff --git a/src/storm-dft/parser/DFTGalileoParser.h b/src/storm-dft/parser/DFTGalileoParser.h
index 3f19683ff..bb79be089 100644
--- a/src/storm-dft/parser/DFTGalileoParser.h
+++ b/src/storm-dft/parser/DFTGalileoParser.h
@@ -35,6 +35,7 @@ namespace storm {
             void readFile(std::string const& filename);
 
             std::string stripQuotsFromName(std::string const& name);
+            std::string parseNodeIdentifier(std::string const& name);
 
             ValueType parseRationalExpression(std::string const& expr);
         };

From d7aa7cc7c8754a6a4ee89df9703e055c2051cb71 Mon Sep 17 00:00:00 2001
From: Sebastian Junges <sebastian.junges@rwth-aachen.de>
Date: Wed, 14 Dec 2016 16:51:28 +0100
Subject: [PATCH 14/47] expression AND with true is immediately simplified

---
 src/storm/storage/expressions/Expression.cpp | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/storm/storage/expressions/Expression.cpp b/src/storm/storage/expressions/Expression.cpp
index 9dbd46986..c9ca8a320 100644
--- a/src/storm/storage/expressions/Expression.cpp
+++ b/src/storm/storage/expressions/Expression.cpp
@@ -235,6 +235,12 @@ namespace storm {
         
         Expression operator&&(Expression const& first, Expression const& second) {
             assertSameManager(first.getBaseExpression(), second.getBaseExpression());
+            if (first.isTrue()) {
+                return second;
+            }
+            if (second.isTrue()) {
+                return first;
+            }
             return Expression(std::shared_ptr<BaseExpression>(new BinaryBooleanFunctionExpression(first.getBaseExpression().getManager(), first.getType().logicalConnective(second.getType()), first.getBaseExpressionPointer(), second.getBaseExpressionPointer(), BinaryBooleanFunctionExpression::OperatorType::And)));
         }
         

From 5c900e4e14c6e86d6ee43b04051b54a9f7cb6956 Mon Sep 17 00:00:00 2001
From: Sebastian Junges <sebastian.junges@rwth-aachen.de>
Date: Wed, 14 Dec 2016 17:58:58 +0100
Subject: [PATCH 15/47] stats for gspn

---
 src/storm-dft-cli/storm-dyftee.cpp            |  1 +
 src/storm-gspn/storage/gspn/GSPN.cpp          | 14 +++++++++
 src/storm-gspn/storage/gspn/GSPN.h            | 10 +++++--
 src/storm-gspn/storm-gspn.h                   | 30 ++++++++++++++++++-
 .../settings/modules/GSPNExportSettings.cpp   | 16 ++++++++++
 .../settings/modules/GSPNExportSettings.h     |  9 ++++++
 6 files changed, 77 insertions(+), 3 deletions(-)

diff --git a/src/storm-dft-cli/storm-dyftee.cpp b/src/storm-dft-cli/storm-dyftee.cpp
index 6c54dc226..7be07940c 100644
--- a/src/storm-dft-cli/storm-dyftee.cpp
+++ b/src/storm-dft-cli/storm-dyftee.cpp
@@ -136,6 +136,7 @@ int main(const int argc, const char** argv) {
             gspnTransformator.transform();
             storm::gspn::GSPN* gspn = gspnTransformator.obtainGSPN();
             uint64_t toplevelFailedPlace = gspnTransformator.toplevelFailedPlaceId();
+            
             storm::handleGSPNExportSettings(*gspn);
             
             std::shared_ptr<storm::expressions::ExpressionManager> exprManager(new storm::expressions::ExpressionManager());
diff --git a/src/storm-gspn/storage/gspn/GSPN.cpp b/src/storm-gspn/storage/gspn/GSPN.cpp
index 5a7f819de..74f5983ae 100644
--- a/src/storm-gspn/storage/gspn/GSPN.cpp
+++ b/src/storm-gspn/storage/gspn/GSPN.cpp
@@ -36,6 +36,14 @@ namespace storm {
         uint64_t GSPN::getNumberOfPlaces() const {
             return places.size();
         }
+        
+        uint64_t GSPN::getNumberOfImmediateTransitions() const {
+            return immediateTransitions.size();
+        }
+        
+        uint64_t GSPN::getNumberOfTimedTransitions() const {
+            return timedTransitions.size();
+        }
 
         std::vector<storm::gspn::TimedTransition<GSPN::RateType>> const& GSPN::getTimedTransitions() const {
             return this->timedTransitions;
@@ -565,6 +573,12 @@ namespace storm {
             stream << space << "</net>" << std::endl;
             stream << "</pnml>" << std::endl;
         }
+        
+        void GSPN::writeStatsToStream(std::ostream& stream) const {
+            stream << "Number of places: " << getNumberOfPlaces() << std::endl;
+            stream << "Number of timed transitions: " << getNumberOfTimedTransitions() << std::endl;
+            stream << "Number of immediate transitions: " << getNumberOfImmediateTransitions() << std::endl;
+        }
     }
 }
 
diff --git a/src/storm-gspn/storage/gspn/GSPN.h b/src/storm-gspn/storage/gspn/GSPN.h
index 7086a6c1c..b58a6adc5 100644
--- a/src/storm-gspn/storage/gspn/GSPN.h
+++ b/src/storm-gspn/storage/gspn/GSPN.h
@@ -37,6 +37,10 @@ namespace storm {
              * @return The number of places.
              */
             uint64_t getNumberOfPlaces() const;
+            
+            uint64_t getNumberOfImmediateTransitions() const;
+            
+            uint64_t getNumberOfTimedTransitions() const;
 
             /*!
              *  
@@ -146,9 +150,11 @@ namespace storm {
              */
             bool isValid() const;
             // TODO doc
-            void toPnpro(std::ostream &stream) const;
+            void toPnpro(std::ostream& stream) const;
             // TODO doc
-            void toPnml(std::ostream &stream) const;
+            void toPnml(std::ostream& stream) const;
+            
+            void writeStatsToStream(std::ostream& stream) const;
         private:
             storm::gspn::Place* getPlace(uint64_t id);
             storm::gspn::Place* getPlace(std::string const& name);
diff --git a/src/storm-gspn/storm-gspn.h b/src/storm-gspn/storm-gspn.h
index 3af59a9c1..3a3f9d55a 100644
--- a/src/storm-gspn/storm-gspn.h
+++ b/src/storm-gspn/storm-gspn.h
@@ -22,11 +22,39 @@ namespace storm {
         if (exportSettings.isWriteToDotSet()) {
             std::ofstream fs;
             fs.open(exportSettings.getWriteToDotFilename());
-            gspn.writeDotToStream(std::cout);
             gspn.writeDotToStream(fs);
             fs.close();
         }
         
+        if (exportSettings.isWriteToPnproSet()) {
+            std::ofstream fs;
+            fs.open(exportSettings.getWriteToPnproFilename());
+            gspn.toPnpro(fs);
+            fs.close();
+        }
+        
+        if (exportSettings.isWriteToPnmlSet()) {
+            std::ofstream fs;
+            fs.open(exportSettings.getWriteToPnmlFilename());
+            gspn.toPnml(fs);
+            fs.close();
+        }
+        
+        if (exportSettings.isDisplayStatsSet()) {
+            std::cout << "============GSPN Statistics==============" << std::endl;
+            gspn.writeStatsToStream(std::cout);
+            std::cout << "=========================================" << std::endl;
+        }
+        
+        if (exportSettings.isWriteStatsToFileSet()) {
+            std::ofstream fs;
+            fs.open(exportSettings.getWriteStatsFilename());
+            gspn.writeStatsToStream(fs);
+            fs.close();
+        }
+        
+        
+        
     }
     
 }
\ No newline at end of file
diff --git a/src/storm/settings/modules/GSPNExportSettings.cpp b/src/storm/settings/modules/GSPNExportSettings.cpp
index 9be15c75e..8a5c315dc 100644
--- a/src/storm/settings/modules/GSPNExportSettings.cpp
+++ b/src/storm/settings/modules/GSPNExportSettings.cpp
@@ -19,6 +19,8 @@ namespace storm {
             
             const std::string GSPNExportSettings::writeToPnmlOptionName = "to-pnml";
             const std::string GSPNExportSettings::writeToPnproOptionName = "to-pnpro";
+            const std::string GSPNExportSettings::writeStatsOptionName = "to-stats";
+            const std::string GSPNExportSettings::displayStatsOptionName = "show-stats";
             
             //const std::string GSPNExportSettings::janiFileOptionShortName = "dotoutput";
             
@@ -27,6 +29,8 @@ namespace storm {
                 this->addOption(storm::settings::OptionBuilder(moduleName, writeToDotOptionName, false, "Destination for the dot output.").addArgument(storm::settings::ArgumentBuilder::createStringArgument("filename", "path to file").build()).build());
                 this->addOption(storm::settings::OptionBuilder(moduleName, writeToPnmlOptionName, false, "Destination for the pnml output").addArgument(storm::settings::ArgumentBuilder::createStringArgument("filename", "path to file").build()).build());
                 this->addOption(storm::settings::OptionBuilder(moduleName, writeToPnproOptionName, false, "Destination for the pnpro output").addArgument(storm::settings::ArgumentBuilder::createStringArgument("filename", "path to file").build()).build());
+                this->addOption(storm::settings::OptionBuilder(moduleName, writeStatsOptionName, false, "Destination for the stats file").addArgument(storm::settings::ArgumentBuilder::createStringArgument("filename", "path to file").build()).build());
+                this->addOption(storm::settings::OptionBuilder(moduleName, displayStatsOptionName, false, "Print stats to stdout").build());
             }
             
             bool GSPNExportSettings::isWriteToDotSet() const {
@@ -54,6 +58,18 @@ namespace storm {
             }
             
             
+            bool GSPNExportSettings::isDisplayStatsSet() const {
+                return this->getOption(displayStatsOptionName).getHasOptionBeenSet();
+            }
+            
+            bool GSPNExportSettings::isWriteStatsToFileSet() const {
+                return this->getOption(writeStatsOptionName).getHasOptionBeenSet();
+            }
+            
+            std::string GSPNExportSettings::getWriteStatsFilename() const {
+                return this->getOption(writeStatsOptionName).getArgumentByName("filename").getValueAsString();
+            }
+            
             void GSPNExportSettings::finalize() {
                 
             }
diff --git a/src/storm/settings/modules/GSPNExportSettings.h b/src/storm/settings/modules/GSPNExportSettings.h
index 32ae422ba..554cce223 100644
--- a/src/storm/settings/modules/GSPNExportSettings.h
+++ b/src/storm/settings/modules/GSPNExportSettings.h
@@ -38,6 +38,12 @@ namespace storm {
                  */
                 std::string getWriteToPnproFilename() const;
                 
+                bool isDisplayStatsSet() const;
+                
+                bool isWriteStatsToFileSet() const;
+                
+                std::string getWriteStatsFilename() const;
+                
                 
                 bool check() const override;
                 void finalize() override;
@@ -48,6 +54,9 @@ namespace storm {
                 static const std::string writeToDotOptionName;
                 static const std::string writeToPnmlOptionName;
                 static const std::string writeToPnproOptionName;
+                static const std::string displayStatsOptionName;
+                static const std::string writeStatsOptionName;
+                
                 //static const std::string writeToDotOptionShortName;
                 
             };

From f229a531879a6a16fdcccec1209ae51249f5b8ec Mon Sep 17 00:00:00 2001
From: Sebastian Junges <sebastian.junges@rwth-aachen.de>
Date: Wed, 14 Dec 2016 18:30:48 +0100
Subject: [PATCH 16/47] export priorities

---
 src/storm-gspn/storage/gspn/GSPN.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/storm-gspn/storage/gspn/GSPN.cpp b/src/storm-gspn/storage/gspn/GSPN.cpp
index 74f5983ae..19f598c17 100644
--- a/src/storm-gspn/storage/gspn/GSPN.cpp
+++ b/src/storm-gspn/storage/gspn/GSPN.cpp
@@ -408,6 +408,7 @@ namespace storm {
             for (auto& trans : immediateTransitions) {
                 stream << space3 << "<transition name=\"" << trans.getName() << "\" ";
                 stream << "type=\"IMM\" ";
+                stream << "priority=\"" << trans.getPriority() << "\" ";
                 stream << "x=\"" << x << "\" ";
                 stream << "y=\"4\" ";
                 stream << "/>" << std::endl;

From 49537a83d35fbb1ee19261aa4074f69f88ab5559 Mon Sep 17 00:00:00 2001
From: Sebastian Junges <sebastian.junges@rwth-aachen.de>
Date: Wed, 14 Dec 2016 20:04:32 +0100
Subject: [PATCH 17/47] added layout info to gspn - dft to gspn builds some
 layout in be and and

---
 .../DftToGspnTransformator.cpp                | 15 ++++++-
 src/storm-gspn/storage/gspn/GSPN.cpp          | 43 ++++++++++++++++---
 src/storm-gspn/storage/gspn/GSPN.h            | 13 +++++-
 src/storm-gspn/storage/gspn/GspnBuilder.cpp   | 14 +++++-
 src/storm-gspn/storage/gspn/GspnBuilder.h     | 14 ++++--
 src/storm-gspn/storage/gspn/PlacementInfo.h   | 17 ++++++++
 src/storm-gspn/storage/gspn/Transition.h      |  3 ++
 7 files changed, 106 insertions(+), 13 deletions(-)
 create mode 100644 src/storm-gspn/storage/gspn/PlacementInfo.h

diff --git a/src/storm-dft/transformations/DftToGspnTransformator.cpp b/src/storm-dft/transformations/DftToGspnTransformator.cpp
index 355c6f440..9ab52f28c 100644
--- a/src/storm-dft/transformations/DftToGspnTransformator.cpp
+++ b/src/storm-dft/transformations/DftToGspnTransformator.cpp
@@ -90,11 +90,13 @@ namespace storm {
             
             template <typename ValueType>
             void DftToGspnTransformator<ValueType>::drawBE(std::shared_ptr<storm::storage::DFTBE<ValueType> const> dftBE, bool isRepresentative) {
-                
+                double xcenter = 10.0;
+                double ycenter = 10.0;
 				uint64_t beActive = builder.addPlace(defaultCapacity, isBEActive(dftBE) ? 1 : 0, dftBE->name() + STR_ACTIVATED);
                 activeNodes.emplace(dftBE->id(), beActive);
                 uint64_t beFailed = builder.addPlace(defaultCapacity, 0, dftBE->name() + STR_FAILED);
                 
+                
                 uint64_t unavailableNode = 0;
                 if (isRepresentative) {
                     unavailableNode = addUnavailableNode(dftBE);
@@ -116,10 +118,18 @@ namespace storm {
                     builder.addOutputArc(tActive, unavailableNode);
                     builder.addOutputArc(tPassive, unavailableNode);
                 }
+                
+                builder.setPlaceLayoutInfo(beActive, storm::gspn::LayoutInfo(xcenter - 3.0, ycenter));
+                builder.setPlaceLayoutInfo(beFailed, storm::gspn::LayoutInfo(xcenter + 3.0, ycenter));
+                builder.setTransitionLayoutInfo(tActive, storm::gspn::LayoutInfo(xcenter, ycenter + 3.0));
+                builder.setTransitionLayoutInfo(tPassive, storm::gspn::LayoutInfo(xcenter, ycenter - 3.0));
+                
             }
 			
 			template <typename ValueType>
             void DftToGspnTransformator<ValueType>::drawAND(std::shared_ptr<storm::storage::DFTAnd<ValueType> const> dftAnd, bool isRepresentative) {
+                double xcenter = 10.0;
+                double ycenter = 20.0;
                 uint64_t nodeFailed = builder.addPlace(defaultCapacity, 0, dftAnd->name() + STR_FAILED);
                 assert(failedNodes.size() == dftAnd->id());
                 failedNodes.push_back(nodeFailed);
@@ -142,6 +152,9 @@ namespace storm {
                     builder.addOutputArc(tAndFailed, failedNodes[child->id()]);
                 }
                 
+                builder.setPlaceLayoutInfo(nodeFailed, storm::gspn::LayoutInfo(xcenter, ycenter-3.0));
+                builder.setTransitionLayoutInfo(tAndFailed, storm::gspn::LayoutInfo(xcenter, ycenter+3.0));
+                
 			}
 
 			template <typename ValueType>
diff --git a/src/storm-gspn/storage/gspn/GSPN.cpp b/src/storm-gspn/storage/gspn/GSPN.cpp
index 19f598c17..ce0d47d44 100644
--- a/src/storm-gspn/storage/gspn/GSPN.cpp
+++ b/src/storm-gspn/storage/gspn/GSPN.cpp
@@ -376,6 +376,20 @@ namespace storm {
 
             return result;
         }
+        
+        void GSPN::setPlaceLayoutInfo(uint64_t placeId, LayoutInfo const& layout) const {
+            placeLayout[placeId] = layout;
+        }
+        void GSPN::setTransitionLayoutInfo(uint64_t transitionId, LayoutInfo const& layout) const {
+            transitionLayout[transitionId] = layout;
+        }
+        
+        void GSPN::setPlaceLayoutInfo(std::map<uint64_t, LayoutInfo> const& placeLayout) const {
+            this->placeLayout = placeLayout;
+        }
+        void GSPN::setTransitionLayoutInfo(std::map<uint64_t, LayoutInfo> const& transitionLayout) const {
+            this->transitionLayout = transitionLayout;
+        }
 
         void GSPN::toPnpro(std::ostream &stream) const {
             auto space = "  ";
@@ -390,8 +404,14 @@ namespace storm {
             for (auto& place : places) {
                 stream << space3 << "<place marking=\"" << place.getNumberOfInitialTokens() <<"\" ";
                 stream << "name =\"" << place.getName() << "\" ";
-                stream << "x=\"" << x << "\" ";
-                stream << "y=\"1\" ";
+                if (placeLayout.count(place.getID()) > 0) {
+                    stream << "x=\"" << placeLayout.at(place.getID()).x << "\" ";
+                    stream << "y=\"" << placeLayout.at(place.getID()).y << "\" ";
+                } else {
+                    stream << "x=\"" << x << "\" ";
+                    stream << "y=\"1\" ";
+                    
+                }
                 stream << "/>" << std::endl;
                 x = x + 3;
             }
@@ -400,8 +420,14 @@ namespace storm {
                 stream << space3 << "<transition name=\"" << trans.getName() << "\" ";
                 stream << "type=\"EXP\" ";
                 stream << "nservers-x=\"" << trans.getRate() << "\" ";
-                stream << "x=\"" << x << "\" ";
-                stream << "y=\"4\" ";
+                if (transitionLayout.count(trans.getID()) > 0) {
+                    stream << "x=\"" << transitionLayout.at(trans.getID()).x << "\" ";
+                    stream << "y=\"" << transitionLayout.at(trans.getID()).y << "\" ";
+                } else {
+                    stream << "x=\"" << x << "\" ";
+                    stream << "y=\"4\" ";
+                    
+                }
                 stream << "/>" << std::endl;
                 x = x + 3;
             }
@@ -409,8 +435,13 @@ namespace storm {
                 stream << space3 << "<transition name=\"" << trans.getName() << "\" ";
                 stream << "type=\"IMM\" ";
                 stream << "priority=\"" << trans.getPriority() << "\" ";
-                stream << "x=\"" << x << "\" ";
-                stream << "y=\"4\" ";
+                if (transitionLayout.count(trans.getID()) > 0) {
+                    stream << "x=\"" << transitionLayout.at(trans.getID()).x << "\" ";
+                    stream << "y=\"" << transitionLayout.at(trans.getID()).y << "\" ";
+                } else {
+                    stream << "x=\"" << x << "\" ";
+                    stream << "y=\"4\" ";
+                }
                 stream << "/>" << std::endl;
                 x = x + 3;
             }
diff --git a/src/storm-gspn/storage/gspn/GSPN.h b/src/storm-gspn/storage/gspn/GSPN.h
index b58a6adc5..947769af3 100644
--- a/src/storm-gspn/storage/gspn/GSPN.h
+++ b/src/storm-gspn/storage/gspn/GSPN.h
@@ -11,6 +11,7 @@
 #include "storm-gspn/storage/gspn/Place.h"
 #include "storm-gspn/storage/gspn/TimedTransition.h"
 #include "storm-gspn/storage/gspn/TransitionPartition.h"
+#include "storm-gspn/storage/gspn/PlacementInfo.h"
 
 namespace storm {
     namespace gspn {
@@ -140,7 +141,13 @@ namespace storm {
              *  Set Capacities according to name->capacity map.
              */
             void setCapacities(std::unordered_map<std::string, uint64_t> const& mapping);
-
+            
+            void setPlaceLayoutInfo(uint64_t placeId, LayoutInfo const& layout) const;
+            void setTransitionLayoutInfo(uint64_t transitionId, LayoutInfo const& layout) const;
+            void setPlaceLayoutInfo(std::map<uint64_t, LayoutInfo> const& placeLayout) const;
+            void setTransitionLayoutInfo(std::map<uint64_t, LayoutInfo> const& transitionLayout) const;
+            
+            
             /*!
              * Performe some checks
              * - testPlaces()
@@ -191,6 +198,10 @@ namespace storm {
 
             std::vector<storm::gspn::TransitionPartition> partitions;
             
+            mutable std::map<uint64_t, LayoutInfo> placeLayout;
+            mutable std::map<uint64_t, LayoutInfo> transitionLayout;
+            
+            
         };
     }
 }
diff --git a/src/storm-gspn/storage/gspn/GspnBuilder.cpp b/src/storm-gspn/storage/gspn/GspnBuilder.cpp
index fa81444c3..e0bbd76fd 100644
--- a/src/storm-gspn/storage/gspn/GspnBuilder.cpp
+++ b/src/storm-gspn/storage/gspn/GspnBuilder.cpp
@@ -23,6 +23,15 @@ namespace storm {
             places.push_back(place);
             return newId;
         }
+        
+        
+        void GspnBuilder::setPlaceLayoutInfo(uint64_t placeId, LayoutInfo const& layoutInfo) {
+            placeLayout[placeId] = layoutInfo;
+        }
+        
+        void GspnBuilder::setTransitionLayoutInfo(uint64_t transitionId, LayoutInfo const& layoutInfo) {
+            transitionLayout[transitionId] = layoutInfo;
+        }
 
         uint_fast64_t GspnBuilder::addImmediateTransition(uint_fast64_t const& priority, double const& weight, std::string const& name) {
             auto trans = storm::gspn::ImmediateTransition<double>();
@@ -164,7 +173,10 @@ namespace storm {
             }
             std::reverse(orderedPartitions.begin(), orderedPartitions.end());
             
-            return new GSPN(gspnName, places, immediateTransitions, timedTransitions, orderedPartitions);
+            GSPN* result = new GSPN(gspnName, places, immediateTransitions, timedTransitions, orderedPartitions);
+            result->setTransitionLayoutInfo(transitionLayout);
+            result->setPlaceLayoutInfo(placeLayout);
+            return result;
         }
     }
 }
diff --git a/src/storm-gspn/storage/gspn/GspnBuilder.h b/src/storm-gspn/storage/gspn/GspnBuilder.h
index 2f63ba719..79fb2e712 100644
--- a/src/storm-gspn/storage/gspn/GspnBuilder.h
+++ b/src/storm-gspn/storage/gspn/GspnBuilder.h
@@ -20,29 +20,32 @@ namespace storm {
             
             /**
              * Add a place to the gspn.
-             * @param id The id must be unique for the gspn.
              * @param name The name must be unique for the gspn.
              * @param capacity The capacity is the limit of tokens in the place.
              *                 A capacity of -1 indicates an unbounded place.
              * @param initialTokens The number of inital tokens in the place.
              */
             uint_fast64_t addPlace(int_fast64_t const& capacity = 1, uint_fast64_t const& initialTokens = 0, std::string const& name = "");
+            
+            void setPlaceLayoutInfo(uint64_t placeId, LayoutInfo const& layoutInfo);
 
             /**
              * Adds an immediate transition to the gspn.
-             * @param id The id must be unique for the gspn.
              * @param priority The priority for the transtion.
              * @param weight The weight for the transition.
              */
             uint_fast64_t addImmediateTransition(uint_fast64_t const& priority = 0, WeightType const& weight = 0, std::string const& name = "");
-
+            
+            
             /**
              * Adds an timed transition to the gspn.
-             * @param id The name id be unique for the gspn.
              * @param priority The priority for the transtion.
              * @param weight The weight for the transition.
              */
             uint_fast64_t addTimedTransition(uint_fast64_t const &priority, RateType const& rate, std::string const& name = "");
+            
+            void setTransitionLayoutInfo(uint64_t transitionId, LayoutInfo const& layoutInfo);
+
 
             /**
              * Adds an new input arc from a place to an transition.
@@ -112,6 +115,9 @@ namespace storm {
             
             // set containing all places
             std::vector<storm::gspn::Place> places;
+            
+            std::map<uint64_t, LayoutInfo> placeLayout;
+            std::map<uint64_t, LayoutInfo> transitionLayout;
         };
     }
 }
diff --git a/src/storm-gspn/storage/gspn/PlacementInfo.h b/src/storm-gspn/storage/gspn/PlacementInfo.h
new file mode 100644
index 000000000..e59218686
--- /dev/null
+++ b/src/storm-gspn/storage/gspn/PlacementInfo.h
@@ -0,0 +1,17 @@
+#pragma once
+
+namespace storm {
+    namespace gspn {
+        struct LayoutInfo {
+            LayoutInfo() {};
+            LayoutInfo(double x, double y, double rotation = 0.0) : x(x), y(y), rotation(rotation) {};
+            
+            // x location
+            double x = 0.0;
+            // y location
+            double y = 0.0;
+            // degrees
+            double rotation = 0.0;
+        };
+    }
+}
\ No newline at end of file
diff --git a/src/storm-gspn/storage/gspn/Transition.h b/src/storm-gspn/storage/gspn/Transition.h
index d61affaea..9deab2fb0 100644
--- a/src/storm-gspn/storage/gspn/Transition.h
+++ b/src/storm-gspn/storage/gspn/Transition.h
@@ -168,6 +168,9 @@ namespace storm {
             void setID(uint64_t const& id) {
                 this->id = id;
             }
+            
+            
+            uint64_t getID() const { return id; }
         private:
 
             // maps place ids connected to this transition with an input arc to the corresponding multiplicity

From 0bf00ff7acba4384678e6eb259afee45c54c9632 Mon Sep 17 00:00:00 2001
From: Sebastian Junges <sebastian.junges@rwth-aachen.de>
Date: Wed, 14 Dec 2016 20:38:59 +0100
Subject: [PATCH 18/47] preparations for support of exclusive pand and por

---
 src/storm-dft/parser/DFTGalileoParser.h      |  4 +++-
 src/storm-dft/storage/dft/DFTBuilder.cpp     |  4 ++--
 src/storm-dft/storage/dft/DFTBuilder.h       | 14 +++++++++++++-
 src/storm-dft/storage/dft/elements/DFTPand.h | 15 ++++++++++++---
 src/storm-dft/storage/dft/elements/DFTPor.h  | 17 +++++++++++++----
 5 files changed, 43 insertions(+), 11 deletions(-)

diff --git a/src/storm-dft/parser/DFTGalileoParser.h b/src/storm-dft/parser/DFTGalileoParser.h
index bb79be089..04b822914 100644
--- a/src/storm-dft/parser/DFTGalileoParser.h
+++ b/src/storm-dft/parser/DFTGalileoParser.h
@@ -26,7 +26,7 @@ namespace storm {
             std::unordered_map<std::string, storm::expressions::Expression> identifierMapping;
 
         public:
-            DFTGalileoParser() : manager(new storm::expressions::ExpressionManager()), parser(*manager), evaluator(*manager) {
+            DFTGalileoParser(bool defaultInclusive = true) : builder(defaultInclusive), manager(new storm::expressions::ExpressionManager()), parser(*manager), evaluator(*manager) {
             }
 
             storm::storage::DFT<ValueType> parseDFT(std::string const& filename);
@@ -38,6 +38,8 @@ namespace storm {
             std::string parseNodeIdentifier(std::string const& name);
 
             ValueType parseRationalExpression(std::string const& expr);
+            
+            bool defaultInclusive;
         };
     }
 }
diff --git a/src/storm-dft/storage/dft/DFTBuilder.cpp b/src/storm-dft/storage/dft/DFTBuilder.cpp
index 612008226..10c84f5f6 100644
--- a/src/storm-dft/storage/dft/DFTBuilder.cpp
+++ b/src/storm-dft/storage/dft/DFTBuilder.cpp
@@ -144,10 +144,10 @@ namespace storm {
                     element = std::make_shared<DFTOr<ValueType>>(mNextId++, name);
                     break;
                 case DFTElementType::PAND:
-                    element = std::make_shared<DFTPand<ValueType>>(mNextId++, name);
+                    element = std::make_shared<DFTPand<ValueType>>(mNextId++, name, pandDefaultInclusive);
                     break;
                 case DFTElementType::POR:
-                    element = std::make_shared<DFTPor<ValueType>>(mNextId++, name);
+                    element = std::make_shared<DFTPor<ValueType>>(mNextId++, name, porDefaultInclusive);
                     break;
                 case DFTElementType::SPARE:
                    element = std::make_shared<DFTSpare<ValueType>>(mNextId++, name);
diff --git a/src/storm-dft/storage/dft/DFTBuilder.h b/src/storm-dft/storage/dft/DFTBuilder.h
index f9a11d52b..55c1cb588 100644
--- a/src/storm-dft/storage/dft/DFTBuilder.h
+++ b/src/storm-dft/storage/dft/DFTBuilder.h
@@ -35,7 +35,7 @@ namespace storm {
             std::vector<DFTRestrictionPointer> mRestrictions;
             
         public:
-            DFTBuilder() {
+            DFTBuilder(bool defaultInclusive = true) : pandDefaultInclusive(defaultInclusive), porDefaultInclusive(defaultInclusive) {
                 
             }
             
@@ -51,6 +51,13 @@ namespace storm {
                 return addStandardGate(name, children, DFTElementType::PAND);
             }
             
+            bool addPandElement(std::string const& name, std::vector<std::string> const& children, bool inclusive) {
+                bool tmpDefault = pandDefaultInclusive;
+                bool result = addStandardGate(name, children, DFTElementType::PAND);
+                pandDefaultInclusive = tmpDefault;
+                return result;
+            }
+            
             bool addPorElement(std::string const& name, std::vector<std::string> const& children) {
                 return addStandardGate(name, children, DFTElementType::POR);
             }
@@ -187,6 +194,11 @@ namespace storm {
 
             DFTElementVector topoSort();
             
+            // If true, the standard gate adders make a pand inclusive, and exclusive otherwise.
+            bool pandDefaultInclusive;
+            // If true, the standard gate adders make a pand inclusive, and exclusive otherwise.
+            bool porDefaultInclusive;
+            
         };
     }
 }
diff --git a/src/storm-dft/storage/dft/elements/DFTPand.h b/src/storm-dft/storage/dft/elements/DFTPand.h
index bb18efe72..d89e357b1 100644
--- a/src/storm-dft/storage/dft/elements/DFTPand.h
+++ b/src/storm-dft/storage/dft/elements/DFTPand.h
@@ -7,11 +7,13 @@ namespace storm {
         class DFTPand : public DFTGate<ValueType> {
 
         public:
-            DFTPand(size_t id, std::string const& name, std::vector<std::shared_ptr<DFTElement<ValueType>>> const& children = {}) :
-                    DFTGate<ValueType>(id, name, children)
+            DFTPand(size_t id, std::string const& name, bool inclusive, std::vector<std::shared_ptr<DFTElement<ValueType>>> const& children = {}) :
+                    DFTGate<ValueType>(id, name, children),
+                    inclusive(inclusive)
             {}
 
             void checkFails(storm::storage::DFTState<ValueType>& state,  DFTStateSpaceGenerationQueues<ValueType>& queues) const override {
+                assert(inclusive);
                 if(state.isOperational(this->mId)) {
                     bool childOperationalBefore = false;
                     for(auto const& child : this->mChildren)
@@ -31,6 +33,7 @@ namespace storm {
             }
 
             void checkFailsafe(storm::storage::DFTState<ValueType>& state, DFTStateSpaceGenerationQueues<ValueType>& queues) const override {
+                bool(inclusive);
                 STORM_LOG_ASSERT(this->hasFailsafeChild(state), "No failsafe child.");
                 if(state.isOperational(this->mId)) {
                     this->failsafe(state, queues);
@@ -42,9 +45,15 @@ namespace storm {
                 return DFTElementType::PAND;
             }
             
+            bool isInclusive() const {
+                return inclusive;
+            }
+            
             std::string typestring() const override {
-                return "PAND";
+                return "PAND" + inclusive ? "" : "-ex";
             }
+        protected:
+            bool inclusive;
         };
         
         template<typename ValueType>
diff --git a/src/storm-dft/storage/dft/elements/DFTPor.h b/src/storm-dft/storage/dft/elements/DFTPor.h
index 6e2fe731c..3adaf16fc 100644
--- a/src/storm-dft/storage/dft/elements/DFTPor.h
+++ b/src/storm-dft/storage/dft/elements/DFTPor.h
@@ -6,12 +6,14 @@ namespace storm {
         template<typename ValueType>
         class DFTPor : public DFTGate<ValueType> {
         public:
-            DFTPor(size_t id, std::string const& name, std::vector<std::shared_ptr<DFTElement<ValueType>>> const& children = {}) :
-                    DFTGate<ValueType>(id, name, children)
+            DFTPor(size_t id, std::string const& name, bool inclusive, std::vector<std::shared_ptr<DFTElement<ValueType>>> const& children = {}) :
+                    DFTGate<ValueType>(id, name, children),
+                    inclusive(inclusive)
             {}
 
             void checkFails(storm::storage::DFTState<ValueType>& state, DFTStateSpaceGenerationQueues<ValueType>& queues) const override {
-                 if(state.isOperational(this->mId)) {
+                assert(inclusive);
+                if(state.isOperational(this->mId)) {
                     if (state.hasFailed(this->mChildren.front()->id())) {
                         // First child has failed before others
                         this->fail(state, queues);
@@ -28,6 +30,7 @@ namespace storm {
             }
 
             void checkFailsafe(storm::storage::DFTState<ValueType>& state, DFTStateSpaceGenerationQueues<ValueType>& queues) const override {
+                assert(inclusive);
                 if (state.isFailsafe(this->mChildren.front()->id())) {
                     this->failsafe(state, queues);
                     this->childrenDontCare(state, queues);
@@ -39,8 +42,14 @@ namespace storm {
             }
             
             std::string  typestring() const override {
-                return "POR";
+                return "POR" + inclusive ? "" : "-ex";
             }
+            
+            bool isInclusive() {
+                return inclusive;
+            }
+        protected:
+            bool inclusive;
         };
 
         template<typename ValueType>

From 92584d577f2c907f72993532ff70c4374ab7a70d Mon Sep 17 00:00:00 2001
From: Sebastian Junges <sebastian.junges@rwth-aachen.de>
Date: Wed, 14 Dec 2016 21:27:02 +0100
Subject: [PATCH 19/47] initial support for seq in dft->gspn

---
 .../storage/dft/elements/DFTRestriction.h     |  9 +++
 .../DftToGspnTransformator.cpp                | 65 ++++++++++++-------
 .../transformations/DftToGspnTransformator.h  |  8 ++-
 3 files changed, 58 insertions(+), 24 deletions(-)

diff --git a/src/storm-dft/storage/dft/elements/DFTRestriction.h b/src/storm-dft/storage/dft/elements/DFTRestriction.h
index f4a03f688..195a217bb 100644
--- a/src/storm-dft/storage/dft/elements/DFTRestriction.h
+++ b/src/storm-dft/storage/dft/elements/DFTRestriction.h
@@ -36,6 +36,15 @@ namespace storm {
             virtual bool isSeqEnforcer() const {
                 return false;
             }
+            
+            bool allChildrenBEs() const {
+                for(auto const& elem : mChildren) {
+                    if (!elem->isBasicElement()) {
+                        return false;
+                    }
+                }
+                return true;
+            }
 
 
             virtual std::string typestring() const = 0;
diff --git a/src/storm-dft/transformations/DftToGspnTransformator.cpp b/src/storm-dft/transformations/DftToGspnTransformator.cpp
index 9ab52f28c..f3a113215 100644
--- a/src/storm-dft/transformations/DftToGspnTransformator.cpp
+++ b/src/storm-dft/transformations/DftToGspnTransformator.cpp
@@ -63,8 +63,8 @@ namespace storm {
 							drawPOR(std::static_pointer_cast<storm::storage::DFTPor<ValueType> const>(dftElement), isRepresentative);
 							break;
 						case storm::storage::DFTElementType::SEQ:
-							// No method call needed here. SEQ only consists of restrictions, which are handled later.
-							break;
+                            drawSeq(std::static_pointer_cast<storm::storage::DFTSeq<ValueType> const>(dftElement));
+                            break;
 						case storm::storage::DFTElementType::MUTEX:
 							// No method call needed here. MUTEX only consists of restrictions, which are handled later.
 							break;
@@ -78,7 +78,7 @@ namespace storm {
 							drawCONSTS(dftElement, isRepresentative);
 							break;
 						case storm::storage::DFTElementType::PDEP:
-							drawPDEP(std::static_pointer_cast<storm::storage::DFTDependency<ValueType> const>(dftElement), isRepresentative);
+                            drawPDEP(std::static_pointer_cast<storm::storage::DFTDependency<ValueType> const>(dftElement));
 							break;
 						default:
 							STORM_LOG_ASSERT(false, "DFT type unknown.");
@@ -96,9 +96,13 @@ namespace storm {
                 activeNodes.emplace(dftBE->id(), beActive);
                 uint64_t beFailed = builder.addPlace(defaultCapacity, 0, dftBE->name() + STR_FAILED);
                 
+                uint64_t disabledNode = 0;
+                if (!smart || dftBE->nrRestrictions() > 0) {
+                    disabledNode = addDisabledPlace(dftBE);
+                }
                 
                 uint64_t unavailableNode = 0;
-                if (isRepresentative) {
+                if (!smart || isRepresentative) {
                     unavailableNode = addUnavailableNode(dftBE);
                 }
                 
@@ -114,7 +118,12 @@ namespace storm {
                 builder.addInhibitionArc(beFailed, tPassive);
                 builder.addOutputArc(tPassive, beFailed);
                 
-                if (isRepresentative) {
+                if (!smart || dftBE->nrRestrictions() > 0) {
+                    builder.addInhibitionArc(disabledNode, tActive);
+                    builder.addInhibitionArc(disabledNode, tPassive);
+                }
+                
+                if (!smart || isRepresentative) {
                     builder.addOutputArc(tActive, unavailableNode);
                     builder.addOutputArc(tPassive, unavailableNode);
                 }
@@ -350,26 +359,29 @@ namespace storm {
 			}
 //			
 			template <typename ValueType>
-            void DftToGspnTransformator<ValueType>::drawPDEP(std::shared_ptr<storm::storage::DFTDependency<ValueType> const> dftDependency, bool isRepresentative) {
-//				// Only draw dependency, if it wasn't drawn before.
-//				std::string gateName = dftDependency->name().substr(0, dftDependency->name().find("_"));
-//				auto exists = mGspn.getPlace(gateName + STR_FAILED);
-//				if (!exists.first) {
-//					storm::gspn::Place placeDEPFailed;
-//					placeDEPFailed.setName(gateName + STR_FAILED);
-//					placeDEPFailed.setNumberOfInitialTokens(0);
-//					mGspn.addPlace(placeDEPFailed);
-//					
-//					storm::gspn::TimedTransition<double> timedTransitionDEPFailure;
-//					timedTransitionDEPFailure.setName(gateName + STR_FAILING);
-//					timedTransitionDEPFailure.setPriority(getPriority(0, dftDependency));
-//					timedTransitionDEPFailure.setRate(dftDependency->probability());
-//					timedTransitionDEPFailure.setOutputArcMultiplicity(placeDEPFailed, 1);
-//					timedTransitionDEPFailure.setInhibitionArcMultiplicity(placeDEPFailed, 1);
-//					mGspn.addTimedTransition(timedTransitionDEPFailure);
-//				}
+            void DftToGspnTransformator<ValueType>::drawPDEP(std::shared_ptr<storm::storage::DFTDependency<ValueType> const> dftDependency) {
+
 			}
             
+            template <typename ValueType>
+            void DftToGspnTransformator<ValueType>::drawSeq(std::shared_ptr<storm::storage::DFTSeq<ValueType> const> dftSeq) {
+                STORM_LOG_THROW(dftSeq->allChildrenBEs(), storm::exceptions::NotImplementedException, "Sequence enforcers with gates as children are currently not supported");
+                bool first = true;
+                uint64_t tEnable = 0;
+                uint64_t nextPlace = 0;
+                for(auto const& child : dftSeq->children()) {
+                    nextPlace = builder.addPlace(defaultCapacity, first ? 1 : 0, dftSeq->name() + "_next_" + child->name());
+                    if(!first) {
+                        builder.addOutputArc(tEnable, nextPlace);
+                    }
+                    tEnable = builder.addImmediateTransition(defaultPriority, 0.0, dftSeq->name() + "_unblock_" +child->name() );
+                    builder.addInputArc(nextPlace, tEnable);
+                    builder.addInputArc(disabledNodes.at(child->id()), tEnable);
+                    first = false;
+                }
+                
+            }
+            
             template<typename ValueType>
             uint64_t DftToGspnTransformator<ValueType>::addUnavailableNode(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dftElement, bool initialAvailable) {
                 uint64_t unavailableNode = builder.addPlace(defaultCapacity, initialAvailable ? 0 : 1, dftElement->name() + "_unavailable");
@@ -377,6 +389,13 @@ namespace storm {
                 unavailableNodes.emplace(dftElement->id(), unavailableNode);
                 return unavailableNode;
             }
+            
+            template<typename ValueType>
+            uint64_t DftToGspnTransformator<ValueType>::addDisabledPlace(std::shared_ptr<const storm::storage::DFTBE<ValueType> > dftBe) {
+                uint64_t disabledNode = builder.addPlace(dftBe->nrRestrictions(), dftBe->nrRestrictions(), dftBe->name() + "_dabled");
+                disabledNodes.emplace(dftBe->id(), disabledNode);
+                return disabledNode;
+            }
 //			
 			
 			template <typename ValueType>
diff --git a/src/storm-dft/transformations/DftToGspnTransformator.h b/src/storm-dft/transformations/DftToGspnTransformator.h
index 2d763452d..3cf5477e3 100644
--- a/src/storm-dft/transformations/DftToGspnTransformator.h
+++ b/src/storm-dft/transformations/DftToGspnTransformator.h
@@ -114,8 +114,10 @@ namespace storm {
 				/*
 				 * Draw a Petri net PDEP (FDEP is included with a firerate of 1).
 				 */
-				void drawPDEP(std::shared_ptr<storm::storage::DFTDependency<ValueType> const> dftDependency, bool isRepresentative);
+				void drawPDEP(std::shared_ptr<storm::storage::DFTDependency<ValueType> const> dftDependency);
 				
+                
+                void drawSeq(std::shared_ptr<storm::storage::DFTSeq<ValueType> const> dftSeq);
 				 /*
 				  * Return true if BE is active (corresponding place contains one initial token) or false if BE is inactive (corresponding place contains no initial token).
 				  * 
@@ -136,11 +138,15 @@ namespace storm {
                 
                 uint64_t addUnavailableNode(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dftElement, bool initialAvailable = true);
                 
+                uint64_t addDisabledPlace(std::shared_ptr<storm::storage::DFTBE<ValueType> const> dftBe);
+                
                 storm::storage::DFT<ValueType> const& mDft;
                 storm::gspn::GspnBuilder builder;
                 std::vector<uint64_t> failedNodes;
                 std::map<uint64_t, uint64_t> unavailableNodes;
                 std::map<uint64_t, uint64_t> activeNodes;
+                std::map<uint64_t, uint64_t> disabledNodes;
+                bool smart = true;
                 
                 static constexpr const char* STR_FAILING = "_failing";			// Name standard for transitions that point towards a place, which in turn indicates the failure of a gate.
                 static constexpr const char* STR_FAILED = "_failed";			// Name standard for place which indicates the failure of a gate.

From 349b0404ba8c6e8ace97dbcee2317be4d3c52f8c Mon Sep 17 00:00:00 2001
From: Sebastian Junges <sebastian.junges@rwth-aachen.de>
Date: Wed, 14 Dec 2016 22:32:23 +0100
Subject: [PATCH 20/47] restrictions are now topo-sorted correctly

---
 src/storm-dft/storage/dft/DFTBuilder.cpp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/storm-dft/storage/dft/DFTBuilder.cpp b/src/storm-dft/storage/dft/DFTBuilder.cpp
index 10c84f5f6..69b100783 100644
--- a/src/storm-dft/storage/dft/DFTBuilder.cpp
+++ b/src/storm-dft/storage/dft/DFTBuilder.cpp
@@ -175,7 +175,13 @@ namespace storm {
             } else if(visited[n] == topoSortColour::WHITE) {
                 if(n->isGate()) {
                     visited[n] = topoSortColour::GREY;
-                    for(DFTElementPointer const& c : std::static_pointer_cast<DFTGate<ValueType>>(n)->children()) {
+                    for (DFTElementPointer const& c : std::static_pointer_cast<DFTGate<ValueType>>(n)->children()) {
+                        topoVisit(c, visited, L);
+                    }
+                }
+                if(n->isRestriction()) {
+                    visited[n] = topoSortColour::GREY;
+                    for (DFTElementPointer const& c : std::static_pointer_cast<DFTRestriction<ValueType>>(n)->children()) {
                         topoVisit(c, visited, L);
                     }
                 }

From 6e5a316f1d70be83d983aef90ec7045edce11fa1 Mon Sep 17 00:00:00 2001
From: Sebastian Junges <sebastian.junges@rwth-aachen.de>
Date: Wed, 14 Dec 2016 22:37:37 +0100
Subject: [PATCH 21/47] fix in dft::maxrank

---
 src/storm-dft/storage/dft/DFT.cpp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/storm-dft/storage/dft/DFT.cpp b/src/storm-dft/storage/dft/DFT.cpp
index 8f19119a2..3e06299f1 100644
--- a/src/storm-dft/storage/dft/DFT.cpp
+++ b/src/storm-dft/storage/dft/DFT.cpp
@@ -284,7 +284,13 @@ namespace storm {
         
         template<typename ValueType>
         uint64_t DFT<ValueType>::maxRank() const {
-            return mElements.back()->rank();
+            uint64_t max = 0;
+            for (auto const& e : mElements) {
+                if(e->rank() > max) {
+                    max = e->rank();
+                }
+            }
+            return max;
         }
         
         template<typename ValueType>

From 99428f9a7b87268da07c48bdd750c1a324edfad1 Mon Sep 17 00:00:00 2001
From: Sebastian Junges <sebastian.junges@rwth-aachen.de>
Date: Wed, 14 Dec 2016 22:38:23 +0100
Subject: [PATCH 22/47] priorities updated such that 0 is not used as this is
 often reserved, e.g. in greatspn

---
 src/storm-dft/transformations/DftToGspnTransformator.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/storm-dft/transformations/DftToGspnTransformator.cpp b/src/storm-dft/transformations/DftToGspnTransformator.cpp
index f3a113215..14b037025 100644
--- a/src/storm-dft/transformations/DftToGspnTransformator.cpp
+++ b/src/storm-dft/transformations/DftToGspnTransformator.cpp
@@ -7,7 +7,7 @@ namespace storm {
         namespace dft {
             
             // Prevent some magic constants
-            static constexpr const uint64_t defaultPriority = 0;
+            static constexpr const uint64_t defaultPriority = 1;
             static constexpr const uint64_t defaultCapacity = 1;
 
             template <typename ValueType>
@@ -436,7 +436,7 @@ namespace storm {
 			template <typename ValueType>
             uint64_t DftToGspnTransformator<ValueType>::getFailPriority(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dftElement)
 			{
-                return mDft.maxRank() - dftElement->rank();
+                return mDft.maxRank() - dftElement->rank() + 2;
 			}
 
 			

From 80d578d1303cca9d63597f71348c76b55971e6dc Mon Sep 17 00:00:00 2001
From: Sebastian Junges <sebastian.junges@rwth-aachen.de>
Date: Wed, 14 Dec 2016 23:04:41 +0100
Subject: [PATCH 23/47] POR[inclusive] support seems to be working now

---
 .../DftToGspnTransformator.cpp                | 60 +++++++++++--------
 1 file changed, 35 insertions(+), 25 deletions(-)

diff --git a/src/storm-dft/transformations/DftToGspnTransformator.cpp b/src/storm-dft/transformations/DftToGspnTransformator.cpp
index 14b037025..ccfa5bdf4 100644
--- a/src/storm-dft/transformations/DftToGspnTransformator.cpp
+++ b/src/storm-dft/transformations/DftToGspnTransformator.cpp
@@ -232,27 +232,32 @@ namespace storm {
                 if (isRepresentative) {
                     unavailableNode = addUnavailableNode(dftPand);
                 }
-
-                uint64_t nodeFS = builder.addPlace(defaultCapacity, 0, dftPand->name() + STR_FAILSAVE);
-                uint64_t tNodeFailed = builder.addImmediateTransition(getFailPriority(dftPand), 0.0,  dftPand->name() + STR_FAILING);
-                builder.addInhibitionArc(nodeFailed, tNodeFailed);
-                builder.addInhibitionArc(nodeFS, tNodeFailed);
-                builder.addOutputArc(tNodeFailed, nodeFailed);
-                if (isRepresentative) {
+                
+                if(dftPand->isInclusive()) {
+                    
+                    uint64_t nodeFS = builder.addPlace(defaultCapacity, 0, dftPand->name() + STR_FAILSAVE);
+                    uint64_t tNodeFailed = builder.addImmediateTransition(getFailPriority(dftPand), 0.0,  dftPand->name() + STR_FAILING);
+                    builder.addInhibitionArc(nodeFailed, tNodeFailed);
+                    builder.addInhibitionArc(nodeFS, tNodeFailed);
                     builder.addOutputArc(tNodeFailed, nodeFailed);
-                }
-                for(auto const& child : dftPand->children()) {
-                    builder.addInputArc(failedNodes[child->id()], tNodeFailed);
-                    builder.addOutputArc(tNodeFailed, failedNodes[child->id()]);
-                }
-                for (uint64_t j = 1; j < dftPand->nrChildren(); ++j) {
-                    uint64_t tfs = builder.addImmediateTransition(getFailPriority(dftPand), 0.0, dftPand->name() + STR_FAILSAVING + std::to_string(j));
-                    builder.addInputArc(failedNodes[dftPand->children().at(j)->id()], tfs);
-                    builder.addOutputArc(tfs, failedNodes[dftPand->children().at(j)->id()]);
-                    builder.addInhibitionArc(failedNodes[dftPand->children().at(j-1)->id()], tfs);
-                    builder.addOutputArc(tfs, nodeFS);
-                    builder.addInhibitionArc(nodeFS, tfs);
-
+                    if (isRepresentative) {
+                        builder.addOutputArc(tNodeFailed, nodeFailed);
+                    }
+                    for(auto const& child : dftPand->children()) {
+                        builder.addInputArc(failedNodes[child->id()], tNodeFailed);
+                        builder.addOutputArc(tNodeFailed, failedNodes[child->id()]);
+                    }
+                    for (uint64_t j = 1; j < dftPand->nrChildren(); ++j) {
+                        uint64_t tfs = builder.addImmediateTransition(getFailPriority(dftPand), 0.0, dftPand->name() + STR_FAILSAVING + std::to_string(j));
+                        builder.addInputArc(failedNodes[dftPand->children().at(j)->id()], tfs);
+                        builder.addOutputArc(tfs, failedNodes[dftPand->children().at(j)->id()]);
+                        builder.addInhibitionArc(failedNodes[dftPand->children().at(j-1)->id()], tfs);
+                        builder.addOutputArc(tfs, nodeFS);
+                        builder.addInhibitionArc(nodeFS, tfs);
+                        
+                    }
+                } else {
+                    STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "NOt yet implemented");
                 }
             }
 //			
@@ -318,6 +323,7 @@ namespace storm {
 			template <typename ValueType>
             void DftToGspnTransformator<ValueType>::drawPOR(std::shared_ptr<storm::storage::DFTPor<ValueType> const> dftPor, bool isRepresentative) {
                 uint64_t nodeFailed = builder.addPlace(defaultCapacity, 0, dftPor->name() + STR_FAILED);
+                failedNodes.push_back(nodeFailed);
                 uint64_t nodeFS = builder.addPlace(defaultCapacity, 0, dftPor->name() + STR_FAILSAVE);
                 
                 
@@ -329,11 +335,15 @@ namespace storm {
                 builder.addInhibitionArc(nodeFailed, tfail);
                 uint64_t j = 0;
                 for (auto const& child : dftPor->children()) {
-                    uint64_t tfailsf = builder.addImmediateTransition(getFailPriority(dftPor), 0.0, dftPor->name() + STR_FAILSAVING + std::to_string(j));
-                    builder.addInputArc(failedNodes.at(child->id()), tfailsf);
-                    builder.addOutputArc(tfailsf, failedNodes.at(child->id()));
-                    // TODO
-//                    builder.addInhibitionArc(<#const uint_fast64_t &from#>, <#const uint_fast64_t &to#>)
+                    if(j > 0) {
+                        uint64_t tfailsf = builder.addImmediateTransition(getFailPriority(dftPor), 0.0, dftPor->name() + STR_FAILSAVING + std::to_string(j));
+                        builder.addInputArc(failedNodes.at(child->id()), tfailsf);
+                        builder.addOutputArc(tfailsf, failedNodes.at(child->id()));
+                        builder.addOutputArc(tfailsf, nodeFS);
+                        builder.addInhibitionArc(nodeFS, tfailsf);
+                        builder.addInhibitionArc(failedNodes.at(dftPor->children().front()->id()), tfailsf);
+                    }
+                    
                     ++j;
                 }
 			}

From fac77c0a3eac62f4a6873733de2b1468af3964c9 Mon Sep 17 00:00:00 2001
From: Sebastian Junges <sebastian.junges@rwth-aachen.de>
Date: Wed, 14 Dec 2016 23:14:54 +0100
Subject: [PATCH 24/47] fixed seq, now correct...

---
 .../transformations/DftToGspnTransformator.cpp        | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/storm-dft/transformations/DftToGspnTransformator.cpp b/src/storm-dft/transformations/DftToGspnTransformator.cpp
index ccfa5bdf4..4a4432f78 100644
--- a/src/storm-dft/transformations/DftToGspnTransformator.cpp
+++ b/src/storm-dft/transformations/DftToGspnTransformator.cpp
@@ -376,18 +376,21 @@ namespace storm {
             template <typename ValueType>
             void DftToGspnTransformator<ValueType>::drawSeq(std::shared_ptr<storm::storage::DFTSeq<ValueType> const> dftSeq) {
                 STORM_LOG_THROW(dftSeq->allChildrenBEs(), storm::exceptions::NotImplementedException, "Sequence enforcers with gates as children are currently not supported");
-                bool first = true;
+                uint64_t j = 0;
                 uint64_t tEnable = 0;
                 uint64_t nextPlace = 0;
                 for(auto const& child : dftSeq->children()) {
-                    nextPlace = builder.addPlace(defaultCapacity, first ? 1 : 0, dftSeq->name() + "_next_" + child->name());
-                    if(!first) {
+                    nextPlace = builder.addPlace(defaultCapacity, j==0 ? 1 : 0, dftSeq->name() + "_next_" + child->name());
+                    if (j>0) {
                         builder.addOutputArc(tEnable, nextPlace);
                     }
                     tEnable = builder.addImmediateTransition(defaultPriority, 0.0, dftSeq->name() + "_unblock_" +child->name() );
                     builder.addInputArc(nextPlace, tEnable);
                     builder.addInputArc(disabledNodes.at(child->id()), tEnable);
-                    first = false;
+                    if (j>0) {
+                        builder.addInputArc(failedNodes.at(dftSeq->children().at(j-1)->id()), tEnable);
+                    }
+                    ++j;
                 }
                 
             }

From 9c5444e059623d2654ebc0749578a489c2c7993d Mon Sep 17 00:00:00 2001
From: Sebastian Junges <sebastian.junges@rwth-aachen.de>
Date: Wed, 14 Dec 2016 23:44:19 +0100
Subject: [PATCH 25/47] better inclusive/exclusive support, including parsing

---
 src/storm-dft/parser/DFTGalileoParser.cpp    | 8 ++++++++
 src/storm-dft/storage/dft/DFTBuilder.h       | 9 +++++++++
 src/storm-dft/storage/dft/elements/DFTPand.h | 6 +++++-
 src/storm-dft/storage/dft/elements/DFTPor.h  | 9 +++++++--
 4 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/src/storm-dft/parser/DFTGalileoParser.cpp b/src/storm-dft/parser/DFTGalileoParser.cpp
index ec0b446d9..f872f4526 100644
--- a/src/storm-dft/parser/DFTGalileoParser.cpp
+++ b/src/storm-dft/parser/DFTGalileoParser.cpp
@@ -110,8 +110,16 @@ namespace storm {
                         success = builder.addVotElement(name, threshold, childNames);
                     } else if (tokens[1] == "pand") {
                         success = builder.addPandElement(name, childNames);
+                    } else if (tokens[1] == "pand-inc") {
+                        success = builder.addPandElement(name, childNames, true);
+                    } else if (tokens[1] == "pand-ex") {
+                        success = builder.addPandElement(name, childNames, false);
                     } else if (tokens[1] == "por") {
                         success = builder.addPorElement(name, childNames);
+                    } else if (tokens[1] == "por-ex") {
+                        success = builder.addPorElement(name, childNames, false);
+                    } else if (tokens[1] == "por-inc") {
+                        success = builder.addPorElement(name, childNames, true);
                     } else if (tokens[1] == "wsp" || tokens[1] == "csp") {
                         success = builder.addSpareElement(name, childNames);
                     } else if (tokens[1] == "seq") {
diff --git a/src/storm-dft/storage/dft/DFTBuilder.h b/src/storm-dft/storage/dft/DFTBuilder.h
index 55c1cb588..fbec0943e 100644
--- a/src/storm-dft/storage/dft/DFTBuilder.h
+++ b/src/storm-dft/storage/dft/DFTBuilder.h
@@ -53,6 +53,7 @@ namespace storm {
             
             bool addPandElement(std::string const& name, std::vector<std::string> const& children, bool inclusive) {
                 bool tmpDefault = pandDefaultInclusive;
+                pandDefaultInclusive = inclusive;
                 bool result = addStandardGate(name, children, DFTElementType::PAND);
                 pandDefaultInclusive = tmpDefault;
                 return result;
@@ -62,6 +63,14 @@ namespace storm {
                 return addStandardGate(name, children, DFTElementType::POR);
             }
             
+            bool addPorElement(std::string const& name, std::vector<std::string> const& children, bool inclusive) {
+                bool tmpDefault = porDefaultInclusive;
+                porDefaultInclusive = inclusive;
+                bool result = addStandardGate(name, children, DFTElementType::POR);
+                pandDefaultInclusive = tmpDefault;
+                return result;
+            }
+            
             bool addSpareElement(std::string const& name, std::vector<std::string> const& children) {
                 return addStandardGate(name, children, DFTElementType::SPARE);
             }
diff --git a/src/storm-dft/storage/dft/elements/DFTPand.h b/src/storm-dft/storage/dft/elements/DFTPand.h
index d89e357b1..8e5e2716a 100644
--- a/src/storm-dft/storage/dft/elements/DFTPand.h
+++ b/src/storm-dft/storage/dft/elements/DFTPand.h
@@ -50,7 +50,11 @@ namespace storm {
             }
             
             std::string typestring() const override {
-                return "PAND" + inclusive ? "" : "-ex";
+                if (inclusive) {
+                    return "PAND-inc";
+                } else {
+                    return "PAND-ex";
+                }
             }
         protected:
             bool inclusive;
diff --git a/src/storm-dft/storage/dft/elements/DFTPor.h b/src/storm-dft/storage/dft/elements/DFTPor.h
index 3adaf16fc..565b5dacd 100644
--- a/src/storm-dft/storage/dft/elements/DFTPor.h
+++ b/src/storm-dft/storage/dft/elements/DFTPor.h
@@ -42,10 +42,15 @@ namespace storm {
             }
             
             std::string  typestring() const override {
-                return "POR" + inclusive ? "" : "-ex";
+                if (inclusive) {
+                    return "POR-inc";
+                } else {
+                    return "POR-ex";
+                }
+                
             }
             
-            bool isInclusive() {
+            bool isInclusive() const {
                 return inclusive;
             }
         protected:

From c718b1caef03fe8ba7684d8a367c1fd6ec8b74a7 Mon Sep 17 00:00:00 2001
From: Sebastian Junges <sebastian.junges@rwth-aachen.de>
Date: Wed, 14 Dec 2016 23:44:55 +0100
Subject: [PATCH 26/47] dft-por exclusive added; also ensured that PORs work
 under SPAREs

---
 .../DftToGspnTransformator.cpp                | 50 +++++++++++++------
 1 file changed, 36 insertions(+), 14 deletions(-)

diff --git a/src/storm-dft/transformations/DftToGspnTransformator.cpp b/src/storm-dft/transformations/DftToGspnTransformator.cpp
index 4a4432f78..6d22c8184 100644
--- a/src/storm-dft/transformations/DftToGspnTransformator.cpp
+++ b/src/storm-dft/transformations/DftToGspnTransformator.cpp
@@ -324,28 +324,50 @@ namespace storm {
             void DftToGspnTransformator<ValueType>::drawPOR(std::shared_ptr<storm::storage::DFTPor<ValueType> const> dftPor, bool isRepresentative) {
                 uint64_t nodeFailed = builder.addPlace(defaultCapacity, 0, dftPor->name() + STR_FAILED);
                 failedNodes.push_back(nodeFailed);
-                uint64_t nodeFS = builder.addPlace(defaultCapacity, 0, dftPor->name() + STR_FAILSAVE);
                 
+                uint64_t unavailableNode = 0;
+                if (!smart || isRepresentative) {
+                    unavailableNode = addUnavailableNode(dftPor);
+                }
                 
                 uint64_t tfail = builder.addImmediateTransition(getFailPriority(dftPor), 0.0, dftPor->name() + STR_FAILING);
-                builder.addInhibitionArc(nodeFS, tfail);
-                builder.addInputArc(failedNodes.at(dftPor->children().front()->id()), tfail);
-                builder.addOutputArc(tfail, failedNodes.at(dftPor->children().front()->id()));
                 builder.addOutputArc(tfail, nodeFailed);
                 builder.addInhibitionArc(nodeFailed, tfail);
-                uint64_t j = 0;
-                for (auto const& child : dftPor->children()) {
-                    if(j > 0) {
-                        uint64_t tfailsf = builder.addImmediateTransition(getFailPriority(dftPor), 0.0, dftPor->name() + STR_FAILSAVING + std::to_string(j));
-                        builder.addInputArc(failedNodes.at(child->id()), tfailsf);
-                        builder.addOutputArc(tfailsf, failedNodes.at(child->id()));
-                        builder.addOutputArc(tfailsf, nodeFS);
-                        builder.addInhibitionArc(nodeFS, tfailsf);
-                        builder.addInhibitionArc(failedNodes.at(dftPor->children().front()->id()), tfailsf);
+                
+                builder.addInputArc(failedNodes.at(dftPor->children().front()->id()), tfail);
+                builder.addOutputArc(tfail, failedNodes.at(dftPor->children().front()->id()));
+                
+                if(!smart || isRepresentative) {
+                    builder.addOutputArc(tfail, unavailableNode);
+                }
+                
+                if(dftPor->isInclusive()) {
+                    uint64_t nodeFS = builder.addPlace(defaultCapacity, 0, dftPor->name() + STR_FAILSAVE);
+                    builder.addInhibitionArc(nodeFS, tfail);
+                    uint64_t j = 0;
+                    for (auto const& child : dftPor->children()) {
+                        if(j > 0) {
+                            uint64_t tfailsf = builder.addImmediateTransition(getFailPriority(dftPor), 0.0, dftPor->name() + STR_FAILSAVING + std::to_string(j));
+                            builder.addInputArc(failedNodes.at(child->id()), tfailsf);
+                            builder.addOutputArc(tfailsf, failedNodes.at(child->id()));
+                            builder.addOutputArc(tfailsf, nodeFS);
+                            builder.addInhibitionArc(nodeFS, tfailsf);
+                            builder.addInhibitionArc(failedNodes.at(dftPor->children().front()->id()), tfailsf);
+                        }
+                        
+                        ++j;
+                    }
+                } else {
+                    uint64_t j = 0;
+                    for (auto const& child : dftPor->children()) {
+                        if(j > 0) {
+                            builder.addInhibitionArc(failedNodes.at(child->id()), tfail);
+                        }
+                        ++j;
                     }
                     
-                    ++j;
                 }
+                
 			}
             
 //			

From 44082fbc37ba9d0a514c8c8fa485a89bc5178f9a Mon Sep 17 00:00:00 2001
From: Sebastian Junges <sebastian.junges@rwth-aachen.de>
Date: Thu, 15 Dec 2016 00:08:00 +0100
Subject: [PATCH 27/47] pand-ex support

---
 .../DftToGspnTransformator.cpp                | 40 +++++++++++++++----
 1 file changed, 32 insertions(+), 8 deletions(-)

diff --git a/src/storm-dft/transformations/DftToGspnTransformator.cpp b/src/storm-dft/transformations/DftToGspnTransformator.cpp
index 6d22c8184..9028db24c 100644
--- a/src/storm-dft/transformations/DftToGspnTransformator.cpp
+++ b/src/storm-dft/transformations/DftToGspnTransformator.cpp
@@ -229,20 +229,22 @@ namespace storm {
                 assert(failedNodes.size() == dftPand->id());
                 failedNodes.push_back(nodeFailed);
                 uint64_t unavailableNode = 0;
-                if (isRepresentative) {
+                if (!smart || isRepresentative) {
                     unavailableNode = addUnavailableNode(dftPand);
                 }
                 
+                uint64_t tNodeFailed = builder.addImmediateTransition(getFailPriority(dftPand), 0.0,  dftPand->name() + STR_FAILING);
+                builder.addInhibitionArc(nodeFailed, tNodeFailed);
+                builder.addOutputArc(tNodeFailed, nodeFailed);
+                if (!smart || isRepresentative) {
+                    builder.addOutputArc(tNodeFailed, nodeFailed);
+                }
+                
+                
                 if(dftPand->isInclusive()) {
                     
                     uint64_t nodeFS = builder.addPlace(defaultCapacity, 0, dftPand->name() + STR_FAILSAVE);
-                    uint64_t tNodeFailed = builder.addImmediateTransition(getFailPriority(dftPand), 0.0,  dftPand->name() + STR_FAILING);
-                    builder.addInhibitionArc(nodeFailed, tNodeFailed);
                     builder.addInhibitionArc(nodeFS, tNodeFailed);
-                    builder.addOutputArc(tNodeFailed, nodeFailed);
-                    if (isRepresentative) {
-                        builder.addOutputArc(tNodeFailed, nodeFailed);
-                    }
                     for(auto const& child : dftPand->children()) {
                         builder.addInputArc(failedNodes[child->id()], tNodeFailed);
                         builder.addOutputArc(tNodeFailed, failedNodes[child->id()]);
@@ -257,7 +259,29 @@ namespace storm {
                         
                     }
                 } else {
-                    STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "NOt yet implemented");
+                    uint64_t fi = 0;
+                    uint64_t tn = 0;
+                    for(uint64_t j = 0; j < dftPand->nrChildren(); ++j) {
+                        auto const& child = dftPand->children()[j];
+                        if (j > 0) {
+                            builder.addInhibitionArc(failedNodes.at(child->id()), tn);
+                        }
+                        if (j != dftPand->nrChildren() - 1) {
+                            tn = builder.addImmediateTransition(getFailPriority(dftPand), 0.0, dftPand->name() + STR_FAILING + "_" +std::to_string(j));
+                        } else {
+                            tn = tNodeFailed;
+                        }
+                        builder.addInputArc(failedNodes.at(child->id()), tn);
+                        builder.addOutputArc(tn, failedNodes.at(child->id()));
+                        if (j > 0) {
+                            builder.addInputArc(fi, tn);
+                        }
+                        if (j != dftPand->nrChildren() - 1) {
+                            fi = builder.addPlace(defaultCapacity, 0, dftPand->name() + "_F_" + std::to_string(j));
+                            builder.addOutputArc(tn, fi);
+                        }
+                        
+                    }
                 }
             }
 //			

From ec060a59b274b9a8d0a0ea012c14c48eb6b5d06a Mon Sep 17 00:00:00 2001
From: Matthias Volk <matthias.volk@cs.rwth-aachen.de>
Date: Thu, 15 Dec 2016 00:23:42 +0100
Subject: [PATCH 28/47] Fixed warnings

---
 src/storm-dft/storage/dft/elements/DFTPand.h | 2 +-
 src/storm-dft/storage/dft/elements/DFTPor.h  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/storm-dft/storage/dft/elements/DFTPand.h b/src/storm-dft/storage/dft/elements/DFTPand.h
index d89e357b1..9879b8c31 100644
--- a/src/storm-dft/storage/dft/elements/DFTPand.h
+++ b/src/storm-dft/storage/dft/elements/DFTPand.h
@@ -50,7 +50,7 @@ namespace storm {
             }
             
             std::string typestring() const override {
-                return "PAND" + inclusive ? "" : "-ex";
+                return inclusive ? "PAND" : "PAND-ex";
             }
         protected:
             bool inclusive;
diff --git a/src/storm-dft/storage/dft/elements/DFTPor.h b/src/storm-dft/storage/dft/elements/DFTPor.h
index 3adaf16fc..7fd168b33 100644
--- a/src/storm-dft/storage/dft/elements/DFTPor.h
+++ b/src/storm-dft/storage/dft/elements/DFTPor.h
@@ -42,7 +42,7 @@ namespace storm {
             }
             
             std::string  typestring() const override {
-                return "POR" + inclusive ? "" : "-ex";
+                return inclusive ? "POR" : "POR-ex";
             }
             
             bool isInclusive() {

From a6cf0d2e0d2f91c9dab8b2e35854908d8481109d Mon Sep 17 00:00:00 2001
From: Matthias Volk <matthias.volk@cs.rwth-aachen.de>
Date: Thu, 15 Dec 2016 00:37:50 +0100
Subject: [PATCH 29/47] Fixed typo

---
 src/storm-dft/storage/dft/elements/DFTPand.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/storm-dft/storage/dft/elements/DFTPand.h b/src/storm-dft/storage/dft/elements/DFTPand.h
index 9879b8c31..233dbc651 100644
--- a/src/storm-dft/storage/dft/elements/DFTPand.h
+++ b/src/storm-dft/storage/dft/elements/DFTPand.h
@@ -33,7 +33,7 @@ namespace storm {
             }
 
             void checkFailsafe(storm::storage::DFTState<ValueType>& state, DFTStateSpaceGenerationQueues<ValueType>& queues) const override {
-                bool(inclusive);
+                assert(inclusive);
                 STORM_LOG_ASSERT(this->hasFailsafeChild(state), "No failsafe child.");
                 if(state.isOperational(this->mId)) {
                     this->failsafe(state, queues);

From 63d594fb45decd7cd590104253f64a9a8868252b Mon Sep 17 00:00:00 2001
From: Matthias Volk <matthias.volk@cs.rwth-aachen.de>
Date: Thu, 15 Dec 2016 00:48:58 +0100
Subject: [PATCH 30/47] Rudimentary DFT parser from Cytoscape's JSON

---
 src/storm-dft-cli/storm-dyftee.cpp            |  17 +-
 src/storm-dft/parser/DFTJsonParser.cpp        | 168 ++++++++++++++++++
 src/storm-dft/parser/DFTJsonParser.h          |  48 +++++
 .../settings/modules/DFTSettings.cpp          |  14 +-
 src/storm-dft/settings/modules/DFTSettings.h  |  16 ++
 src/storm-dft/storage/dft/DFT.h               |  15 +-
 src/storm-dft/storage/dft/DFTBuilder.cpp      |  10 +-
 src/storm-dft/storage/dft/DFTBuilder.h        |   8 +-
 src/storm-dft/storage/dft/DFTLayoutInfo.h     |  15 ++
 .../DftToGspnTransformator.cpp                |   8 +-
 10 files changed, 304 insertions(+), 15 deletions(-)
 create mode 100644 src/storm-dft/parser/DFTJsonParser.cpp
 create mode 100644 src/storm-dft/parser/DFTJsonParser.h
 create mode 100644 src/storm-dft/storage/dft/DFTLayoutInfo.h

diff --git a/src/storm-dft-cli/storm-dyftee.cpp b/src/storm-dft-cli/storm-dyftee.cpp
index 7be07940c..37b048b96 100644
--- a/src/storm-dft-cli/storm-dyftee.cpp
+++ b/src/storm-dft-cli/storm-dyftee.cpp
@@ -15,6 +15,7 @@
 #include "storm/settings/modules/EliminationSettings.h"
 
 #include "storm-dft/parser/DFTGalileoParser.h"
+#include "storm-dft/parser/DFTJsonParser.h"
 #include "storm-dft/modelchecker/dft/DFTModelChecker.h"
 #include "storm-dft/modelchecker/dft/DFTASFChecker.h"
 #include "storm-dft/transformations/DftToGspnTransformator.h"
@@ -29,6 +30,7 @@
 
 
 #include <boost/lexical_cast.hpp>
+#include <memory>
 
 /*!
  * Load DFT from filename, build corresponding Model and check against given property.
@@ -123,16 +125,21 @@ int main(const int argc, const char** argv) {
         
         storm::settings::modules::DFTSettings const& dftSettings = storm::settings::getModule<storm::settings::modules::DFTSettings>();
         storm::settings::modules::GeneralSettings const& generalSettings = storm::settings::getModule<storm::settings::modules::GeneralSettings>();
-        if (!dftSettings.isDftFileSet()) {
+        if (!dftSettings.isDftFileSet() && !dftSettings.isDftJsonFileSet()) {
             STORM_LOG_THROW(false, storm::exceptions::InvalidSettingsException, "No input model.");
         }
 
         
         if (dftSettings.isTransformToGspn()) {
-            
-            storm::parser::DFTGalileoParser<double> parser;
-            storm::storage::DFT<double> dft = parser.parseDFT(dftSettings.getDftFilename());
-            storm::transformations::dft::DftToGspnTransformator<double> gspnTransformator(dft);
+            std::shared_ptr<storm::storage::DFT<double>> dft;
+            if (dftSettings.isDftJsonFileSet()) {
+                storm::parser::DFTJsonParser<double> parser;
+                dft = std::make_shared<storm::storage::DFT<double>>(parser.parseJson(dftSettings.getDftJsonFilename()));
+            } else {
+                storm::parser::DFTGalileoParser<double> parser;
+                dft = std::make_shared<storm::storage::DFT<double>>(parser.parseDFT(dftSettings.getDftFilename()));
+            }
+            storm::transformations::dft::DftToGspnTransformator<double> gspnTransformator(*dft);
             gspnTransformator.transform();
             storm::gspn::GSPN* gspn = gspnTransformator.obtainGSPN();
             uint64_t toplevelFailedPlace = gspnTransformator.toplevelFailedPlaceId();
diff --git a/src/storm-dft/parser/DFTJsonParser.cpp b/src/storm-dft/parser/DFTJsonParser.cpp
new file mode 100644
index 000000000..4bedbe7ac
--- /dev/null
+++ b/src/storm-dft/parser/DFTJsonParser.cpp
@@ -0,0 +1,168 @@
+#include "DFTJsonParser.h"
+
+#include <iostream>
+#include <fstream>
+#include <boost/algorithm/string.hpp>
+#include <boost/lexical_cast.hpp>
+#include <boost/algorithm/string/replace.hpp>
+#include "storm/storage/expressions/ExpressionManager.h"
+#include "storm/exceptions/NotImplementedException.h"
+#include "storm/exceptions/FileIoException.h"
+#include "storm/exceptions/NotSupportedException.h"
+#include "storm/utility/macros.h"
+
+namespace storm {
+    namespace parser {
+
+        template<typename ValueType>
+        storm::storage::DFT<ValueType> DFTJsonParser<ValueType>::parseJson(const std::string& filename) {
+            readFile(filename);
+            storm::storage::DFT<ValueType> dft = builder.build();
+            STORM_LOG_DEBUG("Elements:" << std::endl << dft.getElementsString());
+            STORM_LOG_DEBUG("Spare Modules:" << std::endl << dft.getSpareModulesString());
+            return dft;
+        }
+
+        template<typename ValueType>
+        std::string DFTJsonParser<ValueType>::stripQuotsFromName(std::string const& name) {
+            size_t firstQuots = name.find("\"");
+            size_t secondQuots = name.find("\"", firstQuots+1);
+            
+            if(firstQuots == std::string::npos) {
+                return name;
+            } else {
+                STORM_LOG_THROW(secondQuots != std::string::npos, storm::exceptions::FileIoException, "No ending quotation mark found in " << name);
+                return name.substr(firstQuots+1,secondQuots-1);
+            }
+        }
+
+        template<typename ValueType>
+        std::string DFTJsonParser<ValueType>::getString(json const& structure, std::string const& errorInfo) {
+            STORM_LOG_THROW(structure.is_string(), storm::exceptions::FileIoException, "Expected a string in " << errorInfo << ", got '" << structure.dump() << "'");
+            return structure.front();
+        }
+
+        template<typename ValueType>
+        std::string DFTJsonParser<ValueType>::parseNodeIdentifier(std::string const& name) {
+            return boost::replace_all_copy(name, "'", "__prime__");
+        }
+
+        template<typename ValueType>
+        void DFTJsonParser<ValueType>::readFile(const std::string& filename) {
+            std::cout << "Parsing from JSON" << std::endl;
+
+            std::ifstream file;
+            file.exceptions ( std::ifstream::failbit );
+            try {
+                file.open(filename);
+            }
+            catch (std::ifstream::failure e) {
+                STORM_LOG_THROW(false, storm::exceptions::FileIoException, "Exception during file opening on " << filename << ".");
+                return;
+            }
+            file.exceptions( std::ifstream::goodbit );
+
+            json parsedJson;
+            parsedJson << file;
+            file.close();
+
+            // Start by building mapping from ids to names
+            std::map<std::string, std::string> nameMapping;
+            for (auto& element: parsedJson) {
+                if (element.at("classes") != "") {
+                    json data = element.at("data");
+                    std::string id = data.at("id");
+                    std::string name = data.at("name");
+                    nameMapping[id] = name;
+                }
+            }
+
+            // TODO: avoid hack
+            std::string toplevelId = nameMapping["1"];
+
+            for (auto& element : parsedJson) {
+                std::cout << element << std::endl;
+
+                bool success = true;
+                if (element.at("classes") == "") {
+                    continue;
+                }
+                json data = element.at("data");
+                std::string name = data.at("name");
+                std::vector<std::string> childNames;
+                if (data.count("children") > 0) {
+                    for (auto& child : data.at("children")) {
+                        childNames.push_back(nameMapping[child]);
+                    }
+                }
+
+                std::string type = getString(element.at("classes"), "classes");
+
+                if(type == "and") {
+                    success = builder.addAndElement(name, childNames);
+                } else if (type == "or") {
+                    success = builder.addOrElement(name, childNames);
+                } else if (type == "pand") {
+                    success = builder.addPandElement(name, childNames);
+                } else if (type == "por") {
+                    success = builder.addPorElement(name, childNames);
+                } else if (type == "spare") {
+                    success = builder.addSpareElement(name, childNames);
+                } else if (type == "seq") {
+                    success = builder.addSequenceEnforcer(name, childNames);
+                } else if (type== "fdep") {
+                    success = builder.addDepElement(name, childNames, storm::utility::one<ValueType>());
+                } else if (type== "pdep") {
+                    ValueType probability = parseRationalExpression(data.at("prob"));
+                    success = builder.addDepElement(name, childNames, probability);
+                } else if (type == "be") {
+                    ValueType failureRate = parseRationalExpression(data.at("rate"));
+                    ValueType dormancyFactor = parseRationalExpression(data.at("dorm"));
+                    success = builder.addBasicElement(name, failureRate, dormancyFactor);
+                } else {
+                    STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Type name: " << type << "  not recognized.");
+                    success = false;
+                }
+
+                json position = element.at("position");
+                double x = position.at("x");
+                double y = position.at("y");
+                builder.addLayoutInfo(name, x, y);
+                STORM_LOG_THROW(success, storm::exceptions::FileIoException, "Error while adding element '" << element << "'.");
+            }
+
+            if(!builder.setTopLevel(toplevelId)) {
+                STORM_LOG_THROW(false, storm::exceptions::FileIoException, "Top level id unknown.");
+            }
+        }
+
+        template<typename ValueType>
+        ValueType DFTJsonParser<ValueType>::parseRationalExpression(std::string const& expr) {
+            STORM_LOG_ASSERT(false, "Specialized method should be called.");
+            return 0;
+        }
+
+        template<>
+        double DFTJsonParser<double>::parseRationalExpression(std::string const& expr) {
+            return boost::lexical_cast<double>(expr);
+        }
+
+        // Explicitly instantiate the class.
+        template class DFTJsonParser<double>;
+
+#ifdef STORM_HAVE_CARL
+        template<>
+        storm::RationalFunction DFTJsonParser<storm::RationalFunction>::parseRationalExpression(std::string const& expr) {
+            STORM_LOG_TRACE("Translating expression: " << expr);
+            storm::expressions::Expression expression = parser.parseFromString(expr);
+            STORM_LOG_TRACE("Expression: " << expression);
+            storm::RationalFunction rationalFunction = evaluator.asRational(expression);
+            STORM_LOG_TRACE("Parsed expression: " << rationalFunction);
+            return rationalFunction;
+        }
+
+        template class DFTJsonParser<RationalFunction>;
+#endif
+        
+    }
+}
diff --git a/src/storm-dft/parser/DFTJsonParser.h b/src/storm-dft/parser/DFTJsonParser.h
new file mode 100644
index 000000000..cf2e83826
--- /dev/null
+++ b/src/storm-dft/parser/DFTJsonParser.h
@@ -0,0 +1,48 @@
+#pragma  once
+
+#include <map>
+
+#include "storm/storage/expressions/ExpressionManager.h"
+#include "storm/parser/ExpressionParser.h"
+#include "storm/storage/expressions/ExpressionEvaluator.h"
+
+#include "storm-dft/storage/dft/DFT.h"
+#include "storm-dft/storage/dft/DFTBuilder.h"
+
+// JSON parser
+#include "json.hpp"
+
+using json = nlohmann::json;
+
+namespace storm {
+    namespace parser {
+
+        template<typename ValueType>
+        class DFTJsonParser {
+            storm::storage::DFTBuilder<ValueType> builder;
+
+            std::shared_ptr<storm::expressions::ExpressionManager> manager;
+
+            storm::parser::ExpressionParser parser;
+
+            storm::expressions::ExpressionEvaluator<ValueType> evaluator;
+
+            std::unordered_map<std::string, storm::expressions::Expression> identifierMapping;
+
+        public:
+            DFTJsonParser() : manager(new storm::expressions::ExpressionManager()), parser(*manager), evaluator(*manager) {
+            }
+
+            storm::storage::DFT<ValueType> parseJson(std::string const& filename);
+            
+        private:
+            void readFile(std::string const& filename);
+
+            std::string stripQuotsFromName(std::string const& name);
+            std::string parseNodeIdentifier(std::string const& name);
+            std::string getString(json const& structure, std::string const& errorInfo);
+
+            ValueType parseRationalExpression(std::string const& expr);
+        };
+    }
+}
diff --git a/src/storm-dft/settings/modules/DFTSettings.cpp b/src/storm-dft/settings/modules/DFTSettings.cpp
index 5bf705d8a..898360c4b 100644
--- a/src/storm-dft/settings/modules/DFTSettings.cpp
+++ b/src/storm-dft/settings/modules/DFTSettings.cpp
@@ -16,6 +16,8 @@ namespace storm {
             const std::string DFTSettings::moduleName = "dft";
             const std::string DFTSettings::dftFileOptionName = "dftfile";
             const std::string DFTSettings::dftFileOptionShortName = "dft";
+            const std::string DFTSettings::dftJsonFileOptionName = "dftfile-json";
+            const std::string DFTSettings::dftJsonFileOptionShortName = "dftjson";
             const std::string DFTSettings::symmetryReductionOptionName = "symmetryreduction";
             const std::string DFTSettings::symmetryReductionOptionShortName = "symred";
             const std::string DFTSettings::modularisationOptionName = "modularisation";
@@ -37,6 +39,8 @@ namespace storm {
             DFTSettings::DFTSettings() : ModuleSettings(moduleName) {
                 this->addOption(storm::settings::OptionBuilder(moduleName, dftFileOptionName, false, "Parses the model given in the Galileo format.").setShortName(dftFileOptionShortName)
                                 .addArgument(storm::settings::ArgumentBuilder::createStringArgument("filename", "The name of the file from which to read the DFT model.").addValidationFunctionString(storm::settings::ArgumentValidators::existingReadableFileValidator()).build()).build());
+                this->addOption(storm::settings::OptionBuilder(moduleName, dftJsonFileOptionName, false, "Parses the model given in the Cytoscape JSON format.").setShortName(dftJsonFileOptionShortName)
+                                .addArgument(storm::settings::ArgumentBuilder::createStringArgument("filename", "The name of the JSON file from which to read the DFT model.").addValidationFunctionString(storm::settings::ArgumentValidators::existingReadableFileValidator()).build()).build());
                 this->addOption(storm::settings::OptionBuilder(moduleName, symmetryReductionOptionName, false, "Exploit symmetric structure of model.").setShortName(symmetryReductionOptionShortName).build());
                 this->addOption(storm::settings::OptionBuilder(moduleName, modularisationOptionName, false, "Use modularisation (not applicable for expected time).").build());
                 this->addOption(storm::settings::OptionBuilder(moduleName, disableDCOptionName, false, "Disable Dont Care propagation.").build());
@@ -60,7 +64,15 @@ namespace storm {
             std::string DFTSettings::getDftFilename() const {
                 return this->getOption(dftFileOptionName).getArgumentByName("filename").getValueAsString();
             }
-            
+
+            bool DFTSettings::isDftJsonFileSet() const {
+                return this->getOption(dftJsonFileOptionName).getHasOptionBeenSet();
+            }
+
+            std::string DFTSettings::getDftJsonFilename() const {
+                return this->getOption(dftJsonFileOptionName).getArgumentByName("filename").getValueAsString();
+            }
+
             bool DFTSettings::useSymmetryReduction() const {
                 return this->getOption(symmetryReductionOptionName).getHasOptionBeenSet();
             }
diff --git a/src/storm-dft/settings/modules/DFTSettings.h b/src/storm-dft/settings/modules/DFTSettings.h
index 1b1b097f9..c1a9df7e5 100644
--- a/src/storm-dft/settings/modules/DFTSettings.h
+++ b/src/storm-dft/settings/modules/DFTSettings.h
@@ -34,6 +34,20 @@ namespace storm {
                  */
                 std::string getDftFilename() const;
 
+                /*!
+                 * Retrieves whether the dft file option for Json was set.
+                 *
+                 * @return True if the dft file option was set.
+                 */
+                bool isDftJsonFileSet() const;
+
+                /*!
+                 * Retrieves the name of the json file that contains the dft specification.
+                 *
+                 * @return The name of the json file that contains the dft specification.
+                 */
+                std::string getDftJsonFilename() const;
+
                 /*!
                  * Retrieves whether the option to use symmetry reduction is set.
                  *
@@ -144,6 +158,8 @@ namespace storm {
                // Define the string names of the options as constants.
                 static const std::string dftFileOptionName;
                 static const std::string dftFileOptionShortName;
+                static const std::string dftJsonFileOptionName;
+                static const std::string dftJsonFileOptionShortName;
                 static const std::string symmetryReductionOptionName;
                 static const std::string symmetryReductionOptionShortName;
                 static const std::string modularisationOptionName;
diff --git a/src/storm-dft/storage/dft/DFT.h b/src/storm-dft/storage/dft/DFT.h
index 9ef232a65..1304bbfa9 100644
--- a/src/storm-dft/storage/dft/DFT.h
+++ b/src/storm-dft/storage/dft/DFT.h
@@ -15,7 +15,7 @@
 #include "storm-dft/storage/dft/DFTElements.h"
 #include "storm-dft/storage/dft/SymmetricUnits.h"
 #include "storm-dft/storage/dft/DFTStateGenerationInfo.h"
-
+#include "storm-dft/storage/dft/DFTLayoutInfo.h"
 
 namespace storm {
     namespace storage {
@@ -63,7 +63,8 @@ namespace storm {
             std::vector<size_t> mTopModule;
             std::map<size_t, size_t> mRepresentants; // id element -> id representative
             std::vector<std::vector<size_t>> mSymmetries;
-            
+            std::map<size_t, DFTLayoutInfo> mLayoutInfo;
+
         public:
             DFT(DFTElementVector const& elements, DFTElementPointer const& tle);
             
@@ -263,7 +264,15 @@ namespace storm {
             std::vector<size_t> immediateFailureCauses(size_t index) const;
             
             std::vector<size_t> findModularisationRewrite() const;
-        
+
+            void setElementLayoutInfo(size_t id, DFTLayoutInfo const& layoutInfo) {
+                mLayoutInfo[id] = layoutInfo;
+            }
+
+            DFTLayoutInfo const& getElementLayoutInfo(size_t id) const {
+                return mLayoutInfo.at(id);
+            }
+
         private:
             std::pair<std::vector<size_t>, std::vector<size_t>> getSortedParentAndOutDepIds(size_t index) const;
             
diff --git a/src/storm-dft/storage/dft/DFTBuilder.cpp b/src/storm-dft/storage/dft/DFTBuilder.cpp
index 10c84f5f6..68ffce742 100644
--- a/src/storm-dft/storage/dft/DFTBuilder.cpp
+++ b/src/storm-dft/storage/dft/DFTBuilder.cpp
@@ -73,8 +73,16 @@ namespace storm {
             for(DFTElementPointer e : elems) {
                 e->setId(id++);
             }
+
             STORM_LOG_ASSERT(!mTopLevelIdentifier.empty(), "No top level element.");
-            return DFT<ValueType>(elems, mElements[mTopLevelIdentifier]);
+            DFT<ValueType> dft(elems, mElements[mTopLevelIdentifier]);
+
+            // Set layout info
+            for (auto& elem : mElements) {
+                dft.setElementLayoutInfo(elem.second->id(), mLayoutInfo.at(elem.first));
+            }
+
+            return dft;
         }
 
         template<typename ValueType>
diff --git a/src/storm-dft/storage/dft/DFTBuilder.h b/src/storm-dft/storage/dft/DFTBuilder.h
index 55c1cb588..baa9232a0 100644
--- a/src/storm-dft/storage/dft/DFTBuilder.h
+++ b/src/storm-dft/storage/dft/DFTBuilder.h
@@ -7,7 +7,7 @@
 
 #include "storm-dft/storage/dft/DFTElements.h"
 #include "storm-dft/storage/dft/elements/DFTRestriction.h"
-
+#include "storm-dft/storage/dft/DFTLayoutInfo.h"
 
 namespace storm {
     namespace storage {
@@ -33,6 +33,7 @@ namespace storm {
             std::unordered_map<DFTRestrictionPointer, std::vector<std::string>> mRestrictionChildNames;
             std::vector<DFTDependencyPointer> mDependencies;
             std::vector<DFTRestrictionPointer> mRestrictions;
+            std::unordered_map<std::string, DFTLayoutInfo> mLayoutInfo;
             
         public:
             DFTBuilder(bool defaultInclusive = true) : pandDefaultInclusive(defaultInclusive), porDefaultInclusive(defaultInclusive) {
@@ -154,6 +155,11 @@ namespace storm {
                 mElements[name] = std::make_shared<DFTBE<ValueType>>(mNextId++, name, failureRate, dormancyFactor);
                 return true;
             }
+
+            void addLayoutInfo(std::string const& name, double x, double y) {
+                STORM_LOG_ASSERT(mElements.count(name) > 0, "Element '" << name << "' not found.");
+                mLayoutInfo[name] = storm::storage::DFTLayoutInfo(x, y);
+            }
             
             bool setTopLevel(std::string const& tle) {
                 mTopLevelIdentifier = tle;
diff --git a/src/storm-dft/storage/dft/DFTLayoutInfo.h b/src/storm-dft/storage/dft/DFTLayoutInfo.h
new file mode 100644
index 000000000..c61de0f6d
--- /dev/null
+++ b/src/storm-dft/storage/dft/DFTLayoutInfo.h
@@ -0,0 +1,15 @@
+#pragma once
+
+namespace storm {
+    namespace storage {
+        struct DFTLayoutInfo {
+            DFTLayoutInfo() {};
+            DFTLayoutInfo(double x, double y) : x(x), y(y) {};
+            
+            // x location
+            double x = 0.0;
+            // y location
+            double y = 0.0;
+        };
+    }
+}
diff --git a/src/storm-dft/transformations/DftToGspnTransformator.cpp b/src/storm-dft/transformations/DftToGspnTransformator.cpp
index f3a113215..caed44166 100644
--- a/src/storm-dft/transformations/DftToGspnTransformator.cpp
+++ b/src/storm-dft/transformations/DftToGspnTransformator.cpp
@@ -90,8 +90,8 @@ namespace storm {
             
             template <typename ValueType>
             void DftToGspnTransformator<ValueType>::drawBE(std::shared_ptr<storm::storage::DFTBE<ValueType> const> dftBE, bool isRepresentative) {
-                double xcenter = 10.0;
-                double ycenter = 10.0;
+                double xcenter = mDft.getElementLayoutInfo(dftBE->id()).x;
+                double ycenter = mDft.getElementLayoutInfo(dftBE->id()).y;
 				uint64_t beActive = builder.addPlace(defaultCapacity, isBEActive(dftBE) ? 1 : 0, dftBE->name() + STR_ACTIVATED);
                 activeNodes.emplace(dftBE->id(), beActive);
                 uint64_t beFailed = builder.addPlace(defaultCapacity, 0, dftBE->name() + STR_FAILED);
@@ -137,8 +137,8 @@ namespace storm {
 			
 			template <typename ValueType>
             void DftToGspnTransformator<ValueType>::drawAND(std::shared_ptr<storm::storage::DFTAnd<ValueType> const> dftAnd, bool isRepresentative) {
-                double xcenter = 10.0;
-                double ycenter = 20.0;
+                double xcenter = mDft.getElementLayoutInfo(dftAnd->id()).x;
+                double ycenter = mDft.getElementLayoutInfo(dftAnd->id()).y;
                 uint64_t nodeFailed = builder.addPlace(defaultCapacity, 0, dftAnd->name() + STR_FAILED);
                 assert(failedNodes.size() == dftAnd->id());
                 failedNodes.push_back(nodeFailed);

From c2ea78b880a338c3a2408834830b39de1f9e2eb2 Mon Sep 17 00:00:00 2001
From: Sebastian Junges <sebastian.junges@rwth-aachen.de>
Date: Thu, 15 Dec 2016 00:54:24 +0100
Subject: [PATCH 31/47] no need anymore to create files from formulas if
 properties are present anyway

---
 src/storm/storage/jani/JSONExporter.cpp | 10 +++++-----
 src/storm/storage/jani/JSONExporter.h   |  8 +++++---
 src/storm/utility/storm.cpp             |  4 ++--
 3 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/src/storm/storage/jani/JSONExporter.cpp b/src/storm/storage/jani/JSONExporter.cpp
index 7548fd323..889496265 100644
--- a/src/storm/storage/jani/JSONExporter.cpp
+++ b/src/storm/storage/jani/JSONExporter.cpp
@@ -516,7 +516,7 @@ namespace storm {
         
         
         
-        void JsonExporter::toFile(storm::jani::Model const& janiModel, std::vector<std::shared_ptr<storm::logic::Formula const>> const& formulas, std::string const& filepath, bool checkValid) {
+        void JsonExporter::toFile(storm::jani::Model const& janiModel, std::vector<storm::jani::Property> const& formulas, std::string const& filepath, bool checkValid) {
             std::ofstream ofs;
             ofs.open (filepath, std::ofstream::out );
             if(ofs.is_open()) {
@@ -526,7 +526,7 @@ namespace storm {
             }
         }
         
-        void JsonExporter::toStream(storm::jani::Model const& janiModel,  std::vector<std::shared_ptr<storm::logic::Formula const>> const& formulas, std::ostream& os, bool checkValid) {
+        void JsonExporter::toStream(storm::jani::Model const& janiModel,  std::vector<storm::jani::Property> const& formulas, std::ostream& os, bool checkValid) {
             if(checkValid) {
                 janiModel.checkValid();
             }
@@ -759,13 +759,13 @@ namespace storm {
         }
         
         
-        void JsonExporter::convertProperties( std::vector<std::shared_ptr<storm::logic::Formula const>> const& formulas, storm::jani::Model const& model) {
+        void JsonExporter::convertProperties( std::vector<storm::jani::Property> const& formulas, storm::jani::Model const& model) {
             std::vector<modernjson::json> properties;
             uint64_t index = 0;
             for(auto const& f : formulas) {
                 modernjson::json propDecl;
-                propDecl["name"] = "prop" + std::to_string(index);
-                propDecl["expression"] = convertFilterExpression(storm::jani::FilterExpression(f), model);
+                propDecl["name"] = f.getName();
+                propDecl["expression"] = convertFilterExpression(f.getFilter(), model);
                 ++index;
                 properties.push_back(propDecl);
             }
diff --git a/src/storm/storage/jani/JSONExporter.h b/src/storm/storage/jani/JSONExporter.h
index 1008ec097..1eceb5d2e 100644
--- a/src/storm/storage/jani/JSONExporter.h
+++ b/src/storm/storage/jani/JSONExporter.h
@@ -4,6 +4,7 @@
 #include "storm/storage/expressions/ExpressionVisitor.h"
 #include "storm/logic/FormulaVisitor.h"
 #include "Model.h"
+#include "storm/storage/jani/Property.h"
 #include "storm/adapters/NumberAdapter.h"
 // JSON parser
 #include "json.hpp"
@@ -66,12 +67,13 @@ namespace storm {
             JsonExporter() = default;
             
         public:
-            static void toFile(storm::jani::Model const& janiModel, std::vector<std::shared_ptr<storm::logic::Formula const>> const& formulas, std::string const& filepath, bool checkValid = true);
-            static void toStream(storm::jani::Model const& janiModel, std::vector<std::shared_ptr<storm::logic::Formula const>> const& formulas, std::ostream& ostream, bool checkValid = false);
+            static void toFile(storm::jani::Model const& janiModel, std::vector<storm::jani::Property> const& formulas, std::string const& filepath, bool checkValid = true);
+            static void toStream(storm::jani::Model const& janiModel, std::vector<storm::jani::Property> const& formulas, std::ostream& ostream, bool checkValid = false);
+            
             
         private:
             void convertModel(storm::jani::Model const& model);
-            void convertProperties(std::vector<std::shared_ptr<storm::logic::Formula const>> const& formulas, storm::jani::Model const& model);
+            void convertProperties(std::vector<storm::jani::Property> const& formulas, storm::jani::Model const& model);
             void appendVariableDeclaration(storm::jani::Variable const& variable);
             
             modernjson::json finalize() {
diff --git a/src/storm/utility/storm.cpp b/src/storm/utility/storm.cpp
index 62c499fbd..9a0e6faba 100644
--- a/src/storm/utility/storm.cpp
+++ b/src/storm/utility/storm.cpp
@@ -36,9 +36,9 @@ namespace storm{
         if (storm::settings::getModule<storm::settings::modules::JaniExportSettings>().isExportAsStandardJaniSet()) {
             storm::jani::Model normalisedModel = model;
             normalisedModel.makeStandardJaniCompliant();
-            storm::jani::JsonExporter::toFile(normalisedModel, formulasInProperties(properties), filepath);
+            storm::jani::JsonExporter::toFile(normalisedModel, properties, filepath);
         } else {
-            storm::jani::JsonExporter::toFile(model, formulasInProperties(properties), filepath);
+            storm::jani::JsonExporter::toFile(model, properties, filepath);
         }
     }
 

From d379baef732d6cbd7389f41c5804709ed1adeedb Mon Sep 17 00:00:00 2001
From: sjunges <sebastian.junges@gmail.com>
Date: Thu, 15 Dec 2016 01:21:50 +0100
Subject: [PATCH 32/47] fix correct capit. to compile on linux

---
 src/storm-gspn/storm-gspn.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/storm-gspn/storm-gspn.h b/src/storm-gspn/storm-gspn.h
index 3a3f9d55a..63b0746f1 100644
--- a/src/storm-gspn/storm-gspn.h
+++ b/src/storm-gspn/storm-gspn.h
@@ -3,7 +3,7 @@
 #include "storm/storage/jani/Model.h"
 
 #include "storm-gspn/builder/JaniGSPNBuilder.h"
-#include "storm-gspn/storage/gspn/Gspn.h"
+#include "storm-gspn/storage/gspn/GSPN.h"
 
 #include "storm/settings/modules/GSPNExportSettings.h"
 

From 31efb4f0c97f1919fd7ad360addd1addeb82511d Mon Sep 17 00:00:00 2001
From: sjunges <sebastian.junges@gmail.com>
Date: Thu, 15 Dec 2016 01:26:35 +0100
Subject: [PATCH 33/47] prep for more formulas

---
 src/storm-dft-cli/storm-dyftee.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/storm-dft-cli/storm-dyftee.cpp b/src/storm-dft-cli/storm-dyftee.cpp
index 37b048b96..13f048a55 100644
--- a/src/storm-dft-cli/storm-dyftee.cpp
+++ b/src/storm-dft-cli/storm-dyftee.cpp
@@ -151,8 +151,9 @@ int main(const int argc, const char** argv) {
             storm::jani::Model* model =  builder.build();
             storm::jani::Variable const& topfailedVar = builder.getPlaceVariable(toplevelFailedPlace);
             
-            
-            auto evtlFormula = std::make_shared<storm::logic::AtomicExpressionFormula>(exprManager->integer(1) == topfailedVar.getExpressionVariable().getExpression());
+
+            storm::expressions::Expression targetExpression = exprManager->integer(1) == topfailedVar.getExpressionVariable().getExpression();
+            auto evtlFormula = std::make_shared<storm::logic::AtomicExpressionFormula>(targetExpression);
             auto tbFormula = std::make_shared<storm::logic::BoundedUntilFormula>(std::make_shared<storm::logic::BooleanLiteralFormula>(true), evtlFormula, 0.0, 10.0);
             auto tbUntil = std::make_shared<storm::logic::ProbabilityOperatorFormula>(tbFormula);
             

From a42703a49a47229cc5668e70a9b90b60a028d9a9 Mon Sep 17 00:00:00 2001
From: sjunges <sebastian.junges@gmail.com>
Date: Thu, 15 Dec 2016 01:27:03 +0100
Subject: [PATCH 34/47] towards support for n-ary pdeps

---
 src/storm-dft/storage/dft/DFTBuilder.cpp      | 32 ++++++++++++------
 src/storm-dft/storage/dft/DFTBuilder.h        | 33 ++++++++++++-------
 .../storage/dft/elements/DFTDependency.h      | 19 ++++-------
 3 files changed, 50 insertions(+), 34 deletions(-)

diff --git a/src/storm-dft/storage/dft/DFTBuilder.cpp b/src/storm-dft/storage/dft/DFTBuilder.cpp
index 7953bf498..ed35b176d 100644
--- a/src/storm-dft/storage/dft/DFTBuilder.cpp
+++ b/src/storm-dft/storage/dft/DFTBuilder.cpp
@@ -50,17 +50,29 @@ namespace storm {
                 }
             }
 
-            // Initialize dependencies
-            for (auto& dependency : mDependencies) {
-                DFTGatePointer triggerEvent = std::static_pointer_cast<DFTGate<ValueType>>(mElements[dependency->nameTrigger()]);
-                STORM_LOG_ASSERT(mElements[dependency->nameDependent()]->isBasicElement(), "Dependent element is not BE.");
-                std::shared_ptr<DFTBE<ValueType>> dependentEvent = std::static_pointer_cast<DFTBE<ValueType>>(mElements[dependency->nameDependent()]);
-                dependency->initialize(triggerEvent, dependentEvent);
-                triggerEvent->addOutgoingDependency(dependency);
-                dependentEvent->addIngoingDependency(dependency);
+            for(auto& elem : mDependencyChildNames) {
+                bool first = true;
+                std::vector<std::shared_ptr<DFTBE<ValueType>>> dependencies;
+                for(auto const& childName : elem.second) {
+                    auto itFind = mElements.find(childName);
+                    STORM_LOG_ASSERT(itFind != mElements.end(), "Child '" << childName << "' not found");
+                    DFTElementPointer childElement = itFind->second;
+                    if (!first) {
+                        dependencies.push_back(std::static_pointer_cast<DFTBE<ValueType>>(childElement));
+                    } else {
+                        elem.first->setTriggerElement(std::static_pointer_cast<DFTGate<ValueType>>(childElement));
+                        childElement->addOutgoingDependency(elem.first);
+                    }
+                    first = false;
+                }
+                if (binaryDependencies) {
+                    assert(dependencies.size() == 1);
+                }
+                assert(binaryDependencies);
+                elem.first->setDependentEvent(dependencies[0]);
+                dependencies[0]->addIngoingDependency(elem.first);
             }
-
-
+            
 
             // Sort elements topologically
             // compute rank
diff --git a/src/storm-dft/storage/dft/DFTBuilder.h b/src/storm-dft/storage/dft/DFTBuilder.h
index 4109272b7..9f216720c 100644
--- a/src/storm-dft/storage/dft/DFTBuilder.h
+++ b/src/storm-dft/storage/dft/DFTBuilder.h
@@ -31,6 +31,7 @@ namespace storm {
             std::unordered_map<std::string, DFTElementPointer> mElements;
             std::unordered_map<DFTElementPointer, std::vector<std::string>> mChildNames;
             std::unordered_map<DFTRestrictionPointer, std::vector<std::string>> mRestrictionChildNames;
+            std::unordered_map<DFTDependencyPointer, std::vector<std::string>> mDependencyChildNames;
             std::vector<DFTDependencyPointer> mDependencies;
             std::vector<DFTRestrictionPointer> mRestrictions;
             std::unordered_map<std::string, DFTLayoutInfo> mLayoutInfo;
@@ -101,7 +102,7 @@ namespace storm {
 
                 //TODO Matthias: collect constraints for SMT solving
                 //0 <= probability <= 1
-                if (!storm::utility::isOne(probability) && children.size() > 2) {
+                if (binaryDependencies && !storm::utility::isOne(probability) && children.size() > 2) {
                     // Introduce additional element for first capturing the proabilistic dependency
                     std::string nameAdditional = name + "_additional";
                     addBasicElement(nameAdditional, storm::utility::zero<ValueType>(), storm::utility::zero<ValueType>());
@@ -114,17 +115,25 @@ namespace storm {
                     return true;
                 } else {
                     // Add dependencies
-                    for (size_t i = 1; i < children.size(); ++i) {
-                        std::string nameDep = name + "_" + std::to_string(i);
-                        if(mElements.count(nameDep) != 0) {
-                            // Element with that name already exists.
-                            STORM_LOG_ERROR("Element with name: " << nameDep << " already exists.");
-                            return false;
+                    if(binaryDependencies) {
+                        for (size_t i = 1; i < children.size(); ++i) {
+                            std::string nameDep = name + "_" + std::to_string(i);
+                            if (mElements.count(nameDep) != 0) {
+                                // Element with that name already exists.
+                                STORM_LOG_ERROR("Element with name: " << nameDep << " already exists.");
+                                return false;
+                            }
+                            STORM_LOG_ASSERT(storm::utility::isOne(probability) || children.size() == 2,
+                                             "PDep with multiple children supported.");
+                            DFTDependencyPointer element = std::make_shared<DFTDependency<ValueType>>(mNextId++,
+                                                                                                      nameDep,
+                                                                                                      probability);
+                            mElements[element->name()] = element;
+                            mDependencyChildNames[element] = {trigger, children[i]};
+                            mDependencies.push_back(element);
                         }
-                        STORM_LOG_ASSERT(storm::utility::isOne(probability) || children.size() == 2, "PDep with multiple children supported.");
-                        DFTDependencyPointer element = std::make_shared<DFTDependency<ValueType>>(mNextId++, nameDep, trigger, children[i], probability);
-                        mElements[element->name()] = element;
-                        mDependencies.push_back(element);
+                    } else {
+
                     }
                     return true;
                 }
@@ -213,6 +222,8 @@ namespace storm {
             bool pandDefaultInclusive;
             // If true, the standard gate adders make a pand inclusive, and exclusive otherwise.
             bool porDefaultInclusive;
+
+            bool binaryDependencies;
             
         };
     }
diff --git a/src/storm-dft/storage/dft/elements/DFTDependency.h b/src/storm-dft/storage/dft/elements/DFTDependency.h
index 2c5b7d0cc..957048d68 100644
--- a/src/storm-dft/storage/dft/elements/DFTDependency.h
+++ b/src/storm-dft/storage/dft/elements/DFTDependency.h
@@ -12,35 +12,28 @@ namespace storm {
             using DFTBEPointer = std::shared_ptr<DFTBE<ValueType>>;
             
         protected:
-            std::string mNameTrigger;
-            std::string mNameDependent;
             ValueType mProbability;
             DFTGatePointer mTriggerEvent;
             DFTBEPointer mDependentEvent;
 
         public:
-            DFTDependency(size_t id, std::string const& name, std::string const& trigger, std::string const& dependent, ValueType probability) :
-                DFTElement<ValueType>(id, name), mNameTrigger(trigger), mNameDependent(dependent), mProbability(probability)
+            DFTDependency(size_t id, std::string const& name, ValueType probability) :
+                DFTElement<ValueType>(id, name), mProbability(probability)
             {
             }
 
             virtual ~DFTDependency() {}
 
-            void initialize(DFTGatePointer triggerEvent, DFTBEPointer dependentEvent) {
-                STORM_LOG_ASSERT(triggerEvent->name() == mNameTrigger, "Name does not match.");
-                STORM_LOG_ASSERT(dependentEvent->name() == mNameDependent, "Name does not match.");
+            void setTriggerElement(DFTGatePointer const& triggerEvent) {
                 mTriggerEvent = triggerEvent;
-                mDependentEvent = dependentEvent;
-            }
 
-            std::string nameTrigger() const {
-                return mNameTrigger;
             }
 
-            std::string nameDependent() const {
-                return mNameDependent;
+            void setDependentEvent(DFTBEPointer const& dependentEvent) {
+                mDependentEvent = dependentEvent;
             }
 
+
             ValueType const& probability() const {
                 return mProbability;
             }

From a5c7057fc382aa450f381e88605c08b6e88124f2 Mon Sep 17 00:00:00 2001
From: sjunges <sebastian.junges@gmail.com>
Date: Thu, 15 Dec 2016 02:12:46 +0100
Subject: [PATCH 35/47] quickfix for setting layout info only when available
 (review tomorrow)

---
 src/storm-dft/storage/dft/DFTBuilder.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/storm-dft/storage/dft/DFTBuilder.cpp b/src/storm-dft/storage/dft/DFTBuilder.cpp
index ed35b176d..35ed767b8 100644
--- a/src/storm-dft/storage/dft/DFTBuilder.cpp
+++ b/src/storm-dft/storage/dft/DFTBuilder.cpp
@@ -91,7 +91,9 @@ namespace storm {
 
             // Set layout info
             for (auto& elem : mElements) {
-                dft.setElementLayoutInfo(elem.second->id(), mLayoutInfo.at(elem.first));
+                if(mLayoutInfo.count(elem.first) > 0) {
+                    dft.setElementLayoutInfo(elem.second->id(), mLayoutInfo.at(elem.first));
+                }
             }
 
             return dft;

From d35bc5ed367419b685f8c7a252680a6fb85991e7 Mon Sep 17 00:00:00 2001
From: sjunges <sebastian.junges@gmail.com>
Date: Thu, 15 Dec 2016 02:13:30 +0100
Subject: [PATCH 36/47] n-ary pdeps supported as a datastructure

---
 src/storm-dft/storage/dft/DFT.cpp             |  3 +-
 src/storm-dft/storage/dft/DFTBuilder.cpp      |  4 ++-
 src/storm-dft/storage/dft/DFTIsomorphism.h    | 23 +++++++++++++--
 src/storm-dft/storage/dft/DFTState.cpp        | 14 +++++----
 src/storm-dft/storage/dft/elements/DFTBE.h    |  3 +-
 .../storage/dft/elements/DFTDependency.h      | 29 ++++++++++++-------
 .../storage/dft/elements/DFTElement.cpp       |  4 ++-
 7 files changed, 58 insertions(+), 22 deletions(-)

diff --git a/src/storm-dft/storage/dft/DFT.cpp b/src/storm-dft/storage/dft/DFT.cpp
index 3e06299f1..e38c40ce1 100644
--- a/src/storm-dft/storage/dft/DFT.cpp
+++ b/src/storm-dft/storage/dft/DFT.cpp
@@ -174,7 +174,8 @@ namespace storm {
                 std::shared_ptr<DFTDependency<ValueType> const> dependency = getDependency(idDependency);
                 visitQueue.push(dependency->id());
                 visitQueue.push(dependency->triggerEvent()->id());
-                visitQueue.push(dependency->dependentEvent()->id());
+                STORM_LOG_THROW(dependency->dependentEvents().size() == 1, storm::exceptions::NotSupportedException, "Direct state generation does not support n-ary dependencies. Consider rewriting them by setting the binary dependency flag.");
+                visitQueue.push(dependency->dependentEvents()[0]->id());
             }
             stateIndex = performStateGenerationInfoDFS(generationInfo, visitQueue, visited, stateIndex);
 
diff --git a/src/storm-dft/storage/dft/DFTBuilder.cpp b/src/storm-dft/storage/dft/DFTBuilder.cpp
index 35ed767b8..44846612f 100644
--- a/src/storm-dft/storage/dft/DFTBuilder.cpp
+++ b/src/storm-dft/storage/dft/DFTBuilder.cpp
@@ -268,7 +268,9 @@ namespace storm {
                 {
                     DFTDependencyPointer dependency = std::static_pointer_cast<DFTDependency<ValueType>>(element);
                     children.push_back(dependency->triggerEvent()->name());
-                    children.push_back(dependency->dependentEvent()->name());
+                    for(auto const& depEv : dependency->dependentEvents()) {
+                        children.push_back(depEv->name());
+                    }
                     addDepElement(element->name(), children, dependency->probability());
                     break;
                 }
diff --git a/src/storm-dft/storage/dft/DFTIsomorphism.h b/src/storm-dft/storage/dft/DFTIsomorphism.h
index 86625c975..081b76f0b 100644
--- a/src/storm-dft/storage/dft/DFTIsomorphism.h
+++ b/src/storm-dft/storage/dft/DFTIsomorphism.h
@@ -258,7 +258,8 @@ namespace storage {
         }
         
         void colourize(std::shared_ptr<const DFTDependency<ValueType>> const& dep) {
-            depColour[dep->id()] = std::pair<ValueType, ValueType>(dep->probability(), dep->dependentEvent()->activeFailureRate());
+            // TODO this can be improved for n-ary dependencies.
+            depColour[dep->id()] = std::pair<ValueType, ValueType>(dep->probability(), dep->dependentEvents()[0]->activeFailureRate());
         }
         
         void colourize(std::shared_ptr<const DFTRestriction<ValueType>> const& restr) {
@@ -486,10 +487,26 @@ namespace storage {
                     STORM_LOG_ASSERT(dft.isDependency(indexpair.second), "Element is no dependency.");
                     auto const& lDep = dft.getDependency(indexpair.first);
                     auto const& rDep = dft.getDependency(indexpair.second);
+
                     if(bijection.at(lDep->triggerEvent()->id()) != rDep->triggerEvent()->id()) {
                         return false;
-                    } 
-                    if(bijection.at(lDep->dependentEvent()->id()) != rDep->dependentEvent()->id()) {
+                    }
+
+                    std::set<size_t> dependenciesLeftMapped;
+                    for (auto const& depEv : lDep->dependentEvents()) {
+                        if (bleft.has(depEv->id())) {
+                            dependenciesLeftMapped.insert(bijection.at(depEv->id()));
+                        }
+                    }
+
+                    std::set<size_t> dependenciesRight;
+                    for (auto const& depEv : rDep->dependentEvents()) {
+                        if (bright.has(depEv->id())) {
+                            dependenciesRight.insert(depEv->id());
+                        }
+                    }
+
+                    if (dependenciesLeftMapped != dependenciesRight) {
                         return false;
                     }
                 } else if(dft.isRestriction(indexpair.first)) {
diff --git a/src/storm-dft/storage/dft/DFTState.cpp b/src/storm-dft/storage/dft/DFTState.cpp
index 78c0937d8..ec6509944 100644
--- a/src/storm-dft/storage/dft/DFTState.cpp
+++ b/src/storm-dft/storage/dft/DFTState.cpp
@@ -57,7 +57,8 @@ namespace storm {
             for (size_t dependencyId : mDft.getDependencies()) {
                 std::shared_ptr<DFTDependency<ValueType> const> dependency = mDft.getDependency(dependencyId);
                 STORM_LOG_ASSERT(dependencyId == dependency->id(), "Ids do not match.");
-                if (hasFailed(dependency->triggerEvent()->id()) && getElementState(dependency->dependentEvent()->id()) == DFTElementState::Operational) {
+                assert(dependency->dependentEvents().size() == 1);
+                if (hasFailed(dependency->triggerEvent()->id()) && getElementState(dependency->dependentEvents()[0]->id()) == DFTElementState::Operational) {
                     mFailableDependencies.push_back(dependencyId);
                     STORM_LOG_TRACE("New dependency failure: " << dependency->toString());
                 }
@@ -198,8 +199,9 @@ namespace storm {
             
             for (auto dependency : mDft.getElement(id)->outgoingDependencies()) {
                 STORM_LOG_ASSERT(dependency->triggerEvent()->id() == id, "Ids do not match.");
-                if (getElementState(dependency->dependentEvent()->id()) == DFTElementState::Operational) {
-                    STORM_LOG_ASSERT(!isFailsafe(dependency->dependentEvent()->id()), "Dependent event is failsafe.");
+                assert(dependency->dependentEvents().size() == 1);
+                if (getElementState(dependency->dependentEvents()[0]->id()) == DFTElementState::Operational) {
+                    STORM_LOG_ASSERT(!isFailsafe(dependency->dependentEvents()[0]->id()), "Dependent event is failsafe.");
                     mFailableDependencies.push_back(dependency->id());
                     STORM_LOG_TRACE("New dependency failure: " << dependency->toString());
                 }
@@ -213,7 +215,8 @@ namespace storm {
             STORM_LOG_ASSERT(hasFailed(id), "Element has not failed.");
             
             for (auto dependency : mDft.getBasicElement(id)->ingoingDependencies()) {
-                STORM_LOG_ASSERT(dependency->dependentEvent()->id() == id, "Ids do not match.");
+                assert(dependency->dependentEvents().size() == 1);
+                STORM_LOG_ASSERT(dependency->dependentEvents()[0]->id() == id, "Ids do not match.");
                 setDependencyDontCare(dependency->id());
             }
         }
@@ -244,7 +247,8 @@ namespace storm {
                 // Consider failure due to dependency
                 STORM_LOG_ASSERT(index < nrFailableDependencies(), "Index invalid.");
                 std::shared_ptr<DFTDependency<ValueType> const> dependency = mDft.getDependency(mFailableDependencies[index]);
-                std::pair<std::shared_ptr<DFTBE<ValueType> const>,bool> res(mDft.getBasicElement(dependency->dependentEvent()->id()), true);
+                assert(dependency->dependentEvents().size() == 1);
+                std::pair<std::shared_ptr<DFTBE<ValueType> const>,bool> res(mDft.getBasicElement(dependency->dependentEvents()[0]->id()), true);
                 mFailableDependencies.erase(mFailableDependencies.begin() + index);
                 setFailed(res.first->id());
                 setDependencySuccessful(dependency->id());
diff --git a/src/storm-dft/storage/dft/elements/DFTBE.h b/src/storm-dft/storage/dft/elements/DFTBE.h
index 216227af6..3be82d9f1 100644
--- a/src/storm-dft/storage/dft/elements/DFTBE.h
+++ b/src/storm-dft/storage/dft/elements/DFTBE.h
@@ -38,7 +38,8 @@ namespace storm {
             }
             
             bool addIngoingDependency(DFTDependencyPointer const& e) {
-                STORM_LOG_ASSERT(e->dependentEvent()->id() == this->id(), "Ids do not match.");
+                // TODO write this assertion for n-ary dependencies, probably by addign a method to the dependencies to support this.
+                //STORM_LOG_ASSERT(e->dependentEvent()->id() == this->id(), "Ids do not match.");
                 if(std::find(mIngoingDependencies.begin(), mIngoingDependencies.end(), e) != mIngoingDependencies.end()) {
                     return false;
                 }
diff --git a/src/storm-dft/storage/dft/elements/DFTDependency.h b/src/storm-dft/storage/dft/elements/DFTDependency.h
index 957048d68..e389f519e 100644
--- a/src/storm-dft/storage/dft/elements/DFTDependency.h
+++ b/src/storm-dft/storage/dft/elements/DFTDependency.h
@@ -14,7 +14,7 @@ namespace storm {
         protected:
             ValueType mProbability;
             DFTGatePointer mTriggerEvent;
-            DFTBEPointer mDependentEvent;
+            std::vector<DFTBEPointer> mDependentEvents;
 
         public:
             DFTDependency(size_t id, std::string const& name, ValueType probability) :
@@ -30,7 +30,7 @@ namespace storm {
             }
 
             void setDependentEvent(DFTBEPointer const& dependentEvent) {
-                mDependentEvent = dependentEvent;
+                mDependentEvents = { dependentEvent };
             }
 
 
@@ -43,9 +43,9 @@ namespace storm {
                 return mTriggerEvent;
             }
 
-            DFTBEPointer const& dependentEvent() const {
-                STORM_LOG_ASSERT(mDependentEvent, "Dependent element does not exists.");
-                return mDependentEvent;
+            std::vector<DFTBEPointer> const& dependentEvents() const {
+                STORM_LOG_ASSERT(mDependentEvents.size() > 0, "Dependent element does not exists.");
+                return mDependentEvents;
             }
 
             DFTElementType type() const override {
@@ -69,9 +69,11 @@ namespace storm {
 
             virtual std::vector<size_t> independentUnit() const override {
                 std::set<size_t> unit = {this->mId};
-                mDependentEvent->extendUnit(unit);
-                if(unit.count(mTriggerEvent->id()) != 0) {
-                    return {};
+                for(auto const& depEv : mDependentEvents) {
+                    depEv->extendUnit(unit);
+                    if(unit.count(mTriggerEvent->id()) != 0) {
+                        return {};
+                    }
                 }
                 return std::vector<size_t>(unit.begin(), unit.end());
             }
@@ -83,7 +85,10 @@ namespace storm {
                     // Parent in the subdft, ie it is *not* a subdft
                     return;
                 }
-                mDependentEvent->extendSubDft(elemsInSubtree, parentsOfSubRoot, blockParents, sparesAsLeaves);
+                for (auto const& depEv : mDependentEvents) {
+                    depEv->extendSubDft(elemsInSubtree, parentsOfSubRoot, blockParents, sparesAsLeaves);
+                    if (elemsInSubtree.empty()) return;
+                }
                 if(elemsInSubtree.empty()) {
                     // Parent in the subdft, ie it is *not* a subdft
                     return;
@@ -95,7 +100,11 @@ namespace storm {
             virtual std::string toString() const override {
                 std::stringstream stream;
                 bool fdep = storm::utility::isOne(mProbability);
-                stream << "{" << this->name() << "} " << (fdep ? "FDEP" : "PDEP") << "(" << mTriggerEvent->name() << " => " << mDependentEvent->name() << ")";
+                stream << "{" << this->name() << "} " << (fdep ? "FDEP" : "PDEP") << "(" << mTriggerEvent->name() << " => { ";
+                for(auto const& depEv : mDependentEvents) {
+                    stream << depEv->name() << " ";
+                }
+                stream << "}";
                 if (!fdep) {
                     stream << " with probability " << mProbability;
                 }
diff --git a/src/storm-dft/storage/dft/elements/DFTElement.cpp b/src/storm-dft/storage/dft/elements/DFTElement.cpp
index 61a087bdb..287af8e98 100644
--- a/src/storm-dft/storage/dft/elements/DFTElement.cpp
+++ b/src/storm-dft/storage/dft/elements/DFTElement.cpp
@@ -14,8 +14,10 @@ namespace storm {
             }
             
             // Check that no outgoing dependencies can be triggered anymore
+            // Notice that n-ary dependencies are supported via rewriting them during build-time
             for (DFTDependencyPointer dependency : mOutgoingDependencies) {
-                if (state.isOperational(dependency->dependentEvent()->id()) && state.isOperational(dependency->triggerEvent()->id())) {
+                assert(dependency->dependentEvents().size() == 1);
+                if (state.isOperational(dependency->dependentEvents()[0]->id()) && state.isOperational(dependency->triggerEvent()->id())) {
                     return false;
                 }
             }

From 159890844e6a8fef56b930c2297e034c947fcca2 Mon Sep 17 00:00:00 2001
From: Matthias Volk <matthias.volk@cs.rwth-aachen.de>
Date: Thu, 15 Dec 2016 09:57:27 +0100
Subject: [PATCH 37/47] Layout for AND and BE

---
 src/storm-dft/parser/DFTJsonParser.cpp        |  7 +++--
 .../DftToGspnTransformator.cpp                | 27 ++++++++++++++-----
 2 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/src/storm-dft/parser/DFTJsonParser.cpp b/src/storm-dft/parser/DFTJsonParser.cpp
index 4bedbe7ac..2a1f3f1ac 100644
--- a/src/storm-dft/parser/DFTJsonParser.cpp
+++ b/src/storm-dft/parser/DFTJsonParser.cpp
@@ -49,7 +49,7 @@ namespace storm {
 
         template<typename ValueType>
         void DFTJsonParser<ValueType>::readFile(const std::string& filename) {
-            std::cout << "Parsing from JSON" << std::endl;
+            STORM_LOG_DEBUG("Parsing from JSON");
 
             std::ifstream file;
             file.exceptions ( std::ifstream::failbit );
@@ -81,8 +81,6 @@ namespace storm {
             std::string toplevelId = nameMapping["1"];
 
             for (auto& element : parsedJson) {
-                std::cout << element << std::endl;
-
                 bool success = true;
                 if (element.at("classes") == "") {
                     continue;
@@ -124,10 +122,11 @@ namespace storm {
                     success = false;
                 }
 
+                // Set layout positions
                 json position = element.at("position");
                 double x = position.at("x");
                 double y = position.at("y");
-                builder.addLayoutInfo(name, x, y);
+                builder.addLayoutInfo(name, x / 10, y / 10);
                 STORM_LOG_THROW(success, storm::exceptions::FileIoException, "Error while adding element '" << element << "'.");
             }
 
diff --git a/src/storm-dft/transformations/DftToGspnTransformator.cpp b/src/storm-dft/transformations/DftToGspnTransformator.cpp
index 868ab652c..176ed3254 100644
--- a/src/storm-dft/transformations/DftToGspnTransformator.cpp
+++ b/src/storm-dft/transformations/DftToGspnTransformator.cpp
@@ -90,9 +90,7 @@ namespace storm {
             
             template <typename ValueType>
             void DftToGspnTransformator<ValueType>::drawBE(std::shared_ptr<storm::storage::DFTBE<ValueType> const> dftBE, bool isRepresentative) {
-                double xcenter = mDft.getElementLayoutInfo(dftBE->id()).x;
-                double ycenter = mDft.getElementLayoutInfo(dftBE->id()).y;
-				uint64_t beActive = builder.addPlace(defaultCapacity, isBEActive(dftBE) ? 1 : 0, dftBE->name() + STR_ACTIVATED);
+                uint64_t beActive = builder.addPlace(defaultCapacity, isBEActive(dftBE) ? 1 : 0, dftBE->name() + STR_ACTIVATED);
                 activeNodes.emplace(dftBE->id(), beActive);
                 uint64_t beFailed = builder.addPlace(defaultCapacity, 0, dftBE->name() + STR_FAILED);
                 
@@ -127,7 +125,10 @@ namespace storm {
                     builder.addOutputArc(tActive, unavailableNode);
                     builder.addOutputArc(tPassive, unavailableNode);
                 }
-                
+
+                double xcenter = mDft.getElementLayoutInfo(dftBE->id()).x;
+                double ycenter = mDft.getElementLayoutInfo(dftBE->id()).y;
+
                 builder.setPlaceLayoutInfo(beActive, storm::gspn::LayoutInfo(xcenter - 3.0, ycenter));
                 builder.setPlaceLayoutInfo(beFailed, storm::gspn::LayoutInfo(xcenter + 3.0, ycenter));
                 builder.setTransitionLayoutInfo(tActive, storm::gspn::LayoutInfo(xcenter, ycenter + 3.0));
@@ -137,8 +138,6 @@ namespace storm {
 			
 			template <typename ValueType>
             void DftToGspnTransformator<ValueType>::drawAND(std::shared_ptr<storm::storage::DFTAnd<ValueType> const> dftAnd, bool isRepresentative) {
-                double xcenter = mDft.getElementLayoutInfo(dftAnd->id()).x;
-                double ycenter = mDft.getElementLayoutInfo(dftAnd->id()).y;
                 uint64_t nodeFailed = builder.addPlace(defaultCapacity, 0, dftAnd->name() + STR_FAILED);
                 assert(failedNodes.size() == dftAnd->id());
                 failedNodes.push_back(nodeFailed);
@@ -160,7 +159,10 @@ namespace storm {
                     builder.addInputArc(failedNodes[child->id()], tAndFailed);
                     builder.addOutputArc(tAndFailed, failedNodes[child->id()]);
                 }
-                
+
+                double xcenter = mDft.getElementLayoutInfo(dftAnd->id()).x;
+                double ycenter = mDft.getElementLayoutInfo(dftAnd->id()).y;
+
                 builder.setPlaceLayoutInfo(nodeFailed, storm::gspn::LayoutInfo(xcenter, ycenter-3.0));
                 builder.setTransitionLayoutInfo(tAndFailed, storm::gspn::LayoutInfo(xcenter, ycenter+3.0));
                 
@@ -171,6 +173,11 @@ namespace storm {
                 uint64_t nodeFailed = builder.addPlace(defaultCapacity, 0, dftOr->name() + STR_FAILED);
                 assert(failedNodes.size() == dftOr->id());
                 failedNodes.push_back(nodeFailed);
+
+                double xcenter = mDft.getElementLayoutInfo(dftOr->id()).x;
+                double ycenter = mDft.getElementLayoutInfo(dftOr->id()).y;
+                builder.setPlaceLayoutInfo(nodeFailed, storm::gspn::LayoutInfo(xcenter, ycenter-3.0));
+
                 uint64_t unavailableNode = 0;
                 if (isRepresentative) {
                     unavailableNode = addUnavailableNode(dftOr);
@@ -188,6 +195,7 @@ namespace storm {
                     builder.addInputArc(failedNodes[child->id()], tNodeFailed);
                     builder.addOutputArc(tNodeFailed, failedNodes[child->id()]);
                     ++i;
+                    builder.setTransitionLayoutInfo(tNodeFailed, storm::gspn::LayoutInfo(xcenter-5+i*3, ycenter+3.0));
                 }
 			}
 			
@@ -228,6 +236,11 @@ namespace storm {
                 uint64_t nodeFailed = builder.addPlace(defaultCapacity, 0, dftPand->name()  + STR_FAILED);
                 assert(failedNodes.size() == dftPand->id());
                 failedNodes.push_back(nodeFailed);
+
+                double xcenter = mDft.getElementLayoutInfo(dftPand->id()).x;
+                double ycenter = mDft.getElementLayoutInfo(dftPand->id()).y;
+                builder.setPlaceLayoutInfo(nodeFailed, storm::gspn::LayoutInfo(xcenter, ycenter-3.0));
+
                 uint64_t unavailableNode = 0;
                 if (!smart || isRepresentative) {
                     unavailableNode = addUnavailableNode(dftPand);

From f78d30ab4fa073ae77666dc9a5b40d9a523880d8 Mon Sep 17 00:00:00 2001
From: Sebastian Junges <sebastian.junges@rwth-aachen.de>
Date: Thu, 15 Dec 2016 10:50:59 +0100
Subject: [PATCH 38/47] default layout info including warning

---
 src/storm-dft/storage/dft/DFT.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/storm-dft/storage/dft/DFT.h b/src/storm-dft/storage/dft/DFT.h
index 1304bbfa9..4c904ec5c 100644
--- a/src/storm-dft/storage/dft/DFT.h
+++ b/src/storm-dft/storage/dft/DFT.h
@@ -270,6 +270,10 @@ namespace storm {
             }
 
             DFTLayoutInfo const& getElementLayoutInfo(size_t id) const {
+                if(mLayoutInfo.count(id) == 0) {
+                    STORM_LOG_WARN("Layout info for element with id " << id << " not found");
+                    return DFTLayoutInfo();
+                }
                 return mLayoutInfo.at(id);
             }
 

From 0d010fa6dcc94ebb1a1b5c005a5f9cdc26a77a0a Mon Sep 17 00:00:00 2001
From: Sebastian Junges <sebastian.junges@rwth-aachen.de>
Date: Thu, 15 Dec 2016 10:52:06 +0100
Subject: [PATCH 39/47] dependencies as children are dummy output

---
 src/storm-dft/storage/dft/DFTBuilder.cpp | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/storm-dft/storage/dft/DFTBuilder.cpp b/src/storm-dft/storage/dft/DFTBuilder.cpp
index 44846612f..f2a17541a 100644
--- a/src/storm-dft/storage/dft/DFTBuilder.cpp
+++ b/src/storm-dft/storage/dft/DFTBuilder.cpp
@@ -25,9 +25,11 @@ namespace storm {
                     if (itFind != mElements.end()) {
                         // Child found
                         DFTElementPointer childElement = itFind->second;
-                        STORM_LOG_ASSERT(!childElement->isDependency(), "Child is dependency.");
-                        gate->pushBackChild(childElement);
-                        childElement->addParent(gate);
+                        STORM_LOG_TRACE("Ignore functional dependency " << child << " in gate " << gate->name());
+                        if(!childElement->isDependency()) {
+                            gate->pushBackChild(childElement);
+                            childElement->addParent(gate);
+                        }
                     } else {
                         // Child not found -> find first dependent event to assure that child is dependency
                         // TODO: Not sure whether this is the intended behaviour?

From 87b6182ea3638264ca84304e54f0e3bac2320f59 Mon Sep 17 00:00:00 2001
From: Sebastian Junges <sebastian.junges@rwth-aachen.de>
Date: Thu, 15 Dec 2016 10:53:04 +0100
Subject: [PATCH 40/47] build n-ary pdeps for transformation

---
 src/storm-dft-cli/storm-dyftee.cpp                 | 2 +-
 src/storm-dft/parser/DFTGalileoParser.h            | 2 +-
 src/storm-dft/storage/dft/DFTBuilder.cpp           | 8 +++++---
 src/storm-dft/storage/dft/DFTBuilder.h             | 7 +++++--
 src/storm-dft/storage/dft/elements/DFTDependency.h | 4 ++--
 5 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/src/storm-dft-cli/storm-dyftee.cpp b/src/storm-dft-cli/storm-dyftee.cpp
index 13f048a55..61959158a 100644
--- a/src/storm-dft-cli/storm-dyftee.cpp
+++ b/src/storm-dft-cli/storm-dyftee.cpp
@@ -136,7 +136,7 @@ int main(const int argc, const char** argv) {
                 storm::parser::DFTJsonParser<double> parser;
                 dft = std::make_shared<storm::storage::DFT<double>>(parser.parseJson(dftSettings.getDftJsonFilename()));
             } else {
-                storm::parser::DFTGalileoParser<double> parser;
+                storm::parser::DFTGalileoParser<double> parser(true, false);
                 dft = std::make_shared<storm::storage::DFT<double>>(parser.parseDFT(dftSettings.getDftFilename()));
             }
             storm::transformations::dft::DftToGspnTransformator<double> gspnTransformator(*dft);
diff --git a/src/storm-dft/parser/DFTGalileoParser.h b/src/storm-dft/parser/DFTGalileoParser.h
index 04b822914..c2a35bc50 100644
--- a/src/storm-dft/parser/DFTGalileoParser.h
+++ b/src/storm-dft/parser/DFTGalileoParser.h
@@ -26,7 +26,7 @@ namespace storm {
             std::unordered_map<std::string, storm::expressions::Expression> identifierMapping;
 
         public:
-            DFTGalileoParser(bool defaultInclusive = true) : builder(defaultInclusive), manager(new storm::expressions::ExpressionManager()), parser(*manager), evaluator(*manager) {
+            DFTGalileoParser(bool defaultInclusive = true, bool binaryDependencies = true) : builder(defaultInclusive, binaryDependencies), manager(new storm::expressions::ExpressionManager()), parser(*manager), evaluator(*manager) {
             }
 
             storm::storage::DFT<ValueType> parseDFT(std::string const& filename);
diff --git a/src/storm-dft/storage/dft/DFTBuilder.cpp b/src/storm-dft/storage/dft/DFTBuilder.cpp
index f2a17541a..0bff9bd2b 100644
--- a/src/storm-dft/storage/dft/DFTBuilder.cpp
+++ b/src/storm-dft/storage/dft/DFTBuilder.cpp
@@ -70,9 +70,11 @@ namespace storm {
                 if (binaryDependencies) {
                     assert(dependencies.size() == 1);
                 }
-                assert(binaryDependencies);
-                elem.first->setDependentEvent(dependencies[0]);
-                dependencies[0]->addIngoingDependency(elem.first);
+                elem.first->setDependentEvents(dependencies);
+                for (auto& dependency : dependencies) {
+                    dependency->addIngoingDependency(elem.first);
+                }
+                
             }
             
 
diff --git a/src/storm-dft/storage/dft/DFTBuilder.h b/src/storm-dft/storage/dft/DFTBuilder.h
index 9f216720c..636b5e5a1 100644
--- a/src/storm-dft/storage/dft/DFTBuilder.h
+++ b/src/storm-dft/storage/dft/DFTBuilder.h
@@ -37,7 +37,7 @@ namespace storm {
             std::unordered_map<std::string, DFTLayoutInfo> mLayoutInfo;
             
         public:
-            DFTBuilder(bool defaultInclusive = true) : pandDefaultInclusive(defaultInclusive), porDefaultInclusive(defaultInclusive) {
+            DFTBuilder(bool defaultInclusive = true, bool binaryDependencies = true) : pandDefaultInclusive(defaultInclusive), porDefaultInclusive(defaultInclusive), binaryDependencies(binaryDependencies) {
                 
             }
             
@@ -133,7 +133,10 @@ namespace storm {
                             mDependencies.push_back(element);
                         }
                     } else {
-
+                        DFTDependencyPointer element = std::make_shared<DFTDependency<ValueType>>(mNextId++, name, probability);
+                        mElements[element->name()] = element;
+                        mDependencyChildNames[element] = children;
+                        mDependencies.push_back(element);
                     }
                     return true;
                 }
diff --git a/src/storm-dft/storage/dft/elements/DFTDependency.h b/src/storm-dft/storage/dft/elements/DFTDependency.h
index e389f519e..7d11bae2a 100644
--- a/src/storm-dft/storage/dft/elements/DFTDependency.h
+++ b/src/storm-dft/storage/dft/elements/DFTDependency.h
@@ -29,8 +29,8 @@ namespace storm {
 
             }
 
-            void setDependentEvent(DFTBEPointer const& dependentEvent) {
-                mDependentEvents = { dependentEvent };
+            void setDependentEvents(std::vector<DFTBEPointer> const& dependentEvents) {
+                mDependentEvents = dependentEvents;
             }
 
 

From 1fc2c2e82d0f28a10143c7fe7acede1c17bd63ff Mon Sep 17 00:00:00 2001
From: Sebastian Junges <sebastian.junges@rwth-aachen.de>
Date: Thu, 15 Dec 2016 10:53:50 +0100
Subject: [PATCH 41/47] dft->gspn for n-ary pdeps: WIP

---
 .../DftToGspnTransformator.cpp                | 26 +++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/src/storm-dft/transformations/DftToGspnTransformator.cpp b/src/storm-dft/transformations/DftToGspnTransformator.cpp
index 176ed3254..0d145ef0c 100644
--- a/src/storm-dft/transformations/DftToGspnTransformator.cpp
+++ b/src/storm-dft/transformations/DftToGspnTransformator.cpp
@@ -429,7 +429,29 @@ namespace storm {
 //			
 			template <typename ValueType>
             void DftToGspnTransformator<ValueType>::drawPDEP(std::shared_ptr<storm::storage::DFTDependency<ValueType> const> dftDependency) {
-
+                double xcenter = mDft.getElementLayoutInfo(dftDependency->id()).x;;
+                double ycenter = mDft.getElementLayoutInfo(dftDependency->id()).y;;
+                
+                uint64_t coinPlace = builder.addPlace(defaultCapacity, 1, dftDependency->name() + "_coin");
+                uint64_t flipPlace = builder.addPlace(defaultCapacity, 1, dftDependency->name() + "_flip");
+                uint64_t forwardPlace = builder.addPlace(defaultCapacity, 1, dftDependency->name() + "_forward");
+                uint64_t t1 = builder.addImmediateTransition(defaultPriority, 0.0, dftDependency->name() + "_start_flip");
+                builder.addInputArc(coinPlace, t1);
+                builder.addInputArc(failedNodes.at(dftDependency->triggerEvent()->id()), t1);
+                builder.addOutputArc(t1, failedNodes.at(dftDependency->triggerEvent()->id()));
+                builder.addOutputArc(t1, flipPlace);
+                uint64_t t2 = builder.addImmediateTransition(defaultPriority + 1, dftDependency->probability(), "_win_flip");
+                builder.addInputArc(flipPlace, t2);
+                builder.addOutputArc(t2, forwardPlace);
+                if (dftDependency->probability() < 1.0) {
+                    uint64_t t3 = builder.addImmediateTransition(defaultPriority + 1, 1 - dftDependency->probability(), "_loose_flip");
+                    builder.addInputArc(flipPlace, t3);
+                }
+                
+                builder.setPlaceLayoutInfo(coinPlace, storm::gspn::LayoutInfo(xcenter-5.0, ycenter+2.0));
+                builder.setPlaceLayoutInfo(flipPlace, storm::gspn::LayoutInfo(xcenter-2.0, ycenter+2.0));
+                builder.setPlaceLayoutInfo(forwardPlace, storm::gspn::LayoutInfo(xcenter+1.0, ycenter+2.0));
+                
 			}
             
             template <typename ValueType>
@@ -443,7 +465,7 @@ namespace storm {
                     if (j>0) {
                         builder.addOutputArc(tEnable, nextPlace);
                     }
-                    tEnable = builder.addImmediateTransition(defaultPriority, 0.0, dftSeq->name() + "_unblock_" +child->name() );
+                    tEnable = builder.addImmediateTransition(defaultPriority + 1, 0.0, dftSeq->name() + "_unblock_" +child->name() );
                     builder.addInputArc(nextPlace, tEnable);
                     builder.addInputArc(disabledNodes.at(child->id()), tEnable);
                     if (j>0) {

From a57c749f72a4aecd61d5ed6b44b38534b0f4df98 Mon Sep 17 00:00:00 2001
From: Sebastian Junges <sebastian.junges@rwth-aachen.de>
Date: Thu, 15 Dec 2016 11:26:23 +0100
Subject: [PATCH 42/47] topo sort for dependencies (stupid way..)

---
 src/storm-dft/storage/dft/DFTBuilder.cpp | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/storm-dft/storage/dft/DFTBuilder.cpp b/src/storm-dft/storage/dft/DFTBuilder.cpp
index 0bff9bd2b..70df810cf 100644
--- a/src/storm-dft/storage/dft/DFTBuilder.cpp
+++ b/src/storm-dft/storage/dft/DFTBuilder.cpp
@@ -205,12 +205,20 @@ namespace storm {
                         topoVisit(c, visited, L);
                     }
                 }
+                // TODO restrictions and dependencies have no parents, so this can be done more efficiently.
                 if(n->isRestriction()) {
                     visited[n] = topoSortColour::GREY;
                     for (DFTElementPointer const& c : std::static_pointer_cast<DFTRestriction<ValueType>>(n)->children()) {
                         topoVisit(c, visited, L);
                     }
                 }
+                if(n->isDependency()) {
+                    visited[n] = topoSortColour::GREY;
+                    for (DFTElementPointer const& c : std::static_pointer_cast<DFTDependency<ValueType>>(n)->dependentEvents()) {
+                        topoVisit(c, visited, L);
+                    }
+                    topoVisit(std::static_pointer_cast<DFTDependency<ValueType>>(n)->triggerEvent(), visited, L);
+                }
                 visited[n] = topoSortColour::BLACK;
                 L.push_back(n);
             }

From 8ef9b8a57673fa380bf1c2dbbb31e6b2a10f3756 Mon Sep 17 00:00:00 2001
From: Sebastian Junges <sebastian.junges@rwth-aachen.de>
Date: Thu, 15 Dec 2016 11:26:34 +0100
Subject: [PATCH 43/47] pdeps now fully working

---
 .../DftToGspnTransformator.cpp                | 101 +++++++-----------
 1 file changed, 36 insertions(+), 65 deletions(-)

diff --git a/src/storm-dft/transformations/DftToGspnTransformator.cpp b/src/storm-dft/transformations/DftToGspnTransformator.cpp
index 0d145ef0c..12d85e000 100644
--- a/src/storm-dft/transformations/DftToGspnTransformator.cpp
+++ b/src/storm-dft/transformations/DftToGspnTransformator.cpp
@@ -433,24 +433,48 @@ namespace storm {
                 double ycenter = mDft.getElementLayoutInfo(dftDependency->id()).y;;
                 
                 uint64_t coinPlace = builder.addPlace(defaultCapacity, 1, dftDependency->name() + "_coin");
-                uint64_t flipPlace = builder.addPlace(defaultCapacity, 1, dftDependency->name() + "_flip");
-                uint64_t forwardPlace = builder.addPlace(defaultCapacity, 1, dftDependency->name() + "_forward");
+                builder.setPlaceLayoutInfo(coinPlace, storm::gspn::LayoutInfo(xcenter-5.0, ycenter+2.0));
                 uint64_t t1 = builder.addImmediateTransition(defaultPriority, 0.0, dftDependency->name() + "_start_flip");
+                
                 builder.addInputArc(coinPlace, t1);
                 builder.addInputArc(failedNodes.at(dftDependency->triggerEvent()->id()), t1);
                 builder.addOutputArc(t1, failedNodes.at(dftDependency->triggerEvent()->id()));
-                builder.addOutputArc(t1, flipPlace);
-                uint64_t t2 = builder.addImmediateTransition(defaultPriority + 1, dftDependency->probability(), "_win_flip");
-                builder.addInputArc(flipPlace, t2);
-                builder.addOutputArc(t2, forwardPlace);
-                if (dftDependency->probability() < 1.0) {
-                    uint64_t t3 = builder.addImmediateTransition(defaultPriority + 1, 1 - dftDependency->probability(), "_loose_flip");
-                    builder.addInputArc(flipPlace, t3);
+                uint64_t forwardPlace = builder.addPlace(defaultCapacity, 0, dftDependency->name() + "_forward");
+                builder.setPlaceLayoutInfo(forwardPlace, storm::gspn::LayoutInfo(xcenter+1.0, ycenter+2.0));
+                
+                if (!smart || dftDependency->probability() < 1.0) {
+                    uint64_t flipPlace = builder.addPlace(defaultCapacity, 0, dftDependency->name() + "_flip");
+                    builder.addOutputArc(t1, flipPlace);
+                    
+                    builder.setPlaceLayoutInfo(flipPlace, storm::gspn::LayoutInfo(xcenter-2.0, ycenter+2.0));
+                    uint64_t t2 = builder.addImmediateTransition(defaultPriority + 1, dftDependency->probability(), "_win_flip");
+                    builder.addInputArc(flipPlace, t2);
+                    builder.addOutputArc(t2, forwardPlace);
+                    if (dftDependency->probability() < 1.0) {
+                        uint64_t t3 = builder.addImmediateTransition(defaultPriority + 1, 1 - dftDependency->probability(), "_loose_flip");
+                        builder.addInputArc(flipPlace, t3);
+                    }
+                } else {
+                    builder.addOutputArc(t1, forwardPlace);
+                }
+                for(auto const& depEv : dftDependency->dependentEvents()) {
+                    uint64_t tx = builder.addImmediateTransition(defaultPriority, 0.0, dftDependency->name() + "_propagate_" + depEv->name());
+                    builder.addInputArc(forwardPlace, tx);
+                    builder.addOutputArc(tx, forwardPlace);
+                    builder.addOutputArc(tx, failedNodes.at(depEv->id()));
+                    builder.addInhibitionArc(failedNodes.at(depEv->id()), tx);
+                    if (!smart || depEv->nrRestrictions() > 0) {
+                        builder.addInhibitionArc(disabledNodes.at(depEv->id()), tx);
+                    }
+                    if (!smart || mDft.isRepresentative(depEv->id())) {
+                        builder.addOutputArc(tx, unavailableNodes.at(depEv->id()));
+                    }
+                   
                 }
                 
-                builder.setPlaceLayoutInfo(coinPlace, storm::gspn::LayoutInfo(xcenter-5.0, ycenter+2.0));
-                builder.setPlaceLayoutInfo(flipPlace, storm::gspn::LayoutInfo(xcenter-2.0, ycenter+2.0));
-                builder.setPlaceLayoutInfo(forwardPlace, storm::gspn::LayoutInfo(xcenter+1.0, ycenter+2.0));
+                
+                
+                
                 
 			}
             
@@ -536,59 +560,6 @@ namespace storm {
 			
 			template <typename ValueType>
             void DftToGspnTransformator<ValueType>::drawGSPNRestrictions() {
-//				for (std::size_t i = 0; i < mDft.nrElements(); i++) {
-//					auto dftElement = mDft.getElement(i);
-//					
-//					if (dftElement->isRestriction()) {
-//						switch (dftElement->type()) {
-//							case storm::storage::DFTElementType::SEQ:
-//							{
-//								auto children = mDft.getRestriction(i)->children();
-//								
-//								for (std::size_t j = 0; j < children.size() - 1; j++) {
-//									auto suppressor = mGspn.getPlace(children[j]->name() + STR_FAILED);
-//									
-//									switch (children[j + 1]->type()) {
-//										case storm::storage::DFTElementType::BE: // If suppressed is a BE, add 2 arcs to timed transitions.
-//										{
-//											auto suppressedActive = mGspn.getTimedTransition(children[j + 1]->name() + "_activeFailing");
-//											auto suppressedPassive = mGspn.getTimedTransition(children[j + 1]->name() + "_passiveFailing");
-//											
-//											if (suppressor.first && suppressedActive.first && suppressedPassive.first) { // Only add arcs if the objects have been found.
-//												suppressedActive.second->setInputArcMultiplicity(suppressor.second, 1);
-//												suppressedActive.second->setOutputArcMultiplicity(suppressor.second, 1);
-//												suppressedPassive.second->setInputArcMultiplicity(suppressor.second, 1);
-//												suppressedPassive.second->setOutputArcMultiplicity(suppressor.second, 1);
-//											}
-//											break;
-//										}
-//										default: // If supressed is not a BE, add single arc to immediate transition.
-//										{
-//											auto suppressed = mGspn.getImmediateTransition(children[j + 1]->name() + STR_FAILING);
-//											
-//											if (suppressor.first && suppressed.first) { // Only add arcs if the objects have been found.
-//												suppressed.second->setInputArcMultiplicity(suppressor.second, 1);
-//												suppressed.second->setOutputArcMultiplicity(suppressor.second, 1);
-//											}
-//											break;
-//										}
-//									}
-//								}
-//								break;
-//							}
-//							case storm::storage::DFTElementType::MUTEX:
-//							{
-//								// MUTEX is not implemented by the DFTGalileoParser yet. Nothing to do here.
-//								STORM_LOG_ASSERT(false, "MUTEX is not supported by DftToGspnTransformator.");
-//								break;
-//							}
-//							default:
-//							{
-//								break;
-//							}
-//						}
-//					}
-//				}
 			}
 
 			template <typename ValueType>

From 146bd193ea370484d134b1f1a16918f5137ea810 Mon Sep 17 00:00:00 2001
From: Sebastian Junges <sebastian.junges@rwth-aachen.de>
Date: Thu, 15 Dec 2016 12:03:00 +0100
Subject: [PATCH 44/47] spare activation

---
 .../transformations/DftToGspnTransformator.cpp    | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/storm-dft/transformations/DftToGspnTransformator.cpp b/src/storm-dft/transformations/DftToGspnTransformator.cpp
index 12d85e000..f97faa404 100644
--- a/src/storm-dft/transformations/DftToGspnTransformator.cpp
+++ b/src/storm-dft/transformations/DftToGspnTransformator.cpp
@@ -280,7 +280,7 @@ namespace storm {
                             builder.addInhibitionArc(failedNodes.at(child->id()), tn);
                         }
                         if (j != dftPand->nrChildren() - 1) {
-                            tn = builder.addImmediateTransition(getFailPriority(dftPand), 0.0, dftPand->name() + STR_FAILING + "_" +std::to_string(j));
+                            tn = builder.addImmediateTransition(getFailPriority(dftPand), 0.0, dftPand->name() + STR_FAILING + "_" + std::to_string(j));
                         } else {
                             tn = tNodeFailed;
                         }
@@ -307,7 +307,7 @@ namespace storm {
                 if (isRepresentative) {
                     unavailableNode = addUnavailableNode(dftSpare);
                 }
-                uint64_t spareActive = builder.addPlace(defaultCapacity, 0, dftSpare->name() + STR_ACTIVATED);
+                uint64_t spareActive = builder.addPlace(defaultCapacity, isBEActive(dftSpare) ? 1 : 0, dftSpare->name() + STR_ACTIVATED);
                 activeNodes.emplace(dftSpare->id(), spareActive);
 
                 
@@ -345,6 +345,16 @@ namespace storm {
                     builder.addOutputArc(tnextcl, failedNodes.at(child->id()));
                     nextclTransitions.push_back(tnextcl);
                     ++j;
+                    for (uint64_t k : mDft.module(child->id())) {
+                        
+                        uint64_t tactive = builder.addImmediateTransition(defaultPriority+1, 0.0, dftSpare->name() + "_activate_" + std::to_string(j) + "_" +  std::to_string(k));
+                        builder.addInputArc(cucNodes.back(), tactive);
+                        builder.addInputArc(spareActive, tactive);
+                        builder.addOutputArc(tactive, activeNodes.at(k));
+                        builder.addInhibitionArc(activeNodes.at(k), tactive);
+                    }
+                    
+                    
                 }
                 builder.addOutputArc(nextconsiderTransitions.back(), nodeFailed);
                 builder.addOutputArc(nextclTransitions.back(), nodeFailed);
@@ -354,6 +364,7 @@ namespace storm {
                     builder.addOutputArc(nextclTransitions.back(), unavailableNode);
                 }
                 
+                
 
 			}
 //			

From 6672009cd164073f1889915b08cdad0ad996fe99 Mon Sep 17 00:00:00 2001
From: Matthias Volk <matthias.volk@cs.rwth-aachen.de>
Date: Thu, 15 Dec 2016 12:04:03 +0100
Subject: [PATCH 45/47] Layouting for GSPN

---
 src/storm-dft/parser/DFTJsonParser.cpp        |   2 +-
 .../DftToGspnTransformator.cpp                | 220 ++++++++++--------
 .../transformations/DftToGspnTransformator.h  |   2 +-
 3 files changed, 130 insertions(+), 94 deletions(-)

diff --git a/src/storm-dft/parser/DFTJsonParser.cpp b/src/storm-dft/parser/DFTJsonParser.cpp
index 2a1f3f1ac..9a5c5d047 100644
--- a/src/storm-dft/parser/DFTJsonParser.cpp
+++ b/src/storm-dft/parser/DFTJsonParser.cpp
@@ -126,7 +126,7 @@ namespace storm {
                 json position = element.at("position");
                 double x = position.at("x");
                 double y = position.at("y");
-                builder.addLayoutInfo(name, x / 10, y / 10);
+                builder.addLayoutInfo(name, x / 7, y / 7);
                 STORM_LOG_THROW(success, storm::exceptions::FileIoException, "Error while adding element '" << element << "'.");
             }
 
diff --git a/src/storm-dft/transformations/DftToGspnTransformator.cpp b/src/storm-dft/transformations/DftToGspnTransformator.cpp
index 12d85e000..f04aa79c8 100644
--- a/src/storm-dft/transformations/DftToGspnTransformator.cpp
+++ b/src/storm-dft/transformations/DftToGspnTransformator.cpp
@@ -93,6 +93,12 @@ namespace storm {
                 uint64_t beActive = builder.addPlace(defaultCapacity, isBEActive(dftBE) ? 1 : 0, dftBE->name() + STR_ACTIVATED);
                 activeNodes.emplace(dftBE->id(), beActive);
                 uint64_t beFailed = builder.addPlace(defaultCapacity, 0, dftBE->name() + STR_FAILED);
+
+                double xcenter = mDft.getElementLayoutInfo(dftBE->id()).x;
+                double ycenter = mDft.getElementLayoutInfo(dftBE->id()).y;
+                builder.setPlaceLayoutInfo(beActive, storm::gspn::LayoutInfo(xcenter - 3.0, ycenter));
+                builder.setPlaceLayoutInfo(beFailed, storm::gspn::LayoutInfo(xcenter + 3.0, ycenter));
+
                 
                 uint64_t disabledNode = 0;
                 if (!smart || dftBE->nrRestrictions() > 0) {
@@ -101,17 +107,19 @@ namespace storm {
                 
                 uint64_t unavailableNode = 0;
                 if (!smart || isRepresentative) {
-                    unavailableNode = addUnavailableNode(dftBE);
+                    unavailableNode = addUnavailableNode(dftBE, storm::gspn::LayoutInfo(xcenter+9.0, ycenter));
                 }
                 
                 assert(failedNodes.size() == dftBE->id());
                 failedNodes.push_back(beFailed);
                 uint64_t tActive = builder.addTimedTransition(defaultPriority, dftBE->activeFailureRate(), dftBE->name() + "_activeFailing");
+                builder.setTransitionLayoutInfo(tActive, storm::gspn::LayoutInfo(xcenter, ycenter + 3.0));
                 builder.addInputArc(beActive, tActive);
                 builder.addInhibitionArc(beFailed, tActive);
                 builder.addOutputArc(tActive, beActive);
                 builder.addOutputArc(tActive, beFailed);
                 uint64_t tPassive = builder.addTimedTransition(defaultPriority, dftBE->passiveFailureRate(), dftBE->name() + "_passiveFailing");
+                builder.setTransitionLayoutInfo(tPassive, storm::gspn::LayoutInfo(xcenter, ycenter - 3.0));
                 builder.addInhibitionArc(beActive, tPassive);
                 builder.addInhibitionArc(beFailed, tPassive);
                 builder.addOutputArc(tPassive, beFailed);
@@ -125,15 +133,6 @@ namespace storm {
                     builder.addOutputArc(tActive, unavailableNode);
                     builder.addOutputArc(tPassive, unavailableNode);
                 }
-
-                double xcenter = mDft.getElementLayoutInfo(dftBE->id()).x;
-                double ycenter = mDft.getElementLayoutInfo(dftBE->id()).y;
-
-                builder.setPlaceLayoutInfo(beActive, storm::gspn::LayoutInfo(xcenter - 3.0, ycenter));
-                builder.setPlaceLayoutInfo(beFailed, storm::gspn::LayoutInfo(xcenter + 3.0, ycenter));
-                builder.setTransitionLayoutInfo(tActive, storm::gspn::LayoutInfo(xcenter, ycenter + 3.0));
-                builder.setTransitionLayoutInfo(tPassive, storm::gspn::LayoutInfo(xcenter, ycenter - 3.0));
-                
             }
 			
 			template <typename ValueType>
@@ -141,14 +140,19 @@ namespace storm {
                 uint64_t nodeFailed = builder.addPlace(defaultCapacity, 0, dftAnd->name() + STR_FAILED);
                 assert(failedNodes.size() == dftAnd->id());
                 failedNodes.push_back(nodeFailed);
-                
+
+                double xcenter = mDft.getElementLayoutInfo(dftAnd->id()).x;
+                double ycenter = mDft.getElementLayoutInfo(dftAnd->id()).y;
+                builder.setPlaceLayoutInfo(nodeFailed, storm::gspn::LayoutInfo(xcenter, ycenter-3.0));
+
                 uint64_t unavailableNode = 0;
                 if (isRepresentative) {
-                    unavailableNode = addUnavailableNode(dftAnd);
+                    unavailableNode = addUnavailableNode(dftAnd, storm::gspn::LayoutInfo(xcenter+6.0, ycenter-3.0));
                 }
 
                 
                 uint64_t tAndFailed = builder.addImmediateTransition( getFailPriority(dftAnd)  , 0.0, dftAnd->name() + STR_FAILING );
+                builder.setTransitionLayoutInfo(tAndFailed, storm::gspn::LayoutInfo(xcenter, ycenter+3.0));
                 builder.addInhibitionArc(nodeFailed, tAndFailed);
                 builder.addOutputArc(tAndFailed, nodeFailed);
                 if (isRepresentative) {
@@ -159,13 +163,6 @@ namespace storm {
                     builder.addInputArc(failedNodes[child->id()], tAndFailed);
                     builder.addOutputArc(tAndFailed, failedNodes[child->id()]);
                 }
-
-                double xcenter = mDft.getElementLayoutInfo(dftAnd->id()).x;
-                double ycenter = mDft.getElementLayoutInfo(dftAnd->id()).y;
-
-                builder.setPlaceLayoutInfo(nodeFailed, storm::gspn::LayoutInfo(xcenter, ycenter-3.0));
-                builder.setTransitionLayoutInfo(tAndFailed, storm::gspn::LayoutInfo(xcenter, ycenter+3.0));
-                
 			}
 
 			template <typename ValueType>
@@ -180,12 +177,13 @@ namespace storm {
 
                 uint64_t unavailableNode = 0;
                 if (isRepresentative) {
-                    unavailableNode = addUnavailableNode(dftOr);
+                    unavailableNode = addUnavailableNode(dftOr, storm::gspn::LayoutInfo(xcenter+6.0, ycenter-3.0));
                 }
                 
                 uint64_t i = 0;
                 for (auto const& child : dftOr->children()) {
-                    uint64_t tNodeFailed = builder.addImmediateTransition( getFailPriority(dftOr)  , 0.0, dftOr->name() + STR_FAILING + std::to_string(i) );
+                    uint64_t tNodeFailed = builder.addImmediateTransition( getFailPriority(dftOr), 0.0, dftOr->name() + STR_FAILING + std::to_string(i) );
+                    builder.setTransitionLayoutInfo(tNodeFailed, storm::gspn::LayoutInfo(xcenter-5.0+i*3.0, ycenter+3.0));
                     builder.addInhibitionArc(nodeFailed, tNodeFailed);
                     builder.addOutputArc(tNodeFailed, nodeFailed);
                     if (isRepresentative) {
@@ -195,21 +193,28 @@ namespace storm {
                     builder.addInputArc(failedNodes[child->id()], tNodeFailed);
                     builder.addOutputArc(tNodeFailed, failedNodes[child->id()]);
                     ++i;
-                    builder.setTransitionLayoutInfo(tNodeFailed, storm::gspn::LayoutInfo(xcenter-5+i*3, ycenter+3.0));
                 }
 			}
 			
 			template <typename ValueType>
             void DftToGspnTransformator<ValueType>::drawVOT(std::shared_ptr<storm::storage::DFTVot<ValueType> const> dftVot, bool isRepresentative) {
+                // TODO: finish layouting
                 uint64_t nodeFailed = builder.addPlace(defaultCapacity, 0, dftVot->name() + STR_FAILED);
                 assert(failedNodes.size() == dftVot->id());
                 failedNodes.push_back(nodeFailed);
+
+                double xcenter = mDft.getElementLayoutInfo(dftVot->id()).x;
+                double ycenter = mDft.getElementLayoutInfo(dftVot->id()).y;
+                builder.setPlaceLayoutInfo(nodeFailed, storm::gspn::LayoutInfo(xcenter, ycenter-3.0));
+
                 uint64_t unavailableNode = 0;
                 if (isRepresentative) {
-                    unavailableNode = addUnavailableNode(dftVot);
+                    unavailableNode = addUnavailableNode(dftVot, storm::gspn::LayoutInfo(xcenter+6.0, ycenter-3.0));
                 }
                 
                 uint64_t nodeCollector = builder.addPlace(dftVot->nrChildren(), 0, dftVot->name() + "_collector");
+                builder.setPlaceLayoutInfo(nodeCollector, storm::gspn::LayoutInfo(xcenter, ycenter));
+
                 uint64_t tNodeFailed = builder.addImmediateTransition(getFailPriority(dftVot), 0.0, dftVot->name() + STR_FAILING);
                 builder.addOutputArc(tNodeFailed, nodeFailed);
                 if (isRepresentative) {
@@ -239,24 +244,26 @@ namespace storm {
 
                 double xcenter = mDft.getElementLayoutInfo(dftPand->id()).x;
                 double ycenter = mDft.getElementLayoutInfo(dftPand->id()).y;
-                builder.setPlaceLayoutInfo(nodeFailed, storm::gspn::LayoutInfo(xcenter, ycenter-3.0));
+                builder.setPlaceLayoutInfo(nodeFailed, storm::gspn::LayoutInfo(xcenter+3.0, ycenter-3.0));
 
                 uint64_t unavailableNode = 0;
                 if (!smart || isRepresentative) {
-                    unavailableNode = addUnavailableNode(dftPand);
+                    unavailableNode = addUnavailableNode(dftPand, storm::gspn::LayoutInfo(xcenter+9.0, ycenter-3.0));
                 }
                 
                 uint64_t tNodeFailed = builder.addImmediateTransition(getFailPriority(dftPand), 0.0,  dftPand->name() + STR_FAILING);
+                builder.setTransitionLayoutInfo(tNodeFailed, storm::gspn::LayoutInfo(xcenter+3.0, ycenter+3.0));
                 builder.addInhibitionArc(nodeFailed, tNodeFailed);
                 builder.addOutputArc(tNodeFailed, nodeFailed);
                 if (!smart || isRepresentative) {
                     builder.addOutputArc(tNodeFailed, nodeFailed);
                 }
-                
-                
+
                 if(dftPand->isInclusive()) {
-                    
+                    // Inclusive PAND
                     uint64_t nodeFS = builder.addPlace(defaultCapacity, 0, dftPand->name() + STR_FAILSAVE);
+                    builder.setPlaceLayoutInfo(nodeFS, storm::gspn::LayoutInfo(xcenter-3.0, ycenter-3.0));
+
                     builder.addInhibitionArc(nodeFS, tNodeFailed);
                     for(auto const& child : dftPand->children()) {
                         builder.addInputArc(failedNodes[child->id()], tNodeFailed);
@@ -264,6 +271,8 @@ namespace storm {
                     }
                     for (uint64_t j = 1; j < dftPand->nrChildren(); ++j) {
                         uint64_t tfs = builder.addImmediateTransition(getFailPriority(dftPand), 0.0, dftPand->name() + STR_FAILSAVING + std::to_string(j));
+                        builder.setTransitionLayoutInfo(tfs, storm::gspn::LayoutInfo(xcenter-6.0+j*3.0, ycenter+3.0));
+
                         builder.addInputArc(failedNodes[dftPand->children().at(j)->id()], tfs);
                         builder.addOutputArc(tfs, failedNodes[dftPand->children().at(j)->id()]);
                         builder.addInhibitionArc(failedNodes[dftPand->children().at(j-1)->id()], tfs);
@@ -272,6 +281,7 @@ namespace storm {
                         
                     }
                 } else {
+                    // Exclusive PAND
                     uint64_t fi = 0;
                     uint64_t tn = 0;
                     for(uint64_t j = 0; j < dftPand->nrChildren(); ++j) {
@@ -281,6 +291,7 @@ namespace storm {
                         }
                         if (j != dftPand->nrChildren() - 1) {
                             tn = builder.addImmediateTransition(getFailPriority(dftPand), 0.0, dftPand->name() + STR_FAILING + "_" +std::to_string(j));
+                            builder.setTransitionLayoutInfo(tn, storm::gspn::LayoutInfo(xcenter-3.0, ycenter+3.0));
                         } else {
                             tn = tNodeFailed;
                         }
@@ -291,54 +302,128 @@ namespace storm {
                         }
                         if (j != dftPand->nrChildren() - 1) {
                             fi = builder.addPlace(defaultCapacity, 0, dftPand->name() + "_F_" + std::to_string(j));
+                            builder.setPlaceLayoutInfo(fi, storm::gspn::LayoutInfo(xcenter-3.0+j*3.0, ycenter));
                             builder.addOutputArc(tn, fi);
                         }
                         
                     }
                 }
             }
-//			
+
+            template <typename ValueType>
+            void DftToGspnTransformator<ValueType>::drawPOR(std::shared_ptr<storm::storage::DFTPor<ValueType> const> dftPor, bool isRepresentative) {
+                uint64_t nodeFailed = builder.addPlace(defaultCapacity, 0, dftPor->name() + STR_FAILED);
+                failedNodes.push_back(nodeFailed);
+
+                double xcenter = mDft.getElementLayoutInfo(dftPor->id()).x;
+                double ycenter = mDft.getElementLayoutInfo(dftPor->id()).y;
+                builder.setPlaceLayoutInfo(nodeFailed, storm::gspn::LayoutInfo(xcenter+3.0, ycenter-3.0));
+
+                uint64_t unavailableNode = 0;
+                if (!smart || isRepresentative) {
+                    unavailableNode = addUnavailableNode(dftPor, storm::gspn::LayoutInfo(xcenter+9.0, ycenter-3.0));
+                }
+
+                uint64_t tfail = builder.addImmediateTransition(getFailPriority(dftPor), 0.0, dftPor->name() + STR_FAILING);
+                builder.setTransitionLayoutInfo(tfail, storm::gspn::LayoutInfo(xcenter+3.0, ycenter+3.0));
+                builder.addOutputArc(tfail, nodeFailed);
+                builder.addInhibitionArc(nodeFailed, tfail);
+
+                builder.addInputArc(failedNodes.at(dftPor->children().front()->id()), tfail);
+                builder.addOutputArc(tfail, failedNodes.at(dftPor->children().front()->id()));
+
+                if(!smart || isRepresentative) {
+                    builder.addOutputArc(tfail, unavailableNode);
+                }
+
+                if(dftPor->isInclusive()) {
+                    // Inclusive POR
+                    uint64_t nodeFS = builder.addPlace(defaultCapacity, 0, dftPor->name() + STR_FAILSAVE);
+                    builder.setPlaceLayoutInfo(nodeFS, storm::gspn::LayoutInfo(xcenter-3.0, ycenter-3.0));
+
+                    builder.addInhibitionArc(nodeFS, tfail);
+                    uint64_t j = 0;
+                    for (auto const& child : dftPor->children()) {
+                        if(j > 0) {
+                            uint64_t tfailsf = builder.addImmediateTransition(getFailPriority(dftPor), 0.0, dftPor->name() + STR_FAILSAVING + std::to_string(j));
+                            builder.setTransitionLayoutInfo(tfailsf, storm::gspn::LayoutInfo(xcenter-3.0+j*3.0, ycenter+3.0));
+                            builder.addInputArc(failedNodes.at(child->id()), tfailsf);
+                            builder.addOutputArc(tfailsf, failedNodes.at(child->id()));
+                            builder.addOutputArc(tfailsf, nodeFS);
+                            builder.addInhibitionArc(nodeFS, tfailsf);
+                            builder.addInhibitionArc(failedNodes.at(dftPor->children().front()->id()), tfailsf);
+                        }
+
+                        ++j;
+                    }
+                } else {
+                    // Exclusive POR
+                    uint64_t j = 0;
+                    for (auto const& child : dftPor->children()) {
+                        if(j > 0) {
+                            builder.addInhibitionArc(failedNodes.at(child->id()), tfail);
+                        }
+                        ++j;
+                    }
+
+                }
+                
+            }
+
 			template <typename ValueType>
             void DftToGspnTransformator<ValueType>::drawSPARE(std::shared_ptr<storm::storage::DFTSpare<ValueType> const> dftSpare, bool isRepresentative) {
                 
                 uint64_t nodeFailed = builder.addPlace(defaultCapacity, 0, dftSpare->name() + STR_FAILED);
                 failedNodes.push_back(nodeFailed);
+
+                double xcenter = mDft.getElementLayoutInfo(dftSpare->id()).x;
+                double ycenter = mDft.getElementLayoutInfo(dftSpare->id()).y;
+                builder.setPlaceLayoutInfo(nodeFailed, storm::gspn::LayoutInfo(xcenter+10.0, ycenter-8.0));
+
                 uint64_t unavailableNode = 0;
                 if (isRepresentative) {
-                    unavailableNode = addUnavailableNode(dftSpare);
+                    unavailableNode = addUnavailableNode(dftSpare, storm::gspn::LayoutInfo(xcenter+16.0, ycenter-8.0));
                 }
                 uint64_t spareActive = builder.addPlace(defaultCapacity, 0, dftSpare->name() + STR_ACTIVATED);
+                builder.setPlaceLayoutInfo(spareActive, storm::gspn::LayoutInfo(xcenter-20.0, ycenter-8.0));
                 activeNodes.emplace(dftSpare->id(), spareActive);
 
                 
                 std::vector<uint64_t> cucNodes;
-                std::vector<uint64_t> nextClaimNodes;
+                std::vector<uint64_t> considerNodes;
                 std::vector<uint64_t> nextclTransitions;
                 std::vector<uint64_t> nextconsiderTransitions;
                 uint64_t j = 0;
                 for(auto const& child : dftSpare->children()) {
                     if (j > 0) {
-                        nextClaimNodes.push_back(builder.addPlace(defaultCapacity, 0, dftSpare->name()+ "_consider_" + child->name()));
-                        
-                        builder.addOutputArc(nextclTransitions.back(), nextClaimNodes.back(), 1);
+                        size_t nodeConsider = builder.addPlace(defaultCapacity, 0, dftSpare->name()+ "_consider_" + child->name());
+                        considerNodes.push_back(nodeConsider);
+                        builder.setPlaceLayoutInfo(nodeConsider, storm::gspn::LayoutInfo(xcenter-15.0+j*14.0, ycenter-8.0));
+
+                        builder.addOutputArc(nextclTransitions.back(), considerNodes.back(), 1);
                         if (j > 1) {
-                            builder.addOutputArc(nextconsiderTransitions.back(), nextClaimNodes.back());
+                            builder.addOutputArc(nextconsiderTransitions.back(), considerNodes.back());
                         }
                         
                         uint64_t tnextconsider = builder.addImmediateTransition(getFailPriority(dftSpare), 0.0, dftSpare->name() + "_cannot_claim_" + child->name());
-                        builder.addInputArc(nextClaimNodes.back(), tnextconsider);
+                        builder.setTransitionLayoutInfo(tnextconsider, storm::gspn::LayoutInfo(xcenter-7.0+j*14.0, ycenter-8.0));
+                        builder.addInputArc(considerNodes.back(), tnextconsider);
                         builder.addInputArc(unavailableNodes.at(child->id()), tnextconsider);
                         nextconsiderTransitions.push_back(tnextconsider);
                         
                     }
-                    cucNodes.push_back(builder.addPlace(defaultCapacity, j == 0 ? 1 : 0, dftSpare->name() + "_claimed_" + child->name()));
+                    size_t nodeCUC = builder.addPlace(defaultCapacity, j == 0 ? 1 : 0, dftSpare->name() + "_claimed_" + child->name());
+                    cucNodes.push_back(nodeCUC);
+                    builder.setPlaceLayoutInfo(nodeCUC, storm::gspn::LayoutInfo(xcenter-9.0+j*14.0, ycenter+5.0));
                     if (j > 0) {
                         uint64 tclaim = builder.addImmediateTransition(getFailPriority(dftSpare), 0.0, dftSpare->name() + "_claim_" + child->name());
+                        builder.setTransitionLayoutInfo(tclaim, storm::gspn::LayoutInfo(xcenter-9.0+j*14.0, ycenter));
                         builder.addInhibitionArc(unavailableNodes.at(child->id()), tclaim);
-                        builder.addInputArc(nextClaimNodes.back(), tclaim);
+                        builder.addInputArc(considerNodes.back(), tclaim);
                         builder.addOutputArc(tclaim, cucNodes.back());
                     }
                     uint64_t tnextcl = builder.addImmediateTransition(getFailPriority(dftSpare), 0.0, dftSpare->name() + "_next_claim_" + std::to_string(j));
+                    builder.setTransitionLayoutInfo(tnextcl, storm::gspn::LayoutInfo(xcenter-3.0+j*14.0, ycenter+5.0));
                     builder.addInputArc(cucNodes.back(), tnextcl);
                     builder.addOutputArc(tnextcl, cucNodes.back());
                     builder.addInputArc(failedNodes.at(child->id()), tnextcl);
@@ -356,64 +441,14 @@ namespace storm {
                 
 
 			}
-//			
-			template <typename ValueType>
-            void DftToGspnTransformator<ValueType>::drawPOR(std::shared_ptr<storm::storage::DFTPor<ValueType> const> dftPor, bool isRepresentative) {
-                uint64_t nodeFailed = builder.addPlace(defaultCapacity, 0, dftPor->name() + STR_FAILED);
-                failedNodes.push_back(nodeFailed);
-                
-                uint64_t unavailableNode = 0;
-                if (!smart || isRepresentative) {
-                    unavailableNode = addUnavailableNode(dftPor);
-                }
-                
-                uint64_t tfail = builder.addImmediateTransition(getFailPriority(dftPor), 0.0, dftPor->name() + STR_FAILING);
-                builder.addOutputArc(tfail, nodeFailed);
-                builder.addInhibitionArc(nodeFailed, tfail);
-                
-                builder.addInputArc(failedNodes.at(dftPor->children().front()->id()), tfail);
-                builder.addOutputArc(tfail, failedNodes.at(dftPor->children().front()->id()));
-                
-                if(!smart || isRepresentative) {
-                    builder.addOutputArc(tfail, unavailableNode);
-                }
-                
-                if(dftPor->isInclusive()) {
-                    uint64_t nodeFS = builder.addPlace(defaultCapacity, 0, dftPor->name() + STR_FAILSAVE);
-                    builder.addInhibitionArc(nodeFS, tfail);
-                    uint64_t j = 0;
-                    for (auto const& child : dftPor->children()) {
-                        if(j > 0) {
-                            uint64_t tfailsf = builder.addImmediateTransition(getFailPriority(dftPor), 0.0, dftPor->name() + STR_FAILSAVING + std::to_string(j));
-                            builder.addInputArc(failedNodes.at(child->id()), tfailsf);
-                            builder.addOutputArc(tfailsf, failedNodes.at(child->id()));
-                            builder.addOutputArc(tfailsf, nodeFS);
-                            builder.addInhibitionArc(nodeFS, tfailsf);
-                            builder.addInhibitionArc(failedNodes.at(dftPor->children().front()->id()), tfailsf);
-                        }
-                        
-                        ++j;
-                    }
-                } else {
-                    uint64_t j = 0;
-                    for (auto const& child : dftPor->children()) {
-                        if(j > 0) {
-                            builder.addInhibitionArc(failedNodes.at(child->id()), tfail);
-                        }
-                        ++j;
-                    }
-                    
-                }
-                
-			}
-            
-//			
+
 			template <typename ValueType>
             void DftToGspnTransformator<ValueType>::drawCONSTF(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dftConstF, bool isRepresentative) {
 			    failedNodes.push_back(builder.addPlace(defaultCapacity, 1, dftConstF->name() + STR_FAILED));
                 uint64_t unavailableNode = 0;
                 if (isRepresentative) {
-                    unavailableNode = addUnavailableNode(dftConstF, false);
+                    // TODO set position
+                    unavailableNode = addUnavailableNode(dftConstF, storm::gspn::LayoutInfo(0, 0), false);
                 }
 
 			}
@@ -501,10 +536,11 @@ namespace storm {
             }
             
             template<typename ValueType>
-            uint64_t DftToGspnTransformator<ValueType>::addUnavailableNode(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dftElement, bool initialAvailable) {
+            uint64_t DftToGspnTransformator<ValueType>::addUnavailableNode(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dftElement, storm::gspn::LayoutInfo const& layoutInfo, bool initialAvailable) {
                 uint64_t unavailableNode = builder.addPlace(defaultCapacity, initialAvailable ? 0 : 1, dftElement->name() + "_unavailable");
                 assert(unavailableNode != 0);
                 unavailableNodes.emplace(dftElement->id(), unavailableNode);
+                builder.setPlaceLayoutInfo(unavailableNode, layoutInfo);
                 return unavailableNode;
             }
             
diff --git a/src/storm-dft/transformations/DftToGspnTransformator.h b/src/storm-dft/transformations/DftToGspnTransformator.h
index 3cf5477e3..4ec911b23 100644
--- a/src/storm-dft/transformations/DftToGspnTransformator.h
+++ b/src/storm-dft/transformations/DftToGspnTransformator.h
@@ -136,7 +136,7 @@ namespace storm {
 				 uint64_t getFailPriority(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dFTElement);
 
                 
-                uint64_t addUnavailableNode(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dftElement, bool initialAvailable = true);
+                uint64_t addUnavailableNode(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dftElement, storm::gspn::LayoutInfo const& layoutInfo, bool initialAvailable = true);
                 
                 uint64_t addDisabledPlace(std::shared_ptr<storm::storage::DFTBE<ValueType> const> dftBe);
                 

From 9851100602bcaa22260127bfcb23f8713c57980e Mon Sep 17 00:00:00 2001
From: Sebastian Junges <sebastian.junges@rwth-aachen.de>
Date: Thu, 15 Dec 2016 23:14:25 +0100
Subject: [PATCH 46/47] mttf

---
 src/storm-dft-cli/storm-dyftee.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/storm-dft-cli/storm-dyftee.cpp b/src/storm-dft-cli/storm-dyftee.cpp
index 61959158a..f246438fe 100644
--- a/src/storm-dft-cli/storm-dyftee.cpp
+++ b/src/storm-dft-cli/storm-dyftee.cpp
@@ -157,9 +157,12 @@ int main(const int argc, const char** argv) {
             auto tbFormula = std::make_shared<storm::logic::BoundedUntilFormula>(std::make_shared<storm::logic::BooleanLiteralFormula>(true), evtlFormula, 0.0, 10.0);
             auto tbUntil = std::make_shared<storm::logic::ProbabilityOperatorFormula>(tbFormula);
             
+            auto evFormula = std::make_shared<storm::logic::EventuallyFormula>(evtlFormula, storm::logic::FormulaContext::Time);
+            auto rewFormula = std::make_shared<storm::logic::TimeOperatorFormula>(evFormula, storm::logic::OperatorInformation(), storm::logic::RewardMeasureType::Expectation);
+            
             storm::settings::modules::JaniExportSettings const& janiSettings = storm::settings::getModule<storm::settings::modules::JaniExportSettings>();
             if (janiSettings.isJaniFileSet()) {
-                storm::exportJaniModel(*model, {storm::jani::Property("time-bounded", tbUntil)}, janiSettings.getJaniFilename());
+                storm::exportJaniModel(*model, {storm::jani::Property("time-bounded", tbUntil), storm::jani::Property("mttf", rewFormula)}, janiSettings.getJaniFilename());
             }
             
             delete model;

From 7c3649297a58c15631944531f7b9ff0dba6ca7bd Mon Sep 17 00:00:00 2001
From: Sebastian Junges <sebastian.junges@rwth-aachen.de>
Date: Thu, 15 Dec 2016 23:23:14 +0100
Subject: [PATCH 47/47] fix spares

---
 src/storm-dft/transformations/DftToGspnTransformator.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/storm-dft/transformations/DftToGspnTransformator.cpp b/src/storm-dft/transformations/DftToGspnTransformator.cpp
index c95a7f21d..8c3ef0448 100644
--- a/src/storm-dft/transformations/DftToGspnTransformator.cpp
+++ b/src/storm-dft/transformations/DftToGspnTransformator.cpp
@@ -425,7 +425,6 @@ namespace storm {
                     uint64_t tnextcl = builder.addImmediateTransition(getFailPriority(dftSpare), 0.0, dftSpare->name() + "_next_claim_" + std::to_string(j));
                     builder.setTransitionLayoutInfo(tnextcl, storm::gspn::LayoutInfo(xcenter-3.0+j*14.0, ycenter+5.0));
                     builder.addInputArc(cucNodes.back(), tnextcl);
-                    builder.addOutputArc(tnextcl, cucNodes.back());
                     builder.addInputArc(failedNodes.at(child->id()), tnextcl);
                     builder.addOutputArc(tnextcl, failedNodes.at(child->id()));
                     nextclTransitions.push_back(tnextcl);
@@ -434,6 +433,7 @@ namespace storm {
                         
                         uint64_t tactive = builder.addImmediateTransition(defaultPriority+1, 0.0, dftSpare->name() + "_activate_" + std::to_string(j) + "_" +  std::to_string(k));
                         builder.addInputArc(cucNodes.back(), tactive);
+                        builder.addOutputArc(tactive, cucNodes.back());
                         builder.addInputArc(spareActive, tactive);
                         builder.addOutputArc(tactive, activeNodes.at(k));
                         builder.addInhibitionArc(activeNodes.at(k), tactive);