Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7027863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:18:16+00:00 2026-05-28T00:18:16+00:00

This question answers pseudocode for roulette wheel selection . But it’s for maximization problem.

  • 0

This question answers pseudocode for roulette wheel selection. But it’s for maximization problem. But my problem is to minimize the value of fitness function. That means, individuals with low fitness get higher probability for being selected than individual with high fitness. How can I implement that?

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T00:18:17+00:00Added an answer on May 28, 2026 at 12:18 am
    import java.util.Random;
    import java.util.Arrays;
    import java.util.Comparator;
    
    class MyComparator implements Comparator
    {
        public int compare(Object o1, Object o2)
        {
            Number n1 = (Number) o1;
            Number n2 = (Number) o2;
    
            if(n1.jump > n2.jump)
            {
                return 1;
            }
            else if(n1.jump < n2.jump)
            {
                return -1;
            }
            else
            {
                return 0;
            }
        }
    }
    
    
    class Number
    {
        public double i;
        public int pos;
        public double jump = 0;
    
    
        public Random r = new Random();
    
        public Number(int pos)
        {
            this.pos = pos;
    
            i = r.nextInt();
        }
    }
    
    
    public class Temp
    {
        public static  void main(String[] args)
        {
            Number[] n = new Number[50];
    
            double total = 0;
    
            for(int i=0; i<50; i++)
            {
                n[i] = new Number(i);
    
                total += n[i].i;
            }
    
            for(int i=0; i<50; i++)
            {
                n[i].jump = n[i].i/total;
            }
    
    
            Arrays.sort(n, new MyComparator());     
    
            for(int i=0; i<50; i++)
            {
                System.out.print(n[i].pos + ", ");
            }
    
            System.out.println();
    
            for(int i=0; i<50; i++)
            {
                n[i].jump = n[i].i / total;
                n[i].jump = 1-n[i].jump;
            }
    
            Arrays.sort(n, new MyComparator());     
    
            for(int i=0; i<50; i++)
            {
                System.out.print(n[i].pos + ", ");
            }
    
            System.out.println();   
        }
    }
    

    In above example, say Number class is your individual class, i is fitness, jump is the probability of being selected as parent. At first we compute the probability of being selected as parent like before. At this step, higher fitness will get higher probability. Then we subtract probability from 1. This gives lower fitness individual higher fitness (pseudo fitness for selection’s sake). Now recalculate the probability. See, the order of being is totally reversed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In the answers to this question , we read that function f() {} defines
[This question is somewhat related to this question , but the answers are not...]
I've read this question and the answers, but what isn't clear to me is
Ive found simlar posts before about this but nothing really answers the question. In
<hyperbole> Whoever answers this question can claim credit for solving the world's most challenging
From the answers to this question it appears there's a file somewhere on our
This follows on from this question where I was getting a few answers assuming
This question already has an answer here: What are Extension Methods? 5 answers Usage
This question was posted on some site. I didnt find right answers there, so
According to the answers to this question, I cannot embed a file version in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.