Class: Dither::IPOG

Inherits:
Object
  • Object
show all
Includes:
IPOGHelper
Defined in:
lib/dither/ipog.rb

Instance Method Summary collapse

Methods included from IPOGHelper

#init_params, #initialize, #maximize_coverage, #violates_constraints?

Instance Method Details

#runObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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/dither/ipog.rb', line 7

def run
  # add into test set a test for each combination of values
  # of the first t parameter
  test_set = comb

  (t...params.length).each do |i|
    # let pi
    # be the set of t-way combinations of values involving
    # parameter Pi and t -1 parameters among the first i – 1
    # parameters
    pi = comb_i(i)

    # horizontal extension for parameter i
    test_set.each do |test_case|
      cover = maximize_coverage(i, test_case, pi)

      if cover.nil?
        test_set.delete(test_case)
      else
        pi -= cover
      end
    end

    # vertical extension for parameter i
    pi.each do |a|
      if test_set.any? { |b| a.subset?(b) }
        pi.delete(a)
      else

        test_case = nil
        test_set.each do |b|
          test_case = b.merge_without_conflict(i, a) do |a|
            violates_constraints?(a)
          end
          break unless test_case.nil?
        end

        if test_case.nil?
          test_set << a.create_unbound(i)
        end
        pi.delete(a)
      end
    end
  end

  @test_set = test_set.map { |a| fill_unbound(a) }
    .delete_if(&:nil?)
    .to_a
  @test_set
end