Skip to contents

Runs one simulation (individual or population) and returns a SimulationResults object containing all results of the simulation. Alternatively if multiple simulations are provided, they will be run concurrently. This feature is only supported for individual simulation

Usage

runSimulations(
  simulations,
  population = NULL,
  agingData = NULL,
  simulationRunOptions = NULL,
  silentMode = FALSE
)

Arguments

simulations

One Simulation or list of Simulation to simulate.

population

Optional instance of a Population to use for the simulation. This is only used when simulating one simulation Alternatively, you can also pass the result of createPopulation directly. In this case, the population will be extracted

agingData

Optional instance of AgingData to use for the simulation. This is only used with a population simulation

simulationRunOptions

Optional instance of a SimulationRunOptions used during the simulation run

silentMode

If TRUE, no warnings are displayed if a simulation fails. Default is FALSE

Value

SimulationResults (one entry per Individual) for a single simulation or a list of SimulationResults objects with names being the IDs of the simulations. If a simulation fails, the result for this simulation is NULL

Examples

simPath <- system.file("extdata", "simple.pkml", package = "ospsuite")
sim <- loadSimulation(simPath)

# Running an individual simulation
# Results is an instance of `SimulationResults`
results <- runSimulations(sim)

# Creating custom simulation run options

simRunOptions <- SimulationRunOptions$new()
simRunOptions$numberOfCores <- 3
simRunOptions$showProgress <- TRUE

# Running a population simulation
popPath <- system.file("extdata", "pop.csv", package = "ospsuite")
population <- loadPopulation(popPath)
results <- runSimulations(sim, population, simulationRunOptions = simRunOptions)

# Running multiple simulations in parallel
sim2 <- loadSimulation(simPath)
sim3 <- loadSimulation(simPath)

# Results is an array of `SimulationResults`
results <- runSimulations(list(sim, sim2, sim3))