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
Public Class Methods
# File lib/y_petri/net/state/feature/firing.rb, line 42 def new id instances[ id ] end
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
Alias of new method.
# File lib/y_petri/net/state/feature/firing.rb, line 48 def of id new id end
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
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
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
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
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 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 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
Is the delta feature timed?
# File lib/y_petri/net/state/feature/firing.rb, line 95 def timed? @timed end
Opposite of #timed?
.
# File lib/y_petri/net/state/feature/firing.rb, line 101 def timeless? ! timed? end
A string briefly describing the firing feature.
# File lib/y_petri/net/state/feature/firing.rb, line 113 def to_s label end
Type of this feature.
# File lib/y_petri/net/state/feature/firing.rb, line 107 def type :firing end