Skip to content

JensRantil/steps

Repository files navigation

steps

GoDoc

"Steps" is a simple discrete event simulator in Go. It's useful for simulations of systems that are driven by events, such as queues, workflows, etc.

See the documentation for API and examples.

Example

sim := NewSimulation()

sim.Schedule(Event{When: sim.Now.Add(10 * time.Second), Action: func(s *Simulation) {
  fmt.Println("Actor 1:", sim.Now)
}})
sim.Schedule(Event{When: sim.Now.Add(time.Second), Action: func(s *Simulation) {
  fmt.Println("Actor 2:", sim.Now)
}})

sim.RunUntilDone()

// Output:
// Actor 2: 0001-01-01 00:00:01 +0000 UTC
// Actor 1: 0001-01-01 00:00:10 +0000 UTC

See here for more examples.

Why write yet another discrete event simulator?

  • simgo was too slow for my needs. I needed to run simulations in an inner loop.
  • godes was too heavyweight and complex for my needs. I just needed a simple performant scheduler (without any goroutines).
  • SimPy was in Python and I wanted something in Go. Love this library, though!

Contact & support

This library was coded up by Jens Rantil. Do not hesitate to contact Sweet Potato Tech for support.

About

A simple discrete event simulator in Go.

Topics

Resources

License

Stars

Watchers

Forks

Languages