Russel and Norvig, Chapter 11 L. Manevitz, Slide...

68
Russel and Norvig, Chapter 11 L. Manevitz, Slide Presentasi, http://www.cs.uiowa.edu 12/11/2009 1 LSR, AI: IK103

Transcript of Russel and Norvig, Chapter 11 L. Manevitz, Slide...

Russel and Norvig, Chapter 11L. Manevitz, Slide Presentasi,

http://www.cs.uiowa.edu

12/11/2009 1LSR, AI: IK103

• Bagaimana mendapatkan goal dari initial state ?

Initial State Goal

The blocks world problem

12/11/2009 2LSR, AI: IK103

12/11/2009 3LSR, AI: IK103

• Planning adalah metode yang telah dipikirkan secara detail sebelum menyelesaikan suatu pekerjaan.

Misalkan: ide atau metode untuk mengalahkan tim lawan dalam pertandingan sepakbola.

• Planning is action or process of making plans for something.

• Planning penting untuk solusi yang tidak dapat dibalik kembali (undo).

12/11/2009 4LSR, AI: IK103

Planning adalah kasus khusus dari searching.

Pada searching, pelacakan dilakukan dari initial state ke goal state dengan mengikuti path yang ada. Path yang merupakan solusi adalah sebuah plan langkah dari initial ke goal state.

Sedangkan pada planning, tidaklah harus masalah itu dipecahkan dari initial ke goal state, tetapi dapat juga dengan memecahkan subgoal.

12/11/2009 5LSR, AI: IK103

STRIPS (STanford Research Institute Planning System-1971 by Fikes and Nilsson)

Goal Stack Planning

Constraint Posting

NOAH

etc

12/11/2009 6LSR, AI: IK103

• Memilih rule terbaik berdasarkan informasi heuristik yang tersedia.

• Mengimplementasikan rule yang dipilih dan menghitung masalah yang muncul dari implementasi ini.

• Mendeteksi ketika solusinya tidak ditemukan.• Mendeteksi jalan buntu(dead end) sehingga

bisa menghindarinya.• Mendeteksi ketika hampir ditemukan solusi

dan menggunakan metode khusus untuk benar-benar menemukan solusi.

12/11/2009 7LSR, AI: IK103

Pertama, mendeteksi/mengumpulkan perbedaan antara goal dan initial dan kemudian mengidentifikasi rule yang relevan untuk mengurangi perbedaan ini.

Jika terdapat beberapa rule yang dapat dipilih, maka gunakan informasi heuristik untuk memilih diantara mereka.

12/11/2009 8LSR, AI: IK103

Setiap rule yang akan diimplementasikan akan memberikan kondisi yang baru/perubahan.

Kita harus bisa mengidentifikasi

- kondisi yang harus dipenuhi untuk menjalankan rule tertentu.

- Akibat dari menjalankan suatu rule tertentu.

12/11/2009 9LSR, AI: IK103

Planning sistem dikatakan menemukan solusi jika telah menemukan sequence operasi dari initial state ke goal state.

12/11/2009 10LSR, AI: IK103

Jika perubahan yang dihasilkan setelah iterasi cukup lama, tidak signifikan untuk mengurangi perbedaan antara initial dgn goal.

Jika kita menggunakan metode forwardchaining: operasi menuju suatu state yang tidak dapat dicapai oleh operasi dari goal state.

Jika metode backward: sebaliknya.

12/11/2009 11LSR, AI: IK103

Jika masalah tersebut dapat didekomposisi(dipecah-pecah) maka solusi tiap subbagian telah ditemukan maka solusi masalah merupakan gabungannya.

12/11/2009 12LSR, AI: IK103

• Metode ini menggunakan satu stack yang mengandung goal dan operator yang diusulkan untuk mencapai goal.

• Adanya set operator yang mendeskripsikandaftar PRECONDITION, ADD, dan DELETE.

• Jika goal lebih dari satu, metode ini akanmemecahkan goal satu persatu.

• Solusi yang diperoleh yaitu sequence operator dari goal pertama kemudian diikutioleh sequence operator goal kedua danseterusnya.

12/11/2009 13LSR, AI: IK103

Setiap langkah adalah untuk menemukan goal pada stack teratas.

Kemudian diikuti oleh goal dibawahnya sampai semua goal telah dipenuhi.

Jika terdapat komponen goal yang tidak dipenuhi maka bagian yang salah dari goal dikembalikan ke dalam stack dan proses dilanjutkan kembali.

12/11/2009 14LSR, AI: IK103

Langkah:

1. Mendefinisikan Operator apa saja.

2. Spesifikasi/Deskripsi Operator (PRECONDITION, ADD dan DELETE).

3. Pendefinisikan Initial dan Goal state.

3. Membuat Stack

4. Implementasi Operator dan menemukan goal

Initial State Goal

12/11/2009 15LSR, AI: IK103

Operators:◦ UNSTACK(A,B) – Pick up block A from its current

position on block B. The arm must be empty and block A must have no blocks on top of it.

◦ STACK(A,B) – Place block A on block B. The arm must already be holding A and the surface of B must be clear.

12/11/2009LSR, AI: IK103 16

◦ PICKUP(A) – Pick up block A from the table and hold it. Te arm must be empty and there must be nothing on top of block A.

◦ PUTDOWN(A) – Put block A down on the table. The arm must have been holding block A.

12/11/2009 17LSR, AI: IK103

Predicates: (Kondisi)◦ ON(A,B) – Block A is on block B.

◦ ONTABLE(A) – Block A is on the table.

◦ CLEAR(A) – There is nothing on top of block A.

◦ HOLDING(A) – The arm is holding block A.

◦ ARMEMPTY – The arm is holding nothing.

12/11/2009 18LSR, AI: IK103

Inference rules:◦ [ x : HOLDING(x)] ARMEMPTY

◦ x : ONTABLE(x) y : ON(x,y)

◦ x : [ y : ON(y,x)] CLEAR(x)

12/11/2009 19LSR, AI: IK103

B

A

ON(A,B)

ONTABLE(B)

CLEAR(A)

12/11/2009 20LSR, AI: IK103

PRECONDITION: daftar predicate yang harus benar sebelum suatu operator dipilih.

ADD: daftar predicate baru (bernilai true) setelah operator diimplementasikan.

DELETE: daftar operator lama yang ketika operator yang diimplementasikan salah.

12/11/2009 22LSR, AI: IK103

STACK(A, B):

P: CLEAR(B) HOLDING(A)

D: CLEAR(B) HOLDING(A)

A: ARMEMPTY ON(A, B)

UNSTACK(A, B):

P: ON(A, B) CLEAR(A) ARMEMPTY

D: ON(A, B) ARMEMPTY

A: HOLDING(A) CLEAR(B)

PICKUP(A):

P: CLEAR(A) ONTABLE(A) ARMEMPTY

D: ONTABLE(A) ARMEMPTY

A: HOLDING(A)

PUTDOWN(A):

P: HOLDING(A)

D: HOLDING(A)

A: ONTABLE(A) ARMEMPTY

12/11/2009 23LSR, AI: IK103

ON(B, A)

ONTABLE(A)

ONTABLE(C)

ONTABLE(D)

ARMEMPTY

start: ON(C, A)

ON(B, D)

ONTABLE(A)

ONTABLE(D)

ARMEMPTY

goal:

Initial State Goal

ON(A,B): Balok A menempel diatas balok BONTABLE(A): Balok A berada dipermukaan mejaCLEAR(A): Tidak ada balok yg sedang menempel di AARMEMPTY: Robot tidak sedang memegang balok

12/11/2009 24LSR, AI: IK103

Goals

Operators to

satisfy

the Goals

Current situation

Specification of

Operators/Actions

Stack Database

+

12/11/2009 25LSR, AI: IK103

Kondisi yang mungkin terjadi:

a). Kondisi 1: jika slot berisi kondisi yang sudah memenuhi current state, tetapi slot ini terletak diatas operator maka, slot diambil dari stack dan pemeriksaan dilanjutkan pada slot berikutnya.

b). Kondisi 2: Operator yang memenuhi suatu kondisi, dimasukkan ke dalam stack.

12/11/2009 26LSR, AI: IK103

c). Kondisi 3: jika slot yang diperiksa adalah slot paling dasar, maka uji kesamaan antara current state dan goal state. Jika sama berarti solusi tercapai.

12/11/2009 27LSR, AI: IK103

1) Initial goal stack:

28

ON(C,A) ON(B,D) ONTABLE(A) ONTABLE(D)ΛΛΛ

Initial State Goal12/11/2009LSR, AI: IK103

2) Choose to work on ON(C,A) before ON(B,D):

29

ON(C,A) ON(B,D) OTADON(B,D)ON(C,A)

ΛΛ

Initial State Goal12/11/2009LSR, AI: IK103

3) Achieve ON(C,A) with STACK(C,A):

30

ON(C,A) ON(B,D) OTADON(B,D)ON(C,A)STACK(C,A)

Initial State Goal12/11/2009LSR, AI: IK103

4) Add STACK’s preconditions:

31

ON(C,A) ON(B,D) OTADON(B,D)STACK(C,A)

HOLDING(C)CLEAR(A)

CLEAR(A) HOLDING(C)

Initial State Goal 12/11/2009LSR, AI: IK103

5) Achieve CLEAR(A) with UNSTACK(B,A):

32

ON(C,A) ON(B,D) OTADON(B,D)STACK(C,A)

HOLDING(C)CLEAR(A) HOLDING(C)

UNSTACK(B,A)

ON(B,A) CLEAR(B) ARMEMPTY

ON(B,A)CLEAR(B)ARMEMPTY

CLEAR(A)

Initial State Goal12/11/2009LSR, AI: IK103

6) Pop satisfied predicates:

33

ON(C,A) ON(B,D) OTADON(B,D)STACK(C,A)

HOLDING(C)CLEAR(A) HOLDING(C)

UNSTACK(B,A)

ON(B,A) CLEAR(B) ARMEMPTY

ON(B,A)CLEAR(B)ARMEMPTY

Initial State Goal12/11/2009LSR, AI: IK103

7) Achieve HOLDING(C) with UNSTACK(C,x):

34

ON(C,A) ON(B,D) OTADON(B,D)STACK(C,A)

HOLDING(C)CLEAR(A) HOLDING(C)

UNSTACK(C,x)ON(C,x) CLEAR(C) ARMEMPTY

ON(C,x)

CLEAR(C)ARMEMPTY

Initial State Goal12/11/2009LSR, AI: IK103

8) Achieve ON(C,x) by STACK(C,x):

35

ON(C,A) ON(B,D) OTADON(B,D)STACK(C,A)CLEAR(A) HOLDING(C)

UNSTACK(C,x)ON(C,x) CLEAR(C) ARMEMPTY

ON(C,x)

CLEAR(C)ARMEMPTY

STACK(C,x)CLEAR(x) HOLDING(C)HOLDING(C)CLEAR(x)

Initial State Goal12/11/2009LSR, AI: IK103

9) Terminate path because HOLDING(C) is duplicated.

36

ON(C,A) ON(B,D) OTADON(B,D)STACK(C,A)CLEAR(A) HOLDING(C)

UNSTACK(C,x)ON(C,x) CLEAR(C) ARMEMPTY

CLEAR(C)ARMEMPTY

STACK(C,x)CLEAR(x) HOLDING(C)HOLDING(C)CLEAR(x)

Initial State Goal12/11/2009LSR, AI: IK103

10) Achieve HOLDING(C) with PICKUP, not UNSTACK:

37

ON(C,A) ON(B,D) OTADON(B,D)STACK(C,A)CLEAR(A) HOLDING(C)

PICKUP(C)ONTABLE(C) CLEAR(C) ARMEMPTY

CLEAR(C)ARMEMPTY

ONTABLE(C)

Initial State Goal 12/11/2009LSR, AI: IK103

11) Pop ONTABLE(C) and CLEAR(C), and achieve ARMEMPTY by STACK(B,D):

38

ON(C,A) ON(B,D) OTADON(B,D)STACK(C,A)CLEAR(A) HOLDING(C)

PICKUP(C)ONTABLE(C) CLEAR(C) ARMEMPTY

CLEAR(C)ARMEMPTY

ONTABLE(C)

STACK(B,D)CLEAR(D) HOLDING(B)

HOLDING(B)CLEAR(D)

Initial State Goal 12/11/2009LSR, AI: IK103

12) Pop entire stack, and return plan:i. UNSTACK(B,A).

ii. STACK(B,D).

iii. PICKUP(C).

iv. STACK(C,A).

39

Initial State Goal

12/11/2009LSR, AI: IK103

1. Tempatkan seluruh kondisi goal-state pada slot stack paling bawah.

2. Masukkan setiap kondisi goal state yang belum tercapai ke dalam sebuah slot stack.

3. Loop

Keluarkan kondisi yang sudang dicapai dari dalam stack.

Ganti kondisi yang belum tercapai dengan operator yang sesuai.

Pindahkan operator yang bisa diaplikasikan kedalam rencana penyelesaian.

Cek apakah current-state == goal state.

if current state == goal state then

sukses

end

end

12/11/2009 40LSR, AI: IK103

12/11/2009 41LSR, AI: IK103

12/11/2009 42LSR, AI: IK103

12/11/2009 43LSR, AI: IK103

12/11/2009 44LSR, AI: IK103

12/11/2009 45LSR, AI: IK103

12/11/2009 46LSR, AI: IK103

12/11/2009LSR, AI: IK103 47

12/11/2009 48LSR, AI: IK103

NOAH plans by developing a hierarchy of subgoals.

The procedural net contains several levels of representation of a plan, each level more detailed than the previous one.

For example: the node representing the abstract goal make coffee may be expanded to : grind coffee, boil water, put the coffee in a filter, pour the water through it.

12/11/2009LSR, AI: IK103 49

12/11/2009LSR, AI: IK103 50

We’ll use NOAH to solve the blocks problem.

The operators used in this example are slightly different from those we have been using .

STACK – will put any object on any other (including the table), provided that both objects are clear. It includes the picking up of the object to be moved.

12/11/2009LSR, AI: IK103 51

A reminder of the problem :

12/11/2009LSR, AI: IK103 52

A

C

B C

B

A

Start: ON(C,A)

ONTABLE(A)

ONTABLE(B)

ARMEMPTY

Goal: ON(A,B)

ON(B,C)

The initial state of the problem solver:

12/11/2009LSR, AI: IK103 53

(ON(A,B) ON(B,C)) Level 1

The first thing that it does is to divide the problem into two subproblems:

12/11/2009LSR, AI: IK103 54

ON(A,B)

Level 2

ON(B,C)

S J

Split Join

At the third level the preconditions of STACK are considered – the two blocks involved must be clear.

12/11/2009LSR, AI: IK103 55

CLEAR(A)

Level 3: before criticism

CLEAR(B)

S J

CLEAR(B)

CLEAR(C)

S J

S

STACK(A,B)

STACK(B,C)

J

1

2

4

5

6

3

Now NOAH employs a set of critics to examine the plan and detect interactions among the subplans.

Each critic is a little program that makes specific observations about the proposed plan.

12/11/2009LSR, AI: IK103 56

The Resolve Conflicts critic – constructs a table that lists all the literals that are mentioned more than once in the plan.

12/11/2009LSR, AI: IK103 57

CLEAR(B): asserted: node 2 “Clear B”

denied: node 3 “Stack A on B”

asserted: node 4 “Clear B”

CLEAR(C): asserted: node 5 “Clear C”

denied: node 6 “Stack B on C”

Constraints on the ordering of operation arise when a given literal must be true before one operation can be performed but will be undone by another.

12/11/2009LSR, AI: IK103 58

CLEAR(B): denied: node 3 “Stack A on B”

asserted: node 4 “Clear B”

Conclusion:

Since putting A on B could undo the preconditions for putting B on C, putting B on C needs to be done first.

12/11/2009LSR, AI: IK103 59

The third level after criticism to resolve conflicts:

12/11/2009LSR, AI: IK103 60

CLEAR(A)

Level 3

CLEAR(B)

S J

CLEAR(B)

CLEAR(C)

S J

S

STACK(A,B)

STACK(B,C)

Can be invoked to eliminate the redundant specification of subgoals. In this case CLEAR(B) appears twice and is only denied by the last step of the plan.

12/11/2009LSR, AI: IK103 61

The third level after all criticism:

12/11/2009LSR, AI: IK103 62

CLEAR(A)

Level 3

J

CLEAR(B)

CLEAR(C)

S J

S

STACK(A,B)

STACK(B,C)

To clear A, C must be removed from A. in order to do that C must be clear :

12/11/2009LSR, AI: IK103 63

CLEAR(C)

Level 4: before criticism

J

CLEAR(B)

CLEAR(C)

S J

S STACK(A,B)

STACK(B,C)

STACK(C,x)

The critic observes that putting B on C will make CLEAR(C) false, so everything that depends on C being clear will have to be done before B is put on C.

12/11/2009LSR, AI: IK103 64

The Resolve Conflicts critic is employed:

12/11/2009LSR, AI: IK103 65

CLEAR(C)

Level 4: after criticism to

resolve conflicts

CLEAR(B)

CLEAR(C)

S

J

S

STACK(A,B)STACK(B,C)

STACK(C,x)

It notices that CLEAR(C) is required twice. Since putting C somewhere must occur before

putting B on C, and both require C being clear then we know that when we get to putting B on C, C will be clear.

CLEAR(C) can be eliminated from the lower path.

12/11/2009LSR, AI: IK103 66

The Eliminate Redundant Preconditions critic is called:

12/11/2009LSR, AI: IK103 67

CLEAR(C)

Level 4: after all criticism

CLEAR(B) J

S

STACK(A,B)STACK(B,C)

STACK(C,x)

The system observes that the remaining goals , CLEAR(C) and CLEAR(B), are true in the initial state.

Therefore the final plan is:

12/11/2009LSR, AI: IK103 68

Final plan

STACK(A,B)STACK(B,C)STACK(C,x)

BA C A

B

C

12/11/2009 69LSR, AI: IK103