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.

Results 1 to 5 of 5

Thread: Need help in roulette wheel Selection in genetic algorithm

  1. #1
    Junior Member
    Join Date
    Feb 2014
    Location
    India
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Post Need help in roulette wheel Selection in genetic algorithm

    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


  2. #2
    Member
    Join Date
    Oct 2013
    Location
    United Kingdom
    Posts
    62
    Thanks
    1
    Thanked 4 Times in 4 Posts

    Default Re: Need help in roulette wheel Selection in genetic algorithm

    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

  3. #3
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Need help in roulette wheel Selection in genetic algorithm

    I can't understand the algorithm clearly
    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.

  4. #4
    Junior Member
    Join Date
    Feb 2014
    Location
    India
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Need help in roulette wheel Selection in genetic algorithm

    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 :-)

  5. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Need help in roulette wheel Selection in genetic algorithm

    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.

Similar Threads

  1. [SOLVED] Help with a simple Genetic Algorithm
    By JMeacham in forum What's Wrong With My Code?
    Replies: 3
    Last Post: December 13th, 2012, 01:38 PM
  2. Need help making a Java roulette simulator.
    By Jmiller4 in forum Loops & Control Statements
    Replies: 1
    Last Post: October 29th, 2012, 07:40 AM
  3. Need some help with my Roulette game please.
    By iDizzle in forum Object Oriented Programming
    Replies: 4
    Last Post: April 15th, 2012, 05:35 PM
  4. Basic Java Sorting Algorithm (Selection/Insertion) help
    By Arte7 in forum Algorithms & Recursion
    Replies: 5
    Last Post: August 22nd, 2011, 01:38 PM
  5. Genetic algorithm
    By rpsaranya in forum Algorithms & Recursion
    Replies: 2
    Last Post: March 5th, 2010, 11:00 PM