simulate

suspend fun simulate(iterator: Iterator<DesignPoint>, numRepsPerDesignPoint: Int? = null, clearRuns: Boolean = true, addRuns: Boolean = true, clearAllData: Boolean = true, onDesignPointComplete: (designPoint: DesignPoint, snapshot: SimulationSnapshot.ExperimentCompleted?) -> Unit? = null, onDesignPointStart: (designPoint: DesignPoint) -> Unit? = null, onDesignPointCancelled: (designPoint: DesignPoint) -> Unit? = null, onDesignPointReplications: (experimentName: String, replications: List<SimulationSnapshot.ReplicationCompleted>) -> Unit? = null)(source)

Simulates the design points presented by iterator concurrently.

Design points are launched in parallel on SimulationDispatcher.default. After all simulations complete, results are committed to kslDb sequentially in iterator order and onDesignPointComplete is fired for each point. Cancellation is checked between each design-point commit, so cooperative cancellation takes effect at design-point boundaries during the commit phase.

This is a suspend function and must be called from a coroutine scope. For command-line or test use, wrap with runBlocking { experiment.simulate(iterator) }.

Parameters

onDesignPointComplete

optional callback invoked after each design point's results are committed to kslDb. Receives the DesignPoint and its SimulationSnapshot.ExperimentCompleted, or null if the design point failed with a RuntimeException.