https://github.com/jensrantil/steps
A discrete event simulator in Go.
https://github.com/jensrantil/steps
discrete-event-simulation golang simulation
Last synced: 11 months ago
JSON representation
A discrete event simulator in Go.
- Host: GitHub
- URL: https://github.com/jensrantil/steps
- Owner: JensRantil
- License: mit
- Created: 2025-01-20T15:19:28.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2025-02-14T22:17:29.000Z (12 months ago)
- Last Synced: 2025-02-14T22:29:55.120Z (12 months ago)
- Topics: discrete-event-simulation, golang, simulation
- Language: Go
- Homepage: https://pkg.go.dev/github.com/JensRantil/steps
- Size: 36.1 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# steps
[](https://pkg.go.dev/github.com/JensRantil/steps)
"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](https://pkg.go.dev/github.com/JensRantil/steps) for API and examples.
## Example
```go
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](https://pkg.go.dev/github.com/JensRantil/steps#pkg-examples) for more examples.
## Why write yet another discrete event simulator?
* [simgo](https://github.com/fschuetz04/simgo) was too slow for my needs. I needed to run simulations in an inner loop.
* [godes](https://github.com/agoussia/godes) was too heavyweight and complex for my needs. I just needed a simple performant scheduler (without any goroutines).
## Contact & support
This library was coded up by [Jens Rantil](https://jensrantil.github.io). Do not hesitate to contact [Sweet Potato Tech](https://jensrantil.github.io/pages/services/) for support.