I
- input symbol typeD
- output domain typepublic abstract class Query<I,D> extends Object
learner
and a
(membership) oracle
, or teacher.
In LearnLib, queries are performed in a callback-like fashion: an oracle does not return
the responses to the queries, but rather invokes the answer(Object)
method on the query
objects it was provided with. This allows for implementing queries which directly react to an answered
query (e.g., by modifying some internal data structure), without the need for buffering answers.
It also allows for a more efficient parallel processing of queries, as there is no need for maintaining
a common (synchronized) result data structure such as a map. However, this means that a learner
cannot rely on the answer(Object)
method of a query being called from the same thread which
invoked MembershipOracle.processQueries(java.util.Collection)
. If this causes concurrency
issues, a safe choice is to use queries of class DefaultQuery
, which simply store the response
and make it accessible via DefaultQuery.getOutput()
for processing after the
MembershipOracle.processQueries(java.util.Collection)
call returns, guaranteeing thread-safety.
Conceptually, a query is divided into a prefix
and a getSuffix()
suffix. The prefix part of a query identifies a state in the (unknown) target system, whereas
the suffix is the "experiment" which is conducted on the system starting from the state to which
it was transferred by the prefix. While the prefix influences the response of the target system
to a query, the answer is the directly observable reaction to executing the suffix.
Example 1: when learning Mealy machines
, the prefix transfers the target
system to a certain state. The outputs produced by the system while executing the prefix are
not part of the answer, as the role of the prefix is limited to reaching a certain state.
The reaction of the target system consists of the output word produced while executing the suffix.
Therefore, in the setting of Mealy machine learning, a valid oracle will call the answer(Object)
method with a word of the same length as the suffix.
Example 2: when learning DFA
s, the reaction of the target system is fully determined
by the state reached by an input word. Since both prefix and suffix have the same effect on producing
this output (by transferring the system to a certain state), the response will always be a single
Boolean
, and, furthermore, for every input word w
, the response to a query will
always be the same regardless of the subdivision of w = uv
into prefix u
and
suffix v
(including the corner cases u = ε
and
v = ε
).
Constructor and Description |
---|
Query() |
Modifier and Type | Method and Description |
---|---|
abstract void |
answer(D output)
Answers the query.
|
boolean |
equals(Object o) |
net.automatalib.words.Word<I> |
getInput()
Retrieves the input word of this query.
|
abstract net.automatalib.words.Word<I> |
getPrefix()
Returns the prefix part of this query.
|
abstract net.automatalib.words.Word<I> |
getSuffix()
Returns the suffix part of this query.
|
int |
hashCode() |
String |
toString()
Returns the string representation of this query.
|
@Nonnull public abstract net.automatalib.words.Word<I> getPrefix()
@Nonnull public abstract net.automatalib.words.Word<I> getSuffix()
public abstract void answer(@Nullable D output)
MembershipOracle
, and only
once per query to process. Calling this method more than once may result in undefined
behavior, possibly (but not necessarily) throwing an exception.output
- the output, i.e., the response to the query@Nonnull public net.automatalib.words.Word<I> getInput()
Copyright © 2016. All rights reserved.