<< Click to Display Table of Contents >> Optimize Example 

This sample was designed to visually demonstrate the capabilities of a genetic algorithm (GA) for function optimization, i.e., for searching for the function global maximum or minimum. We are not going to explain the code for this example, but the user is encouraged to examine it. The code is located in the c:\GENEHUNTER\EXAMPLES\VB6 directory if you installed GeneHunter in the default directory.
Four very different functions of two variables Z=f(X,Y), with unique global maxima, have been chosen for this sample. Color topograms represent values of the Zcoordinates in the coordinate ranges indicated below in the table. The function value is encoded in different colors. The color changes from blue to red as the Zcoordinate increases. The position of the function global maximum is shown in the column "Global Maximum" of the same table in the form (Xmax,Ymax,Zmax).
As the GA produces generations of individuals in the population, the fitness of every individual in the population is plotted on the topogram.
The user can freely change genetic parameters such as population size, crossover rate, mutation rate, and maximum number of generations. The elitist strategy (which retains one or more of the most fit individuals in each population for the next generation) can be turned off. General recommendations are:
Population size  20 ... 50 Crossover rate  0.3 ... 0.9 Mutation rate  0.005 ... 0.01 Elitist strategy  on
Evaluation of the GA performance can be made on the basis of "Best Fitness" values, indicated in the Statistics window.
Here are some notes concerning the functions:
1. In the step function, the maximum (10.0) is reached at only one point (5.0,5.0). Since the probability of reaching this point is very low, the search often converges to the square with X and Y coordinates in the range of (4.04.999). If the chromosome resolution is 8 bits, the probability of reaching the global maximum is much higher.
2. The sum of four Gaussians is the sum of Gaussian functions with slightly different amplitudes (about 3 percent). Still, the GA usually chooses the global maximum. The formulas for this example are:
Gauss1 = .97 * Exp(((X + 3)^2 + (Y + 3)^2) / 5) Gauss2 = .98 * Exp(((X + 3)^2 + (Y  3)^2) / 5) Gauss3 = .99 * Exp(((X  3)^2 + (Y + 3)^2) / 5) Gauss4 = 1.0 * Exp(((X  3)^2 + (Y  3)^2) / 5) Z = Gauss1 + Gauss2 + Gauss3 + Gauss4
3. The fourth function, Rosenbrock's saddle, has a very complicated structure near the top of the hill, with a large number of local maxima. These local maxima have Zvalues which are very close to the global maximum. Therefore, optimization is more complicated in this case. At the top of the hill, the color coding is not proportional to the value of the function. Since the hill function has a large plateau at the top, we changed the coding so that it reveals small details of the relief. To do this we had to make relatively small steps in color coding for the values of the function close to the top. This is done to stress the shape of the function.
Figure 6.2 View of Optimize main form 