简体   繁体   中英

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

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?

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...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM