The.Algorithm.Design.Manual.Springer-Verlag.1998

The.Algorithm.Design.Manual.Springer-Verlag.1998 The.Algorithm.Design.Manual.Springer-Verlag.1998

18.04.2013 Views

War Story: Annealing Arrays ``If it's hard, it's hard. We are going to have to use a heuristic,'' I told him. ``So how do we model this problem?'' ``Well, for each string we can identify the possible prefix and suffix pairs that will realize it. For example, the string `ACC' can be realized in four different ways: prefix `' and suffix `ACC', prefix `A' and suffix `CC', prefix `AC' and suffix `C', or prefix `ACC' and suffix `'. We seek the smallest set of prefixes and suffixes that together realize all the given strings,'' Ricky said. ``Good. This gives us a natural representation for simulated annealing. The state space will consist of all possible subsets of prefixes and suffixes. The natural transitions between states might include inserting or deleting strings from our subsets, or swapping a pair in or out.'' ``What's a good cost function?'' he asked. ``Well, we need as small an array as possible that covers all the strings. How about something like the maximum of number of rows (prefixes) or columns (suffixes) used in our array, plus the number of strings from S that are not yet covered. Try it and let's see what happens.'' Ricky went off and implemented a simulated annealing program along these lines. Printing out the state of the solution each time a transition was accepted, it was fun to watch. Starting from a random solution, the program quickly kicked out unnecessary prefixes and suffixes, and the array began shrinking rapidly in size. But after several hundred iterations, progress started to slow. A transition would knock out an unnecessary suffix, wait a while, then add a different suffix back again. After a few thousand iterations, no real improvement was happening. ``The program doesn't seem to recognize when it is making progress. The evaluation function only gives credit for minimizing the larger of the two dimensions. Why not add a term to give some credit to the other dimension.'' Ricky changed the evaluation function, and we tried again. This time, the program did not hesitate to improve the shorter dimension. Indeed, our arrays started to be skinny rectangles instead of squares. ``OK. Let's add another term to the evaluation function to give it points for being roughly square.'' Ricky tried again. Now the arrays were the right shape, and progress was in the right direction. But the progress was slow. ``Too many of the prefix/suffix insertion moves don't really seem to affect many strings. Maybe we should skew the random selections so that the important prefix/suffixes get picked more often.'' Ricky tried again, Now it converged faster, but sometimes it still got stuck. We changed the cooling schedule. It did better, but was it doing well? Without a lower bound knowing how close we were to file:///E|/BOOK/BOOK3/NODE99.HTM (2 of 4) [19/1/2003 1:29:40]

War Story: Annealing Arrays optimal, it couldn't really tell how good our solution was. We tweaked and tweaked until our program stopped improving. Our final solution refined the initial array by applying the following random moves: ● swap - swap a prefix/suffix on the array with one that isn't. ● add - add a random prefix/suffix to the array. ● delete - delete a random prefix/suffix from the array. ● useful add - add the prefix/suffix with the highest usefulness to the array. ● useful delete - delete the prefix/suffix with the lowest usefulness from the array. ● string add - randomly select a string not on the array, and add the most useful prefix and/or suffix that covers this string (additional preference is given to a prefix/suffix whose corresponding suffix/prefix is already on the array). A standard annealing schedule was used, with an exponentially decreasing temperature (dependent upon the problem size) and a temperature-dependent Boltzmann criterion for accepting states that have higher costs. Our final cost function was defined as where max is the size of the maximum chip dimension, min is the size of the minimum chip dimension, , and is the number of strings in S currently on the chip. Careful analysis of successful moves over the course of the annealing process suggested a second phase of annealing to speed convergence. Once the temperature reaches a predetermined cutoff point, the temperature schedule was changed to force the temperature to decrease more rapidly, and the probability distribution for choosing moves was altered to include only swap, add, and delete, with preference given to swap moves. This modification sped up late convergence, which had been slower than it was in the early stages of the annealing process. file:///E|/BOOK/BOOK3/NODE99.HTM (3 of 4) [19/1/2003 1:29:40]

War Story: Annealing Arrays<br />

optimal, it couldn't really tell how good our solution was. We tweaked and tweaked until our program<br />

stopped improving.<br />

Our final solution refined the initial array by applying the following random moves:<br />

● swap - swap a prefix/suffix on the array with one that isn't.<br />

● add - add a random prefix/suffix to the array.<br />

● delete - delete a random prefix/suffix from the array.<br />

● useful add - add the prefix/suffix with the highest usefulness to the array.<br />

● useful delete - delete the prefix/suffix with the lowest usefulness from the array.<br />

● string add - randomly select a string not on the array, and add the most useful prefix and/or suffix<br />

that covers this string (additional preference is given to a prefix/suffix whose corresponding<br />

suffix/prefix is already on the array).<br />

A standard annealing schedule was used, with an exponentially decreasing temperature (dependent upon<br />

the problem size) and a temperature-dependent Boltzmann criterion for accepting states that have higher<br />

costs. Our final cost function was defined as<br />

where max is the size of the maximum chip dimension, min is the size of the minimum chip dimension, ,<br />

and is the number of strings in S currently on the chip.<br />

Careful analysis of successful moves over the course of the annealing process suggested a second phase<br />

of annealing to speed convergence. Once the temperature reaches a predetermined cutoff point, the<br />

temperature schedule was changed to force the temperature to decrease more rapidly, and the probability<br />

distribution for choosing moves was altered to include only swap, add, and delete, with preference given<br />

to swap moves. This modification sped up late convergence, which had been slower than it was in the<br />

early stages of the annealing process.<br />

file:///E|/BOOK/BOOK3/NODE99.HTM (3 of 4) [19/1/2003 1:29:40]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!