class YPetri::Net::State::Feature::Firing

Firing of an S transition. (Firing is only defined on S transitions, whose action can be computed as firing * stoichometry_vector_of_the_transition.)

Attributes

instances[R]
transition[R]

Public Class Methods

__new__(id)
Alias for: new
new(id) click to toggle source
# File lib/y_petri/net/state/feature/firing.rb, line 42
def new id
  instances[ id ]
end
Also aliased as: __new__
new(transition) click to toggle source

The constructor of a marking feature takes exactly one argument (transition identifier).

# File lib/y_petri/net/state/feature/firing.rb, line 71
def initialize transition
  @transition = net.transition( transition )
end
of(id) click to toggle source

Alias of new method.

# File lib/y_petri/net/state/feature/firing.rb, line 48
def of id
  new id
end
parametrize(*args) click to toggle source

Customization of the Class#parametrize method.

# File lib/y_petri/net/state/feature/firing.rb, line 12
def parametrize *args
  Class.instance_method( :parametrize ).bind( self ).( *args ).tap do |ç|
    # First, prepare the hash of instances.
    hsh = Hash.new do |hsh, id|
      case id
      when self then # missing key "id" is a Firing instance
        hsh[ id.transition ]
      when ç.net.Transition then
        t = begin
              ç.net.S_transitions( id ).first
            rescue TypeError => err
              msg = "Transition #{id} not " +
                "recognized as tS transition in " +
                "net #{ç.net}! (%s)"
              raise TypeError, msg % err
            end
        hsh[ id ] = t.timed? ? ç.timed( t ) : ç.timeless( t )
      else
        hsh[ ç.net.transition( id ) ]
      end
    end
    # And then, assign it to the :@instances variable.
    ç.instance_variable_set :@instances, hsh
  end
end
timed(id) click to toggle source

Expects a single timed transition and constructs a timed firing feature.

# File lib/y_petri/net/state/feature/firing.rb, line 54
def timed id
  __new__( net.T_tt( id ).first )
    .tap { |i| i.instance_variable_set :@timed, true }
end
timeless(id) click to toggle source

Expects a single timeless transition and constructs a timeless firing feature.

# File lib/y_petri/net/state/feature/firing.rb, line 62
def timeless id
  __new__( net.t_tt( id ).first )
    .tap { |i| i.instance_variable_set :@timed, false }
end

Public Instance Methods

==(other) click to toggle source

Firing features are equal if they are of equal PS and refer to the same transition.

# File lib/y_petri/net/state/feature/firing.rb, line 132
def == other
  other.is_a? net.State.Feature.Firing and transition == other.transition
end
extract_from(arg, **named_args) click to toggle source

Extracts the value of this feature from the target (eg. a simulation). If the receiver firing feature is timed, this method requires an additional named argument :delta_time, alias +:Δt+.

# File lib/y_petri/net/state/feature/firing.rb, line 79
def extract_from arg, **named_args
  case arg
  when YPetri::Simulation then
    if timed? then
      arg.send( :TS_transitions, transition ).first
        .firing( named_args.must_have :delta_time, syn!: :Δt )
    else
      arg.send( :tS_transitions, transition ).first.firing
    end
  else
    fail TypeError, "Argument type not supported!"
  end
end
inspect() click to toggle source

Inspect string of the firing feature.

# File lib/y_petri/net/state/feature/firing.rb, line 125
def inspect
  "<Feature::Firing of #{transition.name ? transition.name : transition}>"
end
label() click to toggle source

Label for the firing feature (to use in the graphics etc.)

# File lib/y_petri/net/state/feature/firing.rb, line 119
def label
  "F:#{transition.name}"
end
timed?() click to toggle source

Is the delta feature timed?

# File lib/y_petri/net/state/feature/firing.rb, line 95
def timed?
  @timed
end
timeless?() click to toggle source

Opposite of #timed?.

# File lib/y_petri/net/state/feature/firing.rb, line 101
def timeless?
  ! timed?
end
to_s() click to toggle source

A string briefly describing the firing feature.

# File lib/y_petri/net/state/feature/firing.rb, line 113
def to_s
  label
end
type() click to toggle source

Type of this feature.

# File lib/y_petri/net/state/feature/firing.rb, line 107
def type
  :firing
end