Sha256: 54741942a0572e98bbd7b6d9a40fb6a7b11f5abbbf3a8257542625a05c0b6583

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

# encoding: utf-8

# A mixin for timeless simulations.
# 
class YPetri::Simulation
  module Timeless
    require_relative 'timeless/recorder'

    # False for timeless simulations.
    # 
    def timed?
      false
    end

    private

    # Initialization subroutine for timeless simulations. Sets up the
    # parametrized subclasses +@Core+ (the simulator) and +@Recorder+,
    # and initializes the +@recorder+ attribute.
    # 
    def init **settings
      method = settings[:method] # the simulation method
      init_core_and_recorder_subclasses
      @core = Core().new( method: method, guarded: guarded )
      @recorder = Recorder().new # init the recorder
    end

    # Sets up subclasses of +Core+ (the simulator) and +Recorder+ (the sampler)
    # for timeless simulations.
    # 
    def init_core_and_recorder_subclasses
      param_class( { Core: YPetri::Core::Timeless,
                     Recorder: Recorder },
                   with: { simulation: self } )
    end
  end # module Timeless
end # module YPetri::Simulation

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
y_petri-2.1.42 lib/y_petri/simulation/timeless.rb