Class: Lernen::Algorithm::KearnsVaziraniVPA::KearnsVaziraniVPALearner

Inherits:
Learner
  • Object
show all
Defined in:
lib/lernen/algorithm/kearns_vazirani_vpa/kearns_vazirani_vpa_learner.rb

Overview

KearnzVaziraniVPALearner is an implementation of Kearnz-Vazirani algorithm for VPA.

The idea behind this implementation is described by Isberner (2015) "Foundations of Active Automata Learning: An Algorithmic Overview".

Instance Method Summary collapse

Methods inherited from Learner

#add_alphabet, #learn

Constructor Details

#initialize(alphabet, call_alphabet, return_alphabet, sul, cex_processing: :binary) ⇒ KearnsVaziraniVPALearner

: ( Array alphabet, Array call_alphabet, Array return_alphabet, System::MooreLikeSUL[In | Call | Return, bool] sul, ?cex_processing: cex_processing_method ) -> void



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/lernen/algorithm/kearns_vazirani_vpa/kearns_vazirani_vpa_learner.rb', line 29

def initialize(alphabet, call_alphabet, return_alphabet, sul, cex_processing: :binary)
  super()

  @alphabet = alphabet.dup
  @call_alphabet = call_alphabet.dup
  @return_alphabet = return_alphabet.dup
  @sul = sul
  @cex_processing = cex_processing

  @tree = nil
end

Instance Method Details

#build_hypothesisObject



42
43
44
45
46
47
# File 'lib/lernen/algorithm/kearns_vazirani_vpa/kearns_vazirani_vpa_learner.rb', line 42

def build_hypothesis
  tree = @tree
  return tree.build_hypothesis if tree

  [build_first_hypothesis, { 0 => [] }]
end

#refine_hypothesis(cex, hypothesis, state_to_prefix) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/lernen/algorithm/kearns_vazirani_vpa/kearns_vazirani_vpa_learner.rb', line 50

def refine_hypothesis(cex, hypothesis, state_to_prefix)
  tree = @tree
  if tree
    tree.refine_hypothesis(cex, hypothesis, state_to_prefix) # steep:ignore
    return
  end

  @tree =
    DiscriminationTreeVPA.new(
      @alphabet,
      @call_alphabet,
      @return_alphabet,
      @sul,
      cex:,
      cex_processing: @cex_processing
    )
end