in the name of god an application of planning an application of planningjshop by: m. eftekhari and...

23
In the name of God In the name of God An Application of An Application of Planning Planning JSHOP JSHOP BY: M. Eftekhari and G. Yaghoobi

Upload: journey-bartlette

Post on 31-Mar-2015

217 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: In the name of God An Application of Planning An Application of PlanningJSHOP BY: M. Eftekhari and G. Yaghoobi

In the name of GodIn the name of God

An Application of Planning An Application of Planning

JSHOPJSHOP

BY: M. Eftekhari and G. Yaghoobi

Page 2: In the name of God An Application of Planning An Application of PlanningJSHOP BY: M. Eftekhari and G. Yaghoobi

SHOPSHOP (Simple Hierarchical Ordered Planner) (Simple Hierarchical Ordered Planner)

SHOP and iSHOP and its successors are domain-ts successors are domain-independent implementations of Ordered independent implementations of Ordered Task DecompositionTask Decomposition

AnAn AI planning technique that has been AI planning technique that has been useful in several application domains useful in several application domains (University of Maryland)(University of Maryland)

Page 3: In the name of God An Application of Planning An Application of PlanningJSHOP BY: M. Eftekhari and G. Yaghoobi

JSHOPJSHOP A Java implementation of SHOP A Java implementation of SHOP

As part of their As part of their HICAPHICAP for Noncombatant for Noncombatant Evacuation Operations (NEOs).Evacuation Operations (NEOs).

(HICAP)(HICAP) Hierarchical Interactive Case- Hierarchical Interactive Case-based Architecture for Planning (An based Architecture for Planning (An applet)applet)

Page 4: In the name of God An Application of Planning An Application of PlanningJSHOP BY: M. Eftekhari and G. Yaghoobi

HTNHTNHierarchical Task NetworkHierarchical Task Network

Objective is Objective is to create a plan to perform a set of to create a plan to perform a set of taskstasks (abstract representations of things that (abstract representations of things that need to be done). need to be done).

HTN planning is done by problem reduction: HTN planning is done by problem reduction: the planner recursively decomposes tasks into the planner recursively decomposes tasks into subtasks, stopping when it reaches subtasks, stopping when it reaches primitiveprimitive tasks that can be performed directly by tasks that can be performed directly by planning operatorsplanning operators

Page 5: In the name of God An Application of Planning An Application of PlanningJSHOP BY: M. Eftekhari and G. Yaghoobi

ContinueContinue

In order to tell the planner how to In order to tell the planner how to decompose decompose nonprimitivenonprimitive tasks into tasks into subtasks. it needs to have a set of subtasks. it needs to have a set of methodsmethods ..

where where each methodeach method is a schema for is a schema for decomposing a particular kind of task into a decomposing a particular kind of task into a set of subtasks (provided that some set of set of subtasks (provided that some set of preconditions is satisfied). preconditions is satisfied).

Page 6: In the name of God An Application of Planning An Application of PlanningJSHOP BY: M. Eftekhari and G. Yaghoobi

ContinueContinueWhat is Expressivity?What is Expressivity?

Expressivity of languagesExpressivity of languages A language L is as expressive as another A language L is as expressive as another

language M iff any expression in L can be language M iff any expression in L can be translated into an expression with the same translated into an expression with the same meaning in Mmeaning in M

HTN planning is more expressive than HTN planning is more expressive than state-based planningstate-based planning

STRIPS-style planning is a special case of STRIPS-style planning is a special case of HTN planningHTN planning

Page 7: In the name of God An Application of Planning An Application of PlanningJSHOP BY: M. Eftekhari and G. Yaghoobi

ContinueContinue

No transformations, because HTN models No transformations, because HTN models have have richer structurericher structure ( (because HTNs can because HTNs can represent harder problemsrepresent harder problems than the STRIPS than the STRIPS language)language)

Solutions to STRIPS problems are regular Solutions to STRIPS problems are regular setssets

Solutions to HTN problems can be Solutions to HTN problems can be arbitrary context-free sets arbitrary context-free sets

Thus HTN’s are more expressive than Thus HTN’s are more expressive than STRIPSSTRIPS

Page 8: In the name of God An Application of Planning An Application of PlanningJSHOP BY: M. Eftekhari and G. Yaghoobi

Ordered Task DecompositionOrdered Task Decomposition

Is a special case of Is a special case of HTNHTN planning in which the planning in which the planning algorithm planning algorithm always builds plans always builds plans forwardforward from the initial state of the world from the initial state of the world

ordered-task-decomposition:ordered-task-decomposition: planner plans planner plans for tasks in the for tasks in the same order that the tasks will same order that the tasks will laterlater be performed. be performed.

the planner has already planned every action the planner has already planned every action that that will occur beforehandwill occur beforehand

Page 9: In the name of God An Application of Planning An Application of PlanningJSHOP BY: M. Eftekhari and G. Yaghoobi

continuecontinue

the preconditions of its methods and the preconditions of its methods and operators can include operators can include logical inferenceslogical inferences, , complex numeric computationscomplex numeric computations, and , and calls calls to external programs. to external programs.

Page 10: In the name of God An Application of Planning An Application of PlanningJSHOP BY: M. Eftekhari and G. Yaghoobi

Search StrategySearch Strategy

Ordered task decompositionOrdered task decomposition Require the subtasks of each method to be Require the subtasks of each method to be

totally orderedtotally ordered Decompose these tasks left-to-rightDecompose these tasks left-to-right

• The same order that they’ll later be executedThe same order that they’ll later be executed• Analogous to PROLOG’s search strategyAnalogous to PROLOG’s search strategy

method

subtask 3subtask 2subtask 1 subtask 4

task

Page 11: In the name of God An Application of Planning An Application of PlanningJSHOP BY: M. Eftekhari and G. Yaghoobi

AI Planning Is Different in PracticeAI Planning Is Different in PracticeThan it Was in TheoryThan it Was in Theory

Unstack(x,y) Pre: on(x,y), clear(x), handempty Del: on(x,y), clear(x), handempty Add: holding(x), clear(y)

Theory:Theory: Symbolic computations Symbolic computations

(STRIPS operators)(STRIPS operators) Single agent (the planner)Single agent (the planner) Perfect informationPerfect information

Practice:Practice: Complex numeric computationsComplex numeric computations

(geometry, images, probabilities)(geometry, images, probabilities) Multiple agentsMultiple agents Imperfect information, external Imperfect information, external

information sourcesinformation sources

Page 12: In the name of God An Application of Planning An Application of PlanningJSHOP BY: M. Eftekhari and G. Yaghoobi

GoalGoal

Develop synergy between theory and Develop synergy between theory and applicationsapplications

Theory

Applications

Page 13: In the name of God An Application of Planning An Application of PlanningJSHOP BY: M. Eftekhari and G. Yaghoobi

SHOP (Simple Hierarchical SHOP (Simple Hierarchical Ordered Planner)Ordered Planner)

Domain-independent algorithm forDomain-independent algorithm forOrdered Task DecompositionOrdered Task Decomposition

ImplementationImplementation Common-Lisp implementation available atCommon-Lisp implementation available at

• http://www.cs.umd.edu/projects/shophttp://www.cs.umd.edu/projects/shop Developing a Java implementationDeveloping a Java implementation

Page 14: In the name of God An Application of Planning An Application of PlanningJSHOP BY: M. Eftekhari and G. Yaghoobi

Input and OutputInput and Output Input:Input:

StateState: a set of ground atoms: a set of ground atoms Task ListTask List: a linear list of tasks: a linear list of tasks DomainDomain: methods, operators, axioms: methods, operators, axioms

Output:Output: one or more plans one or more plans depending on what we tell SHOP to look for, it can depending on what we tell SHOP to look for, it can

returnreturn• the first plan it findsthe first plan it finds• all possible plansall possible plans• a least-cost plana least-cost plan• all least-cost plansall least-cost plans• etc.etc.

Page 15: In the name of God An Application of Planning An Application of PlanningJSHOP BY: M. Eftekhari and G. Yaghoobi

Elements of the InputElements of the Input Initial StateInitial State: collection of ground atoms (in Lisp notation): collection of ground atoms (in Lisp notation)

((at home) (have-cash 50.43) (distance home ((at home) (have-cash 50.43) (distance home downtown 10))downtown 10))

Task listTask list: linear list of tasks to perform: linear list of tasks to perform ((travel home downtown) (buy book))((travel home downtown) (buy book))

Each methodEach method: task, preconditions and decomposition: task, preconditions and decomposition• Preconditions to be established using logical Preconditions to be established using logical

inferenceinference• Decomposition is a task listDecomposition is a task list

Each axiom: Each axiom: Horn clauseHorn clause Each primitive operator:Each primitive operator: task,precondition, delete list, task,precondition, delete list,

add listadd list Performs a primitive taskPerforms a primitive task

Page 16: In the name of God An Application of Planning An Application of PlanningJSHOP BY: M. Eftekhari and G. Yaghoobi

Review of the SHOP AlgorithmReview of the SHOP Algorithm

procedureprocedure SHOP (state SHOP (state S, S, task-list task-list T, T, domain domain DD) ) 1.1. if if TT = nil = nil thenthen return return nilnil2.2. tt11 = the first task in = the first task in TT3.3. U U = the remaining tasks in = the remaining tasks in TT4.4. ifif t t is primitive & an operator instance is primitive & an operator instance o o matches matches tt11 thenthen5.5. PP = SHOP ( = SHOP (oo((SS), ), UU, , DD))6.6. ifif PP = FAIL = FAIL then return then return FAILFAIL7.7. returnreturn cons( cons(oo,,PP))8.8. else ifelse if tt is non-primitive is non-primitive & a method instance & a method instance mm matches matches tt1 in 1 in SS & & mm’s preconditions can be inferred from ’s preconditions can be inferred from S S thenthen9.9. return return SHOP (SHOP (SS, append (, append (mm((tt1)1), U, U), ), DD))10.10. elseelse11.11. return return FAILFAIL12.12. endend ififendend SHOP SHOP

state S; task list T=( t1 ,t2,…) operator instance o

state o(S) ; task list T=(t2, …)

task list T=( t1 ,t2,…) method instance m

task list T=( u1,…,uk ,t2,…)

nondeterministic choice among all methods m whose preconditions can be inferred from S

Page 17: In the name of God An Application of Planning An Application of PlanningJSHOP BY: M. Eftekhari and G. Yaghoobi

Initial task list:Initial task list: ((travel home park))((travel home park)) Initial state:Initial state: ((at home) (cash 20) (distance home park 8))((at home) (cash 20) (distance home park 8)) MethodsMethods (task, preconditions, subtasks): (task, preconditions, subtasks):

(:method (travel ?x ?y)(:method (travel ?x ?y)((at x) (walking-distance ?x ?y)) ((!walk ?x ?y)) 1)((at x) (walking-distance ?x ?y)) ((!walk ?x ?y)) 1)

(:method (travel ?x ?y)(:method (travel ?x ?y)((at ?x) (have-taxi-fare ?x ?y))((at ?x) (have-taxi-fare ?x ?y)) ((!call-taxi ?x) (!ride ?x ?y) (!pay-driver ?x ?y)) 1) ((!call-taxi ?x) (!ride ?x ?y) (!pay-driver ?x ?y)) 1)

Axioms:Axioms: (:- (walking-dist ?x ?y) ((distance ?x ?y ?d) (call (<= ?d 5))))(:- (walking-dist ?x ?y) ((distance ?x ?y ?d) (call (<= ?d 5)))) (:- (have-taxi-fare ?x ?y)(:- (have-taxi-fare ?x ?y)

((have-cash ?c) (distance ?x ?y ?d) (call (>= ?c (+ ((have-cash ?c) (distance ?x ?y ?d) (call (>= ?c (+ 1.50 ?d))))1.50 ?d))))

Primitive operatorsPrimitive operators (task, precondition, delete list, add list) (task, precondition, delete list, add list) (:operator (!walk ?x ?y) () ((at ?x)) ((at ?y)))(:operator (!walk ?x ?y) () ((at ?x)) ((at ?y))) ……

Simple ExampleSimple Example

Optional cost;

default is 1

Page 18: In the name of God An Application of Planning An Application of PlanningJSHOP BY: M. Eftekhari and G. Yaghoobi

Precond: Precond:

(travel home park)

(!walk home park)

(!call-taxi home) (!ride home park) (!pay-driver home park)

Fail (distance > 5)Succeed (we have $20,and the fare is only $9.50)Succeed

Succeed

(at home)(walking-distance Home park)

(have-taxi-fare home park)

(at park)(cash 10.50)(distance home park 8)

Simple Example (continued)Simple Example (continued)

(at home)

Initial state:

Final state:

(at home)(cash 20)(distance home park 8)

Page 19: In the name of God An Application of Planning An Application of PlanningJSHOP BY: M. Eftekhari and G. Yaghoobi

Block worldsBlock worlds

11 24 5

3

11 245

3

Initial state

Final state

Final State

Using Methods

Task1 Task2 Task3 Task4 Task5

Book keeping Planning

Classical Planning

Only achieving

goals

How to do?

Page 20: In the name of God An Application of Planning An Application of PlanningJSHOP BY: M. Eftekhari and G. Yaghoobi

What Activities Should a Planning System What Activities Should a Planning System Plan?Plan?

In AI planning, researchers traditionally have only In AI planning, researchers traditionally have only allowed the planner to plan activities that will have a allowed the planner to plan activities that will have a direct physical effectdirect physical effect

Examples:Examples: picking up a blockpicking up a block moving a truckmoving a truck

In human planning, we also plan lots of other activitiesIn human planning, we also plan lots of other activities Example 2:Example 2:

Planning bookkeeping operationsPlanning bookkeeping operations

ticket (a,b) travel (x,a) fly(a,b) travel(b,y)airport(y,b) store some infoabout the ticket

travel by air

airport(x,a)

Page 21: In the name of God An Application of Planning An Application of PlanningJSHOP BY: M. Eftekhari and G. Yaghoobi

Encoding the Blocks World Algorithm into Encoding the Blocks World Algorithm into SHOPSHOP

loop

if there is a clear block x such that

x or a block beneath x is in a location inconsistent with the goal

and

x can be moved to a location such thatx and all blocks beneath x will be in locations consistent with the goal

then move x to that location

else if there is a clear block x such that

x or a block beneath x is in a location inconsistent with the goal

then move x to the table

else exit

endif

repeat

Page 22: In the name of God An Application of Planning An Application of PlanningJSHOP BY: M. Eftekhari and G. Yaghoobi

(:operator (!pickup ?x)(:operator (!pickup ?x)

((clear ?x) (on-table ?x))((clear ?x) (on-table ?x)) ((holding ?x)))((holding ?x))) (:operator (!putdown ?x)(:operator (!putdown ?x) ((holding ?x))((holding ?x)) ((on-table ?x) (clear ?x)))((on-table ?x) (clear ?x))) (:operator (!stack ?x ?y)(:operator (!stack ?x ?y) ((holding ?x) (clear ?y))((holding ?x) (clear ?y)) ((on ?x ?y) (clear ?x)))((on ?x ?y) (clear ?x))) (:operator (!unstack ?x ?y)(:operator (!unstack ?x ?y) ((clear ?x) (on ?x ?y))((clear ?x) (on ?x ?y)) ((holding ?x) (clear ?y)))((holding ?x) (clear ?y)))

Operators for Moving BlocksOperators for Moving Blocks

Page 23: In the name of God An Application of Planning An Application of PlanningJSHOP BY: M. Eftekhari and G. Yaghoobi

Bookkeeping Operator and MethodsBookkeeping Operator and Methods (:operator (!assert ?atoms)(:operator (!assert ?atoms) ; ?atoms is a list of atoms to assert; ?atoms is a list of atoms to assert ()() ; no preconditions; no preconditions ?atoms?atoms ; put the list of atoms into the current state; put the list of atoms into the current state 0)0) ; this operator has no cost; this operator has no cost (:method (assert-goals (?first . ?rest) ?atoms)(:method (assert-goals (?first . ?rest) ?atoms) ; recursively build a list ; recursively build a list ()() ; of atoms to assert into ; of atoms to assert into ((assert-goals ?rest ((goal ?first) . ?atoms))))((assert-goals ?rest ((goal ?first) . ?atoms)))) ; the current state ; the current state

(:method (assert-goals nil ?atoms)(:method (assert-goals nil ?atoms) ; we’ve built the entire list, so assert it; we’ve built the entire list, so assert it ()() '((!assert ?atoms)))'((!assert ?atoms)))

(:method (achieve-goals ?goals)(:method (achieve-goals ?goals) ; assert all the goals into the current ; assert all the goals into the current state,state,

()() ; then call move-block to achieve ; then call move-block to achieve themthem

((assert-goals ?goals nil) (move-block nil)))((assert-goals ?goals nil) (move-block nil)))