Class: Stamina::TransitionSystem::Equivalence::EquivThroughDeco

Inherits:
Utils::Decorate
  • Object
show all
Defined in:
lib/stamina-core/stamina/transition_system/equivalence.rb

Overview

Computes equivalence pairs through decoration

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Utils::Decorate

#backward=, #backward?, #call, #execute, #initiator=, #propagate=, #set_initiator, #set_propagate, #set_start_predicate, #set_suppremum, #start_predicate=, state_output, #suppremum=

Constructor Details

#initialize(reference, algo) ⇒ EquivThroughDeco

Returns a new instance of EquivThroughDeco.



48
49
50
51
# File 'lib/stamina-core/stamina/transition_system/equivalence.rb', line 48

def initialize(reference, algo)
  @reference = reference
  @algo      = algo
end

Instance Attribute Details

#algoObject (readonly)

Returns the value of attribute algo.



52
53
54
# File 'lib/stamina-core/stamina/transition_system/equivalence.rb', line 52

def algo
  @algo
end

#referenceObject (readonly)

Returns the value of attribute reference.



52
53
54
# File 'lib/stamina-core/stamina/transition_system/equivalence.rb', line 52

def reference
  @reference
end

Instance Method Details

#init_deco(s) ⇒ Object



74
75
76
# File 'lib/stamina-core/stamina/transition_system/equivalence.rb', line 74

def init_deco(s)
  s.initial? ? reference.initial_state.index : nil
end

#propagate(deco, edge) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
# File 'lib/stamina-core/stamina/transition_system/equivalence.rb', line 62

def propagate(deco, edge)
  symbol   = edge.symbol
  source   = reference.ith_state(deco)
  eq_edge  = algo.find_edge_counterpart(source, edge)
  unless eq_edge
    algo.fail("No such transition `#{symbol}` from #{source}")
  end
  algo.equivalent_edges!(edge, eq_edge)
  algo.equivalent_states!(edge.target, eq_edge.target)
  eq_edge.target.index
end

#suppremum(d0, d1) ⇒ Object



54
55
56
57
58
59
60
# File 'lib/stamina-core/stamina/transition_system/equivalence.rb', line 54

def suppremum(d0, d1)
  return (d0 || d1) if (d0.nil? or d1.nil?)
  unless d0==d1
    algo.fail("Different states found through same path: #{d0} & #{d1}")
  end
  d0
end

#take_at_start?(s) ⇒ Boolean

Returns:

  • (Boolean)


78
79
80
# File 'lib/stamina-core/stamina/transition_system/equivalence.rb', line 78

def take_at_start?(s)
  s.initial?
end