Learn R Programming

rsyncrosim (version 1.2.9)

addBreakpoint: Add a Scenario breakpoint.

Description

When the Scenario is run the breakpoint's callback function will be called for the specified iterations or timesteps.

Usage

addBreakpoint(x, transformerName, breakpointType, arguments, callback)

# S4 method for Scenario addBreakpoint(x, transformerName, breakpointType, arguments, callback)

Arguments

x

A SyncroSim Scenario.

transformerName

A Stochastic Time Transformer (e.g. stsim_Runtime).

breakpointType

bi: before iteration; ai: after iteration; bt:before timestep; at: after timestep.

arguments

A vector of timesteps or iterations e.g. c(1,2).

callback

A function to be called when the breakpoint is hit.

Value

A SyncroSim Scenario with an updated list of breakpoints.

Details

Breakpoints are only supported for Stochastic Time Transformers.

Examples

Run this code
# NOT RUN {
callbackFunction <- function(x, iteration, timestep) {
  print(paste0("Breakpoint hit: ", scenarioId(x)))
}

temp_dir <- tempdir()
myses <- session()
mylib <- ssimLibrary(name = file.path(temp_dir,"testlib"), session = myses)
myScenario <- scenario(mylib, "testScenario")

myScenario <- addBreakpoint(x= myScenario, transformerName= "stsim_Runtime", breakpointType = "bi", 
              arguments = c(1,2), callback = callbackFunction)
# }

Run the code above in your browser using DataLab