Genetic Algorithm (GA) for binary (bitstring) population type - how will crossover and mutation work on binary vectors?
12 次查看(过去 30 天)
显示 更早的评论
I am trying to run genetic algorithm with binary array as population type by setting 'PopulationType' to 'bitstring' in optimoptions function.
Could someone explain how crossover function ('crossoverarithmetic') and mutation funtion ('mutationuniform') work for this binary case?
Crossover Options - 'crossoverarithmetic'
It says Arithmetic ('crossoverarithmetic') creates children that are the weighted arithmetic mean of two parents.
If two parents selected are, for example,
parent1 = [1 0 0 1 0];
parent2 = [0 0 1 1 1];
Will the children from 'crossoverarithmetic' be parent1 | parent2 ? so children = [1 0 1 1 1]?
Mutation Options - 'mutationuniform'
Documentation says the following: Uniform ('mutationuniform') - uniform mutation is a two-step process. First, the algorithm selects a fraction of the vector entries of an individual for mutation, where each entry has a probability Rate of being mutated. The default value of Rate is 0.01. In the second step, the algorithm replaces each selected entry by a random number selected uniformly from the range for the entry.
Does this mean, if a parent selected is [1 0 0 1 0], each entry has Rate chance of value being flipped?
4 个评论
Walter Roberson
2020-5-5
The code is along the lines of
R = rand(1,N);
for K = 1:N
if R(K) < rate
variable(K) = randi([lb(K), ub(K)]) ;
end
end
for bitstring 0 1, randi 0 1 has a 50% chance of being different than it currently is.
Whereas you are imagining
t = setdiff(lb(K) : ub(K), variable(K)) ;
variable(K) = t(randi(length(t)) ;
which is guaranteed to be different from the current value 100%
回答(1 个)
Walter Roberson
2020-5-5
crossoverfcn is not to be used with integer problems, and bitstring are integer problems
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Genetic Algorithm 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!