march2003 planning lecture

Upload: jalal-abdullah

Post on 06-Apr-2018

218 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/2/2019 March2003 Planning Lecture

    1/41

    1

    Lectures on Planning

    Chris Handy

    Centre for Knowledge Management

    March 2004

  • 8/2/2019 March2003 Planning Lecture

    2/41

    2

    PLANNING

    Definition

    Planning is an important topic in

    artificial intelligence, cognitivepsychology, neurobiology,

    business management,

    manufacturing science andengineering, satellite control,and a host of other subjects.

  • 8/2/2019 March2003 Planning Lecture

    3/41

    3

    PLANNING

    Definition

    In AI, planning involves the

    generation of an action sequence

    or action program for an agent,

    such as a robot or a software

    system or a living artefact, that can

    alter its surroundings.

  • 8/2/2019 March2003 Planning Lecture

    4/41

    4

    PLANNING

    Definition

    For instance, the purpose of a plan

    may be to guide and enable a robot

    to fetch an object, say A, and place

    on top of another object, say B.

  • 8/2/2019 March2003 Planning Lecture

    5/41

    5

    PLANNING

    Definition

    For instance, the purpose of a plan may be to guide

    and enable a robot to fetch an object, say A, andplace on top of another object, say B.

    Note that in the above example:

    the action -- fetching -- has been definedexplicitly, the initial state is clearly described -- an object

    A and an object B, such that A can be placed on top

    of B,

    the goal for the robot or the software system isclearly outlined.

  • 8/2/2019 March2003 Planning Lecture

    6/41

    6

    PLANNING

    Definition

    Planning has also been described

    as one of the reliable method for

    controlling the behaviour of living

    and artificial agents, which may not

    be the fastest of the methods and,

    perhaps, not the only one.

  • 8/2/2019 March2003 Planning Lecture

    7/41

    7

    PLANNING

    Definition

    Planning implies thenotion of synthesis:

    synthesis of actions,goals, initial states.

  • 8/2/2019 March2003 Planning Lecture

    8/41

    8

    PLANNING

    Definition

    Planning is sometimes contrasted with the

    retrieval and application of stored behaviourprograms.

    The later includes a number of 'routine'

    activities performed by humans: for example,

    handling hot surfaces and utensils; opening andclosing doors and windows etc. In familiar situations

    little or no overt planning is in evidence, however the

    predominance of stored behaviour is quite

    noticeable.

  • 8/2/2019 March2003 Planning Lecture

    9/41

    9

    PLANNING

    It is in the handling ofnovel

    situations or critical situationsthat we see the a substantial

    planning-related activities:

    examination of initial states, acollection of actions for

    transforming the initial states and a

    set of goals.

  • 8/2/2019 March2003 Planning Lecture

    10/41

    10

    Definitions of aplan, aplanning

    system, and an operator in a

    planning context

    Definition a: Aplan is a defined as a

    prescription for a sequence of actions that, iffollowed, will change the relations among

    objects so as to achieve a desired goal.

    PLANNING

  • 8/2/2019 March2003 Planning Lecture

    11/41

    11

    PLANNING

    Definition b A planning system performs the following functions:

    1. Choice The system can choose the best

    rule to apply next based on the

    best available heuristic information

    2. Application The system can apply the chosen

    rule to compute the new problem

    state that arises from its

    application.3. Detection The system can detectwhen a

    solution has been found

    4.

    Abandonment

    The system can abandon dead-

    ends and can direct its efforts to

    more fruitful avenues.

  • 8/2/2019 March2003 Planning Lecture

    12/41

    12

    PLANNING

    Definition c An operator in planning is

    essentially a if-then-delete rule; the ifconditions of each operator are called pre-

    requisites. The operator can, for example, used

    to describe an action moving a block, clearing

    some space and so on.

  • 8/2/2019 March2003 Planning Lecture

    13/41

    13

    THE BLOCKS WORLD

    The 'blocks world' was amongst the favourite topics in AI:

    there were Ph D theses, there were learned papers,

    conferences and so on during the late sixties and the early

    seventies.

    The 'blocks world' is an imaginary two-dimensional world

    comprising:

    A number of (usually distinctly labelled) square blocks;

    The square blocks can be arranged to form stacks;

    A table of unbounded size.

  • 8/2/2019 March2003 Planning Lecture

    14/41

    14

    THE BLOCKS WORLD

    The BLOCKSworld states can be described by three kinds ofliterals

    CLEAR (x) There is no block on top ofx

    ON (x, y) Block x rests directly on block y

    HOLDING

    (x)

    A hand of an agent holding

    block x

    The initial state description for a completely

    known world consists of a conjunction of these

  • 8/2/2019 March2003 Planning Lecture

    15/41

    15

    THE BLOCKS WORLD - EXAMPLE 1

    Consider the following initial and final states of a 'world'

    that comprises a table and three blocks: A, B, C:

    C

    A B

    A

    A

    B

    C

    Initial State Goal State

  • 8/2/2019 March2003 Planning Lecture

    16/41

    16

    THE BLOCKS WORLD - EXAMPLE 1

    The initial state of the above 'world'can be described in terms of the

    literals as follows:CLEAR (C)ON (C, A)

    ON (A, Table)CLEAR (B)ON (B, Table)

  • 8/2/2019 March2003 Planning Lecture

    17/41

    17

    THE BLOCKS WORLD - EXAMPLE 2

    Consider blocks A, B, C, and D which

    are on a table.

    The initial situation is as follows: Block A is onblock C, and block D on block B. The goal

    situation is: Block A is on top of block B, B is on

    C, and Cis on the table; block D is also on the

    table.

    In the following generic operators the mapping

    to the above is: A x, C y and D z

  • 8/2/2019 March2003 Planning Lecture

    18/41

    18

    THE BLOCKS WORLD - EXAMPLE 2

    Three operators: The operators are made up of the literals

    explained above and are shown below:

    Operator

    1:

    /* Move block x from block y to block z */

    IF

    ON (x, y)CLEAR (x)

    CLEAR (z)

    ADD LIST ON (x, z)

    CLEAR (y)

    DELETE LIST On (x, y)

    CLEAR (z)

  • 8/2/2019 March2003 Planning Lecture

    19/41

    19

    THE BLOCKS WORLD - EXAMPLE 2

    Operator 2: /* Move block x from block y to Table*/

    IF ON (x, y)

    ADD LIST ON (x, Table)

    CLEAR (y)

    DELETE LIST ON (x, y)

  • 8/2/2019 March2003 Planning Lecture

    20/41

    20

    THE BLOCKS WORLD - EXAMPLE 2

    Operator 3: /* Move block x from Table to block z */

    IF ON (x, Table)

    CLEAR (x)CLEAR (z)

    ADD LIST ON (x, z)

    CLEAR (y)

    DELETE LIST ON (x, Table)

    CLEAR (z).

  • 8/2/2019 March2003 Planning Lecture

    21/41

    21

    A simple breadth-first search will mean

    that every operator will have to be triedand instantiated in every possible way,

    as long as the operators' pre-requisites

    are satisfied. This approach will leadto an exponential tree growth in the

    search space.

    Search strategy not breadth first

    but backward chaining

  • 8/2/2019 March2003 Planning Lecture

    22/41

    22

    Search strategy not breadth

    first but backward chaining

    In order to conduct a more intelligent search for

    the final situation in that the sequencing of the

    operators has to be more carefully organised the

    breadth-first search. The goal is described here

    by only a few assertions that must hold for the

    problem to be solved, whereas any full

    description of a situation involves many more

    assertions. Backward chaining search is,

    therefore, more appropriate than a forward

    chaining search.

  • 8/2/2019 March2003 Planning Lecture

    23/41

    23

    Initial Situation

    On (A, C)

    Clear (A)

    On (D, B)

    Clear (D)

    On (C, Table)

    On (B, Table)

    Initial Situation

    On (A, C)

    Clear (A)

    On (D, B)

    Clear (D)

    ON (C, Table)

    ON (B, Table)

    Initial Situation

    On (A, C)

    Clear (A)

    On (D, B)

    Clear (D)

    On (C, Table)

    On (B, Table)

    Operator 2

    If On (D, B)

    Clear (D)

    Add On (D, Table)

    Clear (B)

    Delete On (D, B)

    Operator 2

    If On (D, B)

    Clear (D)

    Add On (D, Table)

    Clear (B)

    Delete On (D, B)

    Operator 1

    If On (A, C)

    Clear (A)

    Clear (B)

    Add On (A, B)

    Clear (C)

    Delete On (A, C)

    Clear (B)

    Operator 1

    If On (A, C)

    Clear (A)

    Clear (B)

    Add On (A, B)

    Clear (C)

    Delete On (A, C)

    Clear (B)

    Operator 1

    If On (A, C)

    Clear (A)

    Clear (B)

    Add On (A, B)

    Clear (C)

    Delete On (A, C)

    Clear (B)

    Goals

    On (A, B)

    Goals

    On (A, B)

    Goals

    On (A, B)

    Three steps toward constructing a plan for achieving a simple goal using backward chaining. All links shown are Establishes

    links. Most of them tie an addition in one instantiated operator to a prerequisite .in another instantiated operator, thus

    creating an ordering constraint between the tow operators. Other Establishes links are connected to initial-situationassertions or goal assertions.

    Search strategy not breadth first but backward chaining

  • 8/2/2019 March2003 Planning Lecture

    24/41

    24

    Search strategy not breadth first but backward chaining

  • 8/2/2019 March2003 Planning Lecture

    25/41

    25

    Initial Situation

    On (A, C)

    Clear (A)

    On (D, B)Clear (D)

    On (C, Table)

    On (B, Table)

    Initial Situation

    On (A, C)

    Clear (A)

    On (D, B)

    Clear (D)

    On (C, Table)

    On (B, Table)

    Operator 2

    If On (D, B)

    Clear (D)

    Add On (D, Table)

    Clear (B)

    Delete On (D, B)

    Operator 2

    If On (D, B)

    Clear (D)

    Add On (D, Table)

    Clear (B)

    Delete On (D, B)

    Operator 1

    If On (A, C)

    Clear (A)

    Clear (B)

    Add On (A, B)

    Clear (C)

    Delete On (A, C)

    Clear (B)

    Operator 3

    If On (B, Table)

    Clear (B)

    Clear (C)

    Add On (B, C)

    Delete On (B, Table)

    Clear (C)

    Operator 1

    If On (A, C)

    Clear (A)

    Clear (B)

    Add On (A, B)

    Clear (C)

    Delete On (A, C)

    Clear (B)

    Goals

    On (A, B

    On (B, C))

    Goals

    On (A, B)

    On (B, C)

    Construction of a plan for achieving tow goal assertions using backward chaining. All links shown are Establishes links. The

    top portion deals with moving blockA onto blockB; the bottom portion adds an operation intended to move blockB onto block

    C. The plan is flawed because operator 1 interferes with an Establishes link between operator 2 and operator 3.

    Search strategy not breadth first but backward chaining

  • 8/2/2019 March2003 Planning Lecture

    26/41

    26

    CONDITIONALPLANNING

    Conditional planning, also known as contingencyplanning,

    deals with incomplete information by constructing a

    conditional pllan that accounts for each possible situation or

    co

    ntingencythat may arise.Conditional planning differs from the ideal planning and

    execution discussed in the beginning of this lecture. We

    dealt with cases where we were dealing worlds that are

    accessible, static and deterministic and the action

    descriptions must be correct and complete describing all the

    consequences exactly.

    Contingencies are dealt on a one by one basis and the

    planning program finds out which part of the plan to execute

    by including sensing actions in the plan to test for the

  • 8/2/2019 March2003 Planning Lecture

    27/41

    27

    CONDITIONALPLANNINGA worked example

    Consider the problem of repairing the flat tyre of a car. The

    following literals describe the location and the state of the

    malfunctioning tyre:On (x) Tyre x is on (the car)

    Off(x) Tyre x is off (the car)

    Intact (x) Tyre x is intact

    Inflated (x) Tyre x is inflated

    Flat(x) Tyre X is Flat

    ClearHub (x) Tyre x is not on the hub

  • 8/2/2019 March2003 Planning Lecture

    28/41

    28

    CONDITIONALPLANNINGThe following operators will help in fixing the tyre:

    Table 1

    Operator1:

    /*Remove Tyre x*/

    IF On (x)

    Add list Off (x)

    ClearHub (x)

    Delete list On (x)

  • 8/2/2019 March2003 Planning Lecture

    29/41

    29

    Table 2

    Operator

    2:

    /* Put Tyre x On */

    IF Off (x)

    ClearHub(x)

    Add list On (x)

    Delete list ClearHub(x)

    Off(x)

    CONDITIONALPLANNING

  • 8/2/2019 March2003 Planning Lecture

    30/41

    30

    CONDITIONALPLANNING

    Table 3

    Operator

    3:

    /* Inflate Tyre x*/

    IF Intact (x)

    Flat(x)

    Add list Inflated (x)

    Delete list Flat(x)

  • 8/2/2019 March2003 Planning Lecture

    31/41

    31

    The typical goal can be described as:

    On(x) ^ Inflated (x),

    with the initial conditions:

    Inflated (Spare) ^ Intact (Spare) ^ Off(Spare) ^ On(Tyre1)

    ^ Flat (Tyre1)

    The standard plan to repair the car will be as follows:

    [Remove (Tyre1), PutOn(Spare)]

    CONDITIONALPLANNING

  • 8/2/2019 March2003 Planning Lecture

    32/41

    32

    Dealing with incomplete

    informationIn the above example we have assumed

    that the tyre was not intact: the description

    of the initial conditions does not use the

    operatorintact. It is quite possible that when

    the tyre of a car is flat it may be due to the

    fact tyres need to be pumped at regularintervals in that they always leak air, albeit

    very slowly.

  • 8/2/2019 March2003 Planning Lecture

    33/41

    33

    STAGESOF THE PLANNING

    PROCESSThe planning process can be described through six

    stages:

    Stage1 : The plan has the typical Startand Finish states.The initial condition suggests that Tyre1 is a Flattyre and

    that we have an Inflatedspare tyre to replace the Flat

    tyre.

    Start Finish

    On(Tyre1)

    Flat (Tyre1)Inflated

    (Spare)

    On(x)Inflated (x)

  • 8/2/2019 March2003 Planning Lecture

    34/41

    34

    STAGESOF THE PLANNINGPROCESS

    Stage2 : There are two open conditions to be

    resolved: On(x) and Inflated(x). The first is

    satisfied by unifying the literal On in both the initial

    and final state by the variable Tyre1 . The secondis satisfied by adding the step Inflate(Tyre1). Recall

    that the Inflate operator has antecedent conditions

    Flatand Intact. The first antecedent literal (Flat) is

    satisfied by linking it with the same literal in theStartstate. However, we have a problem with the

    Intactliteral. There is no action schema with the

    effect Intact, that is in the statement of the problem

    there are no actions that can make the tire intact.

  • 8/2/2019 March2003 Planning Lecture

    35/41

    35

    STAGESOF THE PLANNINGPROCESS

    Inflate(Tyre1)

    Start FinishOn(Tyre1)

    Flat (Tyre1)

    Inflated

    (Spare)

    On(x)

    Inflated (x)

    Flat (Tyre1)

    Intact ((Tyre1)

  • 8/2/2019 March2003 Planning Lecture

    36/41

    36

    STAGESOF THE PLANNINGPROCESS

    Stage3 : In the conditional planning systems, as opposed to

    conventional planning systems which will abandon Stage2now and

    pursue other goals if they can, one can add an action Check(x) :

    Operator4:

    /* Check Tyre x*/

    IF Tyre (x)

    Add list KnowsWhether(Intact(x))

    This operator helps in determining the truth value of the propositionthat unifies with Intact(x). The check tyre operation helps in

    conditional planningthrough the addition of a conditional linkto

    the Inflate(Tyre1) operation. Such a step is called a conditional step

    because it will become a branch point in the final plan.

  • 8/2/2019 March2003 Planning Lecture

    37/41

    37

    STAGESOF THE PLANNINGPROCESS

    Intact (Tyre1)

    Start Finish

    Inflate(Tyre1)

    On(Tyre1)

    Flat (Tyre1)

    Inflated (Spare)

    On(Tyre1)

    Inflated (Tyre1)

    Flat (Tyre1)

    Intact

    ((Tyre1)Check(Tyre1

    )

    (Intact (Tyre1))

    (Intact (Tyre1))

  • 8/2/2019 March2003 Planning Lecture

    38/41

    38

    STAGESOF THE PLANNINGPROCESS

    Stage4 : This involves planning for the eventuality that Tyre1 may not

    be Intact. Therefore, the tyre cannot be Inflatedand has to be

    replaced by the Spare tyre. There are now two alternative Finish

    states depending upon whether or not Tyre1 was intact or not

    Intact (Tyre1)

    Start

    Inflate(Tyre1)

    On(Tyre1)Flat (Tyre1)

    Inflated

    (Spare)

    On(Tyre1)

    Inflated (Tyre1)

    Flat (Tyre1)

    Intact((Tyre1)Check(Tyre1)

    (Intact (Tyre1))

    Finish

    (Intact (Tyre1))

    Finish

    ( Intact (Tyre1))

    On(x)

    Inflated (x)

  • 8/2/2019 March2003 Planning Lecture

    39/41

    39

    STAGESOF THE PLANNINGPROCESS

    Stage5: The Inflated (Spare) literal in the Startstate can be unified

    with the alternative Finish states literal of the same name but

    comprising a variablex.

    Intact (Tyre1)

    Start

    Inflate(Tyre1)

    On(Tyre1)

    Flat (Tyre1)

    Inflated (Spare)

    On(Tyre1)

    Inflated (Tyre1)

    Flat (Tyre1)

    Intact ((Tyre1)

    Check(Tyre1)(Intact (Tyre1))

    Finish

    (Intact (Tyre1))

    Finish

    ( Intact (Tyre1))

    On(Spare)

    Inflated

    (Spare)

  • 8/2/2019 March2003 Planning Lecture

    40/41

    40

    STAGESOF THE PLANNINGPROCESS

    Stage6: The final stage of planning now involves the addition of theoperators Remove(Tyre1) and PutOn(Tyre1). The PutOn operator has

    the consequent (literal) On and this can be unified by its counterpart in

    the second of the two Finish states. Our plan to fix the Tyre is now

    complete.

    Intact (Tyre1)

    Start

    Inflate(Tyre1)

    On(Tyre1)

    Flat (Tyre1)Inflated (Spare)

    On(Tyre1)

    Inflated (Tyre1)

    Flat (Tyre1)

    Intact ((Tyre1)Check(Tyre1)

    (Intact (Tyre1))

    Finish

    (Intact (Tyre1))

    Finish

    ( Intact (Tyre1))

    On(Spare)

    Inflated(Spare)

    Remove(Tyre1) PutOn(Tyre1)( Intact (Tyre1))( Intact (Tyre1))

    Intact (Tyre1)

  • 8/2/2019 March2003 Planning Lecture

    41/41

    41

    Such an algorithm is called Conditional

    Partial-Order Planner or CPOP for short.

    STAGESOF THE PLANNING

    PROCESS