0% found this document useful (0 votes)
69 views

GA Demystified: Workshop On Soft and Evolutionary Computing

The document describes the steps of a genetic algorithm to compute the maximum value of the function y=Sin(x). The steps are: 1) Initialize a population of random binary strings, 2) Evaluate the fitness of each individual by converting to decimal, calculating x and y=Sin(x) values, 3) Select parents for reproduction using tournament selection, 4) Produce offspring from parents using single-point crossover, replacing the worst individuals to form a new population. The process is repeated until an optimal solution is found.

Uploaded by

Naveen Deepak
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)
69 views

GA Demystified: Workshop On Soft and Evolutionary Computing

The document describes the steps of a genetic algorithm to compute the maximum value of the function y=Sin(x). The steps are: 1) Initialize a population of random binary strings, 2) Evaluate the fitness of each individual by converting to decimal, calculating x and y=Sin(x) values, 3) Select parents for reproduction using tournament selection, 4) Produce offspring from parents using single-point crossover, replacing the worst individuals to form a new population. The process is repeated until an optimal solution is found.

Uploaded by

Naveen Deepak
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/ 10

GA Demystified

Workshop on Soft and Evolutionary Computing Indian Institute of Space Science and Technology 19-21 December 2011

Genetic Algorithm

Compute the maximum value of the function y=Sin(x)

Workshop on Soft and Evolutionary Computing, IIST, 19-21 December 2011

Genetic Algorithm
Step 1 : Initialization (Population Size : 10) 1
0 1
.. 1

2
0 1
.. 0

3
1 0
.. 0

4
1 1
.. 1

5
0 1
.. 1

6
1 1
.. 0

7
0 1
.. 1

8
1 0
.. 0

10

11

pop_size=10; population=rand(pop_size,8)-0.5; population=hardlim(population);

Workshop on Soft and Evolutionary Computing, IIST, 19-21 December 2011

Genetic Algorithm
Step 2 : Function Evaluation 1
0 1
.. 1

2
0 1
.. 0

3
1 0
.. 0

4
1 1
.. 1

5
0 1
.. 1

6
1 1
.. 0

7
0 1
.. 1

8
1 0
.. 0

9
53 222
.. 154

10

11

.. population=hardlim(population); population(:,9)=bin2dec(num2str(population(:,1:8))); ..

Workshop on Soft and Evolutionary Computing, IIST, 19-21 December 2011

Genetic Algorithm
Step 2 : Function Evaluation 1
0 1
.. 1

2
0 1
.. 0

3
1 0
.. 0

4
1 1
.. 1

5
0 1
.. 1

6
1 1
.. 0

7
0 1
.. 1

8
1 0
.. 0

9
53 222
.. 154

10
-1.84 2.33
.. 0.65

11
-0.96 0.73
.. 0.61

.. population(:,9)=bin2dec(num2str(population(:,1:8))); population(:,10)=((population(:,9))/255-0.5)*2*pi; population(:,11)=sin(population(:,10)); ..


Workshop on Soft and Evolutionary Computing, IIST, 19-21 December 2011

Genetic Algorithm
Step 3 : Selection (Tournament Selection) 1
0 1
.. 1

2
0 1
.. 0

3
1 0
.. 0

4
1 1
.. 1

5
0 1
.. 1

6
1 1
.. 0

7
0 1
.. 1

8
1 0
.. 0

9
53 222
.. 154

10
-1.84 2.33
.. 0.65

11
-0.96 0.73
.. 0.61

.. population(:,11)=sin(population(:,10)); pop1=ceil(rand*pop_size); pop2=ceil(rand*pop_size); ..


Workshop on Soft and Evolutionary Computing, IIST, 19-21 December 2011

Genetic Algorithm
Step 3 : Selection (Tournament Selection) 1
0 1
.. 1

2
0 1
.. 0

3
1 0
.. 0

4
1 1
.. 1

5
0 1
.. 1

6
1 1
.. 0

7
0 1
.. 1

8
1 0
.. 0

9
53 222
.. 154

10
-1.84 2.33
.. 0.65

11
-0.96 0.73
.. 0.61

.. pop2=ceil(rand*pop_size); parent1=population(pop1,:); parent2=population(pop2,:); ..


Workshop on Soft and Evolutionary Computing, IIST, 19-21 December 2011

Genetic Algorithm
Step 4 : Crossover (Single point) 1
1

2
0

3
0

4
1

5
1

6
0

7
1

8
0

10

11

.. parent2=population(pop2,:); cross_loc=ceil(rand*8); ..

Workshop on Soft and Evolutionary Computing, IIST, 19-21 December 2011

Genetic Algorithm
Step 4 : Crossover (Single point) 1
1

2
0

3
0

4
1

5
1

6
1

7
0

8
1

10

11

.. cross_loc=ceil(rand*8); child1=[parent1(1:cross_loc-1) parent2(cross_loc:8)]; child2=[parent2(1:cross_loc-1) parent1(cross_loc:8)]; ..


Workshop on Soft and Evolutionary Computing, IIST, 19-21 December 2011

Genetic Algorithm
Step 4 : Crossover (Single point) 1
1

2
0

3
0

4
1

5
1

6
1

7
0

8
1

10

11

.. cross_loc=ceil(rand*8); child1=[parent1(1:cross_loc-1) parent2(cross_loc:8)]; child2=[parent2(1:cross_loc-1) parent1(cross_loc:8)]; ..


Workshop on Soft and Evolutionary Computing, IIST, 19-21 December 2011

You might also like