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) ⇒ 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



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

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

    # 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| transition.empty_name?}

    # 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(_places.first.empty_name?)
    end

    return [place, component_places]
  end

  return nil
end

.rewrite(net, subjects) ⇒ void

This method returns an undefined value.

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

Parameters:

  • net (PNML::Net)

    rewriting target net

  • subjects (Array)

    source place and component places



65
66
67
68
69
70
71
72
73
74
# File 'lib/pione/pnml/output-decomposition-complement.rb', line 65

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

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

  place.name = "%s%s" % [Perspective.modifier(place.name), names.sort.join(" or ")]
end