GeneticAlgorithm_Kernel.C

typedef struct GENETICALGORITHM {

                int no_Dimension;                                           //number of dimension

                double **SearchSpace;                                                //the array to store the search space

                int no_GeneBit;

                int Mutation_Mode;                                      //different mutation mode

                double Mutation_Rate;

                int CrossOver_Mode;                                    //different crossover mode

                int no_CrossOver_Point;                              //number of crossover point

                double CrossOver_Rate;

                int Selection_Mode;                                       //different selection mode

                int Selection_TournamentSize;

                int cur_Population_Size;

                int nxt_Population_Size;

                double **cur_Population;                           //The array to store chromosome in current generation

                double **tmp_Population;                         //The array to temporary store chromosomes

                double **nxt_Population;                           //The array to store the chromosome in next generation

                double *cur_Fitness;

                double *tmp_Fitness;

                double *nxt_Fitness;

                double *Optimal_Chromosome;                              //pointer pointing to the optimal chromosome

                double Optimal_Fitness;

                int *Chromosome_Index;

                double *Chromosome_Fitness;

                double *Chromosome_SelectionPressure;

                double *Chromosome_Probability;

                double *Convergence;

                double *Diversity;

                double *Processing_Time;

                int no_Generation;                                                         //number of generation

} GeneticAlgorithm;

 

void GeneticAlgorithm_Construction(GeneticAlgorithm *cur_GA, int no_dimension, int cur_population_size, int nxt_population_size, double crossover_rate, double mutation_rate);

input:    cur_GA (The address of the GA currently used)

                no_dimension (The number of dimension used in this GA)

                cur_population_size (The population size of this GA)

                nxt_population_size (How many chromosomes will be generated)

                crossover_rate (The rate of crossover used in this GA)

                mutation_rate (The rate of mutation used in this GA)

The function is used to build a new GA structure by the given data. The new structure will be build in the cur_GA.

 

void GeneticAlgorithm_Destruction(GeneticAlgorithm *cur_GA);

input:    cur_GA (The address of the GA currently used)

This function is used to destroy the GA.

 

void GeneticAlgorithm_Selection_Standard_Elitism(GeneticAlgorithm *GA_Info);

Input:    GA_Info (The GA currently using)

This function is the standard elitism selection. The parents and their child will be place together and sort by fitness. Chromosomes ranks within the size of population will be selected as next generation.

 

void GeneticAlgorithm_UnConstraint_CrossOver_Uniform(double *Parent_1, double *Parent_2, double **Child_1, double **Child_2, int no_Dimension, double crossover_rate);

Input:    Parent_1, Parent_2        (Two parents for crossover)

                Child_1, Child_2                (Two child by crossover)

                No_Dimension                  (number of dimension used in this GA)

                Crossover_rate                 (The rate to crossover)

This function is uniform crossover, for each element in the parents, a number will be chosen randomly, if the number is larger than the crossover rate, swap that elements, otherwise just copy that element into the child.

 

void GeneticAlgorithm_UnConstraint_Mutation_RealCode_Uniform(double *Parent, double **Child, double **SearchSpace, int no_Dimension, double Mutation_Rate, int mode);

Input:    Parent  (The parent for mutation)

                Child      (The result of mutation)

                SearchSpace (The search space for mutation)

                No_Dimension  (The number of dimension used in this GA)

                Mutation_Rate (The variance step size)

                Mode (the mode of the mutation, 0 = result in integer, 1 = result in double)

This function is used to mutate the parents to other place in the search space with the variance step size.

 

void GeneticAlgorithm_UnConstraint_Mutation_RealCode_Gaussian(double *Parent, double **Child, double **SearchSpace, int no_Dimension, double Mutation_Rate, int mode);

Input:    Parent  (The parent for mutation)

                Child      (The result of mutation)

                SearchSpace (The search space for mutation)

                No_Dimension  (The number of dimension used in this GA)

                Mutation_Rate (The variance step size)

                Mode (the mode of the mutation, 0 = result in integer, 1 = result in double)

This function is following Gaussian distribution to mutate the parents to other place in the search space with the variance step size.

 

void GeneticAlgorithm_UnConstraint_Standard(GeneticAlgorithm *cur_GA, int optimization_mode, int terminate_mode, double terminate_parameter, double (*fn_ptr)(double *chromosome));

input:    cur_GA                 (The current GA)

                optimization_mode        (mode: 0 = Minization, 1= Maximization)

                terminate_mode             (mode:   0 = fixed generation, parameter = max. no. of iteration

 1 = fixed accuracy, parameter = target accuracy

 2 = fitness improvement, delta improvement)

                terminate_parameter   (The parameter)

                (*fn_ptr)(double *chromosome)  (The function pointer,

This function is the Standard Genetic Algorithm. In every generation, crossover will be occur (population size) /2 times of crossover and generate 2 childs. It will call arithmetic crossover, uniform crossover and point crossover when the number of crossover point equals to -1, 1 and larger than 1 respectively. After crossover, it will call uniform mutation and proportional selection.

 

 

Back to main page