(...)
inputs <- data.frame(file = c("wolves2008.asc", "packs2008.asc", "CMR.asc", "HabitatSuitability.asc"))
wolfModuleStart <- simInit(times = times,# params = list(wolfAlps = wolfiparameters), modules = modules, inputs = inputs, paths = paths)
registerDoParallel(cores=30) #32 pro nodegetDoParWorkers()
Italy_1000 <- foreach(i=1:1000, .packages = c("devtools", "NetLogoR", "SpaDES", "plyr", "data.table")) %dopar% { spades(wolfModuleStart, progress =10,debug=T)gc()}
Error in { : task 24 failed - "if passing levelsAM, then ... must be a numeric matrix"Calls: %dopar% -> <Anonymous>Execution halted
Can you reproduce them in a single core situation? Ie not in the foreach parallel. Ideally you know the seed and the replicate number...
seed <- .Random.seed
Keeping this between reps as reps go by, then you run your code and when it fails, you will have pinpointed the problem replicate and can debug it interactively.
7.261 wolfAlps dispersal 5
7.271 wolfAlps dispersal 5
7.281 wolfAlps dispersal 5
7.291 wolfAlps dispersal 5
7.301 wolfAlps dispersal 5
7.311 wolfAlps dispersal 5
7.999 wolfAlps saveEnd 5
8 wolfAlps saveStart 5
8 wolfAlps yearly 5
8.001 wolfAlps dispersal 5
8.011 wolfAlps dispersal 5
8.021 wolfAlps dispersal 5
8.031 wolfAlps dispersal 5
8.Error in { :
task 9 failed - "numbers of columns of arguments do not match"
Calls: %dopar% -> <Anonymous>
Execution halted
..
} else if (eventType == "dispersal") {
print("SCHEDULE EVENT 24")
sim <- sim$wolfAlpsDispersal(sim) # dispersal movement
print("SCHEDULE EVENT 25")
sim <- sim$wolfAlpsEstablish(sim) # join a pack or build a new territory
print("SCHEDULE EVENT 26")
sim <- sim$wolfAlpsSaveTerrSize(sim) # save the size of the new created territories
print("SCHEDULE EVENT 27")
if(NLcount(NLwith(agents = sim$wolves, var = "dispersing", val = 1)) != 0){
print("SCHEDULE EVENT 28")
sim <- scheduleEvent(sim, time(sim, "year") + 0.01, "wolfAlps", "dispersal")
}
print("SCHEDULE EVENT 29")
} else {
print("SCHEDULE EVENT 30")
warning(paste("Undefined event type: '", current(sim)[1, "eventType", with = FALSE],
"' in module '", current(sim)[1, "moduleName", with = FALSE], "'", sep = ""))
}
print("SCHEDULE EVENT 31")
return(invisible(sim))
}
1.821 wolfAlps dispersal 5
1.831 wolfAlps dispersal 5
1.841 wolfAlps dispersal 5
1.851 wolfAlps dispersal 5
1.861 wolfAlps dispersal 5
1.871 wolfAlps dispersal 5
1.881 wolfAlps dispersal 5
1.999 wolfAlps saveEnd 5
2 wolfAlps saveStart 5
2 wolfAlps yearly 5
2.001 wolfAlps dispersal 5
Because of an interrupted spades call, the sim object at the time of interruption was saved in
SpaDES.core:::.pkgEnv$.sim . It will be deleted on next call to spades
Error in { :
task 1 failed - "'vec' must be sorted non-decreasingly and not contain NAs"
Calls: %dopar% -> <Anonymous>
Execution halted
# Now each wolf has its subset of cells as potential next locations for dispersal # Probability of going to the potential next locations regarding their directions headDispersers <- of(agents = dispersers, var = "heading") nextLocs[,nextAngle:={ dnorm(mean = 0, sd = params(sim)$wolfAlps$sigma, # calculate the probability using the Normal distribution of ... subHeadings(angle1 = headDispersers[id], # ... the rotation of each wolf's heading to ... angle2 = towards(agents = turtle(sim$wolves, who = whoDispersers[id]), # ... the direction towards each of its next potential locations agents2 = cbind(x = x, y = y)) ) )}, by = id] # data.table use of by = id, so each of the above happens within each id
# Probability of going to the potential next locations regarding habitat suitability data.table::set(nextLocs,,"suitabilityValGood", sim$suitabilityValGood[nextLocs$indices])
# Probability of going to the potential next locations regarding the directions, habitat suitability and other wolves presence data.table::set(nextLocs,,"prob", nextLocs$nextAngle * nextLocs$suitabilityValGood * nextLocs$empty) probLoc <- runif(n = NLcount(dispersers), min = 0, max = 1) setkeyv(nextLocs, c("id")) # Selected next potential locations, based on probLoc nextLocs <- nextLocs[,.SD[findInterval(probLoc[id], cumsum(prob/sum(prob))) + 1], by = id, .SDcols = c("x", "y", "prob")] selectedLocID <- as.matrix(nextLocs)[,c(2,3,1), drop = FALSE]