Class: Dither::MIPOG
Instance Method Summary
collapse
Methods included from IPOGHelper
#init_params, #initialize, #maximize_coverage, #violates_constraints?
Instance Method Details
#maximize_unbound_coverage(i, test_case, pi) ⇒ Object
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
|
# File 'lib/dither/mipog.rb', line 7
def maximize_unbound_coverage(i, test_case, pi)
all_unbound = test_case.unbound
.map { |a| a.create_params(params[a.i].length) }
.flatten
current_max = 0
current_max_j = 0
current_outer_param = all_unbound[0]
current_matches = []
all_unbound.each do |outer_param|
test_case << outer_param
(0...params[i].length).each do |j|
current_param = params[i][j]
test_case << current_param
count = pi.count { |a| a.subset?(test_case) }
if count > current_max
current_max = count
current_max_j = j
current_outer_param = outer_param
end
test_case.delete(current_param)
end
test_case.delete(outer_param)
end
test_case << params[i][current_max_j]
test_case << current_outer_param
test_case.delete(unbound_param_pool[current_outer_param.i])
current_matches
end
|
#maximize_vertical_coverage(i, test_case, pi) ⇒ Object
77
78
79
80
81
82
83
|
# File 'lib/dither/mipog.rb', line 77
def maximize_vertical_coverage(i, test_case, pi)
coverage = [pi[0]]
pi[1..-1].each do |a|
coverage << a unless test_case.merge_without_conflict(i, a).nil?
end
[test_case, coverage]
end
|
#run ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/dither/mipog.rb', line 42
def run
test_set = comb
(t...params.length).each do |i|
pi = comb_i(i)
test_set.each do |test_case|
if !test_case.contains_unbound?
cover = maximize_coverage(i, test_case, pi)
else
cover = maximize_unbound_coverage(i, test_case, pi)
end
pi -= cover
end
until pi.empty?
pi.sort!
test_case, coverage = maximize_vertical_coverage(i, pi[0].dup, pi)
test_set << test_case.create_unbound(i)
pi -= coverage
end
end
test_set.map { |a| fill_unbound(a) }
end
|