Class: YPetri::Agent::SimulationAspect::SimulationPoint

Inherits:
HashKeyPointer
  • Object
show all
Defined in:
lib/y_petri/agent/simulation_aspect.rb

Instance Attribute Summary

Attributes inherited from HashKeyPointer

#key, #what_is_hash_value

Instance Method Summary collapse

Methods inherited from HashKeyPointer

#get, #initialize

Constructor Details

This class inherits a constructor from YPetri::Agent::HashKeyPointer

Instance Method Details

#identify(name: nil, net: nil, cc: nil, imc: nil, ssc: nil, **nn) ⇒ Object

Helper method specifying how a simulation is identified by arguments.



45
46
47
# File 'lib/y_petri/agent/simulation_aspect.rb', line 45

def identify( name: nil, net: nil, cc: nil, imc: nil, ssc: nil, **nn )
  name || { net: net, cc: cc, imc: imc, ssc: ssc }.merge( nn )
end

#resetObject

Reset to the first simulation, or nil if that is absent.



29
30
31
# File 'lib/y_petri/agent/simulation_aspect.rb', line 29

def reset
  @key = @hash.empty? ? nil : set( @hash.first[0] )
end

#set(**nn) ⇒ Object

A simulation is identified either by its name (if named), or by its parameters and settings (:net, :cc, :imc, :ssc).



36
37
38
39
40
41
# File 'lib/y_petri/agent/simulation_aspect.rb', line 36

def set **nn
  key = identify **nn
  @key = if key.nil? then key
         elsif @hash.has_key? key then key
         else raise "No simulation identified by #{key}!" end
end