Module: YPetri::Simulation::Transitions::Type_Ts

Includes:
Type_T, Type_s
Defined in:
lib/y_petri/simulation/transitions/Ts.rb

Instance Method Summary collapse

Methods included from Type_T

#delta,

Instance Method Details

#gradientObject

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_closuresObject

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_closureObject 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
53
# File 'lib/y_petri/simulation/transitions/Ts.rb', line 33

def to_gradient_closure
  fp = free_places #.tap { |fp| puts; print "fp: "; Kernel::p fp }
  closures = gradient_closures #.tap { |cl| puts; print "closures: "; Kernel::p cl }
  sMV = simulation.MarkingVector
  stu = simulation.time_unit
  zero = ( sMV.zero( fp ) / stu ) #.tap { |z| puts; print "zero mv: "; Kernel::p z }

  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 = zero
    #{body}
    return g
    end
  LAMBDA
  eval λ #.tap { |l| puts; puts "eval code: "; puts l }
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