Skip to content

Commit

Permalink
fix time distribution (see #46)
Browse files Browse the repository at this point in the history
  • Loading branch information
philchalmers committed Dec 4, 2024
1 parent 2c784c6 commit 1491a1c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]", role = c("aut", "cre"),
comment = c(ORCID="0000-0001-5332-2810")),
person("Matthew", "Sigal", role = c("ctb")),
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
11 changes: 10 additions & 1 deletion R/runArraySimulation.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#'
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion man/runArraySimulation.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1491a1c

Please sign in to comment.