2. Genetic Algorithms
•Genetic Algorithms are part of evolutionary computing.
•Genetic Algorithm (GA) is a search-based optimization technique based on the principles
of Genetics and Natural Selection. It is frequently used to find optimal or near-optimal solutions
to difficult problems which otherwise would take a lifetime to solve.
• Optimization is the process of making something better. In any process, we have a set of inputs
and a set of outputs
•Optimization refers to finding the values of inputs in such a way that we get the “best” output
values.
•The definition of “best” varies from problem to problem, but in mathematical terms, it refers to
maximizing or minimizing one or more objective functions, by varying the input parameters.
3. Search Space
If We are solving some problem, we are usually looking for solutions best among others.
The space of all feasible solutions is called Search Space( State space).
Each point in the Search space represent one feasible solution. Each feasible solution can be
marked by its value of fitness for the problem.
Various techniques to find suitable solution are Hill Climbing, Best-First Search etc.
The solution is often considered as good solution because it is not possible to prove what is real
optimum.
NP-Hard Problems are kind of difficult problems which cannot be solved by traditional way.
It is difficult to find solution but once we have it, it is easy to check the solution. This fact led to
NP-Complete Problem.
4. Search Space(contd.)
NP- means Non-Deterministic Polynomial
It means that it is possible to guess the solution( by some non-deterministic algorithm) and
then check it, both in polynomial time.
NP-Complete problems are of type for which answer is simply ‘Yes’ or ‘No’.
The problems with complicated outputs are called NP-Hard problems.
To find a solution, simply try all the alternatives but this is very slow and sometimes not
usable at all.
Genetic Algorithms are alternative method to solve NP-Problem. E.g. Travelling Salesman
Problem
5. Principle behind Genetic Algorithms
•SELECT THE BEST, DISCARD THE REST
•It is based on Darwin’s principle of natural selection.
• If there are Organisms that reproduce, and
• If Offsprings inherit traits from there progenitors, and
• If there is variability of traits, and
• If the environment cannot support all members of a growing population,
• Then those members of the population with less adaptive traits( determined by the
environment) will die out, and
• Those members with more adaptive traits( determined by the environment ) will thrive.
• The Result is evolution of Species.
6. Evolution through Natural Selection
Initial Population of Animals
Struggle for existence, survival of the fittest
Surviving individuals reproduce, propagate favourable characteristics
Millions of Years
Evolved Species
[Favourable characteristic now a trait of Species.]
7. Nature to Computer Mapping
NATURE
Population
Individual
Fitness
Chromosome
Gene
Reproduction
COMPUTER
Set Of Solutions
Solution to a Problem
Quality of a Solution
Encoding for a Solution
Part of encoding
Crossover
8. Requirements to implement Genetic
Algorithm
Two important elements required for any problem before a genetic algorithm can be used for a solution are
•Method for representing a solution ex: a string of bits, numbers, character ex: determination total weight.
•Method for measuring the quality of any proposed solution, using fitness function.
Basi
9. GA
Genetic Algorithm is started with a set of solutions(represented by Chromosomes) called
population.
Solutions from one Population are taken and used to form a new population.( This is motivated
by hope that the new population will be better than the old one)
Solutions which are selected to form new solutions(Offsprings) are selected according to their
fitness value( the more suitable they are, the more chances they have to reproduce.)
This process is repeated until some condition is satisfied. E.g. No of Populations or improvement
of the best solution.
10. Genetic Algorithm
Step 1- [START] Generate random population of n Chromosomes i.e. suitable solutions to the
problem.
Step 2- [Fitness] Evaluate the fitness f(x) of each Chromosome x in the Population.
Step 3-[New Population] Create a new population by repeating following steps until the new
population is complete.
◦ (a) [Selection] Select two parent Chromosomes from a Population according to their
fitness.(the better fitness, the bigger chances to be selected)
◦ (b)[Crossover] With a crossover probability, cross over the parents to form a new
offspring(children). If no crossover was performed, offspring is an exact copy of parents.
◦ ( c)[Mutation] With a mutation probability, mutate new offspring at each locus( position in
chromosome)
11. Genetic Algorithm(contd.)
◦ ( d)[Accepting] Place new offspring in a new Population.
Step 4- [Replace] Use new generated population for a further run of algorithm.
Step 5- [Test] If the end condition is satisfied, Stop, and return the best Solution in current
Population.
Step 6- [Loop] Go To Step 2.