JTP API Documentation

jtp.disp
Class SequentialDispatcher

java.lang.Object
  |
  +--jtp.disp.SequentialDispatcher
All Implemented Interfaces:
Dispatcher, Reasoner
Direct Known Subclasses:
RuleCreationDispatcher

public class SequentialDispatcher
extends Object
implements Dispatcher

SequentialDispatcher.java Created: Wed Nov 17 00:22:03 1999


Nested Class Summary
static interface SequentialDispatcher.LocationPreference
           
protected static class SequentialDispatcher.Ring
           
 
Field Summary
protected  int count
           
protected  boolean cutoff
           
static int HEAD_PREFERRED
           
static int NO_PREFERENCE
           
static int TAIL_PREFERRED
           
protected  SequentialDispatcher.Ring zero
           
 
Constructor Summary
SequentialDispatcher()
           
 
Method Summary
 boolean acceptable(Object o)
          decides if the goal is suitable for being processed by this reasoner.
 boolean addReasoner(Reasoner r)
          Add a reasoner directly to this dispatcher.
 boolean getCutoff()
          returns the cutoff setting for this dispatcher.
 Class getReasonerClass()
          Returns the class of reasoners this dispatcher works with.
 Collection getReasoners()
          Retrieves the collection of child reasoners directly beneath this dispatcher.
 ReasoningStepIterator process(Object o)
          This method attempts to find proof for the goal.
 boolean removeReasoner(Reasoner r)
          Removes a reasoner directly from this dispatcher.
 void setCutoff(boolean cutoff)
          sets the value for the cutoff property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

zero

protected SequentialDispatcher.Ring zero

count

protected int count

cutoff

protected boolean cutoff

HEAD_PREFERRED

public static final int HEAD_PREFERRED
See Also:
Constant Field Values

TAIL_PREFERRED

public static final int TAIL_PREFERRED
See Also:
Constant Field Values

NO_PREFERENCE

public static final int NO_PREFERENCE
See Also:
Constant Field Values
Constructor Detail

SequentialDispatcher

public SequentialDispatcher()
Method Detail

process

public ReasoningStepIterator process(Object o)
Description copied from interface: Reasoner
This method attempts to find proof for the goal. It returns an enumeration of reasoning steps that correspond to alternative proofs for the goal. Consequently, the items of the enumeration can actually belong to different models of the goal sentence, and have incompatible variable assignments.

Example. A reasoner that performs unification of the goal with facts in a knowledge base can return the following enumeration for the goal (parent joe ?x):

  1. A reasoning step proving (parent joe fred) with variable assignment ?x=fred,
  2. A reasoning step proving (parent joe mary) with variable assignment ?x=mary.

Specified by:
process in interface Reasoner
Parameters:
o - the goal: either a query or an assertion
Returns:
the iterator of reasoning steps - proofs for the query, or consequences of the assertion.

acceptable

public boolean acceptable(Object o)
Description copied from interface: Reasoner
decides if the goal is suitable for being processed by this reasoner. This method should be fast; if there are doubts as to whether a goal is acceptable, and it looks like determining it might take some time, the method should return true and let the process method figure it out.

Example. Many reasoners only process literals with certain predicates and arity. These reasoners will use those criteria to determine acceptability, for example a reasoner dealing with equality could accept goals that are:

  1. Literals,
  2. have = as their relation predicate,
  3. have exactly two arguments.

Specified by:
acceptable in interface Reasoner
Returns:
true if the goal is suitable for this reasoner, false otherwise.

getCutoff

public boolean getCutoff()
returns the cutoff setting for this dispatcher.

Returns:
the cutoff setting for this dispatcher.
See Also:
setCutoff(boolean)

setCutoff

public void setCutoff(boolean cutoff)
sets the value for the cutoff property. If cutoff is set to off (default), the dispatcher will concatenate results obtained from all child reasoners. If cutoff is on, the reasoner will stop after the first child reasoner that returns a non-empty reasoner step iterator. This can be used if some reasoners are to be used at last-resort.

Example. There are 3 child reasoners, A, B and C. A query is given; A returns an empty reasoner step iterator, B returns one with two reasoning steps, B1 and B2; C returns an iterator with a single reasoning step, C1. The reasoning step iterator returned by the dispatcher will be:

Parameters:
cutoff - true if the dispatcher should drop the results from tail reasoners.

addReasoner

public boolean addReasoner(Reasoner r)
Description copied from interface: Dispatcher
Add a reasoner directly to this dispatcher. This function should not attempt to route the reasoner to any possible child dispatchers it may have, that is the job of the function DispatcherUtils.addToDispatcher(jtp.Reasoner, jtp.Dispatcher).

Specified by:
addReasoner in interface Dispatcher
Parameters:
r - the reasoner to add
Returns:
true if the reasoner has been added (i.e., the state has changed).

removeReasoner

public boolean removeReasoner(Reasoner r)
Description copied from interface: Dispatcher
Removes a reasoner directly from this dispatcher. This function should not attempt to find the reasoner at any possible child dispatchers it may have, that is the job of the function DispatcherUtils.removeFromDispatcher(jtp.Reasoner, jtp.Dispatcher).

Specified by:
removeReasoner in interface Dispatcher
Parameters:
r - the reasoner to remove
Returns:
true if the reasoner has been removed (i.e., the state has changed).

getReasonerClass

public Class getReasonerClass()
Description copied from interface: Dispatcher
Returns the class of reasoners this dispatcher works with. Every reasoner you add to this dispatcher must be an instance of this class.

Specified by:
getReasonerClass in interface Dispatcher
Returns:
the class of reasoners this dispatcher works with.

getReasoners

public Collection getReasoners()
Description copied from interface: Dispatcher
Retrieves the collection of child reasoners directly beneath this dispatcher. This collection may be "live", i.e. in some cases modification to this collection will reflect on the state of the dispatcher. Therefore it might be a good idea to make a copy before trying to modify it.

Specified by:
getReasoners in interface Dispatcher
Returns:
the collection of child reasoners directly beneath this dispatcher.

JTP API Documentation