Module: YPetri::Net::OwnState

Defined in:
lib/y_petri/net/own_state.rb

Overview

A mixin catering to the net’s own state (ie. marking owned by the place instances themselves) and its features.

Instance Method Summary collapse

Instance Method Details

#assignment(transition_ids = nil) ⇒ Object

Takes an array of A transition identifiers as an optional argument, and returns the array of their actions under current net state. If no argument is supplied, the array of assignments of all net’s A transitions is returned.



69
70
71
72
# File 'lib/y_petri/net/own_state.rb', line 69

def assignment transition_ids=nil
  return assigment A_tt() if transition_ids.nil?
  transition_ids.map { |id| A_transition( id ).action }
end

#delta(place_ids = nil, transitions: tt) ⇒ Object

Takes an array of place identifier, and a named argument :transitions, and returns the array of the place delta contribution by the indicated transitions.



61
62
63
# File 'lib/y_petri/net/own_state.rb', line 61

def delta place_ids=nil, transitions: tt
  fail NotImplementedError
end

#firing(transition_ids = nil) ⇒ Object

Takes an array of tS transition identifiers as an optional argument, and returns the array of their firing under current net state. If no argument is supplied, the net is required to contain no TS transtions, and the method returns the array of firing of all net’s tS transitions.



28
29
30
31
32
33
34
35
36
# File 'lib/y_petri/net/own_state.rb', line 28

def firing transition_ids=nil
  if transition_ids.nil? then
    fail TypeError, "Method #firing with no arguments is ambiguous for " +
      "nets with TS transitions!" if timed?
    firing tS_tt
  else
    transition_ids.map { |id| tS_transition( id ).firing }
  end
end

#flux(transition_ids = nil) ⇒ Object

Takes an array of TS transition identifiers as an optional argument, and returns the array of their fluxes under current net state. If no argument is supplied, the array of fluxes of all net’s TS transitions is returned.



42
43
44
45
# File 'lib/y_petri/net/own_state.rb', line 42

def flux transition_ids=nil
  return flux TS_tt() if transition_ids.nil?
  transition_ids.map { |id| TS_transition( id ).flux }
end

#gradient(place_ids = pp, transitions: tt) ⇒ Object

Takes an array of place identifiers, and a named argument :transitions, and returns the array of the place gradient contribution by the indicated transitions. The :transitions argument defaults to all the transitions, place identifiers default to all the places. The net must be timed.



53
54
55
# File 'lib/y_petri/net/own_state.rb', line 53

def gradient place_ids=pp, transitions: tt
  fail NotImplementedError
end

#marking(place_ids = nil) ⇒ Object

If no argument is supplied, the method returns the array of the markings owned by the net’s places. If an array of place identifiers is supplied, the return value is the array of the markings owned by those places.



18
19
20
21
# File 'lib/y_petri/net/own_state.rb', line 18

def marking place_ids=nil
  return marking( pp ) if place_ids.nil?
  place_ids.map { |id| place( id ).marking }
end

#stateObject

State owned by the net. This method returns an instance of Net::State class (a subclass of Array), containing marking owned by the net’s places.



10
11
12
# File 'lib/y_petri/net/own_state.rb', line 10

def state
  State().new( marking )
end