de.learnlib.api.algorithm.PassiveLearningAlgorithm Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of learnlib-api Show documentation
Show all versions of learnlib-api Show documentation
Infrastructure and core interfaces of LearnLib
/* Copyright (C) 2013-2020 TU Dortmund
* This file is part of LearnLib, http://www.learnlib.de/.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.learnlib.api.algorithm;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import de.learnlib.api.query.DefaultQuery;
import net.automatalib.automata.fsa.DFA;
import net.automatalib.automata.fsa.FiniteStateAcceptor;
import net.automatalib.automata.fsa.NFA;
import net.automatalib.automata.transducers.MealyMachine;
import net.automatalib.words.Word;
public interface PassiveLearningAlgorithm {
void addSamples(Collection extends DefaultQuery> samples);
@SuppressWarnings("unchecked")
default void addSamples(DefaultQuery... samples) {
addSamples(Arrays.asList(samples));
}
@SuppressWarnings("unchecked")
default void addSamples(D output, Word... words) {
addSamples(output, Arrays.asList(words));
}
default void addSamples(D output, Collection extends Word> words) {
List> queries = new ArrayList<>(words.size());
for (Word word : words) {
queries.add(new DefaultQuery<>(word, output));
}
addSamples(queries);
}
default void addSample(Word input, D output) {
addSample(new DefaultQuery<>(input, output));
}
default void addSample(DefaultQuery sample) {
addSamples(Collections.singleton(sample));
}
M computeModel();
/**
* Basic interface for passive learning algorithms that infer {@link DFA}s.
*
* @param
* input symbol type
*
* @author Malte Isberner
*/
interface PassiveDFALearner extends PassiveAcceptorLearner, I> {}
/**
* Basic interface for passive learning algorithms that infer {@link MealyMachine Mealy machines}.
*
* @param
* input symbol type
* @param
* output symbol type
*
* @author Malte Isberner
*/
interface PassiveMealyLearner extends PassiveLearningAlgorithm, I, Word> {}
/**
* Basic interface for passive learning algorithms that infer {@link NFA}s.
*
* @param
* input symbol type
*
* @author Malte Isberner
*/
interface PassiveNFALearner extends PassiveAcceptorLearner, I> {}
/**
* Basic interface for passive learning algorithms that infer finite-state acceptors ({@link DFA}s or {@link
* NFA}s).
*
* @param
* model type
* @param
* input symbol type
*
* @author Malte Isberner
*/
interface PassiveAcceptorLearner, I>
extends PassiveLearningAlgorithm {
default void addPositiveSample(Word word) {
addSample(word, true);
}
default void addPositiveSamples(Collection extends Word> words) {
addSamples(true, words);
}
@SuppressWarnings("unchecked")
default void addPositiveSamples(Word... words) {
addSamples(true, words);
}
default void addNegativeSample(Word word) {
addSample(word, false);
}
default void addNegativeSamples(Collection extends Word> words) {
addSamples(false, words);
}
@SuppressWarnings("unchecked")
default void addNegativeSamples(Word... words) {
addSamples(false, words);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy