Crossover: Chromosome Crossover

Description Usage Arguments Details Value Examples

Description

Make 2 individual parent chromosomes crossover when breeding offsprings.

Usage

1
crossover(Chromesparent1, parent2numgenes)

Arguments

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.

Details

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.

Value

A matrix with each column representing the offsprings from a process of crossover.

Examples

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)

GilChrist19/GA documentation built on May 13, 2019, 5:32 p.m.