module YPetri::Agent::PetriNetAspect
Petri net aspect of YPetri::Agent
.
Constants
- NetSelection
A class representing a selection of nets.
Attributes
Net
point.
Net
selection.
Public Class Methods
Standard initialization method. Takes no arguments.
# File lib/y_petri/agent/petri_net_aspect.rb, line 20 def initialize net_point_reset @net_selection = NetSelection.new super end
Public Instance Methods
Assignment transition constructor: Creates a new assignment transition in the current world. Ordered arguments are collected as codomain. Domain key (+:domain) is optional. Assignment closure must be supplied in a block.
# File lib/y_petri/agent/petri_net_aspect.rb, line 83 def AT( *codomain, **nn, &block ) fail ArgumentError, "Assignment transition constructor requires a block " + "defining the assignment function!" unless block world.Transition.send( :new, codomain: codomain, assignment: block, **nn ) end
Constructor of a place: Creates a new place in the current world.
# File lib/y_petri/agent/petri_net_aspect.rb, line 64 def Place( *ordered_args, **named_args, &block ) fail ArgumentError, "If block is given, :guard named argument " + "must not be given!" if named_args.has? :guard if block named_args.update( guard: block ) if block # use block as a guard named_args.may_have :default_marking, syn!: :m! named_args.may_have :marking, syn!: :m world.Place.send( :new, *ordered_args, **named_args, &block ) end
Timed stoichiometric transition constructor, that expects stoichiometry given directly as hash-collected arguments. Two special keys allowed are :name
(alias +:ɴ) and :domain
. (Key :codomain
is not allowed.)
# File lib/y_petri/agent/petri_net_aspect.rb, line 110 def TS *domain, **stoichiometry, &block nn = stoichiometry args = { s: nn } args.update name: nn.delete( :name ) if nn.has? :name, syn!: :ɴ if domain.empty? then args.update domain: nn.delete( :domain ) if nn.has? :domain else fail ArgumentError, "There must not be any ordered arguments if " + "named argument :domain is given!" if nn.has? :domain args.update domain: domain end args.update rate: nn.delete( :rate ) if nn.has? :rate, syn!: :rate_closure TT **args, &block end
Timed transition constructor: Creates a new timed transition in the current world. Rate can be supplied either as :rate
named argument, or as a block. If none is supplied, rate argument defaults to 1.
# File lib/y_petri/agent/petri_net_aspect.rb, line 96 def TT( *ordered, **named, &block ) if named.has? :rate then fail ArgumentError, "Block must not be given if :rate named argument " + "is given!" if block else named.update rate: block || 1 # default rate is 1 end world.Transition.send( :new, *ordered, **named ) end
Constructor of a transition: Creates a new transition in the current world.
# File lib/y_petri/agent/petri_net_aspect.rb, line 75 def Transition( *ordered, **named, &block ) world.Transition.send( :new, *ordered, **named, &block ) end
Returns the net identified, or the net at point (if no argument given).
# File lib/y_petri/agent/petri_net_aspect.rb, line 150 def net id=nil id.nil? ? @net_point : world.net( id ) end
Sets net point to a given net.
# File lib/y_petri/agent/petri_net_aspect.rb, line 162 def net_point= id net_point_reset id end
Sets the net point to a given net, or to world.Net::Top if none given.
# File lib/y_petri/agent/petri_net_aspect.rb, line 156 def net_point_reset id=world.Net.instance( :Top ) @net_point = world.net( id ) end
Names of the nets.
# File lib/y_petri/agent/petri_net_aspect.rb, line 58 def nn nets.names end
Returns the name of a place identified by the argument.
# File lib/y_petri/agent/petri_net_aspect.rb, line 34 def pl( place_id ) place( place_id ).name end
Names of the places.
# File lib/y_petri/agent/petri_net_aspect.rb, line 46 def pn places.names end
Names of the transitions.
# File lib/y_petri/agent/petri_net_aspect.rb, line 52 def tn transitions.names end
Returns the name of a transition identified by the argument.
# File lib/y_petri/agent/petri_net_aspect.rb, line 40 def tr( transition_id ) transition( transition_id ).name end