class YPetri::Transition

Summary: Having vs. not having rate distinguishes the need to multiply the closure result by Δ time.

Stoichiometricity

Summary: stoichiometricity distinguishes the need to multiply the rate/action closure result by stoichiometry.

Assignment action

Assignment transitions (_A_ transitions) are special transitions, that replace the codomain marking rather than modifying it – they assign new marking to their codomain, like we are used to from spreadsheets. Technically, this behavior is easily achievable with normal ts transitions, so the existence of separate A transitions is just a convenience, not a new type of a transition in the mathematical sense.

Functional / functionless transitions

Other Petri net implementation often distinguies between “ordinary” (vanilla as per C. A. Petri) and functional transitions, whose operation is governed by a function. In YPetri, transitions are generally functional, but there remains a possibility of creating vanilla (functionless) transitions by not specifying any rate / action, while specifying the stoichiometry. Action closure as per C. A. Petri is automatically constructed for these.

Constants

TYPES

Attributes

action[R]

For rateless transition, action closure must be present. Action closure input arguments must correspond to the domain places, and for timed transitions, the first argument of the action closure must be Δtime.

action_arcs[R]

Codomain, 'downstream arcs', or 'action arcs', is a collection of places, whose marking is directly changed by this transition's firing.

action_closure[R]

For rateless transition, action closure must be present. Action closure input arguments must correspond to the domain places, and for timed transitions, the first argument of the action closure must be Δtime.

codomain[R]

Codomain, 'downstream arcs', or 'action arcs', is a collection of places, whose marking is directly changed by this transition's firing.

codomain_arcs[R]

Codomain, 'downstream arcs', or 'action arcs', is a collection of places, whose marking is directly changed by this transition's firing.

codomain_places[R]

Codomain, 'downstream arcs', or 'action arcs', is a collection of places, whose marking is directly changed by this transition's firing.

domain[R]

Domain, or 'upstream arcs', is a collection of places, whose marking directly affects the transition's action.

domain_arcs[R]

Domain, or 'upstream arcs', is a collection of places, whose marking directly affects the transition's action.

domain_places[R]

Domain, or 'upstream arcs', is a collection of places, whose marking directly affects the transition's action.

downstream[R]

Codomain, 'downstream arcs', or 'action arcs', is a collection of places, whose marking is directly changed by this transition's firing.

downstream_arcs[R]

Codomain, 'downstream arcs', or 'action arcs', is a collection of places, whose marking is directly changed by this transition's firing.

downstream_places[R]

Codomain, 'downstream arcs', or 'action arcs', is a collection of places, whose marking is directly changed by this transition's firing.

flux[R]

In YPetri, rate is a unifying term for both flux and propensity, both of which are treated as aliases of rate. The decision between discrete and continuous computation is a concern of the simulation. Rate closure arity should correspond to the transition's domain.

flux_closure[R]

In YPetri, rate is a unifying term for both flux and propensity, both of which are treated as aliases of rate. The decision between discrete and continuous computation is a concern of the simulation. Rate closure arity should correspond to the transition's domain.

propensity[R]

In YPetri, rate is a unifying term for both flux and propensity, both of which are treated as aliases of rate. The decision between discrete and continuous computation is a concern of the simulation. Rate closure arity should correspond to the transition's domain.

propensity_closure[R]

In YPetri, rate is a unifying term for both flux and propensity, both of which are treated as aliases of rate. The decision between discrete and continuous computation is a concern of the simulation. Rate closure arity should correspond to the transition's domain.

rate[R]

In YPetri, rate is a unifying term for both flux and propensity, both of which are treated as aliases of rate. The decision between discrete and continuous computation is a concern of the simulation. Rate closure arity should correspond to the transition's domain.

rate_closure[R]

In YPetri, rate is a unifying term for both flux and propensity, both of which are treated as aliases of rate. The decision between discrete and continuous computation is a concern of the simulation. Rate closure arity should correspond to the transition's domain.

stoichiometry[R]

Stoichiometry (implies that the transition is stoichiometric).

upstream[R]

Domain, or 'upstream arcs', is a collection of places, whose marking directly affects the transition's action.

upstream_arcs[R]

Domain, or 'upstream arcs', is a collection of places, whose marking directly affects the transition's action.

upstream_places[R]

Domain, or 'upstream arcs', is a collection of places, whose marking directly affects the transition's action.

Public Class Methods

new(*args, &block) click to toggle source

Transition class represents many different kinds of Petri net transitions. It makes the constructor syntax a bit more polymorphic. The type of the transition to construct is mostly inferred from the constructor arguments.

Mandatorily, the constructor will always need a way to determine the domain (upstream arcs) and codomain (downstream arcs) of the transition. Also, the constructor must have a way to determine the transition's action. This is best explained by examples – let us have 3 places A, B, C, for whe we will create different kinds of transitions:

TS (timed stoichiometric)

Rate closure and stoichiometry has to be supplied. Rate closure arity should correspond to the domain size. Return arity should be 1 (to be multiplied by the stoichiometry vector, as in all other stoichiometric transitions).

Transition.new stoichiometry: { A: -1, B: 1 },
               rate: -> a { a * 0.5 }

Ts (timed nonstoichiometric)

Rate closure has to be supplied, whose arity should match the domain, and output arity codomain.

tS (timeless stoichiometric)

Stoichiometry has to be supplied, action closure is optional. If supplied, its return arity should be 1 (to be multiplied by the stoichiometry vector).

ts transitions (timeless nonstoichiometric)

Action closure is expected with return arity equal to the codomain size:

Transition.new upstream_arcs: [A, C], downstream_arcs: [A, B],
               action_closure: proc { |m, x|
                                      if x > 0 then [-(m / 2), (m / 2)]
                                      else [1, 0] end
                                    }
# File lib/y_petri/transition.rb, line 165
def initialize *args, &block
  check_in_arguments *args, &block # the big job
  extend( if timed? then Type_T
          elsif assignment_action? then Type_A
          else Type_t end )
  inform_upstream_places         # that they have been connected
  inform_downstream_places       # that they have been connected
  uncock                         # initialize in uncocked state
end

Public Instance Methods

place(id) click to toggle source

# Conversion to a string. # def to_s

"#<Transition: %s>" %
  "#{'%s ' % name if name}(#{type})#{' id:%s' % object_id unless name}"

end

Calls superclass method
# File lib/y_petri/transition.rb, line 280
def place id
  super rescue Place().instance( id )
end
s() click to toggle source

Stoichiometry as a hash of pairs: { codomain_place_name_symbol => stoichiometric_coefficient }

# File lib/y_petri/transition.rb, line 210
def s
  stoichio.with_keys { |k| k.name || k.object_id }
end
stoichio() click to toggle source

Stoichiometry as a hash of pairs: { codomain_place_instance => stoichiometric_coefficient }

# File lib/y_petri/transition.rb, line 203
def stoichio
  Hash[ codomain.zip( @stoichiometry ) ]
end
transition(id) click to toggle source
Calls superclass method Object#transition
# File lib/y_petri/transition.rb, line 284
def transition id
  super rescue Transition().instance( id )
end
zero_action() click to toggle source

Zero action.

# File lib/y_petri/transition.rb, line 235
def zero_action
  codomain.map { 0 }
end