org.jscience.computing.ai.planning
Class Operator

java.lang.Object
  extended by org.jscience.computing.ai.planning.DomainElement
      extended by org.jscience.computing.ai.planning.Operator

public abstract class Operator
extends DomainElement

Each operator at run time is represented as a class derived from this abstract class.


Constructor Summary
Operator(Predicate head, int delVarIdxIn, int addVarIdxIn, Term costIn)
          To initialize the operator.
 
Method Summary
 boolean apply(Term[] binding, State s, java.util.Vector[] delAdd)
          This function is used to apply this operator to a given state.
 double getCost(Term[] binding)
          To get the cost of this operator.
 void setAdd(DelAddElement[] addIn)
          To set the add list.
 void setDel(DelAddElement[] delIn)
          To set the delete list.
 
Methods inherited from class org.jscience.computing.ai.planning.DomainElement
getHead, getIterator, unify
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Operator

public Operator(Predicate head,
                int delVarIdxIn,
                int addVarIdxIn,
                Term costIn)
To initialize the operator.

Parameters:
head - head of the operator.
delVarIdxIn - the index of the delete list as a variable, -1 if the delete list is not a variable.
addVarIdxIn - the index of the add list as a variable, -1 if the add list is not a variable.
costIn - the cost of the operator.
Method Detail

apply

public boolean apply(Term[] binding,
                     State s,
                     java.util.Vector[] delAdd)
This function is used to apply this operator to a given state.

Parameters:
binding - the current binding.
s - current state of the world.
delAdd - a 4-member array of type Vector used to keep track of the atoms and protections deleted from and added to the current state of the world as the result of applying this operator. This data can be used later in case of a backtrack to undo these changes.
Returns:
true if the operator was applicable, false otherwise. An operator is not applicable when at least one of the atoms it tries to delete is protected.

getCost

public double getCost(Term[] binding)
To get the cost of this operator.

Parameters:
binding - the binding to be applied to the cost term.
Returns:
the cost of applying this operator.

setAdd

public void setAdd(DelAddElement[] addIn)
To set the add list.

Parameters:
addIn - the add list.

setDel

public void setDel(DelAddElement[] delIn)
To set the delete list.

Parameters:
delIn - the delete list.