Sha256: d954eed90351e1f32c8fda139ea43253b57b675cca3ce4cc75fb470a24897429

Contents?: true

Size: 1.17 KB

Versions: 7

Compression:

Stored size: 1.17 KB

Contents

#encoding: utf-8

# A mixin for collections of tS transitions.
# 
class YPetri::Simulation::Transitions
  module Type_tS
    include Type_t
    include Type_S

    # firing closure accessor.
    # 
    def firing_closure
      @firing_closure ||= to_firing_closure
    end

    # tS transitions have firing closures.
    # 
    def firing_closures
      map &:firing_closure
    end
    
    # Firing vector (to be multiplied by the stoichiometry to get deltas)
    # 
    def firing_vector
      firing_closure.call
    end

    # Firing vector for these tS transitions, returned as array.
    # 
    def firing
      firing_closures.map &:call
    end

    # Delta contribution to free places.
    # 
    def delta
      stoichiometry_matrix * firing_vector
    end

    # Delta contribution to all places
    # 
    def Δ
      SM() * firing_vector
    end
    alias delta_all Δ

    # Builds the firing vector closure, that outputs the firing vector based on
    # the system state when called.
    # 
    def to_firing_closure
      closures = firing_closures
      -> { closures.map( &:call ).to_column_vector }
    end
  end # module Type_tS
end # class YPetri::Simulation::Transitions

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
y_petri-2.1.12 lib/y_petri/simulation/transitions/tS.rb
y_petri-2.1.11 lib/y_petri/simulation/transitions/tS.rb
y_petri-2.1.10 lib/y_petri/simulation/transitions/tS.rb
y_petri-2.1.9 lib/y_petri/simulation/transitions/tS.rb
y_petri-2.1.7 lib/y_petri/simulation/transitions/tS.rb
y_petri-2.1.6 lib/y_petri/simulation/transitions/tS.rb
y_petri-2.1.3 lib/y_petri/simulation/transitions/tS.rb