Class: Petrinet::Net::Builder::Transition

Inherits:
Object
  • Object
show all
Defined in:
lib/petrinet/net.rb

Instance Method Summary collapse

Constructor Details

#initialize(take_place_names, give_place_names) ⇒ Transition

Returns a new instance of Transition.



135
136
137
138
# File 'lib/petrinet/net.rb', line 135

def initialize(take_place_names, give_place_names)
  @take_place_names = take_place_names
  @give_place_names = give_place_names
end

Instance Method Details

#to_vectors(size, place_index_by_place_name) ⇒ Object



140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/petrinet/net.rb', line 140

def to_vectors(size, place_index_by_place_name)
  take_vector = Array.new(size, 0)
  @take_place_names.each do |take_place_name|
    index = place_index_by_place_name[take_place_name]
    take_vector[index] -= 1
  end

  give_vector = Array.new(size, 0)
  @give_place_names.each do |give_place_name|
    index = place_index_by_place_name[give_place_name]
    give_vector[index] += 1
  end
  [take_vector, give_vector]
end