Description Usage Arguments Details Value Examples
Make 2 individual parent chromosomes crossover when breeding offsprings.
1 | crossover(Chromes,parent1, parent2,numgenes)
|
Chromes |
A matrix, whose each row representing an individual chromosome and each column representing Pop. |
parent1, parent2 |
Numeric vectors represents individual parent chromosome. |
numgenes |
Number of genes in each chromosome. |
This function makes two individual parent chromosomes perfrom crossover when breeding next generation. Note that the crossover randomly pick several break points, perform break and recombination on each set of parents.
A matrix with each column representing the offsprings from a process of crossover.
1 2 3 4 5 | test_Chromes <- matrix(data = sample(c(0,1), size = Pop*genes, replace = TRUE), nrow = Pop, ncol = genes)
test_parent1 <- sample(x = 1:(nPop-1), size = nPop-1, replace = TRUE, prob = 1/relscore)
test_parent2 <- secondParents(firstParents=firstParents, method=method, nPop=nPop, relscore=relscore)
test_numgenes <- ncol(test_Chromes)
crossover(test_Chromes,parent1,parent2,numgenes)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.