Class TimeoutEQOracle<I,O>

java.lang.Object
net.maswag.falcaun.oracle.TimeoutEQOracle<I,O>
Type Parameters:
I - Input symbol
O - Output symbol
All Implemented Interfaces:
EquivalenceOracle<net.automatalib.automaton.transducer.MealyMachine<?,I,?,O>,I,net.automatalib.word.Word<O>>, EquivalenceOracle.MealyEquivalenceOracle<I,O>

public class TimeoutEQOracle<I,O> extends Object implements EquivalenceOracle.MealyEquivalenceOracle<I,O>
An equivalence oracle to add timeout in addition to the original oracle.

The timeout is checked only when findCounterExample(net.automatalib.automaton.transducer.MealyMachine<?, I, ?, O>, java.util.Collection<? extends I>) is called: if the elapsed time since start() exceeds the timeout, the wrapped oracle is skipped. An ongoing invocation of the wrapped oracle is not interrupted, so this is not a strict timeout of the entire black-box checking.

Author:
Masaki Waga <masakiwaga@gmail.com>
  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • timeout

      private final long timeout
    • startTime

      private long startTime
    • timedOut

      private boolean timedOut
      Whether the wrapped oracle has been skipped because of the timeout since the last start().
    • eqOracle

      private final EquivalenceOracle.MealyEquivalenceOracle<I,O> eqOracle
    • nanoTime

      private final LongSupplier nanoTime
      Clock supplier for reading the current time. In production this is System.nanoTime(); for testing it may be a fake clock (e.g. returning synthetic nanosecond values) so that timeout behaviour can be verified without sleeping or wall-clock timing.
  • Constructor Details

    • TimeoutEQOracle

      public TimeoutEQOracle(EquivalenceOracle.MealyEquivalenceOracle<I,O> eqOracle, long timeout)
      Parameters:
      eqOracle - the wrapped equivalence oracle
      timeout - timeout in seconds.
    • TimeoutEQOracle

      TimeoutEQOracle(EquivalenceOracle.MealyEquivalenceOracle<I,O> eqOracle, long timeout, LongSupplier nanoTime)
      Parameters:
      eqOracle - the wrapped equivalence oracle
      timeout - timeout in seconds.
      nanoTime - a LongSupplier that returns current time in nanoseconds. In production this is typically System::nanoTime; for testing provide a fake clock that returns controllable values (e.g. () -> fakeClockValue) so timeout behaviour can be verified without sleeping or wall-clock timing.
  • Method Details

    • start

      public void start()
      Start ticking the clock
    • hasTimedOut

      public boolean hasTimedOut()
      Returns:
      true if and only if the wrapped oracle has been skipped because of the timeout since the last start().
    • findCounterExample

      @Nullable public @Nullable DefaultQuery<I,net.automatalib.word.Word<O>> findCounterExample(net.automatalib.automaton.transducer.MealyMachine<?,I,?,O> objects, Collection<? extends I> collection)
      Specified by:
      findCounterExample in interface EquivalenceOracle<net.automatalib.automaton.transducer.MealyMachine<?,I,?,O>,I,net.automatalib.word.Word<O>>