Module: YPetri::Transition::Types

Defined in:
lib/y_petri/transition/types.rb

Instance Method Summary collapse

Instance Method Details

#a?Boolean

Is this a non-assignment transition? (Opposite of #A?)

Returns:

  • (Boolean)


20
21
22
# File 'lib/y_petri/transition/types.rb', line 20

def a?
  ! assignment_action?
end

#assignment_action?Boolean Also known as: assignment?, A?

Is this a transition with assignment action? (Transitions with assignment action, or “assignment transitions”, completely replace the marking of their codomain with their action closure result, like in spreadsheets.)

Returns:

  • (Boolean)


12
13
14
# File 'lib/y_petri/transition/types.rb', line 12

def assignment_action?
  @assignment_action
end

#functional?Boolean

Is the transition functional?

Explanation: If rate or action closure is supplied, a transition is always considered ‘functional’. Otherwise, it is considered not ‘functional’. Note that even transitions that are not functional still have standard action acc. to Petri’s definition. Also note that a timed transition is necessarily functional.

Returns:

  • (Boolean)


91
92
93
# File 'lib/y_petri/transition/types.rb', line 91

def functional?
  @functional
end

#functionless?Boolean

Opposite of #functional?

Returns:

  • (Boolean)


97
98
99
# File 'lib/y_petri/transition/types.rb', line 97

def functionless?
  not functional?
end

#nonstoichiometric?Boolean Also known as: s?

Is this a non-stoichiometric transition?

Returns:

  • (Boolean)


59
60
61
# File 'lib/y_petri/transition/types.rb', line 59

def nonstoichiometric?
  ! stoichiometric?
end

#stoichiometric?Boolean Also known as: S?

Is this a stoichiometric transition?

Returns:

  • (Boolean)


54
# File 'lib/y_petri/transition/types.rb', line 54

def stoichiometric?; @stoichiometric end

#tObject

Reports the transition’s membership in one of the 5 basic types using one-letter abbreviation:

  1. A .… assignment

  2. B .… timeless nonstoichiometric (ts)

  3. C .… timeless stoichiometric (tS)

  4. D .… timed nonstoichiometric (Ts)

  5. E .… timed stoichiometric (TS)



110
111
112
113
# File 'lib/y_petri/transition/types.rb', line 110

def t
  return :A if assignment_action?
  timed? ? ( stoichiometric? ? :E : :D ) : ( stoichiometric? ? :C : :B )
end

#timed?Boolean Also known as: T?

Does the transition’s action depend on delta time? (Note that although A transitions are technically timeless, for pragmatic reasons, they are excluded from T/t classification, because they are generally handled differently in Petri net execution.)

Returns:

  • (Boolean)


69
70
71
72
# File 'lib/y_petri/transition/types.rb', line 69

def timed?
  return nil if A?
  @timed
end

#timeless?Boolean Also known as: t?

Is the transition timeless? (Opposite of #timed?)

Returns:

  • (Boolean)


77
78
79
80
# File 'lib/y_petri/transition/types.rb', line 77

def timeless?
  return nil if A?
  not timed?
end

#TS?Boolean Also known as: E?

Is this a timed stoichiometric transition?

Returns:

  • (Boolean)


47
48
49
# File 'lib/y_petri/transition/types.rb', line 47

def TS?
  type == :TS
end

#tS?Boolean Also known as: C?

Is this a timeless stoichiometric transition?

Returns:

  • (Boolean)


33
34
35
# File 'lib/y_petri/transition/types.rb', line 33

def tS?
  type == :tS
end

#ts?Boolean Also known as: B?

Is this a timeless non-stoichiometric transition?

Returns:

  • (Boolean)


26
27
28
# File 'lib/y_petri/transition/types.rb', line 26

def ts?
  type == :ts
end

#Ts?Boolean Also known as: D?

Is this a timed non-stoichiometric transition?

Returns:

  • (Boolean)


40
41
42
# File 'lib/y_petri/transition/types.rb', line 40

def Ts?
  type == :Ts
end

#typeObject

Reports the transition’s membership in one of the 5 basic types using two-letter abbreviation + A for assignment transition. This methods reflects the fact that the new users may take time to memorize the meaning of A, B, C, D, E transition types. Two-letter abbreviations may be easier to figure out.

  1. A .… assignment transitions (A-type)

  2. ts .… timeless nonstoichiometric (B-type)

  3. tS .… timeless stoichiometric (C-type)

  4. Ts .… timed nonstoichiometric (D-type)

  5. TS .… timed stoichiometric (E-type)



127
128
129
# File 'lib/y_petri/transition/types.rb', line 127

def type
  { A: :A, B: :ts, C: :tS, D: :Ts, E: :TS }[ t ]
end

#type_fullObject

Reports the transition’s membership in one of the 5 basic types as a full string.

  1. assignment (A-type)

  2. timeless nonstoichiometric (B-type)

  3. timeless stoichiometric (C-type)

  4. timed nonstoichiometric (D-type)

  5. timed stoichiometric (E-type)



140
141
142
143
144
145
146
# File 'lib/y_petri/transition/types.rb', line 140

def type_full
  { A: "assignment",
    ts: "timeless nonstoichiometric",
    tS: "timeless stoichiometric",
    Ts: "timed nonstoichiometric",
    TS: "timed stoichiometric" }[ type ]
end