Skip to content

Commit

Permalink
Speedup loop_ecology that was too slow for the evol simulation
Browse files Browse the repository at this point in the history
  • Loading branch information
ZHG2017 committed Apr 28, 2022
1 parent 38327c4 commit 2e65393
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions R/ecology.R
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,16 @@ loop_ecology <- function(config, data, vars) {
chars <- as.character(die_sure)
} #end of check if any die_sure
} #end loop over ids with at least one species...
species_list <- list()
for (species in data$all_species) {
cells <- names(species[["abundance"]])[species[["abundance"]] != 0]
updated_species <- limit_species_to_cells(species, cells)
species_list <- append(species_list, list(updated_species))
}
# species_list <- list()
# for (species in data$all_species) {
# cells <- names(species[["abundance"]])[species[["abundance"]] != 0]
# updated_species <- limit_species_to_cells(species, cells)
# species_list <- append(species_list, list(updated_species))
# }
species_list <- vector(mode = "list", length = length(data$all_species))
species_list <- lapply(1:length(data$all_species), function(i) {
append(species_list[[i]], limit_species_to_cells(data$all_species[[i]], names(data$all_species[[i]][["abundance"]])[data$all_species[[i]][["abundance"]] != 0]))
})
data$all_species <- species_list

if(config$gen3sis$general$verbose>=3){
Expand Down

0 comments on commit 2e65393

Please sign in to comment.