module YPetri::Transition::Type_t

Mixin for timeless non-assignment Petri net transitions.

Public Instance Methods

action() click to toggle source

Result of the transition's “function”, regardless of the enabled? status.

# File lib/y_petri/transition/t.rb, line 14
def action
  if stoichiometric? then
    rslt = action_closure.( *domain_marking )
    stoichiometry.map { |coeff| rslt * coeff }
  else
    action_closure.( *domain_marking )
  end
end
enabled?() click to toggle source

Timeless transition is enabled if its action would result in a legal codomain marking.

# File lib/y_petri/transition/t.rb, line 46
def enabled?
  codomain.zip( action ).all? do |place, change|
    begin; place.guard.( place.marking + change )
    rescue YPetri::GuardError; false end
  end
end
fir(simulation=world.simulation) click to toggle source

Transition's firing under current simulation.

# File lib/y_petri/transition/t.rb, line 55
def fir simulation=world.simulation
  simulation.net.State.Feature.Firing( self ) % simulation
end
fire() click to toggle source

Fires the transition, honoring cocking. Returns true if the transition fired, false if it wasn't cocked.

# File lib/y_petri/transition/t.rb, line 26
def fire
  cocked?.tap { |x| ( uncock; fire! ) if x }
end
fire!() click to toggle source

Fires the transition regardless of cocking.

# File lib/y_petri/transition/t.rb, line 32
def fire!
  act = Array( action )
  fail TypeError, "Wrong output arity of the action " +
    "closure of #{self}!" if act.size != codomain.size
  codomain.each_with_index do |place, index|
    # adding action node no. index to place
    place.add act.fetch( index )
  end
  return nil
end
function() click to toggle source

For timeless transitions, “function” refers to their action closure.

# File lib/y_petri/transition/t.rb, line 8
def function
  action_closure
end
pa(simulation=world.simulation, **nn) click to toggle source

Prints the transition's action under current simulation.

# File lib/y_petri/transition/t.rb, line 61
def pa simulation=world.simulation, **nn
  ff = simulation.net.State.Features.Delta( codomain, transitions: self )
  ( ff >> ff % simulation ).pretty_print_numeric_values **nn
end