matlab program for comparison and loop
Show older comments
Chromosome[1] = [12;05;23;08] Chromosome[2] = [02;21;18;03] Chromosome[3] = [10;04;13;14] Chromosome[4] = [20;01;10;06] Chromosome[5] = [01;04;13;19] Chromosome[6] = [20;05;17;01]
R[1] = 0.201 R[2] = 0.284 R[3] = 0.099 R[4] = 0.822 R[5] = 0.398 R[6] = 0.501
C[1] = 0.1254 C[2] = 0.2710 C[3] = 0.4118 C[4] = 0.6639 C[5] = 0.7882 C[6] = 1.0
i want to write a simple matlab program in which i have to compare the r(k) with value of c(k) if r(k) lies within the range of c(k) then it will return chromosome of that particular k. actually it is part of genetic algorithm i have write 30% program but i am confused at roulette stage how to write it.
the response of the above program must return the following output.
Chromosome[1] = [02;21;18;03] Chromosome[2] = [10;04;13;14] Chromosome[3] = [12;05;23;08] Chromosome[4] = [20;05;17;01] Chromosome[5] = [10;04;13;14] Chromosome[6] = [20;01;10;06]
manual calculation are as follow.
as r1=0.201 doesnot lie in the range of c1=0.125 (c1<r1), so we move forward and compare it with next, means with c2. as r1=0.201<c2 = 0.2710 it means it must replace chromosome of 1 with 2.
following is the table of replacement.
NewChromosome[1] = Chromosome[2] NewChromosome[2] = Chromosome[3] NewChromosome[3] = Chromosome[1] NewChromosome[4] = Chromosome[6] NewChromosome[5] = Chromosome[3] NewChromosome[6] = Chromosome[4]
Accepted Answer
More Answers (0)
Categories
Find more on Genetic Algorithm in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!