Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

## Changes in SimDesign 2.25

- Fixed a bug where list-based (L'Ecuyer-CMRG) seeds were not applied on the
serial (non-parallel) execution path, causing `runArraySimulation(..., iseed)`
and `runSimulation(seed = <genSeeds() list>)` to be non-reproducible when
`parallel = FALSE`. The internal `set_seed()` helper was assigning
`.Random.seed` to its local frame rather than `.GlobalEnv`, so the RNG state
was silently discarded. The parallel path was unaffected

- `SimErrors()` and `SimWarnings()` functions added to better track and
extract error/warning information. Makes it easier to track down specific
seed states to replicate any of the recorded messages
Expand Down
2 changes: 1 addition & 1 deletion R/util.R
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ pickReps <- function(replications, iter){
}

set_seed <- function(seed){
if(is.list(seed)) .Random.seed <- seed[[1L]]
if(is.list(seed)) .GlobalEnv$.Random.seed <- seed[[1L]]
else set.seed(seed)
invisible(NULL)
}
Expand Down
16 changes: 16 additions & 0 deletions tests/tests/test-03-array.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,22 @@ test_that('array', {

SimClean('mysim-1.rds')

# serial iseed must be byte-for-byte reproducible (L'Ecuyer-CMRG seed
# applied via set_seed(); see GitHub bug re: .GlobalEnv assignment)
res_s1 <- runArraySimulation(design=Design, replications=20,
generate=Generate, analyse=Analyse,
summarise=Summarise, arrayID=1L,
iseed=iseed, filename='serialseed',
parallel=FALSE, verbose=FALSE)
res_s2 <- runArraySimulation(design=Design, replications=20,
generate=Generate, analyse=Analyse,
summarise=Summarise, arrayID=1L,
iseed=iseed, filename='serialseed',
parallel=FALSE, verbose=FALSE)
expect_identical(SimExtract(res_s1, what='results'),
SimExtract(res_s2, what='results'))
SimClean('serialseed-1.rds')

########################
# Same submission job as above, however split the replications over multiple
# evaluations and combine when complete
Expand Down
Loading