Assume I have:
chromosome_1 <- c('0010000001010000')
chromosome_2 <- c('0100000001001010')
How can I implement step 3-5 ?
- Evaluate
- NC1 = no. of 1's in
chromosome_1
- NC2 = no. of 1's in
chromosome_2
- M =
min(NC1, NC2)
- NC1 = no. of 1's in
- Generate a random integer
NC
fromrange(1, M)
Randomly select
NC
gene positions among the genes with allele “1” fromchromosome_1
and form a sets1
of indices of such selected positions.Randomly select
NC
gene positions among the genes with allele “1” fromchromosome_2
and form a sets2
of indices of such selected positions.s = union(s1, s2)
Assumes = 2, 3, 10, 15
for each index
i
ins
Exchange the alleles of chromosomes
chromosome_1
andchromosome_2
at gene positioni
.
The following illustrates the outcome:
I would really really appreciate any help!