Planning Module THREE: Planning, Production Systems,Expert Systems, Uncertainty Dr M M Awais.

46
Planning Module THREE: Planning, Production Systems,Expert Systems, Uncertainty Dr M M Awais

Transcript of Planning Module THREE: Planning, Production Systems,Expert Systems, Uncertainty Dr M M Awais.

Planning

Module THREE:Planning, Production

Systems,Expert Systems, Uncertainty

Dr M M Awais

CS 331/531 Dr M M Awais 2

search

What is Planning Generate sequences of actions to perform

tasks and achieve objectives. States, actions and goals

Search for solution over abstract space of plans.

Assists humans in practical applications design and manufacturing military operations games space exploration

CS 331/531 Dr M M Awais 3

search

BASIC BASIC CONCEPTCONCEPT

Definitions: Summary

Planning: The problem of finding some action to achieve some goal

System’s Plan:The sequence of such actions is called System’s Plan

CS 331/531 Dr M M Awais 5

search

Means – Ends Analysis (MEA)

• MEA is a simple planning method in AI.

• “It is a technique which, rather than blindly searching through all possible actions, focuses on actions that reduce the difference between the current state and the target state”

CS 331/531 Dr M M Awais 6

search

Algorithm:To find-plan (initial state, Target state)

If all the goals in target state are true in initial state then succeed

Otherwise

1. Select an unresolved target state

2. Find an action that adds goal to the current-state

3. Enable action by finding a plan (PREPLAN) that actives its pre-conditions i.e., find-plan (initial state, pre-conditions.) Let Mid-state 1 be the result of applying that pre-plan to initial state.

4. Apply action to Mid state 1 to give Mid state 2

5. Find a plan (post plan) from Mid state 2 to target state

6. Return a plan consisting of Preplan, Action, and Post Plan

CS 331/531 Dr M M Awais 7

search

Essential Components of a Plan:

Preplan,

Action,

Post Plan.

Always choose Action that takes Always choose Action that takes you close to the goalyou close to the goal

CS 331/531 Dr M M Awais 8

search

Goal: G

Actions: A1 A2 A3 A4 A5

States: P1 P2 P3 B1 B2 B3 B4

Sequence of Action that take us to the G are A3, followed by A4 and then A5

B3 – B4 – B5, this leads to states: B3, B4 and B4

Rules: P1 B1

P2 B2

P3 B3

B3 B4

B4 G

A1

A2

A3

A4

A5

CS 331/531 Dr M M Awais 9

search

How can we change

•InitialState P3

B1

Post plan: None Cannot proceed furtherPreplan: A1

•InitialState P3

B3

Preplan: A3 Post plan: A4

•Pre plan: A4

G

Post plan: A5

•B4

Pre plan: A5

Wrong Choice

CS 331/531 Dr M M Awais 10

search

How can we change

•InitialState P3

B1

Post plan: None Cannot proceed furtherPreplan: A1

•InitialState P3

B3

Preplan: A3 Post plan: A4

•Pre plan: A4

G

Post plan: A5

•B4

Pre plan: A5

CS 331/531 Dr M M Awais 11

search

How can we change

•InitialState P3

B1

Post plan: None Cannot proceed furtherPreplan: A1

•InitialState P3

B3

Preplan: A3 Post plan: A4

•Pre plan: A4

G

Post plan: A5

•B4

Pre plan: A5

CS 331/531 Dr M M Awais 12

search

How can we change

•InitialState P3

B1

Post plan: None Cannot proceed furtherPreplan: A1

•InitialState P3

B3

Preplan: A3 Post plan: A4

•Pre plan: A4

G

Post plan: A5

•B4

Pre plan: A5

CS 331/531 Dr M M Awais 13

search

How can we change

•InitialState P3

B1

Post plan: None Cannot proceed furtherPreplan: A1

•InitialState P3

B3

Preplan: A3 Post plan: A4

•Pre plan: A4

G

Post plan: A5

•B4

Pre plan: A5

CS 331/531 Dr M M Awais 14

search

How can we change

•InitialState P3

B1

Post plan: None Cannot proceed furtherPreplan: A1

•InitialState P3

B3

Preplan: A3 Post plan: A4

•Pre plan: A4

G

Post plan: A5

•B4

Pre plan: A5

CS 331/531 Dr M M Awais 15

search

How can we change

•InitialState P3

B1

Post plan: None Cannot proceed furtherPreplan: A1

•InitialState P3

B3

Preplan: A3 Post plan: A4

•Pre plan: A4

G

Post plan: A5

•B4

Pre plan: A5

So MEA will choose A3 always

CS 331/531 Dr M M Awais 16

search

Difficulty of real world problems Assume a problem-solving agent

using some search method … Which actions are relevant?

Exhaustive search vs. backward search What is a good heuristic functions?

Good estimate of the cost of the state? Problem-dependent vs, -independent

How to decompose the problem? Most real-world problems are nearly

decomposable.

CS 331/531 Dr M M Awais 17

search

Implementation Methods

CS 331/531 Dr M M Awais 18

search

Planning language

What is a good language? Expressive enough to describe a wide variety

of problems. Restrictive enough to allow efficient

algorithms to operate on it. Planning algorithm should be able to take

advantage of the logical structure of the problem.

STRIPS and Action Description Language (ADL)

CS 331/531 Dr M M Awais 19

search

General language features

Representation of states Decompose the world in logical conditions

and represent a state as a conjunction of positive literals.

Closed world assumption Representation of goals

Partially specified state and represented as a conjunction of positive ground literals

A goal is satisfied if the state contains all literals in goal.

Representation of Actions

CS 331/531 Dr M M Awais 20

search

General language features

Representation of states/goals Propositional literals:

poor unknown FO-literals (grounded and function-free):

at(plane1, lahore) at(plane2, karachi)

CS 331/531 Dr M M Awais 21

search

General language features Representations of actions

Action = PRECOND + EFFECTAction(fly(P,From, To),PRECOND: at(P,from) plane(P)

airport(From) airport(To)

EFFECT: ¬at(P,From) at(P,To))= action schema (P, From, To need to be instantiated)

Action name and parameter list Precondition (conj. of function-free literals) Effect (conj of literals and P is True and not P is

false) Add-list vs delete-list in Effect

Literal in ADD list if true else in DELETE list

CS 331/531 Dr M M Awais 22

search

Language semantics?

How do actions affect states? Action:Applied in any state if PRECOND:

satisfied.

Action Applied after finding substitution for the variables in the PRECOND.

CS 331/531 Dr M M Awais 23

search

Language semantics?

Given Facts:at(p1,lhr) at(p2,khi) plane(p1)

plane(p2) airport(lhr) airport(khi)

Satisfies : at(P,From) plane(P) airport(From) airport(To)

With: ={p1/P, lhr/From, khi/To}

CS 331/531 Dr M M Awais 24

search

Strips: Advancement STRIPS is simplified

function-free literals (only propositional representation) Function symbols lead to infinitely many

states and actions Recent extension:Action Description

language (ADL)

Action(fly(P:plane, From: airport, To: airport),

PRECOND: at(P,From) (From To)EFFECT: ¬at(P,From) at(P,To))

Planning domain definition language (PDDL)

CS 331/531 Dr M M Awais 25

search

Example: air cargo transport

Init(at(c1, khi) at(c2,lhr) at(p1,khi) at(P2,lhr) cargo(C1) cargo(c2) plane(p1) plane(p2) airport(lhr) airport(khi))

Goal(at(c1,lhr) at(c2,khi))

Action(load(C,P,A)PRECOND: at(C,A) at(P,A) cargo(C) plane(P) airport(A)EFFECT: ¬at(C,A) in(C,P))

Action(Unload(C,P,A)PRECOND: in(C,P) at(P,A) cargo(C) plane(P) airport(A)EFFECT: at(C,A) ¬in(C,P))

Action(Fly(P,From,To)PRECOND: at(P,From) plane(P) airport(From) airport(To)EFFECT: ¬ at(P,From) at(P,To))

Can any action be applied?, under what substitutions?[load(c1,p1,khi), fly(p1,khi,lhr), load(c2,p2,lhr), fly(p2,lhr,khi)]

CS 331/531 Dr M M Awais 26

searchExample: Spare tire problem

Init(At(Flat, Axle) At(Spare,trunk))Goal(At(Spare,Axle))Action(Remove(Spare,Trunk)

PRECOND: At(Spare,Trunk)EFFECT: ¬At(Spare,Trunk) At(Spare,Ground))

Action(Remove(Flat,Axle)PRECOND: At(Flat,Axle)EFFECT: ¬At(Flat,Axle) At(Flat,Ground))

Action(PutOn(Spare,Axle)PRECOND: At(Spare,Groundp) ¬At(Flat,Axle)EFFECT: At(Spare,Axle) ¬Ar(Spare,Ground))

Action(LeaveOvernight)PRECOND:EFFECT: ¬ At(Spare,Ground) ¬ At(Spare,Axle) ¬ At(Spare,trunk) ¬ At(Flat,Ground) ¬ At(Flat,Axle) )

This example goes beyond STRIPS: negative literal in pre-condition (ADL description)

CS 331/531 Dr M M Awais 27

search

Example: Blocks worldInit(On(A, Table) On(B,Table) On(C,Table) Block(A)

Block(B) Block(C) Clear(A) Clear(B) Clear(C))Goal(On(A,B) On(B,C))

Action(Move(b,x,y)PRECOND: On(b,x) Clear(b) Clear(y) Block(b) (b x) (b y) (x y) EFFECT: On(b,y) Clear(x) ¬ On(b,x) ¬ Clear(y))

Action(MoveToTable(b,x)PRECOND: On(b,x) Clear(b) Block(b) (b x) EFFECT: On(b,Table) Clear(x) ¬ On(b,x))

Spurious actions are possible: Move(B,C,C)

CS 331/531 Dr M M Awais 28

search

Example: Blocks world:

Alternative Representation

CS 331/531 Dr M M Awais 29

searchTriangle Table: Effective Representation

gripping()clear(X)on(X,Y) Unstack (X,Y)

gripping(X)clear(Y)

Pre-cond

Effects

CS 331/531 Dr M M Awais 30

searchTriangle Table: Effective Representation

gripping()clear(X)on(X,Y) unstack (X,Y)

gripping(X)clear(Y)

gripping()ontable(X)

clear(X)

putdown (X)

CS 331/531 Dr M M Awais 31

searchTriangle Table: Effective Representation

gripping()clear(X)on(X,Y) unstack (X,Y)

gripping(X)clear(Y)

gripping()ontable(X)

clear(X)

putdown (X)

pickup (Y)ontable(Y)

CS 331/531 Dr M M Awais 32

searchTriangle Table: Effective Representation

gripping()clear(X)on(X,Y) unstack (X,Y)

gripping(X)clear(Y)

gripping()ontable(X)

clear(X)

putdown (X)

pickup (Y)ontable(Y) ?????

CS 331/531 Dr M M Awais 33

searchTriangle Table: Effective Representation

gripping()clear(X)on(X,Y) unstack (X,Y)

gripping(X)

gripping()ontable(X)

clear(X)

putdown (X)

pickup (Y)ontable(Y) clear(Y)

By doing this clear (Y) is still theEffect of unstack(X,Y)(same column)

CS 331/531 Dr M M Awais 34

searchTriangle Table: Effective Representation

gripping()clear(X)on(X,Y) unstack (X,Y)

gripping(X)

gripping()ontable(X)

clear(X)

putdown (X)

pickup (Y)ontable(Y) clear(Y)

Are these the pre-cond of pickup(Y):NOYou can shift it anywhere in the column

CS 331/531 Dr M M Awais 35

searchTriangle Table: Effective Representation

gripping()clear(X)on(X,Y) unstack (X,Y)

gripping(X)

gripping()

putdown (X)

pickup (Y)ontable(Y) clear(Y)

gripping(Y)pickup (X)

ontable(X)clear(X)

?????

CS 331/531 Dr M M Awais 36

searchTriangle Table: Effective Representation

gripping()clear(X)on(X,Y) unstack (X,Y)

gripping(X)

gripping()

putdown (X)

pickup (Y)ontable(Y) clear(Y)

gripping(Y)pickup (X)

ontable(X)clear(X)

?????

stack (Y,Z)

CS 331/531 Dr M M Awais 37

searchTriangle Table: Effective Representation

gripping()clear(X)on(X,Y) unstack (X,Y)

gripping(X)

gripping()

putdown (X)

pickup (Y)ontable(Y) clear(Y)

pickup (X)

ontable(X)clear(X)

gripping(Y)stack (Y,Z)

clear(Z)

CS 331/531 Dr M M Awais 38

searchTriangle Table: Effective Representation

gripping()clear(X)on(X,Y) unstack (X,Y)

gripping(X)

gripping()

putdown (X)

pickup (Y)ontable(Y) clear(Y)

pickup (X)

ontable(X)clear(X)

gripping(Y)stack (Y,Z)

clear(Z)

FIRST KERNELEverything thatShould be trueFor unstackincluding some additional predictes

CS 331/531 Dr M M Awais 39

searchTriangle Table: Effective Representation

gripping()clear(X)on(X,Y) unstack (X,Y)

gripping(X)

gripping()

putdown (X)

pickup (Y)ontable(Y) clear(Y)

pickup (X)

ontable(X)clear(X)

gripping(Y)stack (Y,Z)

clear(Z)

SECOND KERNEL

CS 331/531 Dr M M Awais 40

searchTriangle Table: Effective Representation

gripping()clear(X)on(X,Y) unstack (X,Y)

gripping(X)

gripping()

putdown (X)

pickup (Y)ontable(Y) clear(Y)

pickup (X)

ontable(X)clear(X)

gripping(Y)stack (Y,Z)

clear(Z)

THIRD KERNEL

CS 331/531 Dr M M Awais 41

search

Planning with state-space search

Both forward and backward search possible

Forward Chaining:Progression planners forward state-space search Consider the effect of all possible actions in a

given state Backward Chaining:Regression planners

backward state-space search To achieve a goal, what must have been true

in the previous state.

CS 331/531 Dr M M Awais 42

searchProgression and regression

CS 331/531 Dr M M Awais 43

search

Progression algorithm Formulation as state-space search problem:

Initial state = initial state of the planning problem

Literals not appearing are false Actions = those whose preconditions are

satisfied Add positive effects, delete negative

Goal test = does the state satisfy the goal Step cost = each action costs 1

No functions … any graph search that is complete is a complete planning algorithm.

Inefficient: (1) irrelevant action problem (2) good heuristic required for efficient search

CS 331/531 Dr M M Awais 44

search

Regression algorithm How to determine predecessors?

What are the states from which applying a given action leads to the goal?

Goal state = At(C1, B) At(C2, B) … At(C20, B)Relevant action for first conjunct: Unload(C1,p,B)Works only if pre-conditions are satisfied.Previous state= In(C1, p) At(p, B) At(C2, B) … At(C20, B)Subgoal At(C1,B) should not be present in this state.

Actions must not undo desired literals (consistent)

Main advantage: only relevant actions are considered. Often much lower branching factor than

forward search.

CS 331/531 Dr M M Awais 45

search

Regression algorithm General process for predecessor

construction Give a goal description G Let A be an action that is relevant and consistent The predecessors is as follows:

Any positive effects of A that appear in G are deleted. Each precondition literal of A is added , unless it

already appears. Any standard search algorithm can be

added to perform the search. Termination when predecessor satisfied by

initial state. In FO case, satisfaction might require a

substitution.

CS 331/531 Dr M M Awais 46

search

Heuristics for state-space search Neither progression or regression are very

efficient without a good heuristic. How many actions are needed to achieve the goal? Exact solution is NP hard, find a good estimate

Two approaches to find admissible heuristic: The optimal solution to the relaxed problem.

Remove all preconditions from actions The subgoal independence assumptio:

The cost of solving a conjunction of subgoals is approximated by the sum of the costs of solving the subproblems independently.