Given two binary vectors, return the two children by combining the genes of them using a binary crossover mask.
More information: Uniform crossover
- Parents and mask are row vectors of the same size N;
- Output is a 2 x N matrix containing both children;
- The first child must have genes from the first parent at the positions where the mask is true, and genes from the second parent where the mask is false;
- The second child must have genes from the first parent at the positions where the mask is false, and genes from the second parent where the mask is true;
- The mask is also supplied.
Example:
mask = [1 0 0 0 1 1 1 0 0]; parent1 = [0 0 0 1 1 1 0 0 0]; parent2 = [1 1 0 0 1 0 1 1 0];
children = [0 1 0 0 1 1 0 1 0;
1 0 0 1 1 0 1 0 0];
Solution Stats
Problem Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers83
Suggested Problems
-
6990 Solvers
-
Find all elements less than 0 or greater than 10 and replace them with NaN
15812 Solvers
-
349 Solvers
-
280 Solvers
-
Find the index of the largest value in any vector X=[4,3,4,5,9,12,0,4.....5]
403 Solvers
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!