Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scheduling bug when events in init scheduled for end(sim) using option spades.allowInitDuringSimInit #280

Open
achubaty opened this issue May 8, 2024 · 0 comments

Comments

@achubaty
Copy link
Contributor

achubaty commented May 8, 2024

When spades.allowInitDuringSimInit is TRUE, SpaDES.core executes init events in a new simulation, with a modified end time, meaning any events using end(sim) will have those events scheduled for this modified time, and not the actual end time.

This block in resolveDepsRunInitIfPoss is likely the source of the problem:

  if (getOption("spades.allowInitDuringSimInit", TRUE)) {
      ...
      squash <- withCallingHandlers({
        simAlt <- simInit(modules = canSafelyRunInit, paths = paths, params = params,
                          objects = objects, inputs = inputs, outputs = outputs,
                          times = list(start = as.numeric(start(sim)),
                                       end = as.numeric(start(sim)), timeunit = timeunit(sim)))
        simAlt@.xData$._ranInitDuringSimInit <- completed(simAlt)$moduleName
        messageVerbose(crayon::yellow("**** Running spades call for:", safeToRunModules, "****"))
        simAltOut <- spades(simAlt, events = "init", debug = debug)
      })

Note that end time is set to start time.

For now, this can be worked around by scheduling the scheduling of affected events for later.
E.g., ianmseddy/gmcsDataPrep@8bfe8dd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant