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 4081820
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:06:35+00:00 2026-05-20T18:06:35+00:00

I have written a uniform crossover algorithm for part of my homework but it’s

  • 0

I have written a uniform crossover algorithm for part of my homework but it’s not working properly. It’s actually returning worse results than my one point cross over. I would just like someone to point out where I am going wrong so I can fix it please :). I’ve been trying for ages now and this is my last resort!!

    private void DoUniformCrossOver(int p1id,int p2id)
{
    ArrayList<Integer> p1 = population.get(p1id).GetRep();
    ArrayList<Integer> p2 = population.get(p2id).GetRep();
    ArrayList<Integer> c1 = new ArrayList<Integer>();
    ArrayList<Integer> c2 = new ArrayList<Integer>();

for (int i=0;i<nbits;++i)
{
    double selected = CS2004.UI(1,2);
    if (selected ==1)
    {
        c1.add(p1.get(i));
        c2.add(p2.get(i));
    }
    else
    {
        c1.add(p2.get(i));
        c2.add(p1.get(i));
    }
}

    population.add(new ScalesChrome(c1));
    population.add(new ScalesChrome(c2));
}

The method takes in as paramaters the two parents, p1id and p2id. Then creates the arraylists of the representation – p1 and p2.

In the for loop, ‘nbits’ is the weight of the array (or the length of the array). My one-point crossover method uses it in the for loop and it works just fine.

I then generate either 1/2 to determine which gene from each parent the child will get.

The fitness of this algorithm is very very poor!! Any help at all would be greatly appreciated.

Many thanks.

  • 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-20T18:06:36+00:00Added an answer on May 20, 2026 at 6:06 pm

    Well, first of all what kind of information are you encoding and what are you trying to evolve?

    Depending on the problem you are trying to solve, some kinds of cross-over strategies will prevent you from ever finding good solutions.

    A simple example: if the solution you are looking for has inherent symmetry (e.g. a white/black cellular automata majority classifier), single point cross-over will never give you very good results because it’s breaking any symmetry that the genetic algorithm may have stumbled upon (e.g. so in the case of the majority classifier, it will be very good at classifying black or white but not both, so it will never get better than a given – pretty low – fitness).

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

Sidebar

Related Questions

I have written following regex But its not working. Can you please help me?
I have written a recursive insert algorithm for a BST. However, there is a
Have written some RoR sites in the past, but never bothered too much at
I have written a recursive DFS algorithm to traverse a graph: void Graph<E, N>::DFS(Node
I have written following code for the client of RMI. But getting java.rmi.ConnectException: Connection
I have written a site in Prototype but want to switch to jQuery. Any
I have written a RNG class which holds different algorithms, however it does not
I feel bad about not getting this. But, although I have read several articles
I have written this OSGI bundle: /* * To change this template, choose Tools
I have written a packet reader that uses libpcap to read a capture file.

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.