diff --git a/DESCRIPTION b/DESCRIPTION index 28e1ccb..64101ad 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: SimDesign Title: Structure for Organizing Monte Carlo Simulation Designs -Version: 2.17.5 +Version: 2.17.6 Authors@R: c(person("Phil", "Chalmers", email = "rphilip.chalmers@gmail.com", role = c("aut", "cre"), comment = c(ORCID="0000-0001-5332-2810")), person("Matthew", "Sigal", role = c("ctb")), diff --git a/NEWS.md b/NEWS.md index 6c48416..7fe00a6 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,10 @@ ## Changes in SimDesign 2.18 +- `runArraySimulation(..., max_time)` now correctly applies the maximum + time across all subsetted conditions rather than over each condition, thereby + matching, for example, SBATCH commands in SLURM (reported by Michael Troung) + - `SimResults()` now gives the same output behavior when `store_results` or `save_results` are used (see issue #45) diff --git a/R/runArraySimulation.R b/R/runArraySimulation.R index 931a89b..298e5a1 100644 --- a/R/runArraySimulation.R +++ b/R/runArraySimulation.R @@ -27,7 +27,7 @@ #' conditions that require more than the specified time in the shell script. #' The \code{max_time} value should be less than the maximum time allocated #' on the HPC cluster (e.g., approximately 90% of this time or less, though -#' depends on how long each replication takes). Simulations with missing +#' depends on how long, and how variable, each replication is). Simulations with missing #' replication information should submit a new set of jobs at a later time #' to collect the missing replication information. #' @@ -338,11 +338,20 @@ runArraySimulation <- function(design, ..., replications, on.exit(parallel::stopCluster(cl), add=TRUE) } } + max_time <- control$max_time + if(!is.null(max_time)) + max_time <- timeFormater(max_time) + start_time <- proc.time()[3L] for(i in 1L:length(rowpick)){ row <- rowpick[i] seed <- genSeeds(design, iseed=iseed, arrayID=row) dsub <- design[row, , drop=FALSE] attr(dsub, 'Design.ID') <- attr(design, 'Design.ID')[row] + if(!is.null(max_time)){ + control$max_time <- max_time - (proc.time()['elapsed'] - start_time) + if(max_time <= 0) + stop('max_time limit exceeded', call.=FALSE) + } ret <- runSimulation(design=dsub, replications=replications, seed=seed, verbose=verbose, save_details=save_details, parallel=parallel, cl=cl, diff --git a/man/runArraySimulation.Rd b/man/runArraySimulation.Rd index 99d8dba..5404ad4 100644 --- a/man/runArraySimulation.Rd +++ b/man/runArraySimulation.Rd @@ -137,7 +137,7 @@ Additionally, for timed simulations on HPC clusters it is also recommended to pa conditions that require more than the specified time in the shell script. The \code{max_time} value should be less than the maximum time allocated on the HPC cluster (e.g., approximately 90% of this time or less, though -depends on how long each replication takes). Simulations with missing +depends on how long, and how variable, each replication is). Simulations with missing replication information should submit a new set of jobs at a later time to collect the missing replication information. }