PutFitness

<< Click to Display Table of Contents >>

Navigation:  »No topics above this level«

PutFitness

Return to chapter overview

 

PutFitness(Population As Integer, Individual As Integer, Fitness As Single)

 

Purpose: This function sets the fitness of an individual to a specified value.  Chromosome values change after each new generation step (i.e., after the Reproduce function is issued to an internal representation).  The user must calculate the fitness function for all members of every new generation and store fitness function values with the help of the PutFitness function.  The larger the fitness of an individual, the more fit that individual is for survival.  If your fitness function is calculated so that smaller fitness function values designate more fit individuals, then set the individual’s fitness to the negative of this fitness function.  An example of this is when you want to find the minimum of a function, say f(x,y), where x and y are chromosomes.  The fitness you would feed to PutFitness would be -f(x,y).

 

Arguments:

Population is the number of the population with which you are working.

Individual is the number of the individual whose fitness you want to set. Fitness is a variable containing the fitness value to be passed.  Individual numbers start with 0.

 

Example: i = PutFitness(PopNum, 3, FitVal)

 

This example sets the fitness of individual 3 in the population PopNum to the value stored in the FitVal variable.

 

Related Functions: GetFitness, Reproduce