Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

ClassNotes SCT 1 Sept

Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

Genetic Algorithms

What are GAs ?

• Genetic Algorithms (GAs) are adaptive heuristic search algorithm based on the
evolutionary ideas of natural selection and genetics.

• Genetic algorithms (GAs) are a part of Evolutionary computing, a rapidly growing area of
artificial intelligence. GAs are inspired by Darwin's theory about evolution - "survival of
the fittest".

• GAs represent an intelligent exploitation of a random search used to solve optimization


problems.

• GAs, although randomized, exploit historical information to direct the search into
the region of better performance within the search space.

• In nature, competition among individuals for scanty resources results in the fittest
individuals dominating over the weaker ones.
• Introduction

Solving problems mean looking for solutions, which is best among others. Finding the

solution to a problem is often thought:

− In computer science and AI, as a process of search through the space of possible
solutions. The set of possible solutions defines the search space (also called state space)
for a given problem. Solutions or partial solutions are viewed as points in the search
space.

− In engineering and mathematics, as a process of optimization. The problems are first


formulated as mathematical models expressed in terms of functions and then to find a
solution, discover the parameters that optimize the model or the function components
that provide optimal system performance.

• Why Genetic Algorithms?

It is better than conventional AI; it is more robust.

 unlike older AI systems, the GA's do not break easily even if the inputs

changed slightly, or in the presence of reasonable noise.

 while performing search in large state-space, multi-modal state-space, or n-


dimensional surface, a genetic algorithms offer significant benefits over many
other typical search optimization techniques like - linear programming,
heuristic, depth-first, breath-first.

"Genetic Algorithms are good at taking large, potentially huge search spaces and
navigating them, looking for optimal combinations of things, the solutions one might not
otherwise find in a lifetime.” Salvatore Mangano Computer Design, May 1995.
■ Biological Background – Basic Genetics

Every organism has a set of rules, describing how that organism is built. All
living organisms consist of cells.

In each cell there is same set of chromosomes. Chromosomes are strings of


DNA and serve as a model for the whole organism.
A chromosome consists of genes, blocks of DNA.

Each gene encodes a particular protein that represents a trait


(feature), e.g., color of eyes.

Possible settings for a trait (e.g. blue, brown) are called alleles. Each gene has

its own position in the chromosome called its locus.

Complete set of genetic material (all chromosomes) is called a


genome.

Particular set of genes in a genome is called genotype.

The physical expression of the genotype (the organism itself after birth) is called the
phenotype, its physical and mental characteristics, such as eye color, intelligence
etc.

When two organisms mate they share their genes; the resultant offspring may end
up having half the genes from one parent and half from the other. This process is
called recombination (cross over) .

The new created offspring can then be mutated. Mutation means, that the elements
of DNA are a bit changed. This changes are mainly caused by errors in copying genes
from parents.
The fitness of an organism is measured by success of the organism in its life
(survival).

Darwin’s Principle

 IF there are organisms that reproduce, and


 IF offsprings inherit traits from their 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
 THEN those members with more-adaptive traits (determined by the
environment) will thrive

The result is the evolution of species

Initial Population Of Animals

Struggle For Existence-Survival Of the Fittest

Surviving Individuals Reproduce, Propagate Favorable


Characteristics

Millions Of Years

Evolved Species
Nature Computer

Population Set of solutions.


Individual Solution to a problem.
Fitness Quality of a solution.
Chromosome Encoding for a Solution.
Gene Part of the encoding of a solution.
Reproduction Crossover

Begin

Initialize
population

Eva t=0e Solution

N
Optim
um
Selection

T=T+1 Stp Crossover

Mutation
Below shown, the general scheme of evolutionary process in genetic along with pseudo-
code.

Pseudo-Code

BEGIN

INITIALISE population with random candidate solution.

EVALUATE each candidate;

REPEAT UNTIL (termination condition ) is satisfied DO

■ SELECT parents;

■ RECOMBINE pairs of parents;

■ MUTATE the resulting offspring;

■ SELECT individuals or the next generation;

END.

Simple_Genetic_Algorithm()
{
Initialize the Population; Calculate Fitness Function;

While(Fitness Value != Optimal Value)


{
Selection;//Natural Selection, Survival Of Fittest
Crossover;//Reproduction, Propagate favorable
characteristics

Mutation;//Mutation Calculate Fitness Function;


}
}
• Search Space

In solving problems, some solution will be the best among others. The space of all
feasible solutions (among which the desired solution

resides) is called search space (also called state space).

− Each point in the search space represents one possible solution.

− Each possible solution can be "marked" by its value (or fitness) for the problem.

− The GA looks for the best solution among a number of possible solutions
represented by one point in the search space.

− Looking for a solution is then equal to looking for some extreme value (minimum or
maximum) in the search space.

− At times the search space may be well defined, but usually only a few points in the
search space are known.

In using GA, the process of finding solutions generates other points (possible
solutions) as evolution proceeds.
Working Principal
Before getting into GAs, it is necessary to explain few terms.

− Chromosome: a set of genes; a chromosome contains the solution in form of


genes.

− Gene: a part of chromosome; a gene contains a part of solution. It determines


the solution. e.g. 16743 is a chromosome and 1, 6, 7, 4 and 3 are its genes.

− Individual: same as chromosome.

− Population: number of individuals present with same length of


chromosome.

− Fitness: the value assigned to an individual based on how far or close a individual is
from the solution; greater the fitness value better the solution it contains.

− Fitness function: a function that assigns fitness value to the individual. It is problem
specific.

− Breeding: taking two fit individuals and then intermingling there chromosome to

create new two individuals.

− Mutation: changing a random gene in an individual.

− Selection: selecting individuals for creating the next generation.


Genetic algorithm begins with a set of solutions (represented by
chromosomes) called the population.

− Solutions from one population are taken and used to form a new population. This is
motivated by the possibility that the new population will be better than the old one.

− Solutions are selected according to their fitness to form new solutions (offspring);
more suitable they are, more chances they have to reproduce.

− This is repeated until some condition (e.g. number of populations or


improvement of the best solution) is satisfied.
■ Outline of the Basic Genetic Algorithm

[Start] Generate random population of n chromosomes (i.e. suitable solutions for


the problem).

[Fitness] Evaluate the fitness f(x) of each chromosome x in the population.

[New population] Create a new population by repeating following steps until the
new population is complete.

[Selection] Select two parent chromosomes from a population according to


their fitness (better the fitness, bigger the chance to be selected)

[Crossover] With a crossover probability, cross over the parents to form new
offspring (children). If no crossover was performed, offspring is the exact copy
of parents.

[Mutation] With a mutation probability, mutate new offspring at each locus

(position in chromosome).

(d) [Accepting] Place new offspring in the new population

• [Replace] Use new generated population for a further run of the algorithm

• [Test] If the end condition is satisfied, stop, and return the best solution in
current population

• [Loop] Go to step 2

Note : The genetic algorithm's performance is largely influenced by two operators called
crossover and mutation. These two operators are the most important parts of GA.
Encoding Techniques

Before a genetic algorithm can be put to work on any problem, a method is needed to encode
potential solutions to that problem in a form so that a computer can process.

− One common approach is to encode solutions as binary strings: sequences of 1's and 0's,
where the digit at each position represents the value of some aspect of the solution.
Example :

A Gene represents some data (eye color, hair color, sight, etc.).

a Gene looks like : (11100010)


a Chromosome looks like: Gene1 Gene2 Gene3 Gene4

(11000010, 00001110, 001111010, 10100011)

A chromosome should in some way contain information about solution which it


represents; it thus requires encoding. The most popular way of encoding is a binary
string like:

Chromosome 1: 1101100100110110

Chromosome 2: 1101111000011110

Each bit in the string represents some characteristics of the solution.

− There are many other ways of encoding, e.g., encoding values as integer or real numbers
or some permutations and so on.
− The virtue of these encoding method depends on the problem to work on .

You might also like