1 Financial Informatics –VI: Planning Systems 1 Khurshid Ahmad, Professor of Computer Science,...

39
1 Financial Informatics –VI: Planning Systems 1 Khurshid Ahmad, Professor of Computer Science, Department of Computer Science Trinity College, Dublin-2, IRELAND November 17 th , 2008.

Transcript of 1 Financial Informatics –VI: Planning Systems 1 Khurshid Ahmad, Professor of Computer Science,...

Page 1: 1 Financial Informatics –VI: Planning Systems 1 Khurshid Ahmad, Professor of Computer Science, Department of Computer Science Trinity College, Dublin-2,

1

Financial Informatics –VI:Planning Systems

1

Khurshid Ahmad, Professor of Computer Science,

Department of Computer Science

Trinity College,Dublin-2, IRELAND

November 17th, 2008.https://www.cs.tcd.ie/Khurshid.Ahmad/Teaching.html

Page 2: 1 Financial Informatics –VI: Planning Systems 1 Khurshid Ahmad, Professor of Computer Science, Department of Computer Science Trinity College, Dublin-2,

2

PLANNING

DefinitionPlanning is an important topic in

artificial intelligence, cognitive psychology, neurobiology, business

management, manufacturing science and engineering, satellite control, and a

host of other subjects.

Page 3: 1 Financial Informatics –VI: Planning Systems 1 Khurshid Ahmad, Professor of Computer Science, Department of Computer Science Trinity College, Dublin-2,

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.

Page 4: 1 Financial Informatics –VI: Planning Systems 1 Khurshid Ahmad, Professor of Computer Science, Department of Computer Science Trinity College, Dublin-2,

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.  

Page 5: 1 Financial Informatics –VI: Planning Systems 1 Khurshid Ahmad, Professor of Computer Science, Department of Computer Science Trinity College, Dublin-2,

5

PLANNING

DefinitionFor 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.

Note that in the above example: • the action -- fetching -- has been defined explicitly, • 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 is clearly outlined.

Page 6: 1 Financial Informatics –VI: Planning Systems 1 Khurshid Ahmad, Professor of Computer Science, Department of Computer Science Trinity College, Dublin-2,

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.

Page 7: 1 Financial Informatics –VI: Planning Systems 1 Khurshid Ahmad, Professor of Computer Science, Department of Computer Science Trinity College, Dublin-2,

7

PLANNING

Definition

Planning implies the notion of synthesis: synthesis of actions, goals, initial states.

Page 8: 1 Financial Informatics –VI: Planning Systems 1 Khurshid Ahmad, Professor of Computer Science, Department of Computer Science Trinity College, Dublin-2,

8

PLANNING

Definition

Planning is sometimes contrasted with the retrieval and application of stored behaviour programs.

The later includes a number of 'routine' activities performed by humans: for example, handling hot surfaces and utensils; opening and closing doors and windows etc. In familiar situations little or no overt planning is in evidence, however the predominance of stored behaviour is quite noticeable.

Page 9: 1 Financial Informatics –VI: Planning Systems 1 Khurshid Ahmad, Professor of Computer Science, Department of Computer Science Trinity College, Dublin-2,

9

PLANNING

It is in the handling of novel situations or critical situations that we see the a substantial planning-related activities: examination of initial states, a collection of actions for transforming the initial states and a set of goals.

Page 10: 1 Financial Informatics –VI: Planning Systems 1 Khurshid Ahmad, Professor of Computer Science, Department of Computer Science Trinity College, Dublin-2,

10

Definitions of a plan, a planning system, and an operator in a planning context Definition a: A plan is a defined as a prescription for a sequence of actions that, if followed, will change the relations among objects so as to achieve a desired goal.

PLANNING

Page 11: 1 Financial Informatics –VI: Planning Systems 1 Khurshid Ahmad, Professor of Computer Science, Department of Computer Science Trinity College, Dublin-2,

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 information2. Application The system can apply the chosen rule to compute the new problem state that arises from its application.3. Detection The system can detect when a solution has been found

4. Abandonment

The system can abandon dead-ends and can direct its efforts to more fruitful avenues.

Page 12: 1 Financial Informatics –VI: Planning Systems 1 Khurshid Ahmad, Professor of Computer Science, Department of Computer Science Trinity College, Dublin-2,

12

PLANNING

Definition c An operator in planning is essentially a if-then-delete rule; the if conditions 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.

Page 13: 1 Financial Informatics –VI: Planning Systems 1 Khurshid Ahmad, Professor of Computer Science, Department of Computer Science Trinity College, Dublin-2,

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.

Page 14: 1 Financial Informatics –VI: Planning Systems 1 Khurshid Ahmad, Professor of Computer Science, Department of Computer Science Trinity College, Dublin-2,

14

THE BLOCKS WORLDThe BLOCKS world states can be described by three kinds of literals CLEAR (x) There is no block on top of x

   

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 literals.

Page 15: 1 Financial Informatics –VI: Planning Systems 1 Khurshid Ahmad, Professor of Computer Science, Department of Computer Science Trinity College, Dublin-2,

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

Page 16: 1 Financial Informatics –VI: Planning Systems 1 Khurshid Ahmad, Professor of Computer Science, Department of Computer Science Trinity College, Dublin-2,

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)

Page 17: 1 Financial Informatics –VI: Planning Systems 1 Khurshid Ahmad, Professor of Computer Science, Department of Computer Science Trinity College, Dublin-2,

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 on block C, and block D on block B. The goal situation is: Block A is on top of block B, B is on C, and C is on the table; block D is also on the table.

Page 18: 1 Financial Informatics –VI: Planning Systems 1 Khurshid Ahmad, Professor of Computer Science, Department of Computer Science Trinity College, Dublin-2,

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)

Page 19: 1 Financial Informatics –VI: Planning Systems 1 Khurshid Ahmad, Professor of Computer Science, Department of Computer Science Trinity College, Dublin-2,

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)

Page 20: 1 Financial Informatics –VI: Planning Systems 1 Khurshid Ahmad, Professor of Computer Science, Department of Computer Science Trinity College, Dublin-2,

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).

Page 21: 1 Financial Informatics –VI: Planning Systems 1 Khurshid Ahmad, Professor of Computer Science, Department of Computer Science Trinity College, Dublin-2,

21

A simple breadth-first search will mean that every operator will have to be tried and instantiated in every possible way, as long as the operators' pre-requisites are satisfied. This approach will lead to an exponential tree growth in the search space.

Search strategy – not breadth first but backward chaining

Page 22: 1 Financial Informatics –VI: Planning Systems 1 Khurshid Ahmad, Professor of Computer Science, Department of Computer Science Trinity College, Dublin-2,

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.

Page 23: 1 Financial Informatics –VI: Planning Systems 1 Khurshid Ahmad, Professor of Computer Science, Department of Computer Science Trinity College, Dublin-2,

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-situation assertions or goal assertions.

Search strategy – not breadth first but backward chaining

Page 24: 1 Financial Informatics –VI: Planning Systems 1 Khurshid Ahmad, Professor of Computer Science, Department of Computer Science Trinity College, Dublin-2,

24

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 block A onto block B; the bottom portion adds an operation intended to move block B 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

Page 25: 1 Financial Informatics –VI: Planning Systems 1 Khurshid Ahmad, Professor of Computer Science, Department of Computer Science Trinity College, Dublin-2,

25

CONDITIONAL PLANNINGConditional planning, also known as contingency planning, deals with incomplete information by constructing a conditional plan that accounts for each possible situation or contingency that 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 appropriate conditions.

Page 26: 1 Financial Informatics –VI: Planning Systems 1 Khurshid Ahmad, Professor of Computer Science, Department of Computer Science Trinity College, Dublin-2,

26

CONDITIONAL PLANNINGA 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

Page 27: 1 Financial Informatics –VI: Planning Systems 1 Khurshid Ahmad, Professor of Computer Science, Department of Computer Science Trinity College, Dublin-2,

27

CONDITIONAL PLANNINGThe following operators will help in fixing the tyre:

Table 1

 

 

 

 

 

Operator 1:

/* Remove Tyre x*/

  IF On (x)

  Add list Off (x)

    ClearHub (x)

  Delete list On (x)

Page 28: 1 Financial Informatics –VI: Planning Systems 1 Khurshid Ahmad, Professor of Computer Science, Department of Computer Science Trinity College, Dublin-2,

28

Table 2

 

 

 

 

 

 

Operator 2:

/* Put Tyre x On */

  IF Off (x)

    ClearHub(x)

  Add list On (x)

  Delete list ClearHub(x)

    Off(x)

CONDITIONAL PLANNING

Page 29: 1 Financial Informatics –VI: Planning Systems 1 Khurshid Ahmad, Professor of Computer Science, Department of Computer Science Trinity College, Dublin-2,

29

CONDITIONAL PLANNINGTable 3

 

 

 

 

 

Operator 3:

/* Inflate Tyre x*/

  IF Intact (x)

    Flat(x)

  Add list Inflated (x)

  Delete list Flat(x)

Page 30: 1 Financial Informatics –VI: Planning Systems 1 Khurshid Ahmad, Professor of Computer Science, Department of Computer Science Trinity College, Dublin-2,

30

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)]

CONDITIONAL PLANNING

Page 31: 1 Financial Informatics –VI: Planning Systems 1 Khurshid Ahmad, Professor of Computer Science, Department of Computer Science Trinity College, Dublin-2,

31

Dealing with incomplete information

In the above example we have assumed that the tyre was not intact: the description of the initial conditions does not use the operator intact. 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 regular intervals in that they always leak air, albeit very slowly.

Page 32: 1 Financial Informatics –VI: Planning Systems 1 Khurshid Ahmad, Professor of Computer Science, Department of Computer Science Trinity College, Dublin-2,

32

STAGES OF THE PLANNING PROCESS

The planning process can be described through six stages: Stage1 : The plan has the typical Start and Finish states. The initial condition suggests that Tyre1 is a Flat tyre and that we have an Inflated spare tyre to replace the Flat tyre.    Start Finis

h

On(Tyre1)Flat (Tyre1)Inflated (Spare) 

On(x)Inflated (x) 

 

Page 33: 1 Financial Informatics –VI: Planning Systems 1 Khurshid Ahmad, Professor of Computer Science, Department of Computer Science Trinity College, Dublin-2,

33

STAGES OF THE PLANNING PROCESS

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 second is satisfied by adding the

step Inflate(Tyre1). Recall that the Inflate operator has

antecedent conditions Flat and Intact. The first antecedent literal (Flat) is satisfied by linking it with the same literal in the Start state. However, we have a problem with the Intact literal. 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.

Page 34: 1 Financial Informatics –VI: Planning Systems 1 Khurshid Ahmad, Professor of Computer Science, Department of Computer Science Trinity College, Dublin-2,

34

STAGES OF THE PLANNING PROCESS

Inflate(Tyre1)

Start Finish

On(Tyre1)Flat (Tyre1)Inflated (Spare) 

On(x)Inflated (x) 

Flat (Tyre1)Intact ((Tyre1)  

     

 

Page 35: 1 Financial Informatics –VI: Planning Systems 1 Khurshid Ahmad, Professor of Computer Science, Department of Computer Science Trinity College, Dublin-2,

35

STAGES OF THE PLANNING PROCESS

Stage3 : In the conditional planning systems, as opposed to conventional

planning systems which will abandon Stage2 now and pursue other goals if they can, one can add an action Check(x) : 

 

 

 

Operator 4:

/* Check Tyre x*/  IF Tyre (x)  Add list KnowsWhether(‘Intact

(x))

This operator helps in determining the truth value of the proposition that unifies with Intact(x). The check tyre operation helps in conditional planning through the addition of a conditional link to the Inflate(Tyre1)

operation. Such a step is called a conditional step because it will become a branch point in the final plan.

Page 36: 1 Financial Informatics –VI: Planning Systems 1 Khurshid Ahmad, Professor of Computer Science, Department of Computer Science Trinity College, Dublin-2,

36

STAGES OF THE PLANNING PROCESS

        

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))

 

Page 37: 1 Financial Informatics –VI: Planning Systems 1 Khurshid Ahmad, Professor of Computer Science, Department of Computer Science Trinity College, Dublin-2,

37

STAGES OF THE PLANNING PROCESS

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

Intact. Therefore, the tyre cannot be Inflated and 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(Tyre

1)

On(Tyre1)Flat (Tyre1)Inflated (Spare) 

On(Tyre1)Inflated (Tyre1) 

Flat (Tyre1)Intact ((Tyre1)  

Check(Tyre

1)

(Intact (Tyre1))

Finish(Intact (Tyre1))

Finish

( ¬ Intact (Tyre1))

On(x)Inflated (x) 

Page 38: 1 Financial Informatics –VI: Planning Systems 1 Khurshid Ahmad, Professor of Computer Science, Department of Computer Science Trinity College, Dublin-2,

38

STAGES OF THE PLANNING PROCESS

Stage5: The Inflated (Spare) literal in the Start state can be unified with the

alternative Finish state’s literal of the same name but comprising a variable x.

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) 

Page 39: 1 Financial Informatics –VI: Planning Systems 1 Khurshid Ahmad, Professor of Computer Science, Department of Computer Science Trinity College, Dublin-2,

39

STAGES OF THE PLANNING PROCESS

Stage6: The final stage of planning now involves the addition of the operators

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)