Sha256: e90b9a591c16d2fe2e67e578cf985e9b5be49f9b65e48f89a2c12c8eb38753ef

Contents?: true

Size: 941 Bytes

Versions: 4

Compression:

Stored size: 941 Bytes

Contents

#encoding: utf-8

# A mixin for TS transition representations.
# 
class YPetri::Simulation::TransitionRepresentation
  module Type_TS
    include Type_T
    include Type_S
    
    attr_reader :rate_closure
    
    # Initialization subroutine.
    # 
    def init
      super
      @rate_closure = to_rate_closure
    end
    
    # Transition's rate, given the current system state.
    # 
    def rate
      rate_closure.call
    end
    alias flux rate
    alias propensity rate
    
    # Firing of the transition (rate * Δtime).
    # 
    def firing Δt
      rate * Δt
    end
    
    # Gradient contribution of the transition to all places.
    # 
    def ∇
      codomain >> stoichiometry.map { |coeff| rate * coeff }
    end
    alias gradient_all ∇
    
    # Builds a flux closure.
    # 
    def to_rate_closure
      build_closure
    end
  end # module Type_TS
end # class YPetri::Simulation::TransitionRepresentation

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
y_petri-2.1.9 lib/y_petri/simulation/transition_representation/TS.rb
y_petri-2.1.7 lib/y_petri/simulation/transition_representation/TS.rb
y_petri-2.1.6 lib/y_petri/simulation/transition_representation/TS.rb
y_petri-2.1.3 lib/y_petri/simulation/transition_representation/TS.rb