I want java coding for roulette wheel selection in genetic algorithm with some explanation. I can't understand the algorithm clearly to implement in my project .... Can anyone explain in detail
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
I want java coding for roulette wheel selection in genetic algorithm with some explanation. I can't understand the algorithm clearly to implement in my project .... Can anyone explain in detail
Sorry we cant provide the code in this forum. If you can come up with a code or algorithm then we can help in your project
Thanks and regards,
Sambit Swain
What algorithm? Show us what you don't understand, and ask questions about it. If you don't have an algorithm and haven't been able to come up with one, then describe what the algorithm should do. Write pseudo code or real code from that if you can. Recommend you check out the API page for Random to get some ideas.I can't understand the algorithm clearly
here is the part i got from other website. I don't understand the proper algorithm ... Proper reason for those variables and loop.... I have calculated the fitness for all the population. Now i want to do selection process using "roulette wheel selection algorithm" ...... What should i do...
public double[] roulettewheel(){
double min=0,max;
Random r = new Random();int popSize=30;
double[] populationNew = new double[popSize];
//sum the total fitness of the population
for (int i = 0; i < popSize; i++) {
totalfitness =+ fitness[i];
}
/* sum the fitness of each individual in the population again
* until the running sum is >= to the randomly chosen number.
*/
max = totalfitness + 1;
for (int i = 0; i < popSize; i++) {
//pick a random number between 0 and that sum.
double randomNumber;
//randomNumber = r.nextDouble(totalfitness + 1);
randomNumber = r.nextDouble() * 3.67;
int runningSum = 0;
int index = 0;
int lastAddedIndex = 0;
while (runningSum < randomNumber) {
runningSum += aPopulation[index].fitnessVal;
lastAddedIndex = index;
index++;
}
populationNew[i] = aPopulation[lastAddedIndex];
runningSum = 0;
index = 0;
lastAddedIndex = 0;
}
return populationNew;
}
Thanks in advance :-)
Please edit your post and wrap your code with code tags:
[code=java]
YOUR CODE HERE
[/code]
to get highlighting and preserve formatting.
If you don't understand my answer, don't ignore it, ask a question.