module YPetri::Place::Arcs

Connectivity aspect of a Petri net place.

Attributes

downstream_arcs[R]

Transitions whose action directly depends on this place. Aliased as #downstream_transitions.

downstream_transitions[R]

Transitions whose action directly depends on this place. Aliased as #downstream_transitions.

upstream_arcs[R]

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.)

upstream_transitions[R]

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.)

ϝ[R]

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

aa(arg=nil) click to toggle source

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(id) click to toggle source

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
arcs() click to toggle source

All the transitions connected to the place.

# File lib/y_petri/place/arcs.rb, line 22
def arcs
  upstream_arcs | downstream_arcs
end
dependents() click to toggle source

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
Also aliased as: downstream_places
downstream_net() click to toggle source

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
downstream_places()
Alias for: dependents
fire_downstream() click to toggle source

Fires the downstream transitions.

# File lib/y_petri/place/arcs.rb, line 107
def fire_downstream
  downstream_arcs.each &:fire
end
fire_downstream!() click to toggle source

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
fire_downstream_recursively() click to toggle source

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
fire_upstream() click to toggle source

Fires the upstream transitions.

# File lib/y_petri/place/arcs.rb, line 86
def fire_upstream
  upstream_arcs.each &:fire
end
fire_upstream!() click to toggle source

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
fire_upstream_recursively() click to toggle source

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
local_net() click to toggle source

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
precedents() click to toggle source

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
Also aliased as: upstream_places
upstream_net() click to toggle source

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
upstream_places()
Alias for: precedents

Private Instance Methods

register_downstream_transition( transition ) click to toggle source

Notes a new downstream transition.

# File lib/y_petri/place/arcs.rb, line 137
def register_downstream_transition( transition )
  @downstream_arcs << transition
end
register_upstream_transition( transition ) click to toggle source

Notes a new upstream transition.

# File lib/y_petri/place/arcs.rb, line 131
def register_upstream_transition( transition )
  @upstream_arcs << transition
end