A1.java available from that site.
To solve a problem using my version of the A* algorithm, you will need to define a class that implements the State interface (which is also given on the web site). Your class will also need an appropriate constructor. And since the answer to the problem is to be clear by looking at the solution state, your class will likely need a version of the toString method that is more informative than the one that is inherited from the Object class. The arguments that each constructor needs should be clear from the description below of the corresponding problem; you may also look at the test class A1.java to double check. This test class also gives the class names (and thus the constructor names) that you are to use.
Recall that the A* algorithm is not guaranteed to work correctly for an optimization problem unless the estimator has the properties given in the documentation for the State.findEstimate method.
Please use Java 5.0 for this assignment, if at all possible. If you use an earlier version of Java, you will need to rewrite the search method of the AStar class so that it uses a while loop controlled by an iterator. I will also accept submissions in Scheme, but in this case you are responsible for translating the Java code that I am providing into Scheme.
Each problem is worth up to 40 points; for your overall grade for this assignment I will add the 3 highest grades for individual problems. However the grading scale will assume a maxmium of 100 points for the assignment. Thus you can get full credit (plus up to 20 points of extra credit) by doing only 3 problems. There is unlikely to be extra credit available on later assignments or tests.
You needn't check for illegal input to a problem. If you do so, I may allow this extra work to offset other deductions that I make for that problem, but in no case will you get more than 40 points per problem.
For each problem, you should assume that the state space takes the form of a tree. You needn't worry about the text's more general version of the A* algorithm, or about making your estimator monotonic.
For the given problems I am primarly concerned that you can use the A* algorithm. I am less concerned about having the most efficient possible implementation, so I will deduct for inefficiency only in the case of gross inefficiency. Some of the problems may have asymptotically better solution algorithms that do not involve the A* algorithm. In this case you should NOT use these particular algorithms, but make sure to use the A* algorithm.
If you do not solve all 7 problems, or if some test cases don't work for the problems that
you do solve, feel free to comment out the corresponding code for the test class A1.java,
or to replace the given test cases by others. Of course, you can expect a deduction for a problem if you cannot handle all of its given test cases. It's also possible that you will receive a deduction if you can handle all of the given test cases, but cannot handle all possible instances of a problem. Finally, note that for some problems, it's possible that a more efficient representation or estimator will allow the solution of more instances in a reasonable time than a less efficient representation will.
As for every assignment this semester, any of your Java classes may have extra methods or variables in addition to those that are required by the assignment.
You are to test your program with the test class A1.java available from the class web site. You are to turn in both hard and soft copies of all of your code (but not A1.java, unless you modify it) as well as a hard copy of the results of your testing. Unless I say otherwise in class, the soft copy of your code should be turned in on a diskette.
Finally, here are the 7 problems that you may attempt:
LinkedList of the integer weights (you don't have to represent the items explicitly).
LinkedList of Strings, while the alphabet is represented only implicitly, as the set of all characters appearing in some string of S. For example, if S={abb, bab, abab, bba} (so that A = {a,b}), then one possibility for M is ababba.
IntegerPair that is given on the class web site. The set of tasks is to
be defined implicitly as the set of all task that appear in some pair of C, so the
constructor for the TopologicalSortState is to take a LinkedList
of IntegerPairs of integers as its only argument.
{20,30,40,50,60}, two bins are enough -- one to contain the items of weights 40 and 60, and one to contain the items of weights 20, 30, and 50. On the other hand, the
inputs{20,30,40,50,61} or {40,40,40,40,40} would each require three bins.
{"1","10111","10"} and B = {"111","10","0"}, then the string
"101111110" is a solution, since it is the concatenation of A[1], A[0], A[0], and A[2]
and also the concatenation of B[1], B[0], B[0], and B[2].
On the other hand,
if A = {"1","10","0"} and B = {"11","101","10"}, then there is no solution,
since the concatenation of any nonempty sequence of strings from A is shorter than the concatenation
of the sequence of corresponding strings from B. Note that the state space for this problem is infinite, so that A* will run forever if there is no solution. The test cases for this problem have been selected
so that they all have solutions; however you should choose your estimator so that every state in the
state space has a chance to be visited. It turns out that there is no solution algorithm of any kind for this problem, so in a sense, A* does as well as one could hope for.