How to frame a genetic algorithm for this problem?

  • Thread starter Thread starter zak100
  • Start date Start date
  • Tags Tags
    Algorithm Frame
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
3 replies · 2K views
zak100
Messages
462
Reaction score
11
Hi,
I have a random array which represents method calls. For instance: [3, 4, 7, 40, 39, ...] meaning that method 0 is called 3 times, method 1 is called 4 times, method 2 is called 7 times, method 3 is called 40 times, method 4 is called 39 times and so on upto n. Now consider a module as a collection of random methods from 1-5 and there are 20 such modules. Find out a module whose execution causes exercising maximum number of method calls with minimum number of method.

I have applied the genetic algorithm without considering the binary values and I have obtained the module which can have maximum method calls with minimum number of methods. The steps of my algorithm are:

Initial population Fitness function Selection

However, I have not applied the other two steps i.e. crossover and mutation. Some body please guide me how to apply these two steps in my algorithm. Also I am not using binary values. How to incorporate binary values in the data? Some body please guide me.

Zulfi.
 
Physics news on Phys.org
Mutation means that you select a random array from a collection of random arrays (think each random array a string of letters) and then you alter one or more of its elements like you increase the count or zero one count and bump another like selectively changing the letters of the string

from xxxxxxxxxx to xxYxxxZxxxxAxx the capital letters represent the mutations

For crossover, you select two random arrays from your collection of random array solutions and mate them together by swapping selected elements between them. You can use a random number generator to select indices of elements to swap.

array 1: aaabbbcccddd
array 2: AAABBBCCCDDD

new array aAAbbbCCcDdD

The mutated and crossover arrays along with the original solutions become a part of your solution pool to try out for the next cycle. Their scores determine whether they remain or are tossed out.
 
Hi,
Thanks for your information. But Mutation would increase the population. I have to find the largest generation. What is the method of discarding the population. I can use fittest function but then I won't be able to incorporate mutation and cross over concepts. I want to use the concepts of Mutation and cross over but to discard the population so that I would be left with only largest genes or near largest valued genes.

Please guide me.

Zulfi.
 
You use the score you got, order your solutions from highest to lowest and cutoff the population at some number like say the top 20 solutions go to the next iteration aka generation.

The Best of the Best go forward.