RunResult

sealed class RunResult(source)

Terminal outcome of a simulation run, returned by RunHandle.result.await().

All variants are normal completions of the underlying kotlinx.coroutines.Deferredawait() never throws. Consumers use a when expression to branch on the outcome rather than try/catch:

when (val r = handle.result.await()) {
is RunResult.Completed -> showResults(r.snapshot)
is RunResult.BatchCompleted -> showBatchResults(r.snapshots)
is RunResult.OptimizationCompleted -> showOptResults(r.bestSolution, r.iterationHistory)
is RunResult.Cancelled -> showCancelled(r.reason)
is RunResult.Failed -> showError(r.error)
}

The last event on RunHandle.events mirrors this outcome: RunEvent.RunCompleted, RunEvent.RunCancelled, or RunEvent.RunFailed.

Inheritors

Constructors

Link copied to clipboard
protected constructor()

Types

Link copied to clipboard
data class BatchCompleted(val summary: OrchestratorSummary, val snapshots: List<SimulationSnapshot.ExperimentCompleted>, val replicationsByItem: Map<String, List<SimulationSnapshot.ReplicationCompleted>> = emptyMap()) : RunResult

A scenario sweep or designed experiment finished. Every successfully completed scenario or design point contributes one SimulationSnapshot.ExperimentCompleted to snapshots; the list is non-empty on a clean run.

Link copied to clipboard
data class Cancelled(val reason: String) : RunResult

The run was stopped by an explicit call to RunHandle.cancel.

Link copied to clipboard
data class Completed(val summary: RunSummary, val snapshot: SimulationSnapshot.ExperimentCompleted) : RunResult

A single-model run finished normally (all requested replications ran, or the model ended itself via endSimulation()).

Link copied to clipboard
data class Failed(val error: KSLRuntimeError) : RunResult

The run was terminated by an unexpected exception during replication execution.

Link copied to clipboard
data class OptimizationCompleted(val summary: OrchestratorSummary, val bestSolution: SolverStateSnapshot, val iterationHistory: List<SolverStateSnapshot>) : RunResult

A simulation-optimization run finished. Carries the solver's best solution and the full per-iteration history for convergence analysis.