Class AdaptiveQueryCache<I,​O>

  • Type Parameters:
    I - input symbol type
    O - output symbol type
    All Implemented Interfaces:
    LearningCache<net.automatalib.automaton.transducer.MealyMachine<?,​I,​?,​O>,​I,​net.automatalib.word.Word<O>>, AdaptiveMembershipOracle<I,​O>, BatchProcessor<AdaptiveQuery<I,​O>>, Resumable<AdaptiveQueryCache.AdaptiveQueryCacheState<I,​O>>, net.automatalib.alphabet.SupportsGrowingAlphabet<I>

    public class AdaptiveQueryCache<I,​O>
    extends Object
    implements AdaptiveMembershipOracle<I,​O>, LearningCache<net.automatalib.automaton.transducer.MealyMachine<?,​I,​?,​O>,​I,​net.automatalib.word.Word<O>>, net.automatalib.alphabet.SupportsGrowingAlphabet<I>, Resumable<AdaptiveQueryCache.AdaptiveQueryCacheState<I,​O>>
    A cache for an AdaptiveMembershipOracle. Upon construction, it is provided with a delegate oracle. Queries that can be answered from the cache are answered directly, others are forwarded to the delegate oracle. Queried symbols that have to be delegated are incorporated into the cache directly.

    Internally, an incrementally growing tree (in form of a mealy automaton) is used for caching.

    Note that due to the step-wise processing of adaptive queries, duplicates within a single batch cannot be cached. If you want to maximize cache efficiency, you would have to give up on potential parallelization and pose queries one by one.

    • Constructor Detail

      • AdaptiveQueryCache

        public AdaptiveQueryCache​(AdaptiveMembershipOracle<I,​O> delegate,
                                  net.automatalib.alphabet.Alphabet<I> alphabet)
    • Method Detail

      • createCacheConsistencyTest

        public EquivalenceOracle<net.automatalib.automaton.transducer.MealyMachine<?,​I,​?,​O>,​I,​net.automatalib.word.Word<O>> createCacheConsistencyTest()
        Description copied from interface: LearningCache
        Creates a cache consistency test. A cache consistency test is an equivalence oracle which checks a given hypothesis against the current contents of the cache. Hence, no queries are posed to the underlying system.

        The created cache consistency test is backed by the cache contents. This method does not need to be invoked repeatedly when the cache contents change.

        Specified by:
        createCacheConsistencyTest in interface LearningCache<net.automatalib.automaton.transducer.MealyMachine<?,​I,​?,​O>,​I,​net.automatalib.word.Word<O>>
        Returns:
        a cache consistency test for the contents of this cache
      • addAlphabetSymbol

        public void addAlphabetSymbol​(I symbol)
        Specified by:
        addAlphabetSymbol in interface net.automatalib.alphabet.SupportsGrowingAlphabet<I>
      • getCache

        public net.automatalib.automaton.transducer.MealyMachine<Integer,​I,​?,​O> getCache()
        Returns a (structural) view of the cache in form of a MealyMachine.
        Returns:
        a view of the cache
      • getInit

        public Integer getInit()
        Returns the initial state of the structural view of the cache.
        Returns:
        the initial state of the cache
        See Also:
        getCache()
      • insert

        public Integer insert​(net.automatalib.word.Word<I> input,
                              net.automatalib.word.Word<O> output)
        Inserts the given trace of input symbols and associates the trace of given output symbols with it.
        Parameters:
        input - the sequence of input symbols
        output - the sequence of output symbols
        Returns:
        the identifier of the state reached by the input sequence
      • insert

        public Integer insert​(Integer state,
                              net.automatalib.word.Word<I> input,
                              net.automatalib.word.Word<O> output)
        Inserts the given trace of input symbols at the given cache state and associates the trace of given output symbols with it.
        Parameters:
        state - the (cache) state at which the traces should be inserted
        input - the sequence of input symbols
        output - the sequence of output symbols
        Returns:
        the identifier of the state reached by the input sequence