Skip to content

Commit

Permalink
improve logging of seeds
Browse files Browse the repository at this point in the history
  • Loading branch information
mllg committed Jan 8, 2018
1 parent 306427a commit 7a3ff0c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion R/Job.R
Expand Up @@ -86,7 +86,7 @@ Experiment = R6Class("Experiment", cloneable = FALSE, inherit = BaseJob,
return(result)
}
}
seed = if (is.null(p$seed)) self$seed else p$seed + self$repl - 1L
seed = if (is.null(p$seed)) self$seed else getSeed(p$seed, self$repl - 1L)
wrapper = function(...) p$fun(job = self, data = p$data, ...)
result = with_seed(seed, do.call(wrapper, self$prob.pars, envir = .GlobalEnv))
if (p$cache)
Expand Down
3 changes: 2 additions & 1 deletion R/execJob.R
Expand Up @@ -32,6 +32,7 @@ execJob.JobCollection = function(job) {
#' @export
execJob.Job = function(job) {
local_options(list(error = function(e) traceback(2L)))
catf("Starting job %i (seed = %i) ...", job$id, job$seed)
if (".job" %chin% names(formals(job$fun))) {
with_seed(job$seed, do.call(job$fun, c(job$pars, list(.job = job)), envir = .GlobalEnv))
} else {
Expand All @@ -47,7 +48,7 @@ execJob.Experiment = function(job) {
force(instance)
job$allow.access.to.instance = FALSE

catf("Applying algorithm '%s' on problem '%s' ...", job$algo.name, job$prob.name)
wrapper = function(...) job$algorithm$fun(job = job, data = job$problem$data, instance = instance, ...)
catf("Applying algorithm '%s' on problem '%s' for job %i (seed = %i) ...", job$algo.name, job$prob.name, job$id, job$seed)
with_seed(job$seed, do.call(wrapper, job$algo.pars, envir = .GlobalEnv))
}

0 comments on commit 7a3ff0c

Please sign in to comment.