How to frame a genetic algorithm for this problem?

  • Thread starter Thread starter zak100
  • Start date Start date
  • Tags Tags
    Algorithm Frame
Click For Summary

Discussion Overview

The discussion revolves around the application of genetic algorithms to optimize the selection of modules based on method calls. Participants explore how to implement crossover and mutation steps in the algorithm while addressing the challenge of maintaining a manageable population size.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant describes a problem involving a random array representing method calls and seeks guidance on applying crossover and mutation in a genetic algorithm.
  • Another participant explains mutation as altering elements of a random array and describes crossover as swapping elements between two arrays.
  • A participant expresses concern that mutation would increase the population size and seeks methods to discard less fit solutions while still applying mutation and crossover concepts.
  • One participant suggests using a scoring system to rank solutions and retain only the top performers for the next generation.

Areas of Agreement / Disagreement

Participants generally agree on the definitions and processes of mutation and crossover, but there is disagreement on how to effectively manage population size while incorporating these concepts into the algorithm.

Contextual Notes

Participants have not resolved how to balance the introduction of new genetic material through mutation with the need to maintain a population of the largest or fittest solutions. The discussion includes assumptions about the scoring system and the criteria for selecting which solutions to retain.

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.
 
Technology 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.
 

Similar threads

  • · Replies 13 ·
Replies
13
Views
5K
  • · Replies 11 ·
Replies
11
Views
5K
Replies
7
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
Replies
14
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 29 ·
Replies
29
Views
4K