Genetic Algorithm (GA) for binary (bitstring) population type - how will crossover and mutation work on binary vectors?
3 views (last 30 days)
Show older comments
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 Comments
Walter Roberson
on 5 May 2020
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%
Answers (1)
Walter Roberson
on 5 May 2020
crossoverfcn is not to be used with integer problems, and bitstring are integer problems
See Also
Categories
Find more on Genetic Algorithm in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!