1 / 3

Quiz Oct. 11 2008

Quiz Oct. 11 2008. “Solving” a Jiggsaw puzzle. We want to build a “jigsaw puzzle solver”. You are given 3 jigsaw puzzle pieces, A,B,C and a template. Your task is to place the pieces A,B,C into the grid, i.e. A  1, B 2 , C  3 would be a valid configuration.

libby
Download Presentation

Quiz Oct. 11 2008

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Quiz Oct. 11 2008

  2. “Solving” a Jiggsaw puzzle • We want to build a “jigsaw puzzle solver”. • You are given 3 jigsaw puzzle pieces, A,B,C and a template. • Your task is to place the pieces A,B,C into the grid, i.e. A1, B2, C3 would be a valid configuration. • You are also given the a set of pair costs which represent how much of a • dismatch there is between two pieces. High cost means that these pieces don’t like to be neighbors. • Formulate this as a search problem. I.e. define the state space, • successor function, initial state, goal state, step cost. • Place the pieces from left to right, i.e. Empty123. Avoid placing the • same piece twice! Reaching a goal does not necessarily mean you • placed the pieces at their optimal location. • b) Draw the search tree and write the step costs on the edges. • Solve this puzzle by hand using depth first search (DFS). • At every evaluation, write 1) the node you evaluate, 2) the nodes in • the fringe after the evaluation, 3) the path cost for all nodes in the fringe, • e.g. N12; [N1,N4,N8]; [12,34,1]. • c) Is the solution guaranteed to be optimal (why or why not?). • d) What is the time and space complexity of DFS in general? 1 3 2 C(A,B) = 8 C(A,C) = 3 C(B,C) = 5

  3. Solving a Jiggsaw puzzle We want to build a “jigsaw puzzle solver”. You are given 3 jigsaw puzzle pieces, A,B,C and a template. Your task is to place the pieces A,B,C into the grid, i.e. A1, B2, C3 would be a valid configuration. You are also given the a set of pair costs which represent how much of a dismatch there is between two pieces. High cost means that these pieces don’t like to be neighbors. a) Formulate this as a search problem. I.e. define the state space, successor function, initial state, goal state, step cost. Place the pieces from left to right, i.e. Empty123. Avoid placing the same piece twice! Root node is “Empty Template”. This branches into A1,B1,C1 on the first level. Then e.g. for A1 you branch into B2,C2, etc. Step cost is the cost you incur by placing a new piece next to another one, i.e. A1B2 has a step cost of 8. b) Draw the search tree and write the step costs on the edges. Solve this puzzle by hand using depth first search (DFS). At every evaluation, write 1) the node you evaluate, 2) the nodes in the fringe after the evaluation, 3) the path cost for all nodes in the fringe, e.g. N12; [N1,N4,N8]; [12,34,1]. By the time you have descended down a single branch the goal criterium is met and you search no further. c) Is the solution guaranteed to be optimal (why or why not?). Not optimal because you simply find the first configuration you visit d) What is the time and space complexity of DFS in general? Space = O(bm) Time = O(b^m) 1 3 2 C(A,B) = 8 C(A,C) = 3 C(B,C) = 5

More Related