Matakuliah Tahun Versi : T0264/Inteligensia Semu : Juli 2006 : 2/2 Pertemuan 4 Heuristic Search Techniques Problem Reduction 1 Learning Outcomes Pada akhir pertemuan ini, diharapkan mahasiswa akan mampu : • << TIK-99 >> • << TIK-99>> 2 Outline Materi • • • • • Materi 1 Materi 2 Materi 3 Materi 4 Materi 5 3 3.4 Problem Reduction A Simple AND - OR Graph 4 3.4 Problem Reduction AND - OR Graphs 5 Algoritm : Problem Reduction 1. Initialize the graph to the starting node 2. Loop until the starting node is labeled SOLVED or until its cost goes above FUTILITY : a. Traverse the graph, starting at the initial node and following the current best path, and accumulate the set of nodes that are on that path and have not yet been expanded or labeled as solved b. Pick one of these unecpanded nodes and expand it. If there are no successors, assign FUTILITY as the value of this node. Otherwise, add its successors to the graph abd for each of them computer f’. If f’ of any node is O, mark that node as SOLVED 6 Algoritm : Problem Reduction c. Change the f’ estimate of the newly expanded node to reflect the new information provided by its successors. Propagate this change backward through the graph. If any node contains a successors arc whose descendants are all solved, label the node that is visited while going up the graph, decide which of its successor arcs is the most promising and mark it as part of the current best path 7 The Operation of Problem Reduction 8 3.5 Constraint Satisfaction Algorithm : Constrain Satisfaction 1. Propagate available constraints : First set OPEN to the set of all objects that must have values assigned to them in a complete solution. Then do until an inconsistency is detected or until OPEN is empty : a. b. c. Select an object OB from OPEN. Strengthen the set of constraints that apply to OB. If this set is different from the set that was assigned the last time OB was examined or if this is the first OB has been examined, then add to OPEN all objects that share anyconstraints with OB. Remove OB from OPEN. 9 3.5 Constraint Satisfaction 2. If solution, then quit and report the solution. 3. If contradiction, then return failure. 4. If neither, then guess : Loop until a solution is found or all possible solution have been eliminated : a. Select an object whose value is not yet determined & select a way of strengthening the constraints on that object. b. Recursively invoke constraint satisfaction with the current set of constraints augmented by the strengthening constraint just selected. 10 A Criptarithmetic Problem Problem : SEND + MORE MONEY Initial State : • No two letters have the same value • The sums of the digits must be as shown in the problem 11 Initial State M = 1 S = 8 or 9 O = 0 or 1 O = 0 N = E or E+1 N = E+1 C2 = 1 N+R > 8 E <> 9 Solving a Criptarithmetic Problem Send + More Money E=2 N = 3 R = 8 or 9 2+D = Y or 2+D = 10+Y C1=0 2+D N+R R = S = = Y = 10+E 9 8 C1=1 2+D = 10 + Y D = 8+Y D = 8 or 9 D=8 D=9 Y=0 conflict Y=1 conflict 12 A Criptarithmetic Problem • Ulasan : • Solusi Cryptarithmetic Problem dengan Constraint satisfaction • S E N D M Ø R E + ¯¯¯¯¯¯¯¯¯¯¯¯¯¯ MØ N E Y C3 C2 C1 S E N D M Ø R E + ¯¯¯¯¯¯¯¯¯¯¯¯¯¯ MØ N E Y • C3 / C2 / C1 ( C ) = Carry yang bernilai 1 atau 0. 13 A Criptarithmetic Problem • Initial state : • [if !supportLists] 1. [endif] No two letters have the same value. ( masing-masing huruf hanya memiliki 1 nilai dengan range [0-9] ) • [if !supportLists]2. [endif] The sums of the digit must be as shown in the problem. • Jumlah digit antar huruf musti sama dengan soal. • Mis : S+M = MØ, maka S+M harus bernilai belasan agar tercapai 2 digit) • Steps for solving the problem 14 A Criptarithmetic Problem • S + M = MØ nilai S dan M harus berkisar diantara [0-9], karena hanya 1 digit. Maka nilai M adalah 1 (M = 1) karena S+M+C3 tidak bisa lebih besar dari 19. • Karena M = 1, maka (S + 1(M) + C3 = 1(M)Ø) nilai S adalah 8(+1) atau 9 agar didapat 2 digit nilai (10 atau 11). 8 (+1) maksudnya 8 ditambah Carry(C3). • Nilai Ø adalah 0 (Ø = 0) karena S + 1(M) + C3 harus bernilai 10 supaya didapat 2 digit. Nilai 11 bisa didapat kalau menggunakan S = 9 dan C3 = 1, tapi nilai 1 sudah buat M, karena itu nilai Ø tidak boleh 1. • Kemungkinan 1 : S = 8 , C3 = 1 , Ø = 0 • E + Ø = (1) N nilai E + Ø harus bernilai min 10 agar bisa didapat nilai C3 = 1 15 A Criptarithmetic Problem • C2 + E + Ø = N , (1+) 9(E) + 0(Ø) = (1)N , maka 10 = (1)N maka N = 0,hal ini menciptakan kontradiksi karena nilai N = Ø. Jadi kemungkinan ini salah • Kemungkinan 2 : S = 9 , C3 = 0 , Ø = 0 E + Ø = N, C2 + E + Ø = N , maka nilai C2 harus 1 karena nilai E tidak boleh sama dengan N. • Didapat persamaan 1 + E + 0 = N, maka N = E+1. • Karena Nilai pasti tidak didapat, maka kita jalankan langkah 1. • N + R = E (hasil disini harus bernilai belasan agar C2 = 1),D + E = Y. • Langkah 1 sudah dijalankan , tapi tidak ketemu nilai variabel, karena itu kita • jalankan langkah 4. 16 A Criptarithmetic Problem • Kita mulai dengan tebakan kalo E = 2, maka N = 3. Pemilihan nilai E, karena variabel E paling banyak muncul dan paling banyak berinteraksi dengan huruf lain. C1 + N + R = (1)E , C1 + 3 + R = (1)2, berapa nilai C1 + R + 3 agar didapat nilai 12? . • Jawabannya : C1 = 1, R = 8. Lalu kita masukan ke persamaan lanjutan, D + E = Y (Hasil disini harus belasan agar didapat C1 = 1), D + 2 = Y, dari sini didapatkan kesimpulan bahwa kemungkinan ini tidak mungkin, karena sebesar apapun nilai D + 2 tidak akan mencapai nilai belasan. • Kita lanjutkan tebakan kalo E = 3, maka N = 4. C1 + N + R, C1 + 4 + R = (1)3, berapa C1 + R + 4 agar didapat 13? R = 8 dan C1 = 1. 17 A Criptarithmetic Problem • Kita masukan ke D + E = (1)Y, kemungkinan ini tidak mungkin karena D + 3 hanya bernilai paling besar 10(D = 7), dan menyebabkan Y = 0. (Ø = 0) • Sekarang jika E = 4 ,maka N = 5. C1 + N + R, C1 + 5 + R = (1)4, berapa C1 + 5 + R agar didapat 14 ? R = 8 dan C1 = 1. Kita masukan ke D + E = (1)Y kemungkinan ini tidak mungkin karena D(7) + 4 hanya bernilai paling besar 11, dan menyebabkan Y = 1. (M = 1) • Sekarang jika E = 5 ,maka N = 6. C1 + N + R, C1 + 6 + R = (1)5, berapa C1 + 6 + R agar didapat 15 ? R = 8 dan C1 = 1. • Kita masukan ke D + E = (1)Y kemungkinan ini mungkin karena D(7) + 5 bernilai paling besar 12, dan menyebabkan Y = 2. Didapatkan jawaban, maka kita jalankan langkah 2. 18 A Criptarithmetic Problem Jawaban nilai-nilai variabel agar didapat hasil yang sesuai dengan soal : • • • • • M=1 Ø=0 S = 9 —> E = 5 N=6 • • • • • • • R =8 D=7 Y=2 C1 = 1 C2 = 1 C3 = 0 C3 C2 C1 0 1 1 S E N D 9 5 6 7 M Ø R E + —> 1 0 8 5 + ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯ M Ø N E Y 1 0 6 5 2 • Semoga Bisa Dimengerti 19 3.6 Means-ends analysis • Collection of search strategy that can reason either forward or backward, but for given problem, one direction or the other must be chosen. • A mixed strategy would make it possible to solve the major part of problem first and then go back and solve the small problem that arise “gluing” the big pieces together. • The mean-ends analysis process centers around the detection of differences between the current state and the goal state. 20 The Robot ’s Operators Operator PUSH (obj,loc) Preconditions Results at(robot,obj) at(obj,loc) large(obj) at(robot,loc) clear(obj) armempty at(robot,obj) at(obj,loc) small(obj) at(robot,loc) WALK(loc) none at(robot,loc) PICKUP(obj) at(robot,obj) holding(obj) PUTDOWN(obj) holding(obj) holding(obj) PLACE(obj1,obj2) at(robot,obj2) On(obj1,obj2) CARRY(obj,loc) holding(obj1) 21 A Difference Table Push Move object Move robot Clear object * Carry Walk Pick up Put Place down * * * Get object on object * Get arm empty Be holding object * * * 22 Means-ends analysis The Progress of The Means-Ends Analysis Method 23 Algorithm : Means-Ends Analysis 1. Compare CURRENT to GOAL.If there are no differences between them, then return. 2. Otherwise, select the most important difference and reduce it by doing the following until success or failure is signaled : a. Select an as yet untried operator O that is applicable to the current difference. If there are no such operators, then signal failure. b. Attempt to apply O to CURRENT. Generate descriptions of two states : O-START, a state in which O ‘s preconditions are satisfied and ORESULT, the state that would result if O were applied in O-START. 24 Algorithm : Means-Ends Analysis c. If (FIRST-PART MEA(CURRENT,O-START)) And (LAST-PART MEA(O-RESULT,GOAL)) are succesful, the signal success and return the result of concatenating FIRST-PART,O, and LAST-PART. 25 << CLOSING>> End of Pertemuan 4 Good Luck 26
© Copyright 2026 Paperzz