Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow branching of simulations #19

Open
holgerbrandl opened this issue Nov 13, 2021 · 2 comments
Open

Allow branching of simulations #19

holgerbrandl opened this issue Nov 13, 2021 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@holgerbrandl
Copy link
Owner

holgerbrandl commented Nov 13, 2021

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

Current state
✔️ Framework evaluation -> kryo it is, see evaluation branch https://github.com/holgerbrandl/kalasim/tree/kryoeval
✔️ Persist koin
✔️ Persist main entities and environment
✔️ Deserialize environment including sequence iterators of process definitions (graph looks good and runs up to

val restored = kryo.readClassAndObject(input) as Environment
)
❌ 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 Kotlin/kotlinx.coroutines#76 and EsotericSoftware/kryo#867)

@holgerbrandl holgerbrandl added the enhancement New feature or request label Nov 13, 2021
@holgerbrandl holgerbrandl self-assigned this Nov 13, 2021
@holgerbrandl
Copy link
Owner Author

FYI ^^ @arnaudgiuliani and @theigl to give you some context why I had bothered you earlier this week. Thanks again for your great support.

@holgerbrandl
Copy link
Owner Author

@holgerbrandl holgerbrandl removed this from the v0.8 milestone Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant