Class InterpretedUserDefinedPredicate
java.lang.Object
org.projog.core.predicate.udp.InterpretedUserDefinedPredicate
- All Implemented Interfaces:
Predicate
-
Constructor Summary
ConstructorsConstructorDescriptionInterpretedUserDefinedPredicate(Iterator<ClauseAction> clauseActions, SpyPoints.SpyPoint spyPoint, Term query) -
Method Summary
Modifier and TypeMethodDescriptionbooleanCould the next re-evaluation of this instance succeed?booleanevaluate()Evaluates a user defined predicate.
-
Constructor Details
-
InterpretedUserDefinedPredicate
public InterpretedUserDefinedPredicate(Iterator<ClauseAction> clauseActions, SpyPoints.SpyPoint spyPoint, Term query)
-
-
Method Details
-
evaluate
public boolean evaluate()Evaluates a user defined predicate.The process for evaluating a user defined predicate is as follows:
- Iterates through every clause of the user defined predicate.
- For each clause it attempts to unify the arguments in its head (consequent) with the arguments in the query (
queryArgs). - If the head of the clause can be unified with the query then an attempt is made to evaluate the body (antecedent) of the clause.
- If the body of the clause is successfully evaluated then
trueis returned. - If the body of the clause is not successfully evaluated then the arguments in the query are backtracked.
- When there are no more clauses left to check then
falseis returned.
evaluate()has returnedtruesubsequent invocations ofevaluate()will attempt to re-evaluate the antecedent of the previously successfully evaluated clause. If the body of the clause is successfully re-evaluated thentrueis returned. If the body of the clause is not successfully re-evaluated then the arguments in the query are backtracked and the method continues to iterate through the clauses starting with the next clause in the sequence. -
couldReevaluationSucceed
public boolean couldReevaluationSucceed()Description copied from interface:PredicateCould the next re-evaluation of this instance succeed?Specifies whether a specific instance of a specific implementation of
Predicate, that has already hadPredicate.evaluate()called on it at least once, could possibly returntruethe next timePredicate.evaluate()is called on it. i.e. is it worth trying to continue to find solutions for the specific query this particular instance represents and has been evaluating?(Note: the difference between this method and
PredicateFactory.isRetryable()is thatPredicateFactory.isRetryable()deals with whether, in general, a specific implementation (rather than instance) ofPredicatecould ever produce multiple answers for an individual query.)- Specified by:
couldReevaluationSucceedin interfacePredicate- Returns:
trueif an attempt to re-evaluate this instance could possible succeed,falseotherwise
-