Class AbstractBlueFringeRPNI<I,D,SP,TP,M>
- java.lang.Object
-
- de.learnlib.algorithm.rpni.AbstractBlueFringeRPNI<I,D,SP,TP,M>
-
- Type Parameters:
I
- input symbol typeD
- output domain typeSP
- state property typeTP
- transition property typeM
- model type
- All Implemented Interfaces:
PassiveLearningAlgorithm<M,I,D>
- Direct Known Subclasses:
BlueFringeEDSMDFA
,BlueFringeMDLDFA
,BlueFringeRPNIDFA
,BlueFringeRPNIMealy
,BlueFringeRPNIMoore
public abstract class AbstractBlueFringeRPNI<I,D,SP,TP,M> extends Object implements PassiveLearningAlgorithm<M,I,D>
Abstract base class for Blue-Fringe-RPNI algorithms.Unlike most descriptions of RPNI in the literature, the Blue Fringe version of RPNI does not consider all possible pairs of states for merging, but instead maintains a monotonically growing set of "red states", the immediate non-red successors of which are called blue states. In each iteration of the main loop, an attempt is made to merge a blue state into any red state. If this is impossible, the blue state is promoted, meaning it is converted into a red state itself. The procedure terminates when all states are red.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface de.learnlib.algorithm.PassiveLearningAlgorithm
PassiveLearningAlgorithm.PassiveAcceptorLearner<M extends net.automatalib.automaton.fsa.FiniteStateAcceptor<?,I>,I>, PassiveLearningAlgorithm.PassiveDFALearner<I>, PassiveLearningAlgorithm.PassiveMealyLearner<I,O>, PassiveLearningAlgorithm.PassiveMooreLearner<I,O>
-
-
Field Summary
Fields Modifier and Type Field Description protected net.automatalib.alphabet.Alphabet<I>
alphabet
protected int
alphabetSize
-
Constructor Summary
Constructors Constructor Description AbstractBlueFringeRPNI(net.automatalib.alphabet.Alphabet<I> alphabet)
Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description M
computeModel()
Computes the model given the previously added samples.protected abstract BlueFringePTA<SP,TP>
fetchPTA()
Fetches the initialPTA
for model construction.protected abstract M
ptaToModel(BlueFringePTA<SP,TP> pta)
Transforms the final PTA into a model.protected Stream<RedBlueMerge<BlueFringePTAState<SP,TP>,SP,TP>>
selectMerges(Stream<RedBlueMerge<BlueFringePTAState<SP,TP>,SP,TP>> merges)
Implementing the method allows subclasses to decide on (and possibly reject) valid merges.void
setDeterministic(boolean deterministic)
Sets whether the outcome of the algorithm is required to be deterministic (i.e., subsequent calls ofcomputeModel()
on the same input data will perform the same merges and return the same result).void
setParallel(boolean parallel)
Sets whether attempts to merge a blue into a red state are conducted in parallel.void
setProcessingOrder(ProcessingOrder order)
Sets the order in which the respective merge candidates should be processed.protected @Nullable RedBlueMerge<BlueFringePTAState<SP,TP>,SP,TP>
tryMerge(BlueFringePTA<SP,TP> pta, BlueFringePTAState<SP,TP> qr, BlueFringePTAState<SP,TP> qb)
Attempts to merge a blue state into a red state.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.learnlib.algorithm.PassiveLearningAlgorithm
addSample, addSample, addSamples, addSamples, addSamples, addSamples
-
-
-
-
Field Detail
-
alphabet
protected final net.automatalib.alphabet.Alphabet<I> alphabet
-
alphabetSize
protected final int alphabetSize
-
-
Constructor Detail
-
AbstractBlueFringeRPNI
public AbstractBlueFringeRPNI(net.automatalib.alphabet.Alphabet<I> alphabet)
Constructor.- Parameters:
alphabet
- the alphabet
-
-
Method Detail
-
setParallel
public void setParallel(boolean parallel)
Sets whether attempts to merge a blue into a red state are conducted in parallel.Note that setting this to
true
does not inhibit the possibility of deterministic algorithm runs (seesetDeterministic(boolean)
).- Parameters:
parallel
- whether to parallelize the process of finding a possible merge
-
setDeterministic
public void setDeterministic(boolean deterministic)
Sets whether the outcome of the algorithm is required to be deterministic (i.e., subsequent calls ofcomputeModel()
on the same input data will perform the same merges and return the same result).Note that if parallel execution is disabled (see
setParallel(boolean)
), the algorithm will most likely (but is not required to) behave deterministically even with this set tofalse
. However, if parallelization is enabled, results of subsequent invocations will most likely differ with this parameter set tofalse
.- Parameters:
deterministic
- whether to enforce deterministic algorithm behavior
-
setProcessingOrder
public void setProcessingOrder(ProcessingOrder order)
Sets the order in which the respective merge candidates should be processed.- Parameters:
order
- the order
-
computeModel
public M computeModel()
Description copied from interface:PassiveLearningAlgorithm
Computes the model given the previously added samples.Implementation note: It is up to the implementation if this operation is repeatable or not, An implementation may throw an
IllegalStateException
if additional samples are added after the first model construction.- Specified by:
computeModel
in interfacePassiveLearningAlgorithm<I,D,SP>
- Returns:
- the computed model
-
fetchPTA
protected abstract BlueFringePTA<SP,TP> fetchPTA()
Fetches the initialPTA
for model construction. If subclasses need to cache the training data this may be a fresh instance. If subclasses directly insert training data to a local PTA, they should make sure that repeated invocations of this method are not possible.- Returns:
- the
PTA
for model construction.
-
tryMerge
protected @Nullable RedBlueMerge<BlueFringePTAState<SP,TP>,SP,TP> tryMerge(BlueFringePTA<SP,TP> pta, BlueFringePTAState<SP,TP> qr, BlueFringePTAState<SP,TP> qb)
Attempts to merge a blue state into a red state.- Parameters:
pta
- the blue fringe PTAqr
- the red state (i.e., the merge target)qb
- the blue state (i.e., the merge source)- Returns:
- a valid
RedBlueMerge
object representing a possible merge ofqb
intoqr
, ornull
if the merge is impossible
-
ptaToModel
protected abstract M ptaToModel(BlueFringePTA<SP,TP> pta)
Transforms the final PTA into a model.- Parameters:
pta
- the final PTA- Returns:
- a model built from the final PTA
-
selectMerges
protected Stream<RedBlueMerge<BlueFringePTAState<SP,TP>,SP,TP>> selectMerges(Stream<RedBlueMerge<BlueFringePTAState<SP,TP>,SP,TP>> merges)
Implementing the method allows subclasses to decide on (and possibly reject) valid merges.- Parameters:
merges
- the prosed (valid) merges- Returns:
- the merges that should be considered for selecting a merge.
-
-