Module: YPetri::Simulation::InitialMarking::Access

Defined in:
lib/y_petri/simulation/initial_marking/access.rb

Instance Method Summary collapse

Instance Method Details

#Im(array) ⇒ Object

Expects a single array of places, and returns their marking as it would appear right after the simulation reset.



34
35
36
37
38
# File 'lib/y_petri/simulation/initial_marking/access.rb', line 34

def Im array
  places( array ).map { |place|
    place.free? ? initial_marking( place ) : marking_clamp( place )
  }
end

#im(*places) ⇒ Object

Expects an arbitrary number of places or place identifiers, and returns their marking as it would appear right after the simulation reset. If no arguments are given, returns all of them.



44
45
46
47
# File 'lib/y_petri/simulation/initial_marking/access.rb', line 44

def im *places
  return Im places() if places.empty?
  Im( places )
end

#im_vector(ids = nil) ⇒ Object

Returns initial marking vector for all places. Like #initial_marking, but returns a column vector.



59
60
61
# File 'lib/y_petri/simulation/initial_marking/access.rb', line 59

def im_vector ids=nil
  im( ids ).to_column_vector
end

#initial_marking(arg = L! ) ⇒ Object

Expects a single free place and returns the value of its initial marking.



26
27
28
29
# File 'lib/y_petri/simulation/initial_marking/access.rb', line 26

def initial_marking arg=L!
  return initial_markings( arg ).first unless arg.local_object?
  @initial_marking or fail TypeError, "+@initial_marking+ not present yet!"
end

#initial_marking_vector(ids = nil) ⇒ Object

Returns initial marking vector for free places. Like #initial_marking, but returns a column vector.



52
53
54
# File 'lib/y_petri/simulation/initial_marking/access.rb', line 52

def initial_marking_vector ids=nil
  initial_marking( ids ).to_column_vector
end

#initial_markings(*free_places) ⇒ Object

Expects an arbitrary number of arguments identifying free places, whose initial markings are then returned. If no arguments are given, acts as a getter of @initial_marking instance variable.



19
20
21
22
# File 'lib/y_petri/simulation/initial_marking/access.rb', line 19

def initial_markings *free_places
  return initial_marking if free_places.empty?
  Initial_markings( free_places )
end

#Initial_markings(array) ⇒ Object Also known as: initial_Markings

Expects a single array of free places or place ids, and returns an array of their initial markings.



10
11
12
# File 'lib/y_petri/simulation/initial_marking/access.rb', line 10

def Initial_markings array
  Free_places( array ).map { |place| initial_marking[ place place ] }
end