How can I set a chromosome with non repeated alleles using JGAP?

217 Views Asked by At

I'm using JGAP for my code and I want to evaluate chromosomes like this:

Evaluation 0: 

 1 2 3 4 5 6 7 8 9

Evaluation 1: 

 3 5 2 1 4 6 7 8 9

Until now, I'm getting chromosomes with repeated alleles, like this:

Evaluation 1:

 3 3 5 6 7 8 9 9 1

Is there any configuration that I can use in order to get chromosomes with non-repeated alleles?

1

There are 1 best solutions below

0
On

I am supposing that you are talking about generating the initial population of the GA, and what you should to do is to create many random orders of a certain value list.

There are many ways to do so, here's two possibilities:

  1. Create an array of all the possible values, shuffle it, copy it to a new chromosome, repeat... (you can assign a random real value to each possible value, then order the values by the random value).
  2. Put all the values in a list, select a random item from the list, remove it and add it to the chromosome until there are no more values in the list, repeat...