Sha256: 16ec718c4d180819872a759bd504cb4d224f04f1364e8327edc9b34d5abb9199

Contents?: true

Size: 1.38 KB

Versions: 17

Compression:

Stored size: 1.38 KB

Contents

# encoding: utf-8

# A mixin for S transition representations.
# 
class YPetri::Simulation::TransitionRepresentation
  module Type_S
    include Type_a
    
    attr_reader :stoichiometry
    
    # Sparse stoichiometry vector corresponding to the free places.
    # 
    attr_reader :sparse_stoichiometry_vector
    
    # Sparse stoichiometry vector corresponding to all the places.
    # 
    attr_reader :sparse_sv
    
    # True for stoichiometric transitions.
    # 
    def S?
      true
    end
    alias stoichiometric? S?
    
    # False for stoichiometric transitions.
    # 
    def s?
      false
    end
    alias nonstoichiometric? s?
    
    # Initialization subroutine.
    # 
    def init
      super
      @stoichiometry = source.stoichiometry
      @sparse_stoichiometry_vector =
        Matrix.correspondence_matrix( codomain, free_places ) *
        stoichiometry.to_column_vector
      @sparse_sv = Matrix.correspondence_matrix( codomain, places ) *
        stoichiometry.to_column_vector
    end

    # Builds the S transition's function into a closure. Functions of
    # S transitions return only a single number (flux for TS, firing for
    # tS).
    # 
    def build_closure
      mv, f = simulation.m_vector, function
      λ = "-> { f.( %s ) }" % domain_access_code( vector: :mv )
      eval λ
    end
  end # module Type_S
end # class YPetri::Simulation::TransitionRepresentation

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
y_petri-2.4.9 lib/y_petri/simulation/transition_representation/S.rb
y_petri-2.4.8 lib/y_petri/simulation/transition_representation/S.rb
y_petri-2.4.6 lib/y_petri/simulation/transition_representation/S.rb
y_petri-2.4.4 lib/y_petri/simulation/transition_representation/S.rb
y_petri-2.4.3 lib/y_petri/simulation/transition_representation/S.rb
y_petri-2.4.2 lib/y_petri/simulation/transition_representation/S.rb
y_petri-2.4.0 lib/y_petri/simulation/transition_representation/S.rb
y_petri-2.3.12 lib/y_petri/simulation/transition_representation/S.rb
y_petri-2.3.11 lib/y_petri/simulation/transition_representation/S.rb
y_petri-2.3.10 lib/y_petri/simulation/transition_representation/S.rb
y_petri-2.3.9 lib/y_petri/simulation/transition_representation/S.rb
y_petri-2.3.8 lib/y_petri/simulation/transition_representation/S.rb
y_petri-2.3.6 lib/y_petri/simulation/transition_representation/S.rb
y_petri-2.3.5 lib/y_petri/simulation/transition_representation/S.rb
y_petri-2.3.4 lib/y_petri/simulation/transition_representation/S.rb
y_petri-2.3.3 lib/y_petri/simulation/transition_representation/S.rb
y_petri-2.3.2 lib/y_petri/simulation/transition_representation/S.rb