module YPetri::Simulation::Transitions::Type_Ts

Public Instance Methods

gradient() click to toggle source

Gradient contribution for free places.

# File lib/y_petri/simulation/transitions/Ts.rb, line 18
def gradient
  gradient_closure.call
end
gradient_all()
Alias for:
gradient_closure()
Alias for: to_gradient_closure
gradient_closures() click to toggle source

Member gradient closures.

# File lib/y_petri/simulation/transitions/Ts.rb, line 12
def gradient_closures
  map &:gradient_closure
end
to_gradient_closure() click to toggle source

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.

# 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
Also aliased as: gradient_closure
() click to toggle source

Gradient contribution to all places.

# File lib/y_petri/simulation/transitions/Ts.rb, line 24
def 
  f2a * gradient
end
Also aliased as: gradient_all