Class PL_Planner

java.lang.Object
  |
  +--PL_Planner

public class PL_Planner
extends java.lang.Object

This class is for the generation and maintenance of HTN plans for individual DECAF agents. A plan consists of three kinds (classes) of nodes: Conjunctions represent AND and OR branches in the plan, allowing the scheduler to select different branches at run time if a branch is ORed. Each Conjunction has a KnowledgeBase where information about the state of the plan at that point is stored. Children of a Conjunction node may be either Conjunctions or ObjectiveCells. A Conjunction's parent may be a Task or another Conjunction. ObjectiveCells contain a set of ANDed predicate goals that the planner will try to achieve, and a list of the tasks that the planner has selected to achieve them. An ObjectiveCell has one or more Tasks as children, and a Conjunction as parent. Tasks contain a Conjunction of Predicate specifications for their preconditions and outcomes, and a Vector of Predicate specifications for their parameters and provisions, so that the planner knows when and how they can be used. A Task node is parent to Conjunctions, and child to an ObjectiveCell.


Inner Class Summary
(package private) static interface PL_Planner.Status
           
 
Field Summary
(package private)  PL_MyAgent agent
           
(package private)  boolean assumePreconditionsFlag
           
(package private) static int CIRC_LIMIT
           
(package private) static boolean DEBUG
           
(package private) static java.lang.String em
           
(package private)  java.util.Vector incompletePathNodes
           
(package private) static java.lang.String loc
           
(package private)  Task nextTask
           
(package private) static int numberTasksExpected
           
(package private)  int planStatus
           
(package private)  java.util.Vector provides
           
(package private)  Task root
           
(package private)  AttributeCell standard
           
(package private)  java.util.Hashtable taskObjectiveMap
          In taskObjectiveMap, key is a Task, value is vector of Objective s that task addresses in this branch of plan.
(package private)  java.util.Vector tasks
           
 
Constructor Summary
PL_Planner()
           
PL_Planner(Conjunction c)
           
PL_Planner(Task t)
           
 
Method Summary
 void addProvides(PEComponentData p)
           
 void addProvides(java.util.Vector v)
           
 void convertAttributes()
           
 void fillTaskProvisionsFromElsewhereInPlan(Task task)
          Take Task provisions that aren't filled from parent, and look to fill them from KBs up the tree.
 Predicate findMoreSpecificPredicateOrNull(Predicate p, java.lang.Object node)
          Climb up tree, stopping at Conjunctions to check if there is a more specific predicate in the kB of the conjunction, until we hit root.
 AttributeCell getAttributeStandards()
           
 Task getBestNextTask(ObjectiveCell o, java.util.Hashtable taskObjectiveMap)
          Chooses task that addresses the most objectives by counting mappings in hash table parameter; then the one with the fewest variables in Effects.
 KnowledgeBase getNextKnowledgeBase(java.lang.Object node)
          Return closest KnowledgeBase in plan tree at or above this node, or null if none.
 java.lang.Object getParent(java.lang.Object o)
           
 Task getParentTask(java.lang.Object o1)
           
 java.util.Vector getProvides()
           
 void handleExceptionAtConjunction(Conjunction c, java.lang.Exception e)
          Want to pass all exceptions through an AND; but Ors should check to see if all options are exhausted before passing the exception.
 boolean isRoot(java.lang.Object o)
           
static void main(java.lang.String[] args)
           
 void peComponentPrint()
           
 void peComponentWrite(java.lang.String filename, boolean appendFlag)
           
static ProvisionCell PL_run(Agent local)
           
private  Conjunction placeAndAfterOrNode(Conjunction orNode, ObjectiveCell oC)
          replace oC child of orNode with new AND; oC becomes child of AND.
 void plan(Conjunction c)
           
 void plan(Conjunction c, java.util.Hashtable taskObjectiveMap)
          Here distinguish between AND and OR branches by how we pass the uT and taskObjectiveMap.
 void plan(ObjectiveCell currentObjectives)
          Loop on objectives to get all possible tasks; choose single task using getBestNextTask; determine what else the best task covers, then plan again for objectives that are not covered.
 void plan(ObjectiveCell currentObjectives, java.util.Hashtable taskObjectiveMap)
           
 void print()
           
 void propagateAttributes(java.lang.Object node)
           
 void setAttributeStandards(AttributeCell attCell)
           
 void simulateActionOutcomes(Action a, java.lang.Object node)
          Simulate the effects of an action in the plan by placing the instantiated versions of the outcome specifications into the nearest Conjunction's kB.
 void subpeComponentPrint(Node n, java.lang.String indent)
           
 void subpeComponentWrite(Node n, java.io.FileWriter fw)
           
 void subPrint(Conjunction o, java.lang.String indent)
           
 void subPrint(ObjectiveCell o, java.lang.String indent)
           
 void subPrint(java.lang.Object o, java.lang.String indent)
           
 void subPrint(Task p, java.lang.String indent)
           
 boolean tasksCoverObjectives(ObjectiveCell o)
          returns true iff each objective is addressed by some task in the ObjectiveCell's possibleTasks list.
 java.lang.String tellAgentAboutPlan(Agent local)
           
 boolean unifyAddressedPredicatesWithTaskVars(java.util.Vector addressedPredicates, Task task, java.lang.Object node)
          Unify variable names between Predicates in Vector and Predicates in Task.outcomeSpecs.
 boolean verifyConstraintInAgentKB(Predicate p)
           
 boolean verifyConstraintInPlanTree(Predicate p, java.lang.Object node)
          Climb up tree, stopping at Conjunctions to check if there is a more specific predicate in the kB of the conjunction, until we hit root.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

agent

PL_MyAgent agent

root

Task root

tasks

java.util.Vector tasks

provides

java.util.Vector provides

incompletePathNodes

java.util.Vector incompletePathNodes

planStatus

int planStatus

nextTask

Task nextTask

taskObjectiveMap

java.util.Hashtable taskObjectiveMap
In taskObjectiveMap, key is a Task, value is vector of Objective s that task addresses in this branch of plan.

standard

AttributeCell standard

numberTasksExpected

static int numberTasksExpected

CIRC_LIMIT

static int CIRC_LIMIT

DEBUG

static final boolean DEBUG

assumePreconditionsFlag

boolean assumePreconditionsFlag

em

static java.lang.String em

loc

static java.lang.String loc
Constructor Detail

PL_Planner

public PL_Planner()

PL_Planner

public PL_Planner(Conjunction c)

PL_Planner

public PL_Planner(Task t)
Method Detail

plan

public void plan(ObjectiveCell currentObjectives)
          throws CircularityException,
                 PlanningException
Loop on objectives to get all possible tasks; choose single task using getBestNextTask; determine what else the best task covers, then plan again for objectives that are not covered.

plan

public void plan(Conjunction c)
          throws CircularityException,
                 PlanningException

plan

public void plan(Conjunction c,
                 java.util.Hashtable taskObjectiveMap)
          throws CircularityException,
                 PlanningException
Here distinguish between AND and OR branches by how we pass the uT and taskObjectiveMap. For ANDs, just look up at the last uT. For ORs, create a new copy of the UT for each ORed branch so that different plan/knowledge states can be represented.

handleExceptionAtConjunction

public void handleExceptionAtConjunction(Conjunction c,
                                         java.lang.Exception e)
                                  throws java.lang.Exception
Want to pass all exceptions through an AND; but Ors should check to see if all options are exhausted before passing the exception. When get around to SUM, will need to count stuff, so perhaps should implement a status flag in tasks, OCs; when an exception gets to a Conjunction, it can count the status flags of its children before deciding whether or not to pass up the exception.

plan

public void plan(ObjectiveCell currentObjectives,
                 java.util.Hashtable taskObjectiveMap)
          throws CircularityException,
                 PlanningException

fillTaskProvisionsFromElsewhereInPlan

public void fillTaskProvisionsFromElsewhereInPlan(Task task)
Take Task provisions that aren't filled from parent, and look to fill them from KBs up the tree. (Can't just look at most local, since may not have knowledge from branches to left (look only in root kb? no, may not have propagated up thru OR in this branch). Then hash of that predicate in KB should provide pointer to task2 that created it. Connect as a PROVIDES from output of task2 to provision of this task. Task.makeProvidesFromOutcomesToProvisions(task otherTask)

tasksCoverObjectives

public boolean tasksCoverObjectives(ObjectiveCell o)
returns true iff each objective is addressed by some task in the ObjectiveCell's possibleTasks list.

getBestNextTask

public Task getBestNextTask(ObjectiveCell o,
                            java.util.Hashtable taskObjectiveMap)
Chooses task that addresses the most objectives by counting mappings in hash table parameter; then the one with the fewest variables in Effects.

unifyAddressedPredicatesWithTaskVars

public boolean unifyAddressedPredicatesWithTaskVars(java.util.Vector addressedPredicates,
                                                    Task task,
                                                    java.lang.Object node)
Unify variable names between Predicates in Vector and Predicates in Task.outcomeSpecs. Only use if Task is already chosen to be performed, since if unifications are successful, the kB is altered to reflect the substitutions of unification.

getNextKnowledgeBase

public KnowledgeBase getNextKnowledgeBase(java.lang.Object node)
Return closest KnowledgeBase in plan tree at or above this node, or null if none. May be important to climb up kBs if node is below an OR, thus hiding knowledge that may have been added to kBs of nodes above after the kB of the OR was cloned.

peComponentPrint

public void peComponentPrint()

subpeComponentPrint

public void subpeComponentPrint(Node n,
                                java.lang.String indent)

peComponentWrite

public void peComponentWrite(java.lang.String filename,
                             boolean appendFlag)
                      throws java.io.IOException

subpeComponentWrite

public void subpeComponentWrite(Node n,
                                java.io.FileWriter fw)
                         throws java.io.IOException

print

public void print()

subPrint

public void subPrint(ObjectiveCell o,
                     java.lang.String indent)

subPrint

public void subPrint(Conjunction o,
                     java.lang.String indent)

subPrint

public void subPrint(Task p,
                     java.lang.String indent)

subPrint

public void subPrint(java.lang.Object o,
                     java.lang.String indent)

simulateActionOutcomes

public void simulateActionOutcomes(Action a,
                                   java.lang.Object node)
Simulate the effects of an action in the plan by placing the instantiated versions of the outcome specifications into the nearest Conjunction's kB. First instantiates vars in the predicate where possible, by looking above in the plan tree. Eventually, should also do clobbering here.

verifyConstraintInAgentKB

public boolean verifyConstraintInAgentKB(Predicate p)

verifyConstraintInPlanTree

public boolean verifyConstraintInPlanTree(Predicate p,
                                          java.lang.Object node)
Climb up tree, stopping at Conjunctions to check if there is a more specific predicate in the kB of the conjunction, until we hit root.

findMoreSpecificPredicateOrNull

public Predicate findMoreSpecificPredicateOrNull(Predicate p,
                                                 java.lang.Object node)
Climb up tree, stopping at Conjunctions to check if there is a more specific predicate in the kB of the conjunction, until we hit root. Return a more specific predicate if found or return null. May be important to climb up kBs if node is below an OR, thus hiding knowledge that may have been added to kBs of nodes above after the kB or the OR was cloned.

propagateAttributes

public void propagateAttributes(java.lang.Object node)

getParentTask

public Task getParentTask(java.lang.Object o1)

getParent

public java.lang.Object getParent(java.lang.Object o)

isRoot

public boolean isRoot(java.lang.Object o)

placeAndAfterOrNode

private Conjunction placeAndAfterOrNode(Conjunction orNode,
                                        ObjectiveCell oC)
replace oC child of orNode with new AND; oC becomes child of AND.

addProvides

public void addProvides(PEComponentData p)

addProvides

public void addProvides(java.util.Vector v)

getProvides

public java.util.Vector getProvides()

convertAttributes

public void convertAttributes()

setAttributeStandards

public void setAttributeStandards(AttributeCell attCell)

getAttributeStandards

public AttributeCell getAttributeStandards()

tellAgentAboutPlan

public java.lang.String tellAgentAboutPlan(Agent local)

PL_run

public static ProvisionCell PL_run(Agent local)

main

public static void main(java.lang.String[] args)