cran checks CRAN RStudio mirror downloads CRAN Downloads Build Status AppVeyor build status lifecycle codecov

Genetic algorithm to optimize the layout of windfarms. The package is hosted on CRAN


The latest version can be installed from GitHub with:

and the CRAN-version with:


The genetic algorithm is designed to optimize wind farms of any shape. It requires a predefined number of turbines, a uniform rotor radius and an average wind speed per wind direction. It can include a terrain effect model, which downloads an ‘SRTM’ elevation model and a ‘Corine Land Cover’ raster automatically. The elevation model is used to find mountains and valleys and to adjust the wind speeds accordingly by ‘wind multipliers’ and to determine the air densities at rotor heights. The land cover raster with an additional elevation roughness value is used to re-evaluate the surface roughness and to individually determine the wake-decay constant for each turbine.

To start an optimization, either the function windfarmGA or genetic_algorithm can be used. The function windfarmGA checks the user inputs interactively and then runs the function genetic_algorithm. If the input parameters are already known, an optimization can be run directly via genetic_algorithm.

Since version 1.1, hexagonal grid cells are possible, with their center points being possible locations for wind turbines. Furthermore, rasters can be included, which contain information on the Weibull parameters. For Austria this data is already included in the package.

Grid Spacing

Rectangular Grid Cells

Verify that the grid spacing is appropriate. Adapt the following input variables if desired:

  • Rotor: The desired rotor radius in meters.
  • fcrR: The grid spacing factor, which should at least be 2, so that a single grid covers at least the whole rotor diameter.
  • prop: The proportionality factor used for grid calculation. It determines the percentage a grid has to overlay the considered area to be represented as grid cell.

Make sure that the Polygon is projected in meters.

Terrain Effect Model

If the input variable topograp for the functions windfarmGA or genetic_algorithm is TRUE, the genetic algorithm will take terrain effects into account. For this purpose an elevation model and a Corine Land Cover raster are downloaded automatically, but can also be given manually. ( Download a CLC raster ).

If you want to include your own Land Cover Raster, you must assign the Raster Image path to the input variable sourceCCL. The algorithm uses an adapted version of the Raster legend (“clc_legend.csv”), which is stored in the package subdirectory (/extdata). To use own values for the land cover roughness lengths, insert a column named Rauhigkeit_z to the .csv file. Assign a surface roughness length to all land cover types. Be sure that all rows are filled with numeric values and save the .csv file with “;” delimiter. Assign the .csv file path to the input variable sourceCCLRoughness.

Start an Optimization

An optimization run can be initiated with the following functions:

  • genetic_algorithm
  • windfarmGA

Function calls for genetic_algorithm

  • without terrain effects
  • with terrain effects

The argument GridMethod, weibull, weibullsrc can also be given to the function windfarmGA.

Shiny Windfarm Optimization

I also made a Shiny App for the Genetic Algorithm. Unfortunately, as an optimization takes quite some time and the app is currently hosted by under a public license, there is only 1 R-worker at hand. So only 1 optimization can be run at a time.

Full Optimization example:

library(rgdal); library(sp); library(windfarmGA)
Polygon1 <- Polygon(rbind(c(4651704, 2692925), c(4651704, 2694746), 
                          c(4654475, 2694746), c(4654475, 2692925)))
Polygon1 <- sp::Polygons(list(Polygon1), 1);
Polygon1 <- sp::SpatialPolygons(list(Polygon1))
Projection <- "+proj=laea +lat_0=52 +lon_0=10 +x_0=4321000 +y_0=3210000
+ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs"
proj4string(Polygon1) <- CRS(Projection)
plot(Polygon1, col = "blue", axes = TRUE)

wind_df <- data.frame(ws = 12, wd = 0)
windrosePlot <- plot_windrose(data = wind_df, spd = wind_df$ws,
                             dir = wind_df$wd, dirres = 10, spdmax = 20)
Rotor <- 20
fcrR <- 9
Grid <- grid_area(shape = Polygon1, resol = (Rotor*fcrR), prop = 1, plotGrid = TRUE)

result <- windfarmGA(Polygon1 = Polygon1, n = 12, Rotor = Rotor, fcrR = fcrR, iteration = 10,
                     vdirspe = wind_df, crossPart1 = "EQU", selstate = "FIX", mutr = 0.8,
                     Proportionality = 1, SurfaceRoughness = 0.3, topograp = FALSE,
                     elitism = TRUE, nelit = 7, trimForce = TRUE,
                     referenceHeight = 50, RotorHeight = 100)

# The following function will execute all plotting function further below:
plot_windfarmGA(result, Polygon1, whichPl = "all", best = 1, plotEn = 1)

# The plotting functions can also be called individually:
plot_result(result, Polygon1, best = 1, plotEn = 1, topographie = FALSE, Grid = Grid[[2]])
plot_evolution(result, ask = TRUE, spar = 0.1)
plot_parkfitness(result, spar = 0.1)
plot_cloud(result, pl = TRUE)
plot_heatmap(result = result, si = 5)
plot_leaflet(result = result, Polygon1 = polygon, which = 1)