user3441609
user3441609

Reputation: 1

How to avoid repetition of value in genetic algorithm output?

I did a genetic algorithm code as below...

lb = [1 1 1 1 1 1 1 1 1 1];
ub = [10 10 10 10 10 10 10 10 10 10];
intCon = 1:10;
[x,fval] = ga(FitnessFunction,10,[],[],[],[],lb,ub,[],intCon,options)

I get output "x" as a vector of size [1 10] for example as follows...

(my output eg:) x = 4     3     3     2     9     4     4     6     1     1

but i need to get a output as example,

(what i want eg:) x = 2 10 3 8 1 6 4 9 5 7

that is i should not get repeated values and my outputx should be if size [1 10] .... but in my output i get repeated values... please can someone tell me how to remove repetition... should i set any options for that,.... please do reply....

Upvotes: 0

Views: 576

Answers (1)

Redlion
Redlion

Reputation: 81

If your output is based on minimizing a fitness function with genetic algorithm I have for you the fastest version of your fitness function:

min(sum(x)-a)^2

with "a" equal to the sum of n different numbers(ie from 1 to 10 a=55) It means that every time that the sum of your output is different from "a", the cost of the solution increase quadratically.

Thanks to my experience I can tell you that crossover between elite members can create a large amount of poor solutions. I suggest you to increase the factor of mutation with random numbers or mutation with switch between chromosomes.

I do not know why you actually use genetic algorithm to do that, there are many others algorithms that finds solutions in a better-faster way.

Upvotes: 1

Related Questions