Learn R Programming

windfarmGA (version 2.3.0)

crossover: Crossover Method

Description

The crossover method of the genetic algorithm, which takes the selected individuals after the selection function and produces new offsprings through permutation.

Usage

crossover(se6, u, uplimit, crossPart, verbose, seed)

Arguments

se6

The selected individuals. The output of selection (list)

u

The crossover point rate. (numeric)

uplimit

The upper limit of allowed permutations. The current algorithm has an upper bound of 300 permutations. (numeric)

crossPart

The crossover method. Either "EQU" or "RAN". (character)

verbose

If TRUE, will print out further information.

seed

Set a seed for comparability. Default is NULL

Value

Returns a binary coded matrix of all permutations and all grid cells, 0 indicates no turbine and 1 indicates a turbine in the grid cell. (matrix)

See Also

Other Genetic Algorithm Functions: fitness(), genetic_algorithm(), init_population(), mutation(), selection(), trimton(), windfarmGA()

Examples

Run this code
# NOT RUN {
## Create two random parents with an index and random binary values
Parents <- data.frame(
  ID = 1:20,
  bin = sample(c(0,1),20, replace = TRUE, prob = c(70,30)),
  bin.1 = sample(c(0,1),20, replace=TRUE,prob = c(30,70)))

## Create random Fitness values for both individuals
FitParents <- data.frame(ID = 1, Fitness = 1000, Fitness.1 = 20)

## Assign both values to a list
CrossSampl <- list(Parents,FitParents);

## Cross their data at equal locations with 2 crossover parts
crossover(CrossSampl, u = 1.1, uplimit = 300, crossPart = "EQU")

## with 3 crossover parts and equal locations
crossover(CrossSampl, u = 2.5, uplimit = 300, crossPart = "EQU")

## or with random locations and 5 crossover parts
crossover(CrossSampl, u = 4.9, uplimit = 300, crossPart = "RAN")

# }

Run the code above in your browser using DataLab