#pragma once #include #include #include #include "GSPN.h" namespace storm { namespace gspn { class GspnBuilder { public: typedef double RateType; typedef double WeightType; /** * Set GSPN name */ void setGspnName(std::string const& name); /** * Add a place to 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(boost::optional 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 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. * The transition is assumed to have Single-Server-Semantics * @param priority The priority for the transtion. * @param rate The rate for the transition. */ uint_fast64_t addTimedTransition(uint_fast64_t const &priority, RateType const& rate, std::string const& name = ""); /** * Adds an timed transition to the gspn. * @param priority The priority for the transtion. * @param rate The rate for the transition. * @param numServers The number of servers this transition has (in case of K-Server semantics) or boost::none (in case of Infinite-Server-Semantics). */ uint_fast64_t addTimedTransition(uint_fast64_t const &priority, RateType const& rate, boost::optional numServers, std::string const& name = ""); void setTransitionLayoutInfo(uint64_t transitionId, LayoutInfo const& layoutInfo); /** * Adds an new input arc from a place to an transition. * @param from The place from which the arc is originating. * @param to The transtion to which the arc goes to. * @param multiplicity The multiplicity of the arc. */ void addInputArc(uint_fast64_t const &from, uint_fast64_t const &to, uint_fast64_t const &multiplicity = 1); void addInputArc(std::string const& from, std::string const& to, uint64_t multiplicity = 1); /** * Adds an new input arc from a place to an transition. * @param from The place from which the arc is originating. * @param to The transtion to which the arc goes to. * @param multiplicity The multiplicity of the arc. */ void addInhibitionArc(uint_fast64_t const& from, uint_fast64_t const& to, uint_fast64_t const& multiplicity = 1); void addInhibitionArc(std::string const& from, std::string const& to, uint64_t multiplicity = 1); /** * Adds an new input arc from a place to an transition. * @param from The place from which the arc is originating. * @param to The transtion to which the arc goes to. * @param multiplicity The multiplicity of the arc. */ void addOutputArc(uint_fast64_t const& from, uint_fast64_t const& to, uint_fast64_t const& multiplicity = 1); void addOutputArc(std::string const& from, std::string const& to, uint64_t multiplicity = 1); /** * Adds an arc from a named element to a named element. * Can be both input or output arc, but not an inhibition arc. * Convenience function for textual format parsers. * * @param from Source element in the GSPN from where this arc starts * @param to Target element in the GSPN where this arc ends * @param multiplicity (Optional) multiplicity for the arc, default = 1 */ void addNormalArc(std::string const& from, std::string const& to, uint64_t multiplicity = 1); /** * @param exprManager The expression manager that will be associated with the new gspn. If this is nullptr, a new expressionmanager will be created. * @return The gspn which is constructed by the builder. */ storm::gspn::GSPN* buildGspn(std::shared_ptr const& exprManager = nullptr, std::map const& constantsSubstitution = std::map()) const; private: bool isImmediateTransitionId(uint64_t) const; bool isTimedTransitionId(uint64_t) const; Transition& getTransition(uint64_t); std::map placeNames; std::map transitionNames; std::string gspnName = "_gspn_"; std::map> partitions; // set containing all immediate transitions std::vector> immediateTransitions; // set containing all timed transitions std::vector> timedTransitions; // set containing all places std::vector places; std::map placeLayout; std::map transitionLayout; }; } }