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

#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.



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

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.



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

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.



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

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.



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

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.



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

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. More precisely, an instance of the Net::State class, which is an Array subclass, containing the markings owned by the net’s places as its elements.



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

def state
  State().new( marking )
end