module YPetri::Agent::PetriNetAspect

Petri net aspect of YPetri::Agent.

Constants

NetSelection

A class representing a selection of nets.

Attributes

net_point[R]

Net point.

net_selection[R]

Net selection.

Public Class Methods

new() click to toggle source

Standard initialization method. Takes no arguments.

Calls superclass method
# 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

AT( *codomain, **nn, &block ) click to toggle source

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
Net(*ordered, of: nil, **named, &block) click to toggle source

Net constructor: Creates a new Net instance in the current world.

# File lib/y_petri/agent/petri_net_aspect.rb, line 140
def Net *ordered, of: nil, **named, &block
  if of.nil? then
    world.Net.send( :new, *ordered, **named, &block )
  else
    world.Net.of( of, *ordered, **named, &block )
  end
end
Place( *ordered_args, **named_args, &block ) click to toggle source

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
TS(*domain, **stoichiometry, &block) click to toggle source

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
TT( *ordered, **named, &block ) click to toggle source

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
Transition( *ordered, **named, &block ) click to toggle source

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

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

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
net_point_reset(id=world.Net.instance( :Top )) click to toggle source

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

Names of the nets.

# File lib/y_petri/agent/petri_net_aspect.rb, line 58
def nn
  nets.names
end
pl( place_id ) click to toggle source

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

Names of the places.

# File lib/y_petri/agent/petri_net_aspect.rb, line 46
def pn
  places.names
end
tn() click to toggle source

Names of the transitions.

# File lib/y_petri/agent/petri_net_aspect.rb, line 52
def tn
  transitions.names
end
tr( transition_id ) click to toggle source

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