NMath User's Guide

TOC |  Previous |  Next |  Index

26.4 Annealing History (.NET, C#, CSharp, Visual Basic, VB.NET)

For annealing to successfully locate the global minimum of a function, an appropriate annealing schedule must be chosen, but unfortunately this is something of a trial-and-error process. An appropriate regime is entirely dependent on the characteristics of the function being minimized, which may not be well understood in advance.

To help you in this process, class AnnealingMinimizer can be configured to keep a history of the annealing process. There is a cost in memory and execution to record this information, so it is not enabled by default. To record the annealing history, set the KeepHistory property to true. Thus:

AnnealingMinimizer minimizer = new AnnealingMinimizer( schedule );
minimizer.KeepHistory = true;

AnnealingMinimizer performs a minimization at each step in an annealing schedule. When history is turned on, the results of each step are recorded in an AnnealingHistory object. This data may be useful when adjusting the schedule for optimal performance. For example, this code prints out the complete history after a minimization:

DoubleVector min = minimizer.Minimize( f, startingPoint );
AnnealingHistory history = minimizer.AnnealingHistory;
Console.WriteLine( history );

AnnealingHistory also provides a variety of properties for accessing specific information:

The inner class AnnealingHistory.Step encapsulates all of the data associated with a particular step in an AnnealingHistory. The AnnealingHistory.Steps property returns a IList of the steps in the annealing history:

AnnealingHistory history = minimizer.AnnealingHistory;
foreach( AnnealingHistory.Step step in history )
{
  Console.WriteLine( step );
}

The provided indexer can also be used to retrieve information about a particular step. For example, this code prints out a summary of the third step:

Console.WriteLine( history[3] );

TOC |  Previous |  Next |  Index