Learn R Programming

windfarmGA (version 5.0.0)

swap_mutation: Swap mutation of turbine layouts

Description

Replace occupied grid cells with unused ones. The number of swaps is max(min_swaps, Binomial(n, p)), so each individual explores at least min_swaps new cells (default 1). The number of turbines stays n.

Usage

swap_mutation(ids, grid_ids, p, seed = NULL, min_swaps = NULL, visit = NULL)

Value

Integer matrix of unique grid IDs, same dimension as ids

Arguments

ids

Integer matrix with n rows (turbines) and one column per individual

grid_ids

All valid grid cell IDs

p

Mutation probability per turbine

seed

Set a seed for comparability. Default is NULL

min_swaps

Minimum number of swaps per individual. Default is getOption("windfarmGA.min_swaps") (1)

visit

Named visit counts per grid ID. Free cells with fewer visits are more likely to be chosen. Default is NULL (uniform)

See Also

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

Examples

Run this code
ids <- cbind(c(1, 3, 5, 7), c(2, 4, 6, 8))
swap_mutation(ids, grid_ids = 1:20, p = 0.5, seed = 1)

Run the code above in your browser using DataLab