001/* Copyright (C) 2013 TU Dortmund 002 * This file is part of LearnLib, http://www.learnlib.de/. 003 * 004 * LearnLib is free software; you can redistribute it and/or 005 * modify it under the terms of the GNU Lesser General Public 006 * License version 3.0 as published by the Free Software Foundation. 007 * 008 * LearnLib is distributed in the hope that it will be useful, 009 * but WITHOUT ANY WARRANTY; without even the implied warranty of 010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 011 * Lesser General Public License for more details. 012 * 013 * You should have received a copy of the GNU Lesser General Public 014 * License along with LearnLib; if not, see 015 * <http://www.gnu.de/documents/lgpl.en.html>. 016 */ 017package de.learnlib.algorithms.lstargeneric; 018 019import java.util.List; 020 021import net.automatalib.automata.MutableDeterministic; 022import net.automatalib.automata.concepts.SuffixOutput; 023import net.automatalib.words.Alphabet; 024import net.automatalib.words.Word; 025import de.learnlib.algorithms.lstargeneric.ce.ObservationTableCEXHandler; 026import de.learnlib.algorithms.lstargeneric.closing.ClosingStrategy; 027import de.learnlib.algorithms.lstargeneric.table.Row; 028import de.learnlib.api.MembershipOracle; 029import de.learnlib.oracles.DefaultQuery; 030 031public abstract class ExtensibleAutomatonLStar<A,I,O,S,T,SP,TP,AI extends MutableDeterministic<S,I,T,SP,TP>> extends 032AbstractAutomatonLStar<A, I, O,S,T,SP,TP,AI> { 033 034 protected final ObservationTableCEXHandler<? super I, ? super O> cexHandler; 035 protected final ClosingStrategy<? super I, ? super O> closingStrategy; 036 protected final List<Word<I>> initialSuffixes; 037 038 public ExtensibleAutomatonLStar(Alphabet<I> alphabet, 039 MembershipOracle<I,O> oracle, AI internalHyp, 040 List<Word<I>> initialSuffixes, 041 ObservationTableCEXHandler<? super I,? super O> cexHandler, 042 ClosingStrategy<? super I,? super O> closingStrategy) { 043 super(alphabet, oracle, internalHyp); 044 this.initialSuffixes = initialSuffixes; 045 this.cexHandler = cexHandler; 046 this.closingStrategy = closingStrategy; 047 } 048 049 /* 050 * (non-Javadoc) 051 * @see de.learnlib.algorithms.lstargeneric.AbstractLStar#doRefineHypothesis(de.learnlib.oracles.DefaultQuery) 052 */ 053 @Override 054 protected void doRefineHypothesis(DefaultQuery<I, O> ceQuery) { 055 List<List<Row<I>>> unclosed = cexHandler.handleCounterexample(ceQuery, table, hypothesisOutput(), oracle); 056 completeConsistentTable(unclosed, cexHandler.needsConsistencyCheck()); 057 } 058 059 /* 060 * (non-Javadoc) 061 * @see de.learnlib.algorithms.lstargeneric.AbstractLStar#selectClosingRows(java.util.List) 062 */ 063 @Override 064 protected List<Row<I>> selectClosingRows(List<List<Row<I>>> unclosed) { 065 return closingStrategy.selectClosingRows(unclosed, table, oracle); 066 } 067 068 /* 069 * (non-Javadoc) 070 * @see de.learnlib.algorithms.lstargeneric.AbstractLStar#initialSuffixes() 071 */ 072 @Override 073 protected List<Word<I>> initialSuffixes() { 074 return initialSuffixes; 075 } 076 077 protected abstract SuffixOutput<I,O> hypothesisOutput(); 078 079 080}