module YPetri::Place::Arcs
Connectivity aspect of a Petri net place.
Attributes
Transitions whose action directly depends on this place. Aliased as #downstream_transitions
.
Transitions whose action directly depends on this place. Aliased as #downstream_transitions
.
Transitions that can directly add/remove tokens from this place. Aliased as #upstream_transitions
and +#ϝ+. (Digamma resembles “f”, meaning function, well known from existing spreadsheet software.)
Transitions that can directly add/remove tokens from this place. Aliased as #upstream_transitions
and +#ϝ+. (Digamma resembles “f”, meaning function, well known from existing spreadsheet software.)
Transitions that can directly add/remove tokens from this place. Aliased as #upstream_transitions
and +#ϝ+. (Digamma resembles “f”, meaning function, well known from existing spreadsheet software.)
Public Instance Methods
Names of the transitions connected to the place. The optional argument controls what is returned for unnamed instances, and works just like in Array#names
method from y_support/name_magic
: The default value (nil) returns nil, true returns the instance itself, and false drops the unnamed instances from the list altogether.
# File lib/y_petri/place/arcs.rb, line 32 def aa arg=nil arcs.names arg end
Arc (a transition connected to this place) identifier.
# File lib/y_petri/place/arcs.rb, line 38 def arc id transition = transition( id ) arcs.find { |t| t == transition } or fail TypeError, "No transition #{id} connected to #{self}!" end
All the transitions connected to the place.
# File lib/y_petri/place/arcs.rb, line 22 def arcs upstream_arcs | downstream_arcs end
Union of the codomains of the downstream transitions.
# File lib/y_petri/place/arcs.rb, line 53 def dependents downstream_transitions.map( &:downstream_places ).reduce( [], :| ) end
A net containing all the upstream transitions and their connected places.
# File lib/y_petri/place/arcs.rb, line 70 def downstream_net net_klass = world.Net rescue YPetri::Net # for when not used as PS downstream_transitions.each_with_object net_klass.send( :new ) do |t, net| t.arcs.each { |place| net << place } net << t end end
Fires the downstream transitions.
# File lib/y_petri/place/arcs.rb, line 107 def fire_downstream downstream_arcs.each &:fire end
Fires the downstream transitions regardless of cocking. (Normally, transitions should be cocked (#cock
method) before they are fired (#fire
method).)
# File lib/y_petri/place/arcs.rb, line 115 def fire_downstream! @downstream_arcs.each &:fire! end
Fires the whole downstream portion of the net. Cocking ensures that the recursive firing will eventually end.
# File lib/y_petri/place/arcs.rb, line 122 def fire_downstream_recursively # LATER: This as a global hash { place => fire_list } @downstream_arcs.each &:fire_downstream_recursively end
Fires the upstream transitions.
# File lib/y_petri/place/arcs.rb, line 86 def fire_upstream upstream_arcs.each &:fire end
Fires the upstream transitions regardless of cocking. (Normally, transitions should be cocked (#cock
method) before they are fired (#fire
method).)
# File lib/y_petri/place/arcs.rb, line 93 def fire_upstream! upstream_arcs.each &:fire! end
Fires the whole upstream portion of the net. Cocking ensures that the recursive firing will eventually end.
# File lib/y_petri/place/arcs.rb, line 100 def fire_upstream_recursively # LATER: This as a global hash { place => fire_list } @upstream_arcs.each &:fire_upstream_recursively end
A union of upstream local net and downstream local net.
# File lib/y_petri/place/arcs.rb, line 80 def local_net downstream_net + upstream_net end
Union of the domains of the upstream transitions.
# File lib/y_petri/place/arcs.rb, line 46 def precedents upstream_transitions.map( &:upstream_places ).reduce( [], :| ) end
A net containing all the upstream transitions and their connected places.
# File lib/y_petri/place/arcs.rb, line 60 def upstream_net net_klass = world.Net rescue YPetri::Net # for when not used as PS upstream_transitions.each_with_object net_klass.send( :new ) do |t, net| t.arcs.each { |place| net << place } net << t end end
Private Instance Methods
Notes a new downstream transition.
# File lib/y_petri/place/arcs.rb, line 137 def register_downstream_transition( transition ) @downstream_arcs << transition end
Notes a new upstream transition.
# File lib/y_petri/place/arcs.rb, line 131 def register_upstream_transition( transition ) @upstream_arcs << transition end