Genetic Algorithm - Introduction
• The genetic algorithm is a method for
solving optimization problems that mimic some of the processes observed in
natural evolution.
• Genetic algorithms in particular
became popular through the work of John Holland in the early 1970s, and
particularly his book Adaptation in Natural and Artificial Systems
(1975).
• GA
is based on ideas from Darwinian Evolution theory of “Survival of the
fittest”.
• The genetic algorithm repeatedly
modifies a population of individual solutions.
• At each step, the genetic algorithm
selects individuals at random from the current population to be parents and uses
them to produce the children for the next generation. Over successive
generations, the population "evolves" toward an optimal solution.
• The genetic algorithm uses three
main types of rules at each step to create the next generation from the current
population:
• Selection rules select the individuals, called parents,
that contribute to the population at the next generation.
• Crossover rules combine two parents to form
children for the next generation.
• Mutation rules apply random changes to individual
parents to form children.
Biological Background
• Each
cell of a living organisms contains chromosomes - strings of DNA
• Each
chromosome contains a set of genes - blocks of DNA
• A collection of genes – genotype
• A collection of aspects (like eye colour) – phenotype
• Reproduction involves recombination of genes
from parents.
• The fitness of an organism is
how much it can reproduce before it dies.
Search Space
• A population of individuals are
maintained within search space for a GA, each representing a possible
solution to a given problem.
• Each individual is coded as a
finite length vector of components, or variables, in terms of some alphabet,
usually the binary alphabet {0,1}.
• To continue the genetic analogy,
these individuals are likened to chromosomes and the variables are analogous to
genes.
• Thus, a chromosome (solution) is
composed of several genes (variables).
• A fitness score is assigned
to each solution representing the abilities of an individual to `compete'.
• The individual with the optimal (or
generally near optimal) fitness score is sought.
• The GA aims to use selective
`breeding' of the solutions to produce `offspring' better than the parents by
combining information from the chromosomes.
Implementation Details
After
an initial population is randomly generated, the algorithm evolves the through
three operators:
- selection which equates to survival of
the fittest;
- crossover which represents mating
between individuals;
- mutation which introduces random
modifications.
Selection
Operator
• key idea: give preference to better
individuals, allowing them to pass on their genes to the next generation.
• The goodness of each individual
depends on its fitness.
• Fitness may be determined by an
objective function or by a subjective judgement.
Crossover
Operator
• Two individuals are chosen from the
population using the selection operator.
• A crossover site along the bit
strings is randomly chosen.
• The values of the two strings are
exchanged up to this point.
• If S1=000000 and S2=111111 and the crossover point is 2 then S1'=110000 and S2'=001111.
• The two new offspring created from
this mating are put into the next generation of the population.
• By recombining portions of good
individuals, this process is likely to create even better individuals.
Mutation Operator
• With some low probability, a
portion of the new individuals will have some of their bits flipped.
• Its purpose is to maintain
diversity within the population and inhibit premature convergence.
• Mutation alone induces a random
walk through the search space.
• Mutation and selection (without
crossover) create a parallel, noise-tolerant, hill-climbing algorithms.
Termination
• This generational process is
repeated until a termination condition has been reached. Common terminating
conditions are:
• A solution is found that satisfies
minimum criteria.
• Fixed number of generations
reached.
• Allocated budget (computation
time/money) reached.
• The highest-ranking solution's
fitness is reaching or has reached a plateau such that successive iterations no
longer produce better results.
• Manual inspection Combinations of
the above.
Figure 1: Flow Chart of GA
Pseudo-Code
A
generalized pseudo-code for a GA is explained in the following program −
GA()
initialize population
find fitness of population
while (termination criteria is reached)
do
parent selection crossover with
probability pc
mutation with probability pm
decode and fitness calculation
survivor selection
find best
return best
A Genetic Algorithm
Example
• As a simple example, imagine a
population of four strings, each with five bits.
• Also imagine an objective function f(x)=2x.
• The goal is to optimize (in this case maximize) the objective function over the domain 0 ≤
• Now imagine a population of the
four strings in Table 1, generated at random before GA execution.
• The corresponding fitness values
and percentages come from the objective function f(x).
Table 1 Four strings and their fitness values
- The values in the
column provide the probability of each string's selection.
• So initially 11000 has a 38.1%
chance of selection, 00101 has an 7.9% chance, and so on.
• The results of the selections are
given in the “Actual Count” column of Table 1.
• As expected, these values are
similar to those in the “Expected Count” column.
• After selecting the strings, the GA
randomly pairs the newly selected members and looks at each pair individually.
• For each pair (e.g. A = 11000
and B = 10110), the GA decides whether or not to perform
crossover.
• If it does not, then both strings
in the pair are placed into the population with possible mutations (described
later).
• If it does, then a random crossover
point is selected, and crossover proceeds as follows: A = 1 1 | 0 0 0
• B
= 1 0 | 1 1 0
• are crossed and become A' =
1 1 1 1 0 B' = 1 0 0 0 0.
• Then the children A' and B'
are placed in the population with possible mutations.
• The GA invokes the mutation operator on the new bit strings very rarely (usually on the order of ≤0.01 probability), generating a random number for each bit and flipping that particular bit only if the random number is less than or equal to the mutation probability.
• After the current generation's selections,
crossovers, and mutations are complete, the new strings are placed in a new
population representing the next generation, as shown in Table 2.
• In this example generation, average
fitness increased by approximately 30% and maximum fitness increased by 25%.
• This simple process would continue
for several generations until a stopping criterion is met.
Table 2 The population after selection and crossover

Applications
Automotive design
• In designing composite materials
and aerodynamic shapes for race cars and regular means of transportation
(including aviation) can return combinations of best materials and best
engineering to provide faster, lighter, more fuel efficient and safer vehicles.
• The process can be done much
quicker and more efficiently by computer modelling using GA searches to return
a range of options for human designers.

Engineering design
• To optimize the structural and
operational design of buildings, factories, machines, etc. is a rapidly
expanding application of Gas.
• Used to optimizing the design of heat
exchangers, robot gripping arms, satellite booms, building trusses, flywheels,
turbines, and just about any other computer-assisted engineering design
application.

Robotics
• Robotics involves human designers
and engineers trying out all sorts of things in order to create useful machines
that can do work for humans.
• GAs can be programmed to search for
a range of optimal designs and components for each specific use, or to return
results for entirely new types of robots that can perform multiple tasks and
have more general application.

Optimized
Telecommunications Routing
• GAs are being developed that it
will allow for dynamic and anticipatory routing of circuits for
telecommunications networks.
• These could take notice of your
system's instability and anticipate your re-routing needs.
• Optimize placement and routing of
cell towers for best coverage and ease of switching.

Trip, Traffic and
Shipment Routing
• Traveling Salesman Problem or TSP
can be used to plan the most efficient routes and scheduling for travel
planners, traffic routers and even shipping companies.
• The shortest routes for traveling
and the timing to avoid traffic tie-ups
and rush hours.
• GA contributed more to it than
the travel agent did.

• Computer Gaming
• Encryption and Code Breaking
• Computer Aided Molecular
Design
• Gene Expression Profiling
• Finance and Investment strategies
• Marketing and Merchandising
Python Implementation
Below is a Python implementation of a genetic algorithm to maximize the objective function for binary strings of length 5, representing numbers in the range . Four initial strings will be used as the starting population.
Explanation:
Initialization:
- The population consists of 4 random binary strings, each 5 bits long.
Fitness Function:
- The fitness is calculated as , where is the decimal value of the binary string.
Selection:
- Roulette wheel selection is used to choose parents based on their fitness.
Crossover:
- A single-point crossover is performed to generate offspring.
Mutation:
- Each bit in the offspring has a small probability (mutation rate) of flipping.
Iteration:
- The algorithm runs for a specified number of generations, maintaining a population size of 4.
Output:
- The binary string and its corresponding decimal value with the highest fitness are returned as the optimal solution.
This implementation includes debug output to track the best individual in each generation.
Comments
Post a Comment