Assigned: September 15, 2009
Due: September 24, 2009
The goal of this assignment is to give you experience with search algorithms by defining a problem, then comparing alternative search strategies and/or heuristics. Another goal is to give you experience writing a report that logically argues for the relative strengths and weaknesses of algorithms for a problem, and clearly describes their properties. Your work will be graded for correctness, completeness, clarity, and the logic of your presentation.
The missionaries and cannibals problem is usually stated as follows. Three missionaries and three cannibals are on one side of a river, along with a boat that can hold one or two people. Find a way to get everyone to the other side, without ever leaving a group of missionaries in one place outnumbered by the cannibals in that place. For more details about this problem, you can look at the Wikipedia definition of it. (Missionaries_and_cannibals_problem)
(b) Draw a diagram of the complete state space.
(a) List the order in which the first 10 nodes will be visited for iterative deepening search.
(b) Define two heuristics for the missionaries and cannibals problem. Are one or both of your heuristic admissable? Does one heuristic dominate the other? Explain your answers.
(c) List the order in which the first 10 nodes will be visited for A* search. You only need to do this for one of your heuristics (your choice).
(a) Implement the iterative deepening and A* algorithms. Then use this code to solve the missionaries and cannibals problem as stated above. Be sure to use the formulation and heuristics defined in questions 1 and 2b above. Your program should have a main function that takes three input string arguments: problem scenario (described below in terms of <m c b>), search algorithm ("ids", "astar"), and heuristic function ("none", "h1," "h2"). The function should output the found solution and summarize its length (number of moves). In addition, the program should also output: on which depth the solution was found, the maximum length of the fringe, and the time and space usage (in terms of number of nodes generated and expanded).
(b) Since this search problem is quite straightforward, let's make it more interesting. Modify your program so that it now works for any positive number of cannibals, any positive number of missionaries, and any boat-size (i.e. maximum number of people in the boat) of 2 and over. Note that this opens the possibility of the outnumbering of missionaries by cannibals in the boat, not just on the river bank.
(c) Report should include describing and analyzing the results of 3a and 3b. Your report should first show that your implementations for both versions of the missionaries and cannibals problem (3a and 3b) work correctly. That is, demonstrate that your successor function, goal test, cost function, and heuristic functions work correctly by showing pieces of a script of your code running in a verbose mode (i.e., with extra print statements). Please include just enough to convince us your code works (e.g. for 3a, show that your output corresponds to your answers to questions 2a and 2c), and please be sure this is readable (add comments to the file to tell us what we are looking at, if it isn't obvious). Also, state whether you implemented treesearch or graphsearch, and explain why.
More about the report:
For both 3a and 3b, your report should next present your results of running
iterative deepening search and A* search with the heuristics you developed in
2b. To do this, your algorithms should be run for the following scenarios, where
<m c b> identifies the problem version, m being the
number of missionaries, c the number of cannibals, and b the size of the boat:
<3 3 2> <4 4 2> <4 4 3> <6 5 2> <6 6 4> <7 7 4>
Your report should compare the search algorithms and heuristics, supporting your arguments with the output statistics requested above, and other observations from your runs. In your report, you can report raw counts, averages, as well as averages as a function of optimal solution length (similarly to Figure 4.8 on page 107 of R&N). An extra 5 points will be given to the student(s) with the best performing program!
Other ideas for discussion in your report: What are the properties of the problem? That is, how big is the search space? What is the average branching factor? What are the strengths and weaknesses of each algorithm for this problem, and why? If one heuristic dominates the other, show the effect of this (i.e., give the relevant statistic(s) showing the effect).