0% found this document useful (0 votes)
38 views6 pages

Figure Above: Biological Inspiration of Genetic Algorithm

Genetic algorithms are optimization algorithms inspired by natural selection and genetics. They work on a population of potential solutions applying operators like selection, crossover, and mutation to generate new solutions. To solve the knapsack problem using a genetic algorithm, potential solutions are represented as binary strings where each bit corresponds to an item. An initial population of random solutions is generated. A fitness function evaluates each solution based on the value of selected items without exceeding the knapsack weight capacity. Genetic operators like crossover and mutation are applied to breed new solutions, and the process repeats until a termination condition is reached.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views6 pages

Figure Above: Biological Inspiration of Genetic Algorithm

Genetic algorithms are optimization algorithms inspired by natural selection and genetics. They work on a population of potential solutions applying operators like selection, crossover, and mutation to generate new solutions. To solve the knapsack problem using a genetic algorithm, potential solutions are represented as binary strings where each bit corresponds to an item. An initial population of random solutions is generated. A fitness function evaluates each solution based on the value of selected items without exceeding the knapsack weight capacity. Genetic operators like crossover and mutation are applied to breed new solutions, and the process repeats until a termination condition is reached.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Figure above : Biological Inspiration of Genetic Algorithm

Figure above : Process of Genetic Algorithm


Figure above : Natural selection of beetles Darwin theory of Evolution
Q3. What do you optimize in genetic algorithm and how do you optimise?
Answer-: Genetic Algorithms (GAs) are search based algorithms based on the concepts of natural
selection and genetics. GAs are a subset of a much larger branch of computation known as Evolutionary
Computation. Genetic Algorithm is analogous to the population for human beings except that instead of
human beings, we have Candidate Solutions representing human beings.

1. Chromosomes − A chromosome is one such solution to the given problem.


2. Gene − A gene is one element position of a chromosome.
3. Allele − It is the value a gene takes for a particular chromosome.
4. Genotype : Genotype is the population in the computation space. In the computation space,
the solutions are represented in a way which can be easily understood and manipulated using a
computing system.
5. Phenotype : Phenotype is the population in the actual real world solution space in which
solutions are represented in a way they are represented in real world situations.
6. Decoding and Encoding :For simple problems, the phenotype and genotype spaces are the
same. However, in most of the cases, the phenotype and genotype spaces are different.
Decoding is a process of transforming a solution from the genotype to the phenotype space,
while encoding is a process of transforming from the phenotype to genotype space. Decoding
should be fast as it is carried out repeatedly in a GA during the fitness value calculation. For
example, consider the 0/1 Knapsack Problem. The Phenotype space consists of solutions which
just contain the item numbers of the items to be picked. However, in the genotype space it can
be represented as a binary string of length n (where n is the number of items). A 0 at position x
represents that xth item is picked while a 1 represents the reverse. This is a case where
genotype and phenotype spaces are different.

7. Fitness Function : A fitness function simply defined is a function which takes the solution as
input and produces the suitability of the solution as the output. In some cases, the fitness function and
the objective function may be the same, while in others it might be different based on the problem.

8. Genetic Operators :These alter the genetic composition of the offspring. These include
crossover, mutation, selection, etc.
Q4.Demonstrate implementation of strategy of different phases involved in genetic
algorithm.
Answer-: The genetic algorithm is an optimization algorithm inspired by the biological
evolution process. Five phases are considered in a genetic algorithm:
a. Initial population
b. Fitness function
c. Selection
d. Crossover
e. Mutation
Initial Population: This process begins with a group of individuals called a Population. Each
individual is a solution to the problem they want to solve. Individuals are characterized by a set
of parameters (variables) called genes. Genes are joined into a string to form chromosomes
(solutions). In a genetic algorithm, an individual's gene set is represented by a string. Binary
values are usually used (strings of 1's and 0's). We say that chromosomes encode genes.
Fitness Function: A fitness function determines an individual’s fitness (the ability to compete
with others). This will give you a fitness score for each individual. An individual's likelihood of
being selected for reproduction is based on its fitness score.
Selection: The idea of the selection stage is to select the most suitable individuals and pass their
genes on to the next generation. Based on the fitness score he will be selected two pairs of
individuals (parents). Individuals with higher fitness are more likely to be selected for
reproduction.
Reproduction : Generation of offspring happen in 2 ways :
I. Crossover: Crossover is the most important phase in genetic algorithms. Crossovers are
randomly chosen within the gene of each pair of mating parents. There are three major
types of crossover : 1.Single point crossover 2.Two point crossover 3.Uniform
crossover
II. Mutation: Certain newly formed offspring have a low probability of mutating part of the
gene. This means that some bits in a bitstring can be flipped.

Q5. Give a road map how genetic algorithm can be applied to solve a problem Knapsack
Problem(0/1)?
Answer-: Creating one a generation after another continuous until we hit a termination
condition. Post which fittest solution is our high-quality solution to the problem. We take the
example of the knapsack problem and then to solve it using genetic algorithm.
Knapsack using Genetic Algorithm: We have a knapsack that cam hold 15 kg of weight at max.
We have 4 items A, B, C and D; having weights of 7kg, 2 kg, 1 kg ad 9kg and values $5, $4, $7
and $2 respectively. Lets see how we find high-quality solution to this knapsack problem using
Genetic Algorithm and understand each step of it.
Individual Representation: An individual in the Genetic Algorithm is a potential solution. We
first find a way to represent it such that it allows us to evolve. For our knapsack problem, this
representation pretty simple and straightforward; every individual is an n-bit string where each
bit correspond to an item from the n items we have.
Picking individuals: Every single individual is a potential solution to the knapsack problem.
Hence, for the knapsack problem, from a search space of 2πm,we pick a few individuals
randomly.
Fitness Coefficient: The fitness coefficient of an individual completely depends on the problem
at hand, if and if implemented poorly or incorrectly, it can result in misleading data or
inefficiencies. The value the fitness coefficient typically lies in the range 0 to 1 but not a
mandate.
For our, knapsack problem, we can define the fitness co-efficient of an individual as the
summation of the values of the items picked in the knapsack as per the bit string of the total
weight of the picked items is less than the weight knapsack can hold. The fitness coefficient of
an individual is 0 if the total weight of the item picked is greater than the weight that the
knapsack can hold.

You might also like