diff --git a/src/storm/storage/gspn/GSPN.cpp b/src/storm/storage/gspn/GSPN.cpp index 7a2ed6bb4..c06cc0672 100644 --- a/src/storm/storage/gspn/GSPN.cpp +++ b/src/storm/storage/gspn/GSPN.cpp @@ -153,55 +153,50 @@ namespace storm { // print arcs for (auto& trans : this->getImmediateTransitions()) { - auto it = trans->getInputPlacesCBegin(); - while (it != trans->getInputPlacesCEnd()) { - outStream << "\t" << (**it).getName() << " -> " << trans->getName() << "[label=\"" << - ((trans->getInputArcMultiplicity(**it) == 1) ? "" : std::to_string(trans->getInputArcMultiplicity(**it))) - << "\"];" << std::endl; - - ++it; + for (auto const& inEntry : trans.getInputPlaces()) { + if (trans.getOutputPlaces().count(inEntry.first) == 0) { + outStream << "\t" << places.at(inEntry.first).getName() << " -> " << trans.getName() << "[label=\"" << (inEntry.second > 1 ? std::to_string(inEntry.second) : "") << "\"];" << std::endl; + } } - it = trans->getInhibitionPlacesCBegin(); - while (it != trans->getInhibitionPlacesCEnd()) { - outStream << "\t" << (**it).getName() << " -> " << trans->getName() << "[arrowhead=\"dot\", label=\"" << - ((trans->getInhibitionArcMultiplicity(**it) == 1) ? "" : std::to_string(trans->getInhibitionArcMultiplicity(**it))) - << "\"];" << std::endl; - ++it; + for (auto const& inhEntry : trans.getInhibitionPlaces()) { + if (trans.getOutputPlaces().count(inhEntry.first) == 0) { + outStream << "\t" << places.at(inhEntry.first).getName() << " -> " << trans.getName() << "[arrowhead=\"dot\", label=\"" << (inhEntry.second > 1 ? std::to_string(inhEntry.second) : "") << "\"];" << std::endl; + } } - it = trans->getOutputPlacesCBegin(); - while (it != trans->getOutputPlacesCEnd()) { - outStream << "\t" << trans->getName() << " -> " << (**it).getName() << "[label=\"" << - ((trans->getOutputArcMultiplicity(**it) == 1) ? "" : std::to_string(trans->getOutputArcMultiplicity(**it))) - << "\"];" << std::endl; - ++it; + for (auto const& outEntry : trans.getOutputPlaces()) { + if (trans.getInhibitionPlaces().count(outEntry.first) == 1) { + outStream << "\t" << trans.getName() << " -> " << places.at(outEntry.first).getName() << "[arrowtail=\"dot\", label=\"" << (outEntry.second > 1 ? std::to_string(outEntry.second) : "") << "\", dir=both];" << std::endl; + } else if (trans.getInputPlaces().count(outEntry.first) == 1) { + outStream << "\t" << trans.getName() << " -> " << places.at(outEntry.first).getName() << "[arrowtail=\"dot\", label=\"" << (outEntry.second > 1 ? std::to_string(outEntry.second) : "")<< "\", dir=both];" << std::endl; + } else { + outStream << "\t" << trans.getName() << " -> " << places.at(outEntry.first).getName() << "[label=\"" << (outEntry.second > 1 ? std::to_string(outEntry.second) : "") << "\"];" << std::endl; + } } } for (auto& trans : this->getTimedTransitions()) { - auto it = trans->getInputPlacesCBegin(); - while (it != trans->getInputPlacesCEnd()) { - outStream << "\t" << (**it).getName() << " -> " << trans->getName() << "[label=\"" << - ((trans->getInputArcMultiplicity(**it) == 1) ? "" : std::to_string(trans->getInputArcMultiplicity(**it))) - << "\"];" << std::endl; - ++it; + for (auto const& inEntry : trans.getInputPlaces()) { + if (trans.getOutputPlaces().count(inEntry.first) == 0) { + outStream << "\t" << places.at(inEntry.first).getName() << " -> " << trans.getName() << "[label=\"" << (inEntry.second > 1 ? std::to_string(inEntry.second) : "") << "\"];" << std::endl; + } } - it = trans->getInhibitionPlacesCBegin(); - while (it != trans->getInhibitionPlacesCEnd()) { - outStream << "\t" << (**it).getName() << " -> " << trans->getName() << "[arrowhead=\"dot\", label=\"" << - ((trans->getInhibitionArcMultiplicity(**it) == 1) ? "" : std::to_string(trans->getInhibitionArcMultiplicity(**it))) - << "\"];" << std::endl; - ++it; + for (auto const& inhEntry : trans.getInhibitionPlaces()) { + if (trans.getOutputPlaces().count(inhEntry.first) == 0) { + outStream << "\t" << places.at(inhEntry.first).getName() << " -> " << trans.getName() << "[arrowhead=\"dot\", label=\"" << (inhEntry.second > 1 ? std::to_string(inhEntry.second) : "") << "\"];" << std::endl; + } } - it = trans->getOutputPlacesCBegin(); - while (it != trans->getOutputPlacesCEnd()) { - outStream << "\t" << trans->getName() << " -> " << (**it).getName() << "[label=\"" << - ((trans->getOutputArcMultiplicity(**it) == 1) ? "" : std::to_string(trans->getOutputArcMultiplicity(**it))) - << "\"];" << std::endl; - ++it; + for (auto const& outEntry : trans.getOutputPlaces()) { + if (trans.getInhibitionPlaces().count(outEntry.first) == 1) { + outStream << "\t" << trans.getName() << " -> " << places.at(outEntry.first).getName() << "[arrowtail=\"dot\", label=\"" << (outEntry.second > 1 ? std::to_string(outEntry.second) : "") << "\", dir=both];" << std::endl; + } else if (trans.getInputPlaces().count(outEntry.first) == 1) { + outStream << "\t" << trans.getName() << " -> " << places.at(outEntry.first).getName() << "[arrowtail=\"dot\", label=\"" << (outEntry.second > 1 ? std::to_string(outEntry.second) : "")<< "\", dir=both];" << std::endl; + } else { + outStream << "\t" << trans.getName() << " -> " << places.at(outEntry.first).getName() << "[label=\"" << (outEntry.second > 1 ? std::to_string(outEntry.second) : "") << "\"];" << std::endl; + } } } diff --git a/src/storm/storage/gspn/GspnBuilder.cpp b/src/storm/storage/gspn/GspnBuilder.cpp index d23a515e9..f5257456d 100644 --- a/src/storm/storage/gspn/GspnBuilder.cpp +++ b/src/storm/storage/gspn/GspnBuilder.cpp @@ -17,6 +17,7 @@ namespace storm { auto place = storm::gspn::Place(newId); place.setCapacity(capacity); place.setNumberOfInitialTokens(initialTokens); + place.setName(name); places.push_back(place); return newId; } @@ -24,7 +25,7 @@ namespace storm { uint_fast64_t GspnBuilder::addImmediateTransition(uint_fast64_t const& priority, double const& weight, std::string const& name) { auto trans = storm::gspn::ImmediateTransition<double>(); auto newId = GSPN::immediateTransitionIdToTransitionId(immediateTransitions.size()); - trans.setName(std::to_string(newId)); + trans.setName(name); trans.setPriority(priority); trans.setWeight(weight); trans.setID(newId); @@ -36,7 +37,7 @@ namespace storm { uint_fast64_t GspnBuilder::addTimedTransition(uint_fast64_t const &priority, double const &rate, std::string const& name) { auto trans = storm::gspn::TimedTransition<double>(); auto newId = GSPN::timedTransitionIdToTransitionId(timedTransitions.size()); - trans.setName(std::to_string(newId)); + trans.setName(name); trans.setPriority(priority); trans.setRate(rate); trans.setID(newId); @@ -85,7 +86,7 @@ namespace storm { Transition& GspnBuilder::getTransition(uint64_t id) { if (isTimedTransitionId(id)) { - return timedTransitions.at(id); + return timedTransitions.at(GSPN::transitionIdToTimedTransitionId(id)); } else if(isImmediateTransitionId(id)) { return immediateTransitions.at(id); } else {