dlvhex  2.5.0
PluginAtom::Query Struct Reference

Query class which provides the input of an external atom call. More...

#include <include/dlvhex2/PluginInterface.h>

Collaboration diagram for PluginAtom::Query:

Public Member Functions

 Query (const ProgramCtx *ctx, InterpretationConstPtr interpretation, const Tuple &input, const Tuple &pattern, ID eatomID=ID_FAIL, const InterpretationPtr predicateInputMask=InterpretationPtr(), const InterpretationConstPtr assigned=InterpretationConstPtr(), const InterpretationConstPtr changed=InterpretationConstPtr())
 Construct query.
void assign (const Query &q2)
 Assignes the query in depth (copy internal data structures rather than share).
bool operator== (const Query &other) const
 Equality for hashing the query for caching query results.

Data Fields

const ProgramCtxctx
 Reference to the active program context.
InterpretationConstPtr interpretation
 Bitset of ground atoms representing current (partial) model projected to the input of this external atom.
InterpretationConstPtr assigned
 Bitset of ground atoms which are currently assigned.
InterpretationConstPtr changed
 Bitset of ground atoms which potentially changed since last query to the same external atom (cf.
Tuple input
 Input constant vector.
Tuple pattern
 Output term vector.
ID eatomID
 ID of the external atom to be evaluated.
InterpretationPtr predicateInputMask
 Set of all input atoms to this external atom.

Detailed Description

Query class which provides the input of an external atom call.

The Query is passed to external computations as a const ref, therefore its data members are not encapsulated.

Query::input contains the ground terms of the input list.

Query::pattern tuple corresponds to the atom's output list: if it contains variables, the query will be a functional one for those missing values; if it is nullary or completely ground, the query will be a boolean one.

The answer shall contain exactly those tuples that match the pattern and are in the output of the atom's function for the interpretation and the input arguments.

Query objects are passed to PluginAtom::retrieve or PluginAtom::retrieveCached.

Definition at line 720 of file PluginInterface.h.


Constructor & Destructor Documentation

PluginAtom::Query::Query ( const ProgramCtx ctx,
InterpretationConstPtr  interpretation,
const Tuple input,
const Tuple pattern,
ID  eatomID = ID_FAIL,
const InterpretationPtr  predicateInputMask = InterpretationPtr(),
const InterpretationConstPtr  assigned = InterpretationConstPtr(),
const InterpretationConstPtr  changed = InterpretationConstPtr() 
) [inline]

Construct query.

Parameters:
interpretationSet of all true input atoms to external atom.
inputInput tuple.
patterOutput pattern.
eatomIDThe external atom for which the query is to be answered; can be ID_FAIL if unknown.
predicateInputMaskSet of all (true and false) input atoms to the external source.
assignedSet of atoms which are currently assigned; if it is a NULL-pointer, then the assignment is complete.
changedSet of atoms which have possibly changed since last call for the same eatomID (can be used to optimize query answering); can be unknown.

Definition at line 798 of file PluginInterface.h.


Member Function Documentation

Assignes the query in depth (copy internal data structures rather than share).

Parameters:
q2Query to copy.

Definition at line 72 of file PluginInterface.cpp.

References assigned, changed, ctx, eatomID, input, interpretation, pattern, predicateInputMask, and ProgramCtx::registry().

Referenced by PluginAtom::retrieveCached().

bool PluginAtom::Query::operator== ( const Query other) const

Equality for hashing the query for caching query results.

Definition at line 84 of file PluginInterface.cpp.

References assigned, input, interpretation, pattern, and predicateInputMask.


Field Documentation

Bitset of ground atoms which are currently assigned.

For the atoms in assigned, interpretation defines the truth value. For unassigned atoms, the value in interpretation is false. Note: The assigned atoms just hint relevant atoms for effective learning. External atoms always have to compute the answer according to the *values in interpretation*, assuming that all atoms are assigned (those atoms which are not in interpretation are assigned to false). The assigned atoms might be unknown (NULL-pointer).

Definition at line 748 of file PluginInterface.h.

Referenced by assign(), ExternalLearningHelper::learnFromInputOutputBehavior(), ExternalLearningHelper::learnFromNegativeAtoms(), ExternalLearningHelper::DefaultInputNogoodProvider::operator()(), operator==(), TestSetMinusPartialAtom::retrieve(), TestPlugin::TestNumberOfBalls::retrieve(), TestPlugin::TestNumberOfBallsSE::retrieve(), and TestPlugin::TestNumberOfBallsGE::retrieve().

Bitset of ground atoms which potentially changed since last query to the same external atom (cf.

Query::eatomID). Atoms not in this set stayed the same.

The method is intended to provide information which might be used for better learning and caching techniques in this external source.

The changed atoms might be unknown (NULL-pointer).

Definition at line 759 of file PluginInterface.h.

Referenced by assign().

Input constant vector.

For predicate inputs it is the predicate of the ground atoms. For constant inputs it is the input constant. (Variables in input tuples in the program are grounded via auxiliary predicates, so input never contains variable terms.)

If &extatom[a,b](y,Z) the input tuple is <a,b>.

Definition at line 770 of file PluginInterface.h.

Referenced by assign(), BaseModelGenerator::evaluateExternalAtomQuery(), ExternalLearningHelper::getOutputAtom(), ExternalLearningHelper::getOutputAtoms(), hash_value(), ExternalLearningHelper::learnFromNegativeAtoms(), ExternalLearningHelper::learnFromRule(), ExternalLearningHelper::DefaultInputNogoodProvider::operator()(), operator==(), TestConcatAtom::retrieve(), TestListDomainAtom::retrieve(), TestListConcatAtom::retrieve(), FunctionInterprete::retrieve(), TestListLengthAtom::retrieve(), TestListSplitAtom::retrieve(), TestListSplitHalfAtom::retrieve(), TestListMergeAtom::retrieve(), ComfortPluginAtom::retrieve(), TestSubstrAtom::retrieve(), TestSmallerThanAtom::retrieve(), TestFirstAtom::retrieve(), TestPushAtom::retrieve(), TestMoveAtom::retrieve(), TestStrlenAtom::retrieve(), TestSetMinusNonComfortAtom::retrieve(), TestSetMinusPartialAtom::retrieve(), TestSetMinusNogoodBasedLearningAtom::retrieve(), TestSetMinusNongroundNogoodBasedLearningAtom::retrieve(), TestSetMinusRuleBasedLearningAtom::retrieve(), TestIdcAtom::retrieve(), TestNegAtom::retrieve(), TestLessThanAtom::retrieve(), TestEqualAtom::retrieve(), TestTransitiveClosureAtom::retrieve(), TestCycleAtom::retrieve(), TestAppendAtom::retrieve(), TestDisjAtom::retrieve(), TestReachableAtom::retrieve(), TestDLSimulatorAtom::retrieve(), TestPlugin::TestSetUnionAtom::retrieve(), TestPlugin::TestGen2Atom::retrieve(), TestPlugin::TestIsEmpty::retrieve(), TestPlugin::TestNumberOfBalls::retrieve(), TestPlugin::TestNumberOfBallsSE::retrieve(), TestPlugin::TestNumberOfBallsGE::retrieve(), and TestASPQueryAtom::retrieveOrLearnSupportSets().

Bitset of ground atoms representing current (partial) model projected to the input of this external atom.

Partial model contains bits about all atoms relevant for the computation, i.e., all atoms with a predicate equal to a constant given for a predicate input in the input tuple.

Definition at line 735 of file PluginInterface.h.

Referenced by assign(), BaseModelGenerator::evaluateExternalAtomQuery(), hash_value(), ExternalLearningHelper::learnFromInputOutputBehavior(), ExternalLearningHelper::learnFromNegativeAtoms(), ExternalLearningHelper::learnFromRule(), ExternalLearningHelper::DefaultInputNogoodProvider::operator()(), operator==(), TestConcatAllAtom::retrieve(), ComfortPluginAtom::retrieve(), TestMoveAtom::retrieve(), TestSetMinusNonComfortAtom::retrieve(), TestSetMinusPartialAtom::retrieve(), TestSetMinusNogoodBasedLearningAtom::retrieve(), TestSetMinusNongroundNogoodBasedLearningAtom::retrieve(), TestSetMinusRuleBasedLearningAtom::retrieve(), TestNonmonAtom::retrieve(), TestNonmon2Atom::retrieve(), TestIdAtom::retrieve(), TestIdpAtom::retrieve(), TestNegAtom::retrieve(), TestLessThanAtom::retrieve(), TestEqualAtom::retrieve(), TestTransitiveClosureAtom::retrieve(), TestCycleAtom::retrieve(), TestAppendAtom::retrieve(), TestDisjAtom::retrieve(), TestHashAtom::retrieve(), TestReachableAtom::retrieve(), TestDLSimulatorAtom::retrieve(), TestPlugin::TestSetUnionAtom::retrieve(), TestPlugin::TestGen2Atom::retrieve(), TestPlugin::TestIsEmpty::retrieve(), TestPlugin::TestNumberOfBalls::retrieve(), TestPlugin::TestNumberOfBallsSE::retrieve(), TestPlugin::TestNumberOfBallsGE::retrieve(), TestASPQueryAtom::retrieveOrLearnSupportSets(), and PluginAtom::splitQuery().

Output term vector.

The vector of output terms of the external atom. This vector might contain variables, if variables occur as output terms in the program. Several of these variables might even be the same, e.g., if the external atom is &extatom[a,b](X,c,X,d) the pattern is <X,c,X,d>.

Definition at line 780 of file PluginInterface.h.

Referenced by TestCautiousQueryAtom::answerQuery(), assign(), hash_value(), ExternalLearningHelper::learnFromNegativeAtoms(), operator==(), and ComfortPluginAtom::retrieve().


The documentation for this struct was generated from the following files: