Description Usage Arguments Value See Also Examples
View source: R/init_population.R
Create nStart
random sub-selections from the indexed
grid and assign binary variable 1 to selected grids. This function
initiates the genetic algorithm with a first random population and will
only be needed in the first iteration.
1 | init_population(Grid, n, nStart = 100)
|
Grid |
The data.frame output of |
n |
A numeric value indicating the amount of required turbines. |
nStart |
A numeric indicating the amount of randomly generated initial individuals. Default is 100. |
Returns a list of nStart
initial individuals, each consisting
of n
turbines. Resulting list has the x and y coordinates, the grid
cell ID and a binary variable of 1, indicating a turbine in the grid cell.
Other Genetic Algorithm Functions:
crossover()
,
fitness()
,
genetic_algorithm()
,
mutation()
,
selection()
,
trimton()
,
windfarmGA()
1 2 3 4 5 6 7 8 9 10 11 12 13 | library(sf)
## Exemplary input Polygon with 2km x 2km:
Polygon1 <- sf::st_as_sf(sf::st_sfc(
sf::st_polygon(list(cbind(
c(4498482, 4498482, 4499991, 4499991, 4498482),
c(2668272, 2669343, 2669343, 2668272, 2668272)))),
crs = 3035
))
Grid <- grid_area(Polygon1, 200, 1, TRUE)
## Create 5 individuals with 10 wind turbines each.
firstPop <- init_population(Grid = Grid[[1]], n = 10, nStart = 5)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.