class YPetri::Simulation::PlaceMapping
Public Class Methods
load(hash)
click to toggle source
Initializes the initial marking from a hash.
# File lib/y_petri/simulation/place_mapping.rb, line 12 def load hash new.tap do |inst| hash.with_values do |v| v = v.marking if v.is_a? YPetri::Place if v.is_a? Proc then v.call else v end end.tap &inst.method( :load ) end end
Public Instance Methods
delete(place_id)
click to toggle source
Deletes the value for a place.
Calls superclass method
# File lib/y_petri/simulation/place_mapping.rb, line 53 def delete place_id super place( place_id ) end
fetch(place_id)
click to toggle source
Fetches the value for a place.
Calls superclass method
# File lib/y_petri/simulation/place_mapping.rb, line 47 def fetch place_id super place( place_id ) end
keys_to_source_places()
click to toggle source
Returns a hash, whose keys have been replaced with source places of the place representations in this place mapping.
# File lib/y_petri/simulation/place_mapping.rb, line 60 def keys_to_source_places with_keys do |key| key.source end end
load( hash )
click to toggle source
Loads initial the mappings from a hash places >> values.
# File lib/y_petri/simulation/place_mapping.rb, line 41 def load( hash ) hash.each { |place, value| set place, to: value } end
set(place_id, to: (fail ArgumentError, "No :to value!"))
click to toggle source
Sets the mapping value for a given place to a given value.
# File lib/y_petri/simulation/place_mapping.rb, line 35 def set place_id, to: (fail ArgumentError, "No :to value!") update place( place_id ) => to end
vector()
click to toggle source
Returns the initial marking as a column vector.
# File lib/y_petri/simulation/place_mapping.rb, line 28 def vector simulation.MarkingVector[ *self ] end
Also aliased as: to_marking_vector