To enable different trajectories (with controlled randomization), the user may want to branch simulations at a specific time.
Example
// current API
val sim : Environment = createSimulation{
// define simulation entities here
}
// run it for 100 ticks
sim.run(100)
// inspect some metric (see https://www.kalasim.org/analysis/)
sim.gatherStatistic()
// Pseudocode/Desired API from here on
val branches : List<Environment> = sim.branch(100)
val branchStats = branches.forEach { it.run(100) }.map{ it.gatherStatistic() }
To do so we must persist the entire graph including koin, monitors, the environment (including its queue) and process states (which are modelled as kotlin.sequences.Sequence iterators). Naturally - by design of kalasim - user-specific code will also leak into the graph to be persisted.
The feature would also provide means to have file-format for saving/loading simulations
Such a feature would also prepare for distributed simulation, where simulations are packed and shipped over the network to other compute nodes
To enable different trajectories (with controlled randomization), the user may want to branch simulations at a specific time.
Example
To do so we must persist the entire graph including koin, monitors, the environment (including its queue) and process states (which are modelled as
kotlin.sequences.Sequence
iterators). Naturally - by design of kalasim - user-specific code will also leak into the graph to be persisted.Current state :heavy_check_mark: Framework evaluation -> kryo it is, see evaluation branch https://github.com/holgerbrandl/kalasim/tree/kryoeval :heavy_check_mark: Persist koin :heavy_check_mark: Persist main entities and environment :heavy_check_mark: Deserialize environment including sequence iterators of process definitions (graph looks good and runs up to https://github.com/holgerbrandl/kalasim/blob/9d383e07d7dd7e59488a3f7a1c4a03105b6efc62/modules/persistence/src/main/kotlin/Kryo.kt#L77) :x: Run deserialized environment--> Fails to run, which boils to sequence iterators being not serializable as of now in https://github.com/holgerbrandl/kryo-kotlin-sam/blob/master/src/main/kotlin/simpleproc/SimpleProc.kt (see https://github.com/Kotlin/kotlinx.coroutines/issues/76 and https://github.com/EsotericSoftware/kryo/issues/867)