Genetic algorithm optimization example

Genetic algorithm optimization example

Manual simulation calculation example of genetic algorithm

In order to better understand the operation process of the genetic algorithm, the following manual calculations are used to simply simulate the main execution steps of the genetic algorithm.
   
  
     Example: Find the maximum value of the following binary function:

    (1)
           The object of individual coding genetic algorithm is a symbol string representing an individual, so the variables x1, x2 must be encoded as a
       symbol string. In this question, it is represented by an unsigned binary integer.
           By x1, x2 is an integer between 0 and 7, respectively, thus represented by three unsigned binary integer, it
       is connected are 6-bit unsigned binary number composed together to form a genotype, showing a be
       feasible solution.
           For example, the phenotype corresponding to genotype X = 101110 is: x = [5, 6 ].
           Individual phenotype x and genotype X can be converted mutually through encoding and decoding procedures.

(2) The generation of the initial population. The
          genetic algorithm is an evolutionary operation on the population, and some initial
      population data representing the initial search point needs to be prepared for it .
         In this example, the size of the population is 4, that is, the population is composed of 4 individuals, and each individual can be
     generated by a random method.
          Such as: 011101, 101011, 011100, 111001
         
 (3) Fitness juice calculation In the
          genetic algorithm, the fitness of the individual is used to evaluate the pros and cons of each individual, thereby determining
       the size of their genetic opportunities.
          In this example, the objective function always takes a non-negative value, and the maximum value of the function is the optimization objective, so the
       objective function value can be directly used as the fitness of the individual.

 (4) Selection operation
          Selection operation (or copy operation) inherits the individuals with higher fitness in the current population into the next generation population according to a certain rule or model. It is generally required that individuals with higher fitness will have more chances to be passed on to the next generation
      .                   
In this example, we use a probability proportional to fitness to determine the number of individuals copied into the next-generation population
     . The specific operation process is:
         • First calculate the total fitness of all individuals in the group fi (i=1.2,…,M );
         • Secondly, calculate the relative fitness fi / fi of each individual. It It
             is the probability that each individual will be inherited into the next-generation population.
         • Each probability value forms a region, and the sum of all probability values ​​is 1;
         • Finally, a random number between 0 and 1 is generated, according to the random number which appears in the above probability area
             within each individual to determine the number of times selected.

(5) Crossover operation
        Crossover operation is the main process of generating new individuals in genetic algorithms. It exchanges
    some chromosomes between two individuals with a certain probability .
       In this example, the single-point crossover method is used. The specific operation process is:
       • first pair the population randomly;
       • randomly set the position of the crossover point;
       • finally exchange some genes between the paired chromosomes.

(6) mutation operation
         mutation operation is one or a few gene locus of individual values in accordance with a probability less into
     line change, it is also a method of operating a new generation of individuals.
        In this example, we use the basic bit mutation method to perform mutation calculation. The specific operation process is:
        • First determine the genetic mutation position of each individual. The following table shows the randomly generated mutation point position,
          and the number indicates the mutation. The point is set at the locus;
        • Then the original gene value of the mutation point is reversed according to a certain probability.

A new generation of population p(t+1) can be obtained after a round of selection, crossover and mutation operations are performed on the population P(t).

As it can be seen from the table, then evolved population after generation, the fitness of the maximum, average, had
    to significant improvements. In fact, the best individual "111111" has been found here.       
[Note] It      
        should be noted that the data in some columns in the table is randomly generated. In order to better illustrate the problem,
   we have deliberately selected some better values ​​in order to get better results. In the actual calculation process,
   it may take a certain number of cycles to achieve this optimal result.

Manual simulation calculation example of genetic algorithm

In order to better understand the operation process of the genetic algorithm, the following manual calculations are used to simply simulate the main execution steps of the genetic algorithm.
   
  
     Example: Find the maximum value of the following binary function:

    (1)
           The object of individual coding genetic algorithm is a symbol string representing an individual, so the variables x1, x2 must be encoded as a
       symbol string. In this question, it is represented by an unsigned binary integer.
           By x1, x2 is an integer between 0 and 7, respectively, thus represented by three unsigned binary integer, it
       is connected are 6-bit unsigned binary number composed together to form a genotype, showing a be
       feasible solution.
           For example, the phenotype corresponding to genotype X = 101110 is: x = [5, 6 ].
           Individual phenotype x and genotype X can be converted mutually through encoding and decoding procedures.

(2) The generation of the initial population. The
          genetic algorithm is an evolutionary operation on the population, and some initial
      population data representing the initial search point needs to be prepared for it .
         In this example, the size of the population is 4, that is, the population is composed of 4 individuals, and each individual can be
     generated by a random method.
          Such as: 011101, 101011, 011100, 111001
         
 (3) Fitness juice calculation In the
          genetic algorithm, the fitness of the individual is used to evaluate the pros and cons of each individual, thereby determining
       the size of their genetic opportunities.
          In this example, the objective function always takes a non-negative value, and the maximum value of the function is the optimization objective, so the
       objective function value can be directly used as the fitness of the individual.

 (4) Selection operation
          Selection operation (or copy operation) inherits the individuals with higher fitness in the current population into the next generation population according to a certain rule or model. It is generally required that individuals with higher fitness will have more chances to be passed on to the next generation
      .                   
In this example, we use a probability proportional to fitness to determine the number of individuals copied into the next-generation population
     . The specific operation process is:
         • First calculate the total fitness of all individuals in the group fi (i=1.2,…,M );
         • Secondly, calculate the relative fitness fi / fi of each individual. It It
             is the probability that each individual will be inherited into the next-generation population.
         • Each probability value forms a region, and the sum of all probability values ​​is 1;
         • Finally, a random number between 0 and 1 is generated, according to the random number which appears in the above probability area
             within each individual to determine the number of times selected.

(5) Crossover operation
        Crossover operation is the main process of generating new individuals in genetic algorithms. It exchanges
    some chromosomes between two individuals with a certain probability .
       In this example, the single-point crossover method is used. The specific operation process is:
       • first pair the population randomly;
       • randomly set the position of the crossover point;
       • finally exchange some genes between the paired chromosomes.

(6) mutation operation
         mutation operation is one or a few gene locus of individual values in accordance with a probability less into
     line change, it is also a method of operating a new generation of individuals.
        In this example, we use the basic bit mutation method to perform mutation calculation. The specific operation process is:
        • First determine the genetic mutation position of each individual. The following table shows the randomly generated mutation point position,
          and the number indicates the mutation. The point is set at the locus;
        • Then the original gene value of the mutation point is reversed according to a certain probability.

A new generation of population p(t+1) can be obtained after a round of selection, crossover and mutation operations are performed on the population P(t).

As it can be seen from the table, then evolved population after generation, the fitness of the maximum, average, had
    to significant improvements. In fact, the best individual "111111" has been found here.       
[Note] It      
        should be noted that the data in some columns in the table is randomly generated. In order to better illustrate the problem,
   we have deliberately selected some better values ​​in order to get better results. In the actual calculation process,
   it may take a certain number of cycles to achieve this optimal result.

Guess you like

Origin blog.csdn.net/weixin_45736522/article/details/107643525