Class: YPetri::Net::State::Feature::Firing
- Inherits:
-
YPetri::Net::State::Feature
- Object
- YPetri::Net::State::Feature
- YPetri::Net::State::Feature::Firing
- Defined in:
- lib/y_petri/net/state/feature/firing.rb
Overview
Firing of an S transition. (Firing is only defined on S transitions, whose action can be computed as firing * stoichometry_vector_of_the_transition.)
Class Attribute Summary collapse
-
.instances ⇒ Object
readonly
Returns the value of attribute instances.
Instance Attribute Summary collapse
-
#transition ⇒ Object
readonly
Returns the value of attribute transition.
Class Method Summary collapse
- .__new__ ⇒ Object
- .new(id) ⇒ Object
-
.of(id) ⇒ Object
Alias of #new method.
-
.parametrize(*args) ⇒ Object
Customization of the Class#parametrize method.
-
.timed(id) ⇒ Object
Expects a single timed transition and constructs a timed firing feature.
-
.timeless(id) ⇒ Object
Expects a single timeless transition and constructs a timeless firing feature.
Instance Method Summary collapse
-
#==(other) ⇒ Object
Firing features are equal if they are of equal PS and refer to the same transition.
-
#extract_from(arg, **named_args) ⇒ Object
Extracts the value of this feature from the target (eg. a simulation).
-
#initialize(transition) ⇒ Firing
constructor
The constructor of a marking feature takes exactly one argument (transition identifier).
-
#inspect ⇒ Object
Inspect string of the firing feature.
-
#label ⇒ Object
Label for the firing feature (to use in the graphics etc.).
-
#timed? ⇒ Boolean
Is the delta feature timed?.
-
#timeless? ⇒ Boolean
Opposite of
#timed?
. -
#to_s ⇒ Object
A string briefly describing the firing feature.
-
#type ⇒ Object
Type of this feature.
Methods inherited from YPetri::Net::State::Feature
#%, Assignment, Delta, Firing, Flux, Gradient, Marking, infer_from_node
Constructor Details
#initialize(transition) ⇒ Firing
The constructor of a marking feature takes exactly one argument (transition identifier).
71 72 73 |
# File 'lib/y_petri/net/state/feature/firing.rb', line 71 def initialize transition @transition = net.transition( transition ) end |
Class Attribute Details
.instances ⇒ Object (readonly)
Returns the value of attribute instances.
38 39 40 |
# File 'lib/y_petri/net/state/feature/firing.rb', line 38 def instances @instances end |
Instance Attribute Details
#transition ⇒ Object (readonly)
Returns the value of attribute transition.
7 8 9 |
# File 'lib/y_petri/net/state/feature/firing.rb', line 7 def transition @transition end |
Class Method Details
.__new__ ⇒ Object
40 |
# File 'lib/y_petri/net/state/feature/firing.rb', line 40 alias __new__ new |
.new(id) ⇒ Object
42 43 44 |
# File 'lib/y_petri/net/state/feature/firing.rb', line 42 def new id instances[ id ] end |
.of(id) ⇒ Object
Alias of #new method.
48 49 50 |
# File 'lib/y_petri/net/state/feature/firing.rb', line 48 def of id new id end |
.parametrize(*args) ⇒ Object
Customization of the Class#parametrize method.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# 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) ⇒ Object
Expects a single timed transition and constructs a timed firing feature.
54 55 56 57 |
# 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) ⇒ Object
Expects a single timeless transition and constructs a timeless firing feature.
62 63 64 65 |
# 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 |
Instance Method Details
#==(other) ⇒ Object
Firing features are equal if they are of equal PS and refer to the same transition.
132 133 134 |
# 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) ⇒ Object
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.
79 80 81 82 83 84 85 86 87 88 89 90 91 |
# 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 ⇒ Object
Inspect string of the firing feature.
125 126 127 |
# File 'lib/y_petri/net/state/feature/firing.rb', line 125 def inspect "<Feature::Firing of #{transition.name ? transition.name : transition}>" end |
#label ⇒ Object
Label for the firing feature (to use in the graphics etc.)
119 120 121 |
# File 'lib/y_petri/net/state/feature/firing.rb', line 119 def label "F:#{transition.name}" end |
#timed? ⇒ Boolean
Is the delta feature timed?
95 96 97 |
# File 'lib/y_petri/net/state/feature/firing.rb', line 95 def timed? @timed end |
#timeless? ⇒ Boolean
Opposite of #timed?
.
101 102 103 |
# File 'lib/y_petri/net/state/feature/firing.rb', line 101 def timeless? ! timed? end |
#to_s ⇒ Object
A string briefly describing the firing feature.
113 114 115 |
# File 'lib/y_petri/net/state/feature/firing.rb', line 113 def to_s label end |
#type ⇒ Object
Type of this feature.
107 108 109 |
# File 'lib/y_petri/net/state/feature/firing.rb', line 107 def type :firing end |