rgeoda icon indicating copy to clipboard operation
rgeoda copied to clipboard

Random REDCAP and SKATER crashes

Open MattIwicki opened this issue 2 years ago • 1 comments

Hi!

I found that both Redcap and Skater algorithms randomly crash R when given too many polygons. The crash was recreated on different machines, including RStudio Cloud.

library(sf)
library(rgeoda)

# creating test geometry with random values
sfc = st_sfc(st_polygon(list(rbind(c(0,0), c(1,0), c(1,1), c(0,0)))))
grid = st_make_grid(sfc, cellsize = 0.02, square = F)
grid = st_sf(geom = grid)
grid$value = runif(nrow(grid))

# assigning weights
w = queen_weights(grid)

# looping the redcap algorithm
# using print to see after how many iterations R crashes
for(i in 100:1){
  print(i)
  redcap(10, w, grid[,"value"])
}

MattIwicki avatar Apr 07 '22 10:04 MattIwicki

Note: This problem does not occur for cpu_threads = 1 (when parallel processing is not used).

library(sf)
library(rgeoda)
sfc = st_sfc(st_polygon(list(rbind(c(0,0), c(1,0), c(1,1), c(0,0)))))
grid = st_make_grid(sfc, cellsize = 0.02, square = F)
grid = st_sf(value = runif(length(grid)), geom = grid)

w = queen_weights(grid)

for(i in 100:1){
  print(i)
  redcap(10, w, grid[,"value"], cpu_threads = 1)
}

Related issue: https://github.com/GeoDaCenter/rgeoda/issues/27

Nowosad avatar May 18 '22 22:05 Nowosad