MakeEnumChromosome

MakeEnumChromosome

<< Click to Display Table of Contents >>

Navigation:  »No topics above this level«

MakeEnumChromosome

Return to chapter overview

 

MakeEnumChromosome(Population As Integer, EnumChromosome As Integer, Range As Integer, Length As Integer, Type As Integer)

 

Purpose: This function creates a chromosome of the enumerated type and initializes its elements to random values.  Some application problems have parameters which may be coded into enumerated chromosomes.  An enumerated chromosome is an array of integer numbers which contains Length elements.  The elements in the array are ordinal numbers within the range 0 to Range - 1.  The value of Range may be less than, equal to, or greater than Length.  For example, in the traveling salesman problem the tour can be represented as a sequence of numbers of cities to be visited only once.  In this case Length must be equal to Range.  The formal parameter Type determines the type of enumerated chromosome initialization.  Two different types of enumerated chromosomes are implemented:  chromosomes with repeating genes, and chromosomes with unique genes (see below).

 

Arguments:

Population is the number of the population in which you want to create an enumerated chromosome.

EnumChromosome is the number of the enumerated chromosome that you are going to create.  You may use up to 2,000 enumerated chromosomes in one individual.  Enumerated chromosomes are made one by one, and their numbers should be successive.  The first chromosome has the number 0.  New chromosomes can be added at any time.

Range is a number specifying the “alphabet” size for the enumerated chromosome.  The values of the chromosome elements (genes) will vary from 0 to Range-1 inclusively. Range is a number from 2 to 32,767.  The value of the Range is determined by the specificity of the problem parameter, so there are no general recommendations on its concrete value.  For example, in the Traveling Salesman Problem, the Range corresponds to the number of cities to be visited.

Length is the number of elements (genes) in the enumerated chromosome. Length can vary from 2 to 500.  In the Traveling Salesman Problem, the Length corresponds to the number of cities to be visited.

Type is a number, either 0 or 1, that specifies the type of chromosome initialization.  Value 0 corresponds to the representation with repeating genes, and value 1 corresponds to the representation with unique, non-repeating genes.  You can use the symbolic constants REPEATING_GENES and UNIQUE_GENES which are found in GALIB32.BAS.  In the representation with repeating genes, each array element is initialized independently of the others, i.e., there can be duplicate numbers.  In the representation with unique genes, the value of each chromosome element depends on the value of other chromosomes' elements, i.e., there can be no duplicate numbers.

 

Example: i = MakeEnumChromosome( PopNum, 0, 5, 5, UNIQUE_GENES)

 

This example creates the enumerated chromosome number 0 in the population designated by PopNum.  The value of Range and Length will both be 5.  The enumerated chromosome will have unique genes.

 

Related Functions: GetEnumChromosome, PutEnumChromosome