Skip to content

Welcome to kalasim

Download Build Status slack github-discussions

kalasim is a discrete event simulator. It provides a statically typed API, dependency injection, modern persistence, structured logging and automation capabilities.

kalasim is designed for simulation practitioners, process analysts and industrial engineers, who need to go beyond the limitations of existing simulation tools to model and optimize their business-critical use-cases.

In contrast to many other simulation tools, kalasim is neither low-code nor no-code. It is code-first to enable change tracking, scaling, refactoring, CI/CD, unit-tests, and the rest of the gang that makes simulation development fun.

kalasim is written in Kotlin, is designed around suspendable coroutines for process definitions, runs on the JVM for performance and scale, is built with koin as dependency wiring framework, and is using common-math for stats and distributions. See acknowledgements for further references. kalasim is agnostic regarding a visualization frontend, but we provide bindings/examples using plotly.kt, lets-plot as well as kravis.


Meet kalasim at KotlinConf

We presented at KotlinConf 2023 in Amsterdam! We were there together with other technology leads from cloud, mobile & data-science for a great week of discussion and knowledge sharing. Our talk about "Make more money by modeling and optimizing your business processes with Kotlin" was well perceived and a lot of fun. Enjoy:


Core Features

kalasim is a generic process-oriented discrete event simulation (DES) engine.

Find out more about the basics of a kalasim simulation.

First Example

Let’s start with a very simple model. The example demonstrates the main mode of operation, the core API and the component process model implemented in kalasim. We want to build a simulation where a single car is driving around for a some time before stopping in front of a red traffic light.

////Cars.kts
import org.kalasim.*
import kotlin.time.Duration.Companion.hours
import kotlin.time.Duration.Companion.minutes


class Driver : Resource()
class TrafficLight : State<String>("red")

class Car : Component() {

    val trafficLight = get<TrafficLight>()
    val driver = get<Driver>()

    override fun process() = sequence {
        request(driver) {
            hold(30.minutes, description = "driving")

            wait(trafficLight, "green")
        }
    }
}

createSimulation {
    enableComponentLogger()

    dependency { TrafficLight() }
    dependency { Driver() }

    Car()
}.run(5.hours)

Curious about an in-depth analysis of this example? It's your lucky day, see here.

How to contribute?

Feel welcome to post ideas and suggestions to the project tracker.

We always welcome pull requests. :-)

Support

Feel welcome to post questions and ideas in the project's discussion forum

Feel also invited to chat with us in the kotlinlang.slack.com in the #kalasim channel.