Skip to contents

Retrieve the grid ID's from the binary matrix, where the binary code indicates which grid cells are used in the current wind farm constellation.

Usage

get_grids(trimtonOut, Grid)

Arguments

trimtonOut

Input matrix with binary values

Grid

Grid of the considered area

Value

Returns a list of all individuals with X and Y coordinates and the grid cell ID.

See also

Examples

# \donttest{
## Create a random rectangular shapefile
library(sf)
Polygon1 <- sf::st_as_sf(sf::st_sfc(
 sf::st_polygon(list(cbind(
   c(0, 0, 2000, 2000, 0),
   c(0, 2000, 2000, 0, 0)))),
crs = 3035
))

## Calculate a Grid and an indexed data.frame with coordinates and grid cell Ids.
Grid1 <- grid_area(shape = Polygon1, size = 200, prop = 1)
Grid <- Grid1[[1]]
AmountGrids <- nrow(Grid)

startsel <- init_population(Grid,10,20)
wind <- data.frame(ws = 12, wd = 0)
wind <- list(wind, probab = 100)
fit <- fitness(selection = startsel,referenceHeight = 100, RotorHeight=100,
               SurfaceRoughness=0.3,Polygon = Polygon1, resol1 = 200,rot=20,
               dirspeed = wind, srtm_crop="",topograp=FALSE,cclRaster="")
allparks <- do.call("rbind",fit)

## SELECTION
## print the amount of Individuals selected.
## Check if the amount of Turbines is as requested.
selec6best <- selection(fit, Grid,2, TRUE, 6, "VAR")

## CROSSOVER
## u determines the amount of crossover points,
## crossPart determines the method used (Equal/Random),
## uplimit is the maximum allowed permutations
crossOut <- crossover(selec6best, 2, uplimit = 300, crossPart="RAN")

## MUTATION
## Variable Mutation Rate is activated if more than 2 individuals represent the
## current best solution.
mut <- mutation(a = crossOut, p = 0.3)

## TRIMTON
## After Crossover and Mutation, the amount of turbines in a windpark change
## and have to be corrected to the required amount of turbines.
mut1 <- trimton(mut = mut, nturb = 10, allparks = allparks,
               nGrids = AmountGrids, trimForce=FALSE)

## Get the new Grid-Ids and run a new fitness run.
getRectV <- get_grids(mut1, Grid)
fit <- fitness(selection = getRectV,referenceHeight = 100, RotorHeight=100,
               SurfaceRoughness=0.3,Polygon = Polygon1, resol1 = 200,rot=20,
               dirspeed = wind, srtm_crop="",topograp=FALSE,cclRaster="")
head(fit)
#> $`11,23,34,38,46,57,60,61,71,76`
#>          X    Y EfficAllDir EnergyOverall AbschGesamt Run RotorR Rect_ID
#>  [1,]  100  300     92.0774      7262.188         200   1     20      11
#>  [2,]  500  500     92.0774      7262.188           0   1     20      23
#>  [3,]  700  700     92.0774      7262.188           0   1     20      34
#>  [4,] 1500  700     92.0774      7262.188           0   1     20      38
#>  [5,] 1100  900     92.0774      7262.188         100   1     20      46
#>  [6,] 1300 1100     92.0774      7262.188           0   1     20      57
#>  [7,] 1900 1100     92.0774      7262.188           0   1     20      60
#>  [8,]  100 1300     92.0774      7262.188         100   1     20      61
#>  [9,]  100 1500     92.0774      7262.188           0   1     20      71
#> [10,] 1100 1500     92.0774      7262.188           0   1     20      76
#>       Parkfitness
#>  [1,]    7262.188
#>  [2,]    7262.188
#>  [3,]    7262.188
#>  [4,]    7262.188
#>  [5,]    7262.188
#>  [6,]    7262.188
#>  [7,]    7262.188
#>  [8,]    7262.188
#>  [9,]    7262.188
#> [10,]    7262.188
#> 
#> $`2,3,9,23,34,56,71,73,84,91`
#>          X    Y EfficAllDir EnergyOverall AbschGesamt Run RotorR Rect_ID
#>  [1,]  300  100    92.63865      7306.454           0   2     20       2
#>  [2,]  500  100    92.63865      7306.454         200   2     20       3
#>  [3,] 1700  100    92.63865      7306.454           0   2     20       9
#>  [4,]  500  500    92.63865      7306.454         100   2     20      23
#>  [5,]  700  700    92.63865      7306.454         100   2     20      34
#>  [6,] 1100 1100    92.63865      7306.454           0   2     20      56
#>  [7,]  100 1500    92.63865      7306.454         100   2     20      71
#>  [8,]  500 1500    92.63865      7306.454           0   2     20      73
#>  [9,]  700 1700    92.63865      7306.454           0   2     20      84
#> [10,]  100 1900    92.63865      7306.454           0   2     20      91
#>       Parkfitness
#>  [1,]    7306.454
#>  [2,]    7306.454
#>  [3,]    7306.454
#>  [4,]    7306.454
#>  [5,]    7306.454
#>  [6,]    7306.454
#>  [7,]    7306.454
#>  [8,]    7306.454
#>  [9,]    7306.454
#> [10,]    7306.454
#> 
#> $`16,21,49,55,56,59,61,64,82,98`
#>          X    Y EfficAllDir EnergyOverall AbschGesamt Run RotorR Rect_ID
#>  [1,] 1100  300    92.51448      7296.661         100   3     20      16
#>  [2,]  100  500    92.51448      7296.661         100   3     20      21
#>  [3,] 1700  900    92.51448      7296.661         100   3     20      49
#>  [4,]  900 1100    92.51448      7296.661           0   3     20      55
#>  [5,] 1100 1100    92.51448      7296.661           0   3     20      56
#>  [6,] 1700 1100    92.51448      7296.661           0   3     20      59
#>  [7,]  100 1300    92.51448      7296.661           0   3     20      61
#>  [8,]  700 1300    92.51448      7296.661           0   3     20      64
#>  [9,]  300 1700    92.51448      7296.661           0   3     20      82
#> [10,] 1500 1900    92.51448      7296.661           0   3     20      98
#>       Parkfitness
#>  [1,]    7296.661
#>  [2,]    7296.661
#>  [3,]    7296.661
#>  [4,]    7296.661
#>  [5,]    7296.661
#>  [6,]    7296.661
#>  [7,]    7296.661
#>  [8,]    7296.661
#>  [9,]    7296.661
#> [10,]    7296.661
#> 
#> $`13,17,18,24,34,49,69,72,78,82`
#>          X    Y EfficAllDir EnergyOverall AbschGesamt Run RotorR Rect_ID
#>  [1,]  500  300     86.2785      6804.826           0   4     20      13
#>  [2,] 1300  300     86.2785      6804.826           0   4     20      17
#>  [3,] 1500  300     86.2785      6804.826         100   4     20      18
#>  [4,]  700  500     86.2785      6804.826         100   4     20      24
#>  [5,]  700  700     86.2785      6804.826           0   4     20      34
#>  [6,] 1700  900     86.2785      6804.826         100   4     20      49
#>  [7,] 1700 1300     86.2785      6804.826           0   4     20      69
#>  [8,]  300 1500     86.2785      6804.826         100   4     20      72
#>  [9,] 1500 1500     86.2785      6804.826           0   4     20      78
#> [10,]  300 1700     86.2785      6804.826           0   4     20      82
#>       Parkfitness
#>  [1,]    6804.826
#>  [2,]    6804.826
#>  [3,]    6804.826
#>  [4,]    6804.826
#>  [5,]    6804.826
#>  [6,]    6804.826
#>  [7,]    6804.826
#>  [8,]    6804.826
#>  [9,]    6804.826
#> [10,]    6804.826
#> 
#> $`15,22,23,33,41,42,53,81,86,90`
#>          X    Y EfficAllDir EnergyOverall AbschGesamt Run RotorR Rect_ID
#>  [1,]  900  300    87.88807      6931.773           0   5     20      15
#>  [2,]  300  500    87.88807      6931.773         100   5     20      22
#>  [3,]  500  500    87.88807      6931.773         200   5     20      23
#>  [4,]  500  700    87.88807      6931.773         100   5     20      33
#>  [5,]  100  900    87.88807      6931.773         100   5     20      41
#>  [6,]  300  900    87.88807      6931.773           0   5     20      42
#>  [7,]  500 1100    87.88807      6931.773           0   5     20      53
#>  [8,]  100 1700    87.88807      6931.773           0   5     20      81
#>  [9,] 1100 1700    87.88807      6931.773           0   5     20      86
#> [10,] 1900 1700    87.88807      6931.773           0   5     20      90
#>       Parkfitness
#>  [1,]    6931.773
#>  [2,]    6931.773
#>  [3,]    6931.773
#>  [4,]    6931.773
#>  [5,]    6931.773
#>  [6,]    6931.773
#>  [7,]    6931.773
#>  [8,]    6931.773
#>  [9,]    6931.773
#> [10,]    6931.773
#> 
#> $`3,6,14,24,28,32,44,70,80,98`
#>          X    Y EfficAllDir EnergyOverall AbschGesamt Run RotorR Rect_ID
#>  [1,]  500  100    86.25785      6803.197           0   6     20       3
#>  [2,] 1100  100    86.25785      6803.197           0   6     20       6
#>  [3,]  700  300    86.25785      6803.197         200   6     20      14
#>  [4,]  700  500    86.25785      6803.197         100   6     20      24
#>  [5,] 1500  500    86.25785      6803.197         100   6     20      28
#>  [6,]  300  700    86.25785      6803.197           0   6     20      32
#>  [7,]  700  900    86.25785      6803.197           0   6     20      44
#>  [8,] 1900 1300    86.25785      6803.197         100   6     20      70
#>  [9,] 1900 1500    86.25785      6803.197           0   6     20      80
#> [10,] 1500 1900    86.25785      6803.197           0   6     20      98
#>       Parkfitness
#>  [1,]    6803.197
#>  [2,]    6803.197
#>  [3,]    6803.197
#>  [4,]    6803.197
#>  [5,]    6803.197
#>  [6,]    6803.197
#>  [7,]    6803.197
#>  [8,]    6803.197
#>  [9,]    6803.197
#> [10,]    6803.197
#> 

# }