You are on page 1of 4

Practical No.

10

Aim :-Genetic Algorithm (GA) for optimization of Multidimensional function

Objectives:-
1. Understanding of steps in Genetic Algorithm
2. Hyper parameters of Genetic Algorithm

Problem Statement:
Optimize (Minimization) of a continuous function x[0]^2+x[1]^2 that input variables and has
an optima at f(0, 0) = 0.0. Bounds (i.e. Range of inputs) provided for search are [-5,5] and
[-5,5]

Flow Chart for Genetic Algorithm

• Genetic Algorithm (GA) is a population-based probabilistic search and evolutionary


optimization technique, which works based on the mechanism of natural genetics and
Darwin's principle (Theory of Evolution) of natural selection with a binary
representation and simple operators based on genetic recombination and genetic
mutations.
• The GA was introduced by Prof. John Holland of the University of Michigan, Ann
Arbor, USA, in 1965, although his seminal book was published in 1975.
• It is basically an iterative search technique working based on the concept of
probability.

1
Fig-Flowchart of Genetic Algorithm

2
"Genetic algorithms borrow inspiration from biological evolution, where fitter individuals are
more likely to pass on their genes to the next generation."

• The algorithm uses analogs of a genetic representation (bitstrings), fitness (function


evaluations), genetic recombination (crossover of bitstrings), andmutation (flipping
bits).

• The algorithm works by first creating a population of a fixed size of randombitstrings.


The main loop of the algorithm is repeated for a fixed number of iterations or until no
further improvement is seen in the best solution over agiven number of iterations

• One iteration of the algorithm is like an evolutionary generation.

Initialize the Population:

➢ The algorithm works by first creating a population of a fixed size of random


bitstrings. The main loop of the algorithm is repeated for a fixed number of iterations
or until no further improvement is seen in the best solution over a given number of
iterations.

The fitness/goodness value Evaluation:

➢ First, the population of bitstrings (candidate solutions) are evaluated using the
objective function. The objective function evaluation for each candidate solution is
taken as the fitness of the solution, which may be minimized or maximized.

Reproduction:

• All the solutions in a population may not be equally good in terms of their fitness
values. An operator named reproduction (also known as selectionscheme) is utilized
to select the good solutions using their fitness values.
• Thus, it forms a mating pool consisting of good solutions probabilistically.
• It is important to note that the mating pool may contain multiple copies of aparticular
good solution.
• The size of the mating pool is kept equal to that of the population of
solutionsconsidered before reproduction.
• Thus, the average fitness of the mating pool is expected to be higher than thatof the
pre-reproduction population of solutions.

3
• There exists a number of reproduction schemes in the GA-literature, namely
proportionate selection such as Roulette-Wheel selection, tournament
selection,ranking selection, and others.

➢ For our optimization problem is a hyperparameter of tournament selection and set to a


value such as 3.

Crossover:

• The mating pairs (also known as the parents) are selected at random fromthe above
pool, which may participate in crossover depending on the value of crossover
probability.
• In crossover, there is an exchange of properties between the parents andas a result of
which, new children solutions are created.
• It is important to mention that if the parents are good, the children areexpected to be
good.
• Various types of crossover operators are available in the GA-literature, such as single-
point crossover, two-point crossover, multi-pointcrossover, uniform crossover, and
others.
• Crossover is controlled by a hyperparameter set to a large value, such as 80 percent or
90 percent.
Mutation:
• In biology, the word: mutation means a sudden change of parameter.
• For example, the crows are generally black in colour. However, if we could see a
white crow by chance, it might have happened due to a sudden change in parameter
on the gene level, which is known as biological mutation.
• In a GA-search, it is used for achieving a local change around thecurrent solution.
• Thus, if a solution gets stuck at the local minimum, this operator mayhelp it to come
out of this situation.
• Mutation involves flipping bits in created children candidate solutions.Typically, the
mutation rate is set to 1/1, where I. is the length of the bit string
• For example, if a problem used a bitstring with 20 bits, then a good default mutation
rate would be or a probability of 5 percent.

Algorithm Stopping Criteria:

• After the reproduction, crossover and mutation are applied to the whole population of
solutions, one generation of a GA iscompleted
• Different criteria may be used to terminate the program, such as the maximum
number of generations, a desired accuracy in thesolution, and others.

You might also like