Simulated annealing is a general optimization technique for avoiding local optima, at the price of speed. The basic idea is that the parameters of the model are subject to some amount of ``thermal'' noise; at first, quite a lot of noise, then the system is gradually ``cooled'' (hence ``annealed'') by introducing less and less noise each iteration. Our simulated annealing implementation is a variant on more classical methods of HMM training (Baum-Welch expectation maximization).
To train an HMM on the unaligned globins in globins50.fa, run the following:
> hmmt globin1.hmm globins50.fa
hmmt will start from a randomized alignment of the unaligned sequences in globins50.fa and build an initial model from it. It then iterates, producing a new alignment with the current model and producing a new model from the current alignment until the model score converges. After convergence occurs (which is guaranteed) hmmt writes the trained model to the file globin1.hmm.
The score that hmmt is printing at each iteration is the average log-odds probability of the current model against the training sequences (in natural logarithms); this number should become positive, and the higher the better. The length of the model (in match states) is also printed at each iteration. Initially, this number is the average length of the sequences, and it will change towards the end of the run, as a model construction procedure kicks in (a maximum likelihood algorithm) and revises the program's ideas about the best structure for the HMM. The value in the ``change'' column is an indication of how much the model's parameters have changed from the previous model; it is the sum of the squared differences of previous and current parameters (divided by the number of parameters). Finally, the current ``temperature'' (kT) is shown.
The amount of randomness is controlled by two parameters: kT, which can be thought of as the starting ``temperature'' in arbitary units, and ramp, a value from 0 < ramp < 1 which kT is multiplied by at each iteration to achieve exponential cooling. The larger ramp is (without exceeding 1), the slower the cooling, the better models you may expect, and the longer it will take for the parameters to converge. By default, kT is 5 and ramp is 0.95. You can change these values with the -k and -r options. I have not yet systematically explored different values of temperature and ramp!
Indeed, the default annealing schedule is just a simple exponential cooling. I have just begun testing other annealing schedules. The -S <schedulefile> option allows you to provide a customized annealing schedule. This file contains a series of kT temperature values to use at each iteration, one kT value per line. An example file is provided in Demos/saschedule.dat. An example hmmt command line using this customized schedule is:
> hmmt -S saschedule.dat globin2.hmm globins50.fa
Simulated annealing became the default in version 1.8.