solution2 to hw2

Artificial Intelligence: A Modern Approach

  • Homework Help
  • PresidentHackerCaribou10582
  • 8
  • 100% (1) 1 out of 1 people found this document helpful

Info icon This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ICS 171, Summer 2000: Lecture 2 Solutions 1 A farmer has a goat, a wolf and a cabbage on the west side of a river. He wants to get all of his animals and his cabbage across the river onto the east side. The farmer has a row boat but he only has enough room for himself and one other thing. The wolf will eat the goat if they are left together alone. The goat will eat the cabbage if they are left together alone. How can the farmer get everything on the east side? a Formulate this puzzle as search: i.e. give a state space representation, start state, goal state, and operators. There are many possible ways to formulate problem as a search problem. State Space Representation : We can represent the states of the problem with two sets W and E. Contained in the sets are the symbols f, g, w, c representing the farmer, goat, wolf and cabbage. Another representation could be to use an array such as f1,0,0,1g where the position correspond to the location of the farmer, goat, wolf and cabbage. A 0 represents the west side and 1 represents the east side. Thus, for example, f1,0,0,1g means that the farmer and the cabbage are on the east side and the goat and wolf are on the west side. Note that we didn't explicitly represent the boat because it is not necessary. The boat must always be with the farmer, thus we can abstract away this detail. Operators : Move f from the E set to the W set and vice versa. Move f and one of g,c,w from the E set to the W set and vice versa. Start State : W = ff,g,c,wg, E = f;g ; is the empty set Goal State : W = f;g, E = ff,g,c,wg b Solve this problem using search any method of your choice. Draw the search tree and show the nal solution. 1 W = {f,g,w,c}, E = { } W = {g,c}, E = {f,w} W = {w,c}, E = {f,g} W = {g,w}, E = {f,c} W = {f,w,c}, E = {g} W = {c}, E = {f,w,g} W = {w}, E = {f,g,c} W = {f,g,c}, E = {w} W = {g}, E = {f,w,c} W = {f,g}, E = {w,c} W = { }, E = {f,g,w,c} In words: 1. Farmer takes goat across the river. W = fw,cg, E = ff,gg 2. Farmer comes back alone. W = ff,w,cg, E = fgg 3. Farmer takes wolf across. W = fcg, E = ff,g,wg 4. Farmer comes back with goat. W = ff,g,cg, E = fwg 5. Farmer takes cabbage across. W = fgg, E = ff,w,cg 6. Farmer comes back alone. W = ff,gg, E = fw,cg 7. Farmer takes goat across. W = f;g, E = ff,g,w,cg Question 3.3 in course text Russell & Norvig, page 87 solution from R & N a Initial State: looking at rst page of rst book. Goal Test: Looking at entry listing the number of Mr. Jimwill Zollico er in Alameda. 2 2 Operators: look at new book; look at new page; look at new entry on page. Path Cost: We can measure this in seconds roughly 10 for a new book, 2 for a new page and 0.1 for a new entry. b Everything is the same, except that the goal test is to nd a listing for someone with rst name Jimwill or rst initial J! in Alameda, and to verify that it is correct perhaps by calling the number. Note that the search strategy is very di erent when you know the last name, but the formulation as a search problem can be similar in each case. c Initial State: You are somewhere in the Amazon jungle. Goal Test: You are at the sea. Operators: Follow stream upstream for a bit; follow stream downstream for a bit; go inlnad in any direction for a bit. Path Cost: Distance travelled. The best search strategy might be to go downstream until you reach a large river and then follow that downstream, but strategy is distinct from problem formulation. d Initial State: No regions colored. Goal Test: All regions colored, and no two adjacent regions have the same color. Operators: Assign a color to a region. Path Cost: Number of assignments. e Initial State: As described in the text. Goal State: Monkey has bananas. Operators: Hop on crate; Hop o crate; Push crate from one spot to another; Walk from one spot to another; grab bananas if standing on crate. Path Cost: Number of operations. f Initial State: You are at some location in the town. Goal State: You are at the drug store. Operators: Walk forward a bit; Turn right; Turn left; Look for Drug Store signs; perhaps also knock on locked door" and ask native where Drug Store is". Path cost: Number of steps. 3 Consider the following graph representing the state space and operators of a navigation problem: 3 A D S G B E C H F S is the start state and G is the goal state. When placing expanded child nodes on a queue, assume that the child nodes are placed in alphabetical order i.e. if node S is expanded the queue will be: A B. Assume that we never generate child nodes that appear as ancestors of the current node in the search tree. a What is the order that breadth rst search will expand the nodes? SABBDACECEE G b What is the order that depth rst search will expand the nodes? SABCHED G c What is the order that iterative deepening search will expand the nodes? SSABSABD G Note that when we are searching with a depth limit of d we do not expand nodes at that level but we do test them to see if they are goal states. For example, the diagram below shows the search tree on the third iteration depth limit = 3. For this tree we expand nodes S A B D. Nodes C, E, E and G are tested to see if they are goal states but they are not expanded. 4 S A B B D C E E G Alternatively, if we consider nodes at the depth limit as expanded" i.e. in the above example C, E, and G then our solution is: SABSABDBACESABCEDE G 4 Describe a search space where iterative deepening performs much worse than depth rst search. from R&N 3.9 Consider a linear search tree where the branching factor is 1 and there is a goal state at depth n: 5 S d=0 A d=1 B d=2 C d=3 G d=n DFS search will go straight to the goal state expanding n nodes. This is order On. Iterative deepening will expand 1 + 2 + 3 + 4 + : : : + n nodes. This is order On2 . 5 Construct a search tree where it is possible that DFS will use more memory than BFS. S A G B C 6 BFS will nd the shallow goal immediately. DFS could get sidetracked and could keep exploring the left side of the tree forever generating an extremely long path which must be stored on the Q. 6 Suppose we have a problem space where there is a uniform branching factor b and there is a single goal node at depth m. What is the minimum number of nodes expanded and the storage needed for BFS and DFS? Hint: this question asks about the best case performance of BFS and DFS. Consider the case where DFS goes straight to the goal node on level m. G Expanded nodes are shown in black, nodes that have not been expanded are shown in white. Note that the goal node G has not been expanded since in our algorithm description after we pull a node from the queue we test to see if it is a goal state rst and then expand it. In this case DFS expands only m nodes. It will need to store on the queue d , 1b , 1 + b nodes. For BFS, the best case will occur when the goal is on the far left hand side assuming a left to right ordering. 7 G Again, expanded nodes are shown in black, nodes that have not been expanded are shown in white. In this case BFS expands Obm,1 nodes. BFS will need to store Obm nodes on the queue. 8 ...
View Full Document

  • '
  • NoProfessor
  • Left-wing politics, Far left, Iterative deepening depth-first search, goal state

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern