Module: Pione::PNML::OutputDecompositionComplement

Defined in:
lib/pione/pnml/output-decomposition-complement.rb

Overview

OutputDecompositionComplement is a net transformational rule. This rule complements name of source place that forms output decomposition pattern. For example, the net likes following

              +--> empty transition --> 'p1'
              |
empty place --+--> empty transition --> 'p2'
              |
              +--> empty transition --> 'p3'

is rewritten as th following.

                       +--> empty transition --> 'p1'
                       |
'p1' or 'p2' or 'p3' --+--> empty transition --> 'p2'
                       |
                       +--> empty transition --> 'p3'

Class Method Summary collapse

Class Method Details

.find_subjects(net, env) ⇒ Array

Find subjects(source place and component places) of this rule from net. The conditions are followings:

  • There is an empty source place.
  • There are more than 2 target transitions. All traget transitions are empty, and each target transition has only one output named place.
  • There are arcs that connect the source and targets.

Parameters:

Returns:

  • (Array)

    source place and component places



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/pione/pnml/output-decomposition-complement.rb', line 36

def self.find_subjects(net, env)
  net.places.each do |place|
    # source place should be empty
    next unless Perspective.empty_place?(env, place)

    # there should be more than 2 target transitions
    transitions = net.find_all_transitions_by_source_id(place.id)
    next unless transitions.size > 1
    next unless transitions.all? {|transition| Perspective.empty_transition?(env, transition)}

    # each transition has only one output named place
    component_places = []
    next unless transitions.all? do |transition|
      _places = net.find_all_places_by_source_id(transition.id)
      component_places.concat(_places)
      _places.size == 1 and not(Perspective.empty_place?(env, _places.first))
    end

    return [place, component_places]
  end

  return nil
end

.rewrite(net, subjects, env) ⇒ void

This method returns an undefined value.

Rewrite source place's name as disjunction of component place's name.

Parameters:



69
70
71
72
73
74
75
76
77
78
79
# File 'lib/pione/pnml/output-decomposition-complement.rb', line 69

def self.rewrite(net, subjects, env)
  place, component_places = subjects

  # component places' names
  names = component_places.map do |component_place|
    LabelExtractor.extract_data_expr(component_place.name)
  end

  modifier = Perspective.data_modifier(env, place) || ""
  place.name = modifier + names.sort.join(" or ")
end