Module: YPetri::Simulation::Transitions::Type_Ts
Instance Method Summary collapse
-
#gradient ⇒ Object
Gradient contribution for free places.
-
#gradient_closures ⇒ Object
Member gradient closures.
-
#to_gradient_closure ⇒ Object
(also: #gradient_closure)
Constructs a gradient closure that outputs a gradient vector corresponding to free places.
-
#∇ ⇒ Object
(also: #gradient_all)
Gradient contribution to all places.
Methods included from Type_T
Instance Method Details
#gradient ⇒ Object
Gradient contribution for free places.
18 19 20 |
# File 'lib/y_petri/simulation/transitions/Ts.rb', line 18 def gradient gradient_closure.call end |
#gradient_closures ⇒ Object
Member gradient closures.
12 13 14 |
# File 'lib/y_petri/simulation/transitions/Ts.rb', line 12 def gradient_closures map &:gradient_closure end |
#to_gradient_closure ⇒ Object Also known as: gradient_closure
Constructs a gradient closure that outputs a gradient vector corresponding to free places. The vector is the gradient contribution of the transitions in this collection.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/y_petri/simulation/transitions/Ts.rb', line 33 def to_gradient_closure fp = free_places closures = gradient_closures sMV = simulation.MarkingVector stu = simulation.time_unit code_sections = map.with_index do |t, i| "a = closures[ #{i} ].call\n" + t.increment_by_codomain_code( vector: "g", source: "a" ) end body = code_sections.join( "\n" ) λ = <<-LAMBDA -> do g = sMV.zero( fp ) / stu #{body} return g end LAMBDA eval λ end |
#∇ ⇒ Object Also known as: gradient_all
Gradient contribution to all places.
24 25 26 |
# File 'lib/y_petri/simulation/transitions/Ts.rb', line 24 def ∇ f2a * gradient end |