All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.learnlib.api.algorithm.LearningAlgorithm Maven / Gradle / Ivy

There is a newer version: 0.17.0
Show newest version
/* 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 de.learnlib.api.oracle.EquivalenceOracle;
import de.learnlib.api.query.DefaultQuery;
import net.automatalib.automata.fsa.DFA;
import net.automatalib.automata.transducers.MealyMachine;
import net.automatalib.words.Word;

/**
 * Basic interface for a model inference algorithm.
 * 

* Actively inferring models (such as DFAs or Mealy machines) consists of the construction of an initial hypothesis, * which is subsequently refined using counterexamples (see {@link EquivalenceOracle}). * * @param * model type * @param * input symbol type * @param * output domain type * * @author Maik Merten * @author Malte Isberner */ public interface LearningAlgorithm { /** * Starts the model inference process, creating an initial hypothesis in the provided model object. Please note that * it should be illegal to invoke this method twice. */ void startLearning(); /** * Triggers a refinement of the model by providing a counterexample. A counterexample is a query which exposes * different behavior of the real SUL compared to the hypothesis. Please note that invoking this method before an * initial invocation of {@link #startLearning()} should be illegal. * * @param ceQuery * the query which exposes diverging behavior, as posed to the real SUL (i.e. with the SULs output). * * @return {@code true} if the counterexample triggered a refinement of the hypothesis, {@code false} otherwise * (i.e., it was no counterexample). */ boolean refineHypothesis(DefaultQuery ceQuery); /** * Returns the current hypothesis model. *

* N.B.: By the contract of this interface, the model returned by this method may not be modified (i.e., M generally * should refer to an immutable interface), and its validity is retained only until the next invocation of {@link * #refineHypothesis(DefaultQuery)}. If older hypotheses have to be maintained, a copy of the returned model must be * made. *

* Please note that it should be illegal to invoke this method before an initial invocation of {@link * #startLearning()}. * * @return the current hypothesis model. */ M getHypothesisModel(); interface DFALearner extends LearningAlgorithm, I, Boolean> {} interface MealyLearner extends LearningAlgorithm, I, Word> {} }