SCOA Assignment 2
SCOA Assignment 2
Class: BE Comp
Roll No. 8027
Problem Statement
Implement genetic algorithm for benchmark function (eg. Square, Rosenbrock function etc). Initialize
the population from the Standard Normal Distribution. Evaluate the fitness of all its individuals. Then
you will do multiple generation of a genetic algorithm. A generation consists of applying selection,
crossover, mutation, and replacement.
Use:
• Tournament selection without replacement with tournament size s
• One point crossover with probability Pc
• bit-flip mutation with probability Pm
• use full replacement strategy.
Outcome
Understanding and implementation of genetic algorithms.
Software/Hardware Requirements: Python 3.7
Theory:
Genetic algorithms were introduced by John Holland at University of Michigan. Genetic
algorithms are adaptive heuristic search algorithms based on evolutionary ideas of natural
selection and genetics. Evolution by natural selection is based on principle of survival of the
fittest by Charles Darwin.
A genetic algorithm can efficiently explore a large space of candidate designs and find
optimum solutions.
When attempting to map natural evolution into the framework of artificial evolution, we
must first consider the “data” for the system. In nature, these data consist of living
creatures. Each individual represents a potential solution to the problem of survival.
Similarly, in genetic algorithms, we consider a set of potential solutions, which are referred
to collectively as a population
Each single solution is called an individual. Each individual in nature has a form determined
by its DNA. Its collection of genetic traits is commonly known as a genotype. In genetic
algorithms, the term genotype is used to describe the encoding of a problem solution
represented by an individual. Thus, each individual has a genotype, which encodes a
solution. Many individuals in a population may have the same or similar genotypes.
In the GA literature, an individual’s genotype is often referred to as its chromosome.
Genotypes in genetic algorithms are typically represented by strings, sometimes called bits
or characters. Each element of the string represents a gene, which is a single unit of genetic
information. In nature genes control, directly or indirectly, various traits in the individual.
For example, in humans there are genes to determine eye and hair colour, and genes for
determining other characteristics. It is important to note that in nature, several genes often
collectively determine a physical trait, and that they are not necessarily independent. This is
true in genetic algorithms as well, where a solution encoding may make use of several
interacting genes. Each gene has one or more possible values known as alleles. One can
imagine that humans have a hair colour gene with an allele for each colour: brown, blond,
black, red, etc. The reality in humans is far more complicated than this but it serves as an
illustration of the idea. The number of alleles for a specific gene is essentially fixed in nature,
and in artificial evolution it is determined by the encoding of solutions. The simplest genes
are binary, having only two alleles. This means they can be represented by a single bit.
However, some genes may have several alleles and are represented using characters. In
genetic algorithms, the number of genes in the genotypes for a particular problem is usually
fixed.
Since the genotype is intended to express a solution to a specific problem, the genes and
alleles must be designed for that problem and must express the various components of a
potential solution. The design of the genotype structure for a particular application is one of
the two most difficult and important parts of using genetic algorithms. Unfortunately, there
are no straightforward, general-purpose approaches. The task is highly dependent on the
problem and, in many cases, on the particular kind of genetic algorithm one wishes to
employ.
Code:
Output:
Conclusion: