problem Linear planning with STRIPS

AI Planning References: - Russell and Norvig, Artificial Intelligence: A modern approach, 2nd ed. Prentice Hall, 2003 - PRODIGY4.0: The Manual and Tut...
Author: Martina Brown
1 downloads 1 Views 225KB Size
AI Planning References: - Russell and Norvig, Artificial Intelligence: A modern approach, 2nd ed. Prentice Hall, 2003 - PRODIGY4.0: The Manual and Tutorial by the Prodigy Research Group, Dept. of Computer Science, Carnegie Mellon University, Technical Report CMU-CS-92-150, 1992. 1

Outline  Introduction  Search vs. Planning  Representation of a planning domain / problem  Linear planning with STRIPS

2

Introduction

3

Who plans?  Business people: creation of business plans  Lawyers: plan a client’s defense  Industry: plan robot movements for production  Architects: design plans for buildings  Computer scientists: plan a system’s development

4

Who plans?  Telecommunications: plan connection setting  Army: create plans for attack, defense, troop deployment  Transportation logistics: plan moving objects/persons between locations

5

What do they have in common?  Search in a state space  State: a snapshot of the world  Action or operator: transformation of a state into the next

6

What do they have in common?  Initial state: starting point  Goal: conditions for termination of the process  Plan: sequence of operators that transform the initial state into a state that meets the goal  Heuristics: knowledge to guide the search to make it more efficient

7

Tourist example  State  person’s

location, time and money constraints, …  airline (and other) ticket prices, schedules and availability

 Operators  fly

on a given flight  travel on a given train  take a cab  stay in a bed & breakfast, 8

Tourist example  Initial state  we

are in Madrid (home)

 Goal  spend

one week in Pittsburgh

 Plan  takeCab

(Home, BarajasAirport), takeFlight(MAD,PIT), takeCab(PIT,___Hotel), ...

 Heuristics  make

a reservation, prefer airlines with frequentflyer membership 9

Search vs. Planning

10

Search vs. planning  Consider the task get milk, bananas, and a cordless drill  Standard search algorithms seem to fail miserably: why?

11

Search vs. planning

12

Search vs. planning Search

Planning

States

Lisp data structures

Logical sentences

Actions

Lisp code

Preconditions/effects

Goal

Lisp code

Logical sentence (conjunction)

Plan

Sequence from S0

Sequence of actions (linear) Constraints on actions (partial order)

13

Representation of a Planning Domain / Problem

14

An example of a planning domain blocksworld

15

Blocksworld  Problem: build one or more stacks specified in terms of what blocks are on top of other blocks

16

Blocksworld  Underlying hypotheses:      

Set of cube-shaped blocks sitting on a table All blocks are equal except for the name The table is unlimited in size Block position on table does not matter A robot arm can pick one block at a time (only if block has nothing on top) Blocks can be stacked, but only one block fits on top of another 17

Blocksworld  Actions  Blocks

are picked up and put down by the arm  Arm can hold only one block at a time

 Goal  Build

towers of blocks (size, order, etc)

18

Representing the blocksworld  Objects  Blocks:

A, B, C  Table: Table

 States  Conjunctions

of ground literals  On(A, B), OnTable(C), Clear(B), ArmEmpty, Holding(C)

19

Representing the blocksworld  Actions  Operator

schemas with variables e.g.: PickUp(x), PutDown(x, y)

 Domain Axioms  “At

most one block on top of another”  “Hand (i.e. the robot arm) must be initially empty and block must be clear to pick it up”

20

Representation  First order logic is the most frequent representation formalism for states, actions, etc.  It

is expressive enough to describe a wide variety of problems  It is restrictive enough to design efficient algorithms

21

State representation  Let us consider predicate schemata (i.e., predicates that have free variables)  Examples:  HasMoney(x,y)  FlightReservation(x,

flight, date)  FlightInfo(number, origin, destination, departuretime, arrival-time)  ...

22

State representation  A state is represented by a conjunction of instantiated (i.e. “ground”) predicates; e.g.:  HasMoney(Mary,1000),  FlightReservation(Mary,

AA304, 3-Nov-99)  FlightInfo(AA304, Madrid, NewYork,12:05,12:30)

 Instantiated predicates are function free  We assume that what is not explicitly represented as part of the state is false (closed world assumption) 23

STRIPS operators  Tidily arranged actions descriptions, restricted language  Abstracting away many important details!  Restricted language ⇒ efficient algorithm

24

STRIPS operators  An action schema has three parts:  Action

name (with parameter list)  Precondition: Conjunction of function-free positive literals stating what must be true in the state before the action can be executed  Effect: conjunction of function-free literals describing state changes

25

STRIPS operators - ADD list: asserted to be true in  An action schema has three parts: state

the new

DEL asserted to be name-state (withlist:parameter list)false in the new  Precondition: Conjunction of function-free positive literals stating what must be true in the state before the action can be executed  Effect: conjunction of function-free literals describing state changes

 Action

26

STRIPS operators: An example ACTION SCHEMA: Buy(x) PRECONDITION: At(p) ∧ Sells(p,x) EFFECT: Have(x)

27

STRIPS operators: An example ACTION SCHEMA: Buy(x) PRECONDITION: At(p) ∧ Sells(p,x) EFFECT: Have(x)

STRIPS assumption: every literal not mentioned in the effect remains unchanged

28

STRIPS operators: Another example ACTION SCHEMA: Fly(p,from,to) PRECOND: At(p,from) ∧ Plane(p) ∧ Airport(from) ∧ Airport(to) DEL-LIST: At(p,from) ADD-LIST: At(p,to)

29

STRIPS operators: Another example ACTION SCHEMA: Fly(p,from,to) PRECOND: At(p,from) ∧ Plane(p) ∧ Airport(from) ∧ Airport(to) DEL-LIST: At(p,from) ADD-LIST: At(p,to)

Any variable in the precondition and effect lists must also appear in the action’s parameter list 30

Blocksworld (typical) predicates

Initial state

Goal description

On(x,y): block x is on top of block y OnTable (x): block x is on the table Clear(x): block x has nothing on top Holding(x): the robot arm is holding block x ArmFree: the arm is not holding anything 31

Blocksworld (typical) predicates

Initial state

Goal description

Initial state:

On(A,B), On(B,D), OnTable(D), OnTable(C), Clear(A), Clear(C), ArmFree Goal:

OnTable(A),On(C,B) 32

Blocks world (typical) operators - UNSTACK(x, y)

PRE: On(x,y), Clear(x), ArmFree ADD: Holding(x), Clear(y) DEL: On(x,y), ArmFree, Clear(x)

- STACK(x, y)

PRE: Holding(x),Clear(y) ADD: On(x,y),Clear(x), ArmFree DEL: Holding(x), Clear(y)

- PICKUP(x)

PRE: OnTable(x), Clear(x), ArmFree ADD: Holding(x) DEL: OnTable(x), ArmFree, Clear(x)

- PUTDOWN(x)

PRE: Holding(x) ADD: OnTable(x), Clear(x), ArmFree DEL: Holding(x)

33

Linear Planning with STRIPS

34

A typical generic agent architecture

35

How do we plan?  Means-ends analysis (MEA)  Focusing

on the ends (goals) and the means to achieve them (operators)

 Decomposing problems into subproblems ...  Hierarchically

(abstraction techniques)  Based on previous experience/plans (case-based planning)  Reactively (reactive agents / replanning)

 Considering other agents  Obtaining

the planning capability as an emerging property (in a society of agents) 36

Some difficult issues  Our world view may be limited (bounded rationality)  The world may be constantly changing (dynamic environment)  Action execution takes time (temporal reasoning)  Contradictory goals (goal dependencies)  Our world model fails (uncertainty) 37

Some difficult issues  Plans are not always valid (execution and replanning)  Some plans are not good enough (quality of plans)  We must find a way to adapt to the world (adaptive capability / learning)

38

Linear Planning: STRIPS  Precursor: means-ends analysis (GPS 1959)  subgoal

based search: given a goal, choose an op to achieve it

 STRIPS idea:  choose

a goal conjunct (i.e. an element of the conjunction that characterizes the goal)  choose an instantiated operator that achieves it  operator preconditions become new subgoals (cf backward chaining)

39

Linear Planning: STRIPS  Frame problem: What happens to the world context when an action is executed?  Solution: STRIPS assumption: every literal not mentioned in the operator effect remains unchanged

40

Representation  Recall terms, predicates, connectives, quantifiers  Example: ∀ x,y student(x) ∧ subject(y) ∧ [¬ passed(x,y) ∨ firsttime(x,y)] ⇒ register(x,y) There is no single representation for a domain!

41

Linear Planning: STRIPS  Search: Nodes: current state + goal-operator stack Root node: initial state and goal conjunction Heuristics: always choose a relevant operator (achieves one of the goal conjuncts)

42

Linear Planning: STRIPS  Idea: Push into the stack goals and operators to achieve them Pop from stack goals that are true in current state, as well as executed operators

43

STRIPS Algorithm repeat until [empty stack] or [no more nodes can be expanded] if [stack top is an instantiated operator] if [instantiated op can be executed] then [execute operator], [pop operator from stack and add it to the plan] else [push operator preconditions into stack] if [stack top is a goal conjunction] if [the conjunction is true in the current state] then [pop it from stack] else [generate as successors all possible orderings of the goals] [choose one of the goals and push into stack] if [stack top is a goal] if [the goal is true in the current state] then [pop it from the stack] else if [there is a goal loop] then [backtrack] else for each [instantiated operator that adds that goal] [create a successor] if [there are successors] then [choose one] else [backtrack], [push the goal into stack] 44

INIT: OnTable(B) On(A,B) Clear(A) ArmFree

PICKUP(A) Holding(A) PUTDOWN(A) OnTable(A)

X

S0

S0

PUTDOWN(A) OnTable(A)

S0

Holding(A) PUTDOWN(A) OnTable(A)

S0

UNSTACK(A,A) Holding(A) PUTDOWN(A) OnTable(A)

S0

goal loop X

S0

A

Initial state S0

UNSTACK(A,B) Holding(A) PUTDOWN(A) OnTable(A)

S0

A

… OnTable(A) Clear(A) ArmFree OnTable(A),Clear(A), ArmFree PICKUP(A)…OnTable(A)

A B

Goal

X

X OnTable(A),Clear(A), ArmFree PICKUP(A) Holding(A) PUTDOWN(A) OnTable(A)

OnTable(A)

X

X

B S1

B S2

A

S0

√ Clear(A),ArmFree,On(A,B)

S0

√ Holding(A)

S1

UNSTACK(A,B) Holding(A) PUTDOWN(A) OnTable(A)

PUTDOWN(A) OnTable(A)

√ OnTable(A)

S 45 2

Suggest Documents