stamina 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +22 -5
- data/LICENCE.md +2 -2
- data/bin/stamina +1 -7
- data/lib/stamina.rb +10 -19
- metadata +54 -333
- data/.gemtest +0 -0
- data/Gemfile +0 -2
- data/Gemfile.lock +0 -37
- data/Manifest.txt +0 -16
- data/README.md +0 -78
- data/Rakefile +0 -23
- data/example/adl/automaton.adl +0 -49
- data/example/adl/sample.adl +0 -53
- data/example/basic/characteristic_sample.adl +0 -32
- data/example/basic/target.adl +0 -9
- data/example/competition/31_test.adl +0 -1500
- data/example/competition/31_training.adl +0 -1759
- data/lib/stamina/abbadingo.rb +0 -2
- data/lib/stamina/abbadingo/random_dfa.rb +0 -48
- data/lib/stamina/abbadingo/random_sample.rb +0 -146
- data/lib/stamina/adl.rb +0 -298
- data/lib/stamina/automaton.rb +0 -1263
- data/lib/stamina/automaton/complete.rb +0 -36
- data/lib/stamina/automaton/equivalence.rb +0 -55
- data/lib/stamina/automaton/metrics.rb +0 -78
- data/lib/stamina/automaton/minimize.rb +0 -25
- data/lib/stamina/automaton/minimize/hopcroft.rb +0 -116
- data/lib/stamina/automaton/minimize/pitchies.rb +0 -64
- data/lib/stamina/automaton/strip.rb +0 -16
- data/lib/stamina/automaton/walking.rb +0 -363
- data/lib/stamina/classifier.rb +0 -52
- data/lib/stamina/command.rb +0 -45
- data/lib/stamina/command/abbadingo_dfa.rb +0 -81
- data/lib/stamina/command/abbadingo_samples.rb +0 -40
- data/lib/stamina/command/adl2dot.rb +0 -71
- data/lib/stamina/command/classify.rb +0 -48
- data/lib/stamina/command/help.rb +0 -27
- data/lib/stamina/command/infer.rb +0 -141
- data/lib/stamina/command/metrics.rb +0 -51
- data/lib/stamina/command/robustness.rb +0 -22
- data/lib/stamina/command/score.rb +0 -35
- data/lib/stamina/errors.rb +0 -23
- data/lib/stamina/ext/math.rb +0 -20
- data/lib/stamina/induction/blue_fringe.rb +0 -265
- data/lib/stamina/induction/commons.rb +0 -156
- data/lib/stamina/induction/rpni.rb +0 -186
- data/lib/stamina/induction/union_find.rb +0 -377
- data/lib/stamina/input_string.rb +0 -123
- data/lib/stamina/loader.rb +0 -1
- data/lib/stamina/markable.rb +0 -42
- data/lib/stamina/sample.rb +0 -267
- data/lib/stamina/scoring.rb +0 -213
- data/lib/stamina/utils.rb +0 -1
- data/lib/stamina/utils/decorate.rb +0 -81
- data/lib/stamina/version.rb +0 -14
- data/stamina.gemspec +0 -191
- data/stamina.noespec +0 -32
- data/tasks/debug_mail.rake +0 -78
- data/tasks/debug_mail.txt +0 -13
- data/tasks/gem.rake +0 -68
- data/tasks/spec_test.rake +0 -79
- data/tasks/unit_test.rake +0 -77
- data/tasks/yard.rake +0 -51
- data/test/stamina/abbadingo/random_dfa_test.rb +0 -16
- data/test/stamina/abbadingo/random_sample_test.rb +0 -78
- data/test/stamina/adl_test.rb +0 -516
- data/test/stamina/automaton/classifier_test.rb +0 -259
- data/test/stamina/automaton/complete_test.rb +0 -58
- data/test/stamina/automaton/equivalence_test.rb +0 -120
- data/test/stamina/automaton/metrics_test.rb +0 -36
- data/test/stamina/automaton/minimize/hopcroft_test.rb +0 -15
- data/test/stamina/automaton/minimize/minimize_test.rb +0 -55
- data/test/stamina/automaton/minimize/pitchies_test.rb +0 -15
- data/test/stamina/automaton/minimize/rice_edu_10.adl +0 -16
- data/test/stamina/automaton/minimize/rice_edu_10.min.adl +0 -13
- data/test/stamina/automaton/minimize/rice_edu_13.adl +0 -13
- data/test/stamina/automaton/minimize/rice_edu_13.min.adl +0 -7
- data/test/stamina/automaton/minimize/should_strip_1.adl +0 -8
- data/test/stamina/automaton/minimize/should_strip_1.min.adl +0 -6
- data/test/stamina/automaton/minimize/unknown_1.adl +0 -16
- data/test/stamina/automaton/minimize/unknown_1.min.adl +0 -12
- data/test/stamina/automaton/strip_test.rb +0 -36
- data/test/stamina/automaton/to_dot_test.rb +0 -64
- data/test/stamina/automaton/walking/dfa_delta_test.rb +0 -39
- data/test/stamina/automaton/walking_test.rb +0 -206
- data/test/stamina/automaton_additional_test.rb +0 -190
- data/test/stamina/automaton_test.rb +0 -1104
- data/test/stamina/exit.rb +0 -3
- data/test/stamina/induction/blue_fringe_test.rb +0 -83
- data/test/stamina/induction/induction_test.rb +0 -70
- data/test/stamina/induction/redblue_mergesamestatebug_expected.adl +0 -19
- data/test/stamina/induction/redblue_mergesamestatebug_pta.dot +0 -64
- data/test/stamina/induction/redblue_mergesamestatebug_sample.adl +0 -9
- data/test/stamina/induction/redblue_universal_expected.adl +0 -4
- data/test/stamina/induction/redblue_universal_sample.adl +0 -5
- data/test/stamina/induction/rpni_inria_expected.adl +0 -7
- data/test/stamina/induction/rpni_inria_sample.adl +0 -9
- data/test/stamina/induction/rpni_test.rb +0 -129
- data/test/stamina/induction/rpni_test_pta.dot +0 -22
- data/test/stamina/induction/rpni_universal_expected.adl +0 -4
- data/test/stamina/induction/rpni_universal_sample.adl +0 -4
- data/test/stamina/induction/union_find_test.rb +0 -124
- data/test/stamina/input_string_test.rb +0 -323
- data/test/stamina/markable_test.rb +0 -70
- data/test/stamina/randdfa.adl +0 -66
- data/test/stamina/sample.adl +0 -4
- data/test/stamina/sample_classify_test.rb +0 -149
- data/test/stamina/sample_test.rb +0 -290
- data/test/stamina/scoring_test.rb +0 -63
- data/test/stamina/small_dfa.dot +0 -16
- data/test/stamina/small_dfa.gif +0 -0
- data/test/stamina/small_nfa.dot +0 -18
- data/test/stamina/small_nfa.gif +0 -0
- data/test/stamina/stamina_test.rb +0 -80
- data/test/stamina/utils/decorate_test.rb +0 -65
- data/test/test_all.rb +0 -7
@@ -1,259 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'stamina/adl'
|
3
|
-
require 'stamina/stamina_test'
|
4
|
-
module Stamina
|
5
|
-
class Automaton
|
6
|
-
# Tests Classifier module, as to be installed on Automaton.
|
7
|
-
class ClassifierTest < StaminaTest
|
8
|
-
|
9
|
-
# Tests Classify#correctly_classified_by? is correct on valid sample against
|
10
|
-
# small_dfa example
|
11
|
-
def test_valid_sample_correctly_satified_by_small_dfa
|
12
|
-
assert_equal(true, @small_dfa.correctly_classify?(Sample.new))
|
13
|
-
sample = ADL::parse_sample <<-SAMPLE
|
14
|
-
-
|
15
|
-
+ b
|
16
|
-
+ b c
|
17
|
-
- b c a
|
18
|
-
- b c a c
|
19
|
-
- b c a c a
|
20
|
-
- b c a a
|
21
|
-
+ b c a b
|
22
|
-
+ b c a b c a c b
|
23
|
-
- z
|
24
|
-
- b z
|
25
|
-
SAMPLE
|
26
|
-
assert_equal '01100001100', sample.signature
|
27
|
-
assert_equal(true, @small_dfa.correctly_classify?(sample))
|
28
|
-
assert_equal sample.signature, @small_dfa.signature(sample)
|
29
|
-
end
|
30
|
-
|
31
|
-
# Tests Classify#correctly_classified_by? is correct on invalid sample against
|
32
|
-
# small_dfa example
|
33
|
-
def test_invalid_sample_correctly_classified_by_small_dfa
|
34
|
-
sample = ADL::parse_sample <<-SAMPLE
|
35
|
-
-
|
36
|
-
+ b
|
37
|
-
+ b c
|
38
|
-
- b c a
|
39
|
-
# this one is reversed
|
40
|
-
+ b c a c
|
41
|
-
- b c a c a
|
42
|
-
- b c a a
|
43
|
-
+ b c a b
|
44
|
-
+ b c a b c a c b
|
45
|
-
- z
|
46
|
-
- b z
|
47
|
-
SAMPLE
|
48
|
-
assert_equal(false, @small_dfa.correctly_classify?(sample))
|
49
|
-
assert_equal '01100001100', @small_dfa.signature(sample)
|
50
|
-
|
51
|
-
sample = ADL::parse_sample <<-SAMPLE
|
52
|
-
-
|
53
|
-
+ b
|
54
|
-
+ b c
|
55
|
-
- b c a
|
56
|
-
- b c a c
|
57
|
-
- b c a c a
|
58
|
-
- b c a a
|
59
|
-
+ b c a b
|
60
|
-
+ b c a b c a c b
|
61
|
-
# this one is changed
|
62
|
-
+ z
|
63
|
-
- b z
|
64
|
-
SAMPLE
|
65
|
-
assert_equal(false, @small_dfa.correctly_classify?(sample))
|
66
|
-
assert_equal '01100001100', @small_dfa.signature(sample)
|
67
|
-
|
68
|
-
sample = ADL::parse_sample <<-SAMPLE
|
69
|
-
-
|
70
|
-
+ b
|
71
|
-
+ b c
|
72
|
-
- b c a
|
73
|
-
- b c a c
|
74
|
-
- b c a c a
|
75
|
-
- b c a a
|
76
|
-
+ b c a b
|
77
|
-
# this one is changed
|
78
|
-
- b c a b c a c b
|
79
|
-
- z
|
80
|
-
- b z
|
81
|
-
SAMPLE
|
82
|
-
assert_equal(false, @small_dfa.correctly_classify?(sample))
|
83
|
-
assert_equal '01100001100', @small_dfa.signature(sample)
|
84
|
-
end
|
85
|
-
|
86
|
-
# Tests Classify#correctly_classify? is correct on valid sample against
|
87
|
-
# small_nfa example
|
88
|
-
def test_valid_sample_correctly_satified_by_small_nfa
|
89
|
-
assert_equal(true, @small_nfa.correctly_classify?(Sample.new))
|
90
|
-
sample = ADL::parse_sample <<-SAMPLE
|
91
|
-
+
|
92
|
-
+ a
|
93
|
-
- a a
|
94
|
-
+ a a b
|
95
|
-
+ a b
|
96
|
-
+ a b c a
|
97
|
-
- a b c
|
98
|
-
+ a b b b b b b
|
99
|
-
- a z
|
100
|
-
- z
|
101
|
-
SAMPLE
|
102
|
-
assert_equal(true, @small_nfa.correctly_classify?(sample))
|
103
|
-
assert_equal sample.signature, @small_nfa.signature(sample)
|
104
|
-
end
|
105
|
-
|
106
|
-
# Tests Classify#correctly_classify? is correct on invalid sample against
|
107
|
-
# small_nfa example
|
108
|
-
def test_invalid_sample_correctly_satified_by_small_nfa
|
109
|
-
sample = ADL::parse_sample <<-SAMPLE
|
110
|
-
# this one is changed
|
111
|
-
-
|
112
|
-
+ a
|
113
|
-
- a a
|
114
|
-
+ a a b
|
115
|
-
+ a b
|
116
|
-
+ a b c a
|
117
|
-
- a b c
|
118
|
-
+ a b b b b b b
|
119
|
-
- a z
|
120
|
-
- z
|
121
|
-
SAMPLE
|
122
|
-
assert_equal(false, @small_nfa.correctly_classify?(sample))
|
123
|
-
sample = ADL::parse_sample <<-SAMPLE
|
124
|
-
+
|
125
|
-
+ a
|
126
|
-
- a a
|
127
|
-
+ a a b
|
128
|
-
# this one is changed
|
129
|
-
- a b
|
130
|
-
+ a b c a
|
131
|
-
- a b c
|
132
|
-
+ a b b b b b b
|
133
|
-
- a z
|
134
|
-
- z
|
135
|
-
SAMPLE
|
136
|
-
assert_equal(false, @small_nfa.correctly_classify?(sample))
|
137
|
-
sample = ADL::parse_sample <<-SAMPLE
|
138
|
-
+
|
139
|
-
+ a
|
140
|
-
# this one is changed
|
141
|
-
+ a a
|
142
|
-
+ a a b
|
143
|
-
+ a b
|
144
|
-
+ a b c a
|
145
|
-
- a b c
|
146
|
-
+ a b b b b b b
|
147
|
-
- a z
|
148
|
-
- z
|
149
|
-
SAMPLE
|
150
|
-
assert_equal(false, @small_nfa.correctly_classify?(sample))
|
151
|
-
end
|
152
|
-
|
153
|
-
def test_scoring_on_valid_sample
|
154
|
-
sample = ADL::parse_sample <<-SAMPLE
|
155
|
-
-
|
156
|
-
+ b
|
157
|
-
+ b c
|
158
|
-
- b c a
|
159
|
-
- b c a c
|
160
|
-
- b c a c a
|
161
|
-
- b c a a
|
162
|
-
+ b c a b
|
163
|
-
+ b c a b c a c b
|
164
|
-
- z
|
165
|
-
- b z
|
166
|
-
SAMPLE
|
167
|
-
measures = @small_dfa.scoring(sample)
|
168
|
-
assert_equal(sample.positive_count, measures.true_positive)
|
169
|
-
assert_equal(0, measures.false_positive)
|
170
|
-
assert_equal(sample.negative_count, measures.true_negative)
|
171
|
-
assert_equal(0, measures.false_negative)
|
172
|
-
assert_equal(1.0, measures.precision)
|
173
|
-
assert_equal(1.0, measures.recall)
|
174
|
-
assert_equal(1.0, measures.sensitivity)
|
175
|
-
assert_equal(1.0, measures.specificity)
|
176
|
-
assert_equal(1.0, measures.accuracy)
|
177
|
-
end
|
178
|
-
|
179
|
-
def test_scoring_on_invalid_sample
|
180
|
-
sample = ADL::parse_sample <<-SAMPLE
|
181
|
-
+
|
182
|
-
- b
|
183
|
-
- b c
|
184
|
-
+ b c a
|
185
|
-
+ b c a c
|
186
|
-
+ b c a c a
|
187
|
-
+ b c a a
|
188
|
-
- b c a b
|
189
|
-
- b c a b c a c b
|
190
|
-
+ z
|
191
|
-
+ b z
|
192
|
-
SAMPLE
|
193
|
-
measures = @small_dfa.scoring(sample)
|
194
|
-
assert_equal(0.0, measures.true_positive)
|
195
|
-
assert_equal(sample.negative_count, measures.false_positive)
|
196
|
-
assert_equal(0.0, measures.true_negative)
|
197
|
-
assert_equal(sample.positive_count, measures.false_negative)
|
198
|
-
assert_equal(0.0, measures.precision)
|
199
|
-
assert_equal(0.0, measures.recall)
|
200
|
-
assert_equal(0.0, measures.sensitivity)
|
201
|
-
assert_equal(0.0, measures.specificity)
|
202
|
-
assert_equal(0.0, measures.accuracy)
|
203
|
-
end
|
204
|
-
|
205
|
-
def test_scoring_with_positive_only
|
206
|
-
sample = ADL::parse_sample <<-SAMPLE
|
207
|
-
+
|
208
|
-
+ b
|
209
|
-
+ b c
|
210
|
-
+ b c a
|
211
|
-
+ b c a c
|
212
|
-
+ b c a c a
|
213
|
-
+ b c a a
|
214
|
-
+ b c a b
|
215
|
-
+ b c a b c a c b
|
216
|
-
+ z
|
217
|
-
+ b z
|
218
|
-
SAMPLE
|
219
|
-
measures = @small_dfa.scoring(sample)
|
220
|
-
assert_equal(4.0, measures.true_positive)
|
221
|
-
assert_equal(sample.size-sample.positive_count, measures.false_positive)
|
222
|
-
assert_equal(0, measures.true_negative)
|
223
|
-
assert_equal(sample.size-4.0, measures.false_negative)
|
224
|
-
assert_equal(1.0, measures.precision)
|
225
|
-
assert_equal(4.0/sample.size, measures.recall)
|
226
|
-
assert_equal(4.0/sample.size, measures.sensitivity)
|
227
|
-
#assert_equal(0.0/0.0, measures.specificity)
|
228
|
-
assert_equal(4.0/sample.size, measures.accuracy)
|
229
|
-
end
|
230
|
-
|
231
|
-
def test_scoring_with_negative_only
|
232
|
-
sample = ADL::parse_sample <<-SAMPLE
|
233
|
-
-
|
234
|
-
- b
|
235
|
-
- b c
|
236
|
-
- b c a
|
237
|
-
- b c a c
|
238
|
-
- b c a c a
|
239
|
-
- b c a a
|
240
|
-
- b c a b
|
241
|
-
- b c a b c a c b
|
242
|
-
- z
|
243
|
-
- b z
|
244
|
-
SAMPLE
|
245
|
-
measures = @small_dfa.scoring(sample)
|
246
|
-
assert_equal(0.0, measures.true_positive)
|
247
|
-
assert_equal(4.0, measures.false_positive)
|
248
|
-
assert_equal(sample.size-4.0, measures.true_negative)
|
249
|
-
assert_equal(0.0, measures.false_negative)
|
250
|
-
assert_equal(0.0, measures.precision)
|
251
|
-
#assert_equal(0.0, measures.recall)
|
252
|
-
#assert_equal(0.0, measures.sensitivity)
|
253
|
-
assert_equal((sample.size-4.0)/sample.size, measures.specificity)
|
254
|
-
assert_equal((sample.size-4.0)/sample.size, measures.accuracy)
|
255
|
-
end
|
256
|
-
|
257
|
-
end # class ClassifierTest
|
258
|
-
end # class Automaton
|
259
|
-
end # module Stamina
|
@@ -1,58 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'stamina/stamina_test'
|
3
|
-
module Stamina
|
4
|
-
class Automaton
|
5
|
-
class CompleteTest < StaminaTest
|
6
|
-
|
7
|
-
def test_on_not_complete
|
8
|
-
x, y, z = nil, nil, nil
|
9
|
-
dfa = Automaton.new(true) do |fa|
|
10
|
-
fa.alphabet = ["a", "b"]
|
11
|
-
x = fa.add_state(:initial => true, :accepting => true)
|
12
|
-
y = fa.add_state(:initial => false, :accepting => false)
|
13
|
-
fa.connect(0,1,'a')
|
14
|
-
fa.connect(1,0,'b')
|
15
|
-
end
|
16
|
-
|
17
|
-
assert_equal false, dfa.complete?
|
18
|
-
dfa.complete!
|
19
|
-
assert_equal true, dfa.complete?
|
20
|
-
|
21
|
-
assert_equal 3, dfa.state_count
|
22
|
-
z = dfa.ith_state(2)
|
23
|
-
assert_equal z, dfa.dfa_delta(x, "b")
|
24
|
-
assert_equal y, dfa.dfa_delta(x, "a")
|
25
|
-
assert_equal z, dfa.dfa_delta(y, "a")
|
26
|
-
assert_equal x, dfa.dfa_delta(y, "b")
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_on_complete
|
30
|
-
dfa = Automaton.new(true) do |fa|
|
31
|
-
fa.alphabet = ["a"]
|
32
|
-
fa.add_state(:initial => true, :accepting => true)
|
33
|
-
fa.add_state(:initial => false, :accepting => false)
|
34
|
-
fa.connect(0,1,'a')
|
35
|
-
fa.connect(1,0,'a')
|
36
|
-
end
|
37
|
-
assert_equal true, dfa.complete?
|
38
|
-
dfa.complete!
|
39
|
-
assert_equal 2, dfa.state_count
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_it_has_a_non_touching_impl
|
43
|
-
dfa = Automaton.new(true) do |fa|
|
44
|
-
fa.alphabet = ["a", "b"]
|
45
|
-
fa.add_state(:initial => true, :accepting => true)
|
46
|
-
fa.add_state(:initial => false, :accepting => false)
|
47
|
-
fa.connect(0,1,'a')
|
48
|
-
fa.connect(1,0,'b')
|
49
|
-
end
|
50
|
-
c = dfa.complete
|
51
|
-
assert_equal 2, dfa.state_count
|
52
|
-
assert_equal 3, c.state_count
|
53
|
-
end
|
54
|
-
|
55
|
-
end # class CompleteTest
|
56
|
-
end # class Automaton
|
57
|
-
end # module Stamina
|
58
|
-
|
@@ -1,120 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'stamina/stamina_test'
|
3
|
-
module Stamina
|
4
|
-
class Automaton
|
5
|
-
class EquivalenceTest < StaminaTest
|
6
|
-
|
7
|
-
def test_equivalence_on_small_dfa
|
8
|
-
assert_equal true, @small_dfa <=> @small_dfa
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_equivalence_on_real_case
|
12
|
-
dfa1 = Stamina::ADL.parse_automaton <<-EOF
|
13
|
-
3 5
|
14
|
-
0 true false
|
15
|
-
1 false false
|
16
|
-
2 false true
|
17
|
-
0 1 a
|
18
|
-
1 1 a
|
19
|
-
1 2 b
|
20
|
-
2 2 b
|
21
|
-
0 2 b
|
22
|
-
EOF
|
23
|
-
dfa2 = Stamina::ADL.parse_automaton <<-EOF
|
24
|
-
3 5
|
25
|
-
0 false true
|
26
|
-
1 true false
|
27
|
-
2 false false
|
28
|
-
0 0 b
|
29
|
-
1 2 a
|
30
|
-
1 0 b
|
31
|
-
2 2 a
|
32
|
-
2 0 b
|
33
|
-
EOF
|
34
|
-
dfa3 = Stamina::ADL.parse_automaton <<-EOF
|
35
|
-
3 5
|
36
|
-
0 false false
|
37
|
-
1 false true
|
38
|
-
2 true false
|
39
|
-
0 0 a
|
40
|
-
0 1 b
|
41
|
-
1 1 b
|
42
|
-
2 0 a
|
43
|
-
2 1 b
|
44
|
-
EOF
|
45
|
-
assert_equal true, dfa1 <=> dfa2
|
46
|
-
assert_equal true, dfa2 <=> dfa1
|
47
|
-
assert_equal true, dfa1 <=> dfa3
|
48
|
-
assert_equal true, dfa3 <=> dfa1
|
49
|
-
assert_equal true, dfa2 <=> dfa3
|
50
|
-
assert_equal true, dfa3 <=> dfa2
|
51
|
-
end
|
52
|
-
|
53
|
-
def test_equivalence_does_not_change_the_automata
|
54
|
-
dfa1 = Stamina::ADL.parse_automaton <<-EOF
|
55
|
-
1 1
|
56
|
-
0 true true
|
57
|
-
0 0 a
|
58
|
-
EOF
|
59
|
-
assert_not_nil dfa1.initial_state
|
60
|
-
assert_equal true, dfa1 <=> dfa1
|
61
|
-
assert_not_nil dfa1.initial_state
|
62
|
-
end
|
63
|
-
|
64
|
-
def test_non_equivalent_dfa_are_recognized_1
|
65
|
-
dfa1 = Stamina::ADL.parse_automaton <<-EOF
|
66
|
-
3 5
|
67
|
-
0 true false
|
68
|
-
1 false false
|
69
|
-
2 false true
|
70
|
-
0 1 a
|
71
|
-
1 1 a
|
72
|
-
1 2 b
|
73
|
-
2 2 b
|
74
|
-
0 2 b
|
75
|
-
EOF
|
76
|
-
assert_equal false, @small_dfa <=> dfa1
|
77
|
-
assert_equal false, dfa1 <=> @small_dfa
|
78
|
-
end
|
79
|
-
|
80
|
-
def test_non_equivalent_dfa_are_recognized_2
|
81
|
-
dfa1 = Stamina::ADL.parse_automaton <<-EOF
|
82
|
-
5 4
|
83
|
-
0 true false
|
84
|
-
1 false false
|
85
|
-
2 false false
|
86
|
-
3 false false
|
87
|
-
4 false false
|
88
|
-
0 1 a
|
89
|
-
1 2 a
|
90
|
-
2 3 a
|
91
|
-
3 4 a
|
92
|
-
EOF
|
93
|
-
dfa2 = Stamina::ADL.parse_automaton <<-EOF
|
94
|
-
1 1
|
95
|
-
0 true true
|
96
|
-
0 0 a
|
97
|
-
EOF
|
98
|
-
assert_equal false, dfa2 <=> dfa1
|
99
|
-
assert_not_nil dfa1.initial_state
|
100
|
-
assert_not_nil dfa2.initial_state
|
101
|
-
assert_equal false, dfa1 <=> dfa2
|
102
|
-
end
|
103
|
-
|
104
|
-
def test_equivalence_takes_care_of_state_flags
|
105
|
-
dfa1 = Stamina::ADL.parse_automaton <<-EOF
|
106
|
-
1 0
|
107
|
-
0 true false
|
108
|
-
EOF
|
109
|
-
dfa2 = Stamina::ADL.parse_automaton <<-EOF
|
110
|
-
1 0
|
111
|
-
0 true true
|
112
|
-
EOF
|
113
|
-
assert_equal false, dfa1 <=> dfa2
|
114
|
-
assert_equal false, dfa2 <=> dfa1
|
115
|
-
end
|
116
|
-
|
117
|
-
end # class EquivalenceTest
|
118
|
-
end # class Automaton
|
119
|
-
end # module Stamina
|
120
|
-
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'stamina/adl'
|
3
|
-
require 'stamina/stamina_test'
|
4
|
-
module Stamina
|
5
|
-
class Automaton
|
6
|
-
class MetricsTest < StaminaTest
|
7
|
-
|
8
|
-
def test_alphabet_size
|
9
|
-
assert_equal 3, @small_dfa.alphabet_size
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_avg_degree
|
13
|
-
assert_equal 6.to_f/4, @small_dfa.avg_degree
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_avg_out_degree
|
17
|
-
assert_equal 6.to_f/4, @small_dfa.avg_out_degree
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_avg_in_degree
|
21
|
-
assert_equal 6.to_f/4, @small_dfa.avg_in_degree
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_accepting_ratio
|
25
|
-
assert_equal 0.5, @small_dfa.accepting_ratio
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_depth
|
29
|
-
assert_equal 3, @small_dfa.depth
|
30
|
-
assert_equal 2, @small_nfa.depth
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|