Introduction to Artificial Intelligence (CS236501)

advertisement
Introduction to Artificial Intelligence (CS236501)
Home assignment #1 – Search
Due date: Sunday, December 18, at 12:00 noon (midday!)
Warning: Absolutely no extensions will be granted!!!
Submit your work in pairs.
Only typed (i.e., not handwritten) submissions will be accepted.
T.A. in charge: Ola Rozenfeld, [email protected]
In this assignment your task is to implement a number of search algorithms, including those studied in the
classroom and their variants. You will apply these algorithms to a challenging puzzle domain, and analyze
their advantages and disadvantages.
We shall work on the 7D Rings puzzle. Here is a brief description of the puzzle, while a sample
implementation which includes all the instructions is available at this Web site:
http://ftp.se.kde.org/pub/games/PC/gamesdomain/shareware/7drings.exe
The puzzle consists of 2 rings, each having 10 balls of one color and 9 balls of another color (there are 4
colors in the entire puzzle). The ordered (final) state of the puzzle is achieved when all the balls of the same
color are concentrated in one of the rings, and appear in an uninterrupted sequence one after the other. Any
other ordering of the puzzle is not a final one. Note that there is not a single ordered state, but a set of 4
ordered states that are equivalent to one another. Given an unordered (initial) state, the purpose of the 7D
Rings game is to collect in succession all balls of one color by rotating the intersected rings. Each ring can be
rotated either clockwise or counter-clockwise, one ball at a time.
Initial state:
Ordered (final) state:
Instructions:
1) Given the above definition, you should convert this puzzle into a search problem. That is, you should
formally define the search space and search states, as well as identify the goal states (referred to as ordered
states above). Your task is to develop a suitable heuristic function, and use it to solve the puzzle.
2) In order to create an initial state for the puzzle, start with an ordered (solved) puzzle, and then apply to it a
random sequence of reverse legal operations. Note that in our problem reverse operations are the same as
regular operations (i.e., rotations of the rings). This will yield you a new search problem (which difficulty
depends on the length of the random sequence). Note that if you do not take care of applying legal
permutations only, you might create an unsolvable puzzle.
Obviously, your search algorithms should not use any information about how the initial state was created. In
particular, you should not assume that the goal state is indeed the one you started from.
3) Implement each of the algorithms in parts I and II below. Any of the following programming languages
can be used in this assignment: C/C++, Java, Lisp. For other languages ask for approval of the exercise grader
(Ola, [email protected]).
Part I – uninformed search
In this part, you will implement the following combination of iterative deepening DFS (depth first search)
and BFS (breadth first search):
Preprocessing stage:
Perform BFS backwards from all the goal states, until the memory limit n is exhausted. The memory limit is
defined as the maximum number of nodes that can be kept in memory (i.e., the number of nodes in the union
of Open and Closed lists). Save these n nodes in an appropriate data structure.
Search:
Perform IDFS from the initial state until it reaches one of the states saved at the preprocessing stage. Note
that the results of preprocessing can be used to solve multiple problem instances.
Note that n is the tunable parameter of the algorithm.
Part II – informed search
In this part, you will devise and implement a heuristic function and use it in a beam search algorithm, as
studied in class.
Note that beam width m is the tunable parameter of the algorithm.
To Do Summary
0. Study the problem domain. Formally define the search space and search states, as well as identify the goal
states.
1. Develop an appropriate heuristic. Submit an extensive description of your heuristic function and explain its
advantages and disadvantages. What is the complexity of the heuristic? Why did you prefer this function over
others?
2. Implement the algorithms of part I and II.
3. For each algorithm answer the following questions:
 Is this algorithm complete?
 Is this algorithm optimal (finds the shortest path to a goal state)?
4. Create a set of problems of at least 3 difficulty levels and at least 10 problems of each level (recall that the
difficulty level of a problem instance is defined as the number of ring rotations used in creating it). Execute
both algorithms on these problems with different values of the tuning parameter (recall that the tuning
parameter for the first algorithm is the number of saved states in BFS; for the second algorithm, it's the width
of the beam). Analyze the performance in terms of the following measurements:
 Running time (the total number of generated nodes along with the running time in seconds)
 Memory usage (the maximal number of nodes held in memory at any given time)
 Quality of the solution found (the length of the path to goal).
Organize the measurements in tables and graphs as you see fit.
5. Draw conclusions from you results, such as for each algorithm, what effect do the parameter values of the
algorithm have on solving problems of various difficulty levels.
Note: the analysis of experiments constitutes the main point of this assignment. Therefore, you should discuss
your experimental results at great length, explaining the nature of your results and observations.
6. Submit all your code, which should be accompanied with both internal and external documentation. The
maturity level of your documentation should be appropriate for an advanced course in Computer Science.
7. Your entire submission should be in hard copy (no electronic submission is necessary for this assignment).
Submit your work in pairs. In order to find a partner, you might take advantage of the “Find a partner”
mechanism available on the course Web page at http://webcourse.technion.ac.il/236501 (see buttons on the
left).
Good luck!
Questions? Ola Rozenfeld ([email protected])
Flames? /dev/null
Note:
Before sending your question by email, please make sure you’ve checked the “Updates and FAQ” section of
the course web site (http://webcourse.technion.ac.il/236501, Assignments -> ex1 -> Updates and FAQ). We
will not respond to emails when the answer is available at the FAQ page!
Download