SetStrategy(Population As Integer, SelectionType As Integer, GenerationGap As Single, FitnessRatio As Single)
Purpose: This function sets the parameters of the basic GeneHunter operators.
Population is the number of the population for which you are going to set the parameters of the operators.
SelectionType is the type of mate selection for reproducing new offspring. GeneHunter allows two types of selection:
SelectionType = 0: This is roulette wheel selection. The higher the fitness value of the mate, the higher its chances of being chosen for reproduction. Use the symbolic constant PURE_SELECTION.
SelectionType = 1: This is elitist selection. A specified number of elite individuals with the highest fitness values pass into the next generation, by-passing the processes of crossover and mutation. The elitist method assures that the most fit individuals remain in the next generation to continue producing offspring. This method of selection, however, increases the probability of population degeneration because of decreased changeability. It, therefore, requires a higher mutation rate to compensate for this decrease (perhaps double the rate). Elitism is nevertheless recommended. Use the symbolic constant ELITIST_SELECTION.
GenerationGap is the degree to which old and new populations overlap. This value also has a probabilistic nature, and (1 - GenerationGap) gives a probability that an individual will be transferred to the next generation without any changes. Usually, values of 0.8-1.0 are used. If SelectionType = 1 (elitist selection) is used, then the number of elite individuals is determined by the formula:
Number_Of_Elites=PopulationSize * (1-GenerationGap)
If PopulationSize and GenerationGap have values such that Number_Of_Elites < 1, then Number_Of_Elites = 1. If elitist selection has been chosen, at least one elite individual with the highest fitness value will always be passed into the next generation without crossover and mutation.
FitnessRatio is the ratio of the maximum fitness to the average fitness after scaling. The fitness function scaling ratio must be a single-precision number in the range [0,100]. Usually, values in the range of 2.0 to 3.0 are used. Only very advanced users need to use any value other than 3.0.
The user calculates all fitness values of all individuals in a population and stores them in the GALIB32.DLL memory using the PutFitness function. During the call to Reproduce, all fitness function values are recalculated: average fitness is kept constant, while maximum fitness is made FitnessRatio times higher than the average fitness. Fitness transformation is linear and a new value is calculated from the old one by the expression:
newfit= a * oldfit + b,
where newfit and oldfit are values of new and old fitness function values respectively; a and b coefficients are calculated from the conditions given above. The scaling function also makes all fitness function values positive, since the reproduction process requires all fitness function values in a population to be positive. However, the user generally does not have to be concerned about how Reproduce changes fitness function values internally.
Example: i = SetStrategy(PopNum, 0, 0.9, 3)
This example sets the parameters of the GeneHunter operators for the population PopNum. Roulette wheel selection with the generation gap of 0.9 and the fitness ratio of 3 are initialized for this population.