This function allows the user to add breakpoints to a SyncroSim model, for a
given Scenario
. When the Scenario is run
the
function specified by the callback argument will be called for the specified
iterations or timesteps.
addBreakpoint(x, transformerName, breakpointType, arguments, callback)
# S4 method for Scenario
addBreakpoint(x, transformerName, breakpointType, arguments, callback)
Scenario
object
character. A Stochastic Time Transformer e.g. "stsim_Runtime" (optional)
character. Options include "bi" (before iteration), "ai" (after iteration), "bt" (before timestep), or "at" (after timestep) (optional)
vector of timesteps or iterations e.g. c(1,2) (optional)
function to be called when the breakpoint is hit (optional)
A SyncroSim Scenario with an updated list of breakpoints.
Breakpoints are only supported for Stochastic Time Transformers.
if (FALSE) {
# Create callback function
callbackFunction <- function(x, iteration, timestep) {
print(paste0("Breakpoint hit: ", scenarioId(x)))
}
# Install helloworldSpatial package
installPackage("helloworldSpatial")
# Set SsimLibrary name
myLibraryName <- file.path(tempdir(),"testlib")
# Set Session and SsimLibrary
mySession <- session()
myLibrary <- ssimLibrary(name = myLibraryName,
session = mySession,
package = "helloworldSpatial")
myScenario <- scenario(myLibrary, "My Scenario")
# Add breakpoints before the 1st and 2nd iterations
myScenario <- addBreakpoint(x= myScenario,
transformerName= "helloworldSpatial_Primary",
breakpointType = "bi",
arguments = c(1,2),
callback = callbackFunction)
# Check that the breakpoints were added
breakpoint(myScenario)
}