Class: YPetri::Net::State::Feature::Gradient
- Inherits:
-
YPetri::Net::State::Feature
- Object
- YPetri::Net::State::Feature
- YPetri::Net::State::Feature::Gradient
- Defined in:
- lib/y_petri/net/state/feature/gradient.rb
Overview
Gradient of a Petri net place caused by a certain set of T transitions.
Class Attribute Summary collapse
-
.instances ⇒ Object
readonly
Returns the value of attribute instances.
Instance Attribute Summary collapse
-
#place ⇒ Object
readonly
Returns the value of attribute place.
-
#transitions ⇒ Object
readonly
Returns the value of attribute transitions.
Class Method Summary collapse
- .__new__ ⇒ Object
-
.new(*args) ⇒ Object
(also: of)
Constructor #new is redefined to use instance cache.
-
.parametrize(*args) ⇒ Object
Customization of the Class#parametrize method.
Instance Method Summary collapse
-
#extract_from(arg, **nn) ⇒ Object
Extracts the receiver gradient feature from the argument.
-
#initialize(*id) ⇒ Gradient
constructor
The constructor of a gradient feature takes one ordered argument (place identifier), and one named argument,
:transitions, expecting an array of transition identifiers, whose contribution is taken into account in this gradient feature. -
#inspect ⇒ Object
Inspect string of the gradient feature.
-
#label ⇒ Object
Label for the gradient feature (to use in graphics etc.).
-
#to_s ⇒ Object
A string briefly describing the gradient feature.
-
#type ⇒ Object
Type of this feature.
Methods inherited from YPetri::Net::State::Feature
Delta, Firing, Flux, Gradient, Marking
Constructor Details
#initialize(*id) ⇒ Gradient
The constructor of a gradient feature takes one ordered argument (place identifier), and one named argument, :transitions, expecting an array of transition identifiers, whose contribution is taken into account in this gradient feature.
64 65 66 67 |
# File 'lib/y_petri/net/state/feature/gradient.rb', line 64 def initialize *id @place = net.place id.fetch( 0 ) @transitions = net.transitions id.fetch( 1 ).fetch( :transitions ) end |
Class Attribute Details
.instances ⇒ Object (readonly)
Returns the value of attribute instances.
46 47 48 |
# File 'lib/y_petri/net/state/feature/gradient.rb', line 46 def instances @instances end |
Instance Attribute Details
#place ⇒ Object (readonly)
Returns the value of attribute place.
6 7 8 |
# File 'lib/y_petri/net/state/feature/gradient.rb', line 6 def place @place end |
#transitions ⇒ Object (readonly)
Returns the value of attribute transitions.
6 7 8 |
# File 'lib/y_petri/net/state/feature/gradient.rb', line 6 def transitions @transitions end |
Class Method Details
.__new__ ⇒ Object
48 |
# File 'lib/y_petri/net/state/feature/gradient.rb', line 48 alias __new__ new |
.new(*args) ⇒ Object Also known as: of
Constructor #new is redefined to use instance cache.
52 53 54 55 |
# File 'lib/y_petri/net/state/feature/gradient.rb', line 52 def new *args return instances[ *args ] if args.size == 1 instances[ args ] end |
.parametrize(*args) ⇒ Object
Customization of the Class#parametrize method.
11 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 37 38 39 40 41 42 43 44 |
# File 'lib/y_petri/net/state/feature/gradient.rb', line 11 def parametrize *args Class.instance_method( :parametrize ).bind( self ).( *args ).tap do | |
Instance Method Details
#extract_from(arg, **nn) ⇒ Object
Extracts the receiver gradient feature from the argument. This can be typically a simulation instance.
72 73 74 75 76 77 78 79 |
# File 'lib/y_petri/net/state/feature/gradient.rb', line 72 def extract_from arg, **nn case arg when YPetri::Simulation then arg.send( :T_transitions, transitions ).gradient.fetch( place ) else fail TypeError, "Argument type not supported!" end end |
#inspect ⇒ Object
Inspect string of the gradient feature.
101 102 103 104 |
# File 'lib/y_petri/net/state/feature/gradient.rb', line 101 def inspect "<Feature::Gradient ∂:#{place.name || place}:[%s]>" % transitions.names( true ).join( ', ' ) end |
#label ⇒ Object
Label for the gradient feature (to use in graphics etc.)
95 96 97 |
# File 'lib/y_petri/net/state/feature/gradient.rb', line 95 def label "∂:#{place.name}:#{transitions.size}tt" end |
#to_s ⇒ Object
A string briefly describing the gradient feature.
89 90 91 |
# File 'lib/y_petri/net/state/feature/gradient.rb', line 89 def to_s label end |
#type ⇒ Object
Type of this feature.
83 84 85 |
# File 'lib/y_petri/net/state/feature/gradient.rb', line 83 def type :gradient end |