Skip to content

Commit 4f82adc

Browse files
committed
Added interfaces for passive learning
1 parent 507bb0c commit 4f82adc

4 files changed

Lines changed: 158 additions & 0 deletions

File tree

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/* Copyright (C) 2015 TU Dortmund
2+
* This file is part of LearnLib, http://www.learnlib.de/.
3+
*
4+
* LearnLib is free software; you can redistribute it and/or
5+
* modify it under the terms of the GNU Lesser General Public
6+
* License version 3.0 as published by the Free Software Foundation.
7+
*
8+
* LearnLib is distributed in the hope that it will be useful,
9+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11+
* Lesser General Public License for more details.
12+
*
13+
* You should have received a copy of the GNU Lesser General Public
14+
* License along with LearnLib; if not, see
15+
* http://www.gnu.de/documents/lgpl.en.html.
16+
*/
17+
package de.learnlib.passive.api;
18+
19+
import java.util.Collection;
20+
21+
import net.automatalib.automata.fsa.FiniteStateAcceptor;
22+
import net.automatalib.words.Word;
23+
24+
public interface PassiveAcceptorLearner<M extends FiniteStateAcceptor<?, I>,I> extends PassiveLearningAlgorithm<M, I, Boolean> {
25+
26+
default public void addPositiveSample(Word<I> word) {
27+
addSample(word, true);
28+
}
29+
30+
default public void addPositiveSamples(Collection<? extends Word<I>> words) {
31+
addSamples(true, words);
32+
}
33+
34+
@SuppressWarnings("unchecked")
35+
default public void addPositiveSamples(Word<I> ...words) {
36+
addSamples(true, words);
37+
}
38+
39+
40+
default public void addNegativeSample(Word<I> word) {
41+
addSample(word, false);
42+
}
43+
44+
default public void addNegativeSamples(Collection<? extends Word<I>> words) {
45+
addSamples(false, words);
46+
}
47+
48+
@SuppressWarnings("unchecked")
49+
default public void addNegativeSamples(Word<I> ...words) {
50+
addSamples(false, words);
51+
}
52+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* Copyright (C) 2015 TU Dortmund
2+
* This file is part of LearnLib, http://www.learnlib.de/.
3+
*
4+
* LearnLib is free software; you can redistribute it and/or
5+
* modify it under the terms of the GNU Lesser General Public
6+
* License version 3.0 as published by the Free Software Foundation.
7+
*
8+
* LearnLib is distributed in the hope that it will be useful,
9+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11+
* Lesser General Public License for more details.
12+
*
13+
* You should have received a copy of the GNU Lesser General Public
14+
* License along with LearnLib; if not, see
15+
* http://www.gnu.de/documents/lgpl.en.html.
16+
*/
17+
package de.learnlib.passive.api;
18+
19+
import net.automatalib.automata.fsa.DFA;
20+
21+
public interface PassiveDFALearner<I> extends PassiveAcceptorLearner<DFA<?,I>,I> {
22+
23+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/* Copyright (C) 2015 TU Dortmund
2+
* This file is part of LearnLib, http://www.learnlib.de/.
3+
*
4+
* LearnLib is free software; you can redistribute it and/or
5+
* modify it under the terms of the GNU Lesser General Public
6+
* License version 3.0 as published by the Free Software Foundation.
7+
*
8+
* LearnLib is distributed in the hope that it will be useful,
9+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11+
* Lesser General Public License for more details.
12+
*
13+
* You should have received a copy of the GNU Lesser General Public
14+
* License along with LearnLib; if not, see
15+
* http://www.gnu.de/documents/lgpl.en.html.
16+
*/
17+
package de.learnlib.passive.api;
18+
19+
import java.util.ArrayList;
20+
import java.util.Arrays;
21+
import java.util.Collection;
22+
import java.util.Collections;
23+
import java.util.List;
24+
25+
import net.automatalib.words.Word;
26+
import de.learnlib.oracles.DefaultQuery;
27+
28+
public interface PassiveLearningAlgorithm<M, I, D> {
29+
30+
public void addSamples(Collection<? extends DefaultQuery<I,D>> samples);
31+
32+
@SuppressWarnings("unchecked")
33+
default public void addSamples(DefaultQuery<I,D> ...samples) {
34+
addSamples(Arrays.asList(samples));
35+
}
36+
37+
default public void addSample(DefaultQuery<I,D> sample) {
38+
addSamples(Collections.singleton(sample));
39+
}
40+
41+
default public void addSample(Word<I> input, D output) {
42+
addSample(new DefaultQuery<>(input, output));
43+
}
44+
45+
default public void addSamples(D output, Collection<? extends Word<I>> words) {
46+
List<DefaultQuery<I,D>> queries = new ArrayList<>(words.size());
47+
for (Word<I> word : words) {
48+
queries.add(new DefaultQuery<>(word, output));
49+
}
50+
}
51+
52+
@SuppressWarnings("unchecked")
53+
default public void addSamples(D output, Word<I> ...words) {
54+
addSamples(output, Arrays.asList(words));
55+
}
56+
57+
58+
public M computeModel();
59+
60+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* Copyright (C) 2015 TU Dortmund
2+
* This file is part of LearnLib, http://www.learnlib.de/.
3+
*
4+
* LearnLib is free software; you can redistribute it and/or
5+
* modify it under the terms of the GNU Lesser General Public
6+
* License version 3.0 as published by the Free Software Foundation.
7+
*
8+
* LearnLib is distributed in the hope that it will be useful,
9+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11+
* Lesser General Public License for more details.
12+
*
13+
* You should have received a copy of the GNU Lesser General Public
14+
* License along with LearnLib; if not, see
15+
* http://www.gnu.de/documents/lgpl.en.html.
16+
*/
17+
package de.learnlib.passive.api;
18+
19+
import net.automatalib.automata.fsa.NFA;
20+
21+
public interface PassiveNFALearner<I> extends PassiveAcceptorLearner<NFA<?,I>,I> {
22+
23+
}

0 commit comments

Comments
 (0)