# NOT RUN {
## Create a random rectangular shapefile
library(sp)
Polygon1 <- Polygon(rbind(c(4498482, 2668272), c(4498482, 2669343),
c(4499991, 2669343), c(4499991, 2668272)))
Polygon1 <- Polygons(list(Polygon1), 1);
Polygon1 <- SpatialPolygons(list(Polygon1))
Projection <- "+init=epsg:3035"
proj4string(Polygon1) <- CRS(Projection)
## Create a uniform and unidirectional wind data.frame and plot the
## resulting wind rose
data.in <- data.frame(ws = 12, wd = 0)
windrosePlot <- plot_windrose(data = data.in, spd = data.in$ws,
dir = data.in$wd, dirres=10, spdmax=20)
## Runs an optimization run for 20 iterations with the
## given shapefile (Polygon1), the wind data.frame (data.in),
## 12 turbines (n) with rotor radii of 30m (Rotor) and rotor height of 100m.
result <- genetic_algorithm(Polygon1 = Polygon1,
n = 12,
vdirspe = data.in,
Rotor = 30,
RotorHeight = 100)
plot_windfarmGA(result = result, Polygon1 = Polygon1)
## Runs the same optimization, but with parallel processing and 3 cores.
result_par <- genetic_algorithm(Polygon1 = Polygon1, GridMethod ="h", n=12, Rotor=30,
fcrR=5,iteration=10, vdirspe = data.in,crossPart1 = "EQU",
selstate="FIX",mutr=0.8, Proportionality = 1,
SurfaceRoughness = 0.3, topograp = FALSE,
elitism=TRUE, nelit = 7, trimForce = TRUE,
referenceHeight = 50,RotorHeight = 100,
Parallel = TRUE, numCluster = 3)
plot_windfarmGA(result = result_par, GridMethod = "h", Polygon1 = Polygon1)
## Runs the same optimization, this time with hexagonal grids.
result_hex <- genetic_algorithm(Polygon1 = Polygon1, GridMethod ="h", n=12, Rotor=30,
fcrR=5,iteration=10, vdirspe = data.in,crossPart1 = "EQU",
selstate="FIX",mutr=0.8, Proportionality = 1,
SurfaceRoughness = 0.3, topograp = FALSE,
elitism=TRUE, nelit = 7, trimForce = TRUE,
referenceHeight = 50,RotorHeight = 100)
plot_windfarmGA(result = result_hex, GridMethod = "h", Polygon1 = Polygon1)
## Run an optimization with the Weibull parameters included in the package.
result_weibull <- genetic_algorithm(Polygon1 = Polygon1, GridMethod ="h", n=12,
fcrR=5,iteration=10, vdirspe = data.in,crossPart1 = "EQU",
selstate="FIX",mutr=0.8, Proportionality = 1, Rotor=30,
SurfaceRoughness = 0.3, topograp = FALSE,
elitism=TRUE, nelit = 7, trimForce = TRUE,
referenceHeight = 50,RotorHeight = 100,
weibull = TRUE)
plot_windfarmGA(result = result_weibull, GridMethod= "h", Polygon1 = Polygon1)
## Run an optimization with given Weibull parameter rasters.
#araster <- "/..pathto../a_param_raster.tif"
#kraster <- "/..pathto../k_param_raster.tif"
#weibullrasters <- list(raster(kraster), raster(araster))
#result_weibull <- genetic_algorithm(Polygon1 = Polygon1, GridMethod ="h", n=12,
# fcrR=5,iteration=10, vdirspe = data.in,crossPart1 = "EQU",
# selstate="FIX",mutr=0.8, Proportionality = 1, Rotor=30,
# SurfaceRoughness = 0.3, topograp = FALSE,
# elitism=TRUE, nelit = 7, trimForce = TRUE,
# referenceHeight = 50,RotorHeight = 100,
# weibull = TRUE, weibullsrc = weibullrasters)
#plot_windfarmGA(result = result_weibull, GridMethod= "h", Polygon1 = Polygon1)
# }
Run the code above in your browser using DataLab