simul is a discrete-event simulation library for running high-level
simulations of real-world problems and for running simulated experiments.
simul is a discrete-event simulator using incremental time progression,
with M/M/c queues for interactions
between agents. It also supports some forms of experimentation and simulated
annealing to replicate a simulation many times, varying the simulation
parameters.
Use-cases:
- Discrete-event simulation
- Complex adaptive systems
- Simulated annealing
- Job-shop scheduling
- Birth-death processes
- Computer experiments
- Other: simulating logistics, operations research problems, running experiments to approximate a global optimum, simulating queueing systems, distributed systems, performance engineering/analysis, and so on.
Usage
Warning
Experimental and unstable. Almost all APIs are expected to change.
- For some examples, see the
examplessubdirectory. - For use cases where your agents need their own custom state, define a struct,
implement
Agent, and pass your agents intoSimulationvia constructingAgentInitializers.
Basic usage
[]
= "0.4.1"
use *;
use Simulation;
use SimulationParameters;
/// Example of a minimal, simple Simulation that can be executed.
Simulation Concepts / Abstraction
- A simulation is a collection of
Agentsthat interact with each other viaMessages. - The simulation keeps a discrete time (u64) which is incremented on each tick of the Simulation.
- What an
Agentdoes at each tick of the simulation is provided by you in itson_tick()andon_message()methods. Agentsmust have a unique name.- If an
Agentwants to interact with anotherAgent, it can send aMessagevia the&mut ctx: AgentContextpassed intoon_tickandon_message.
The simulation runs all the logic of calling process(), distributing messages,
tracking metrics, incrementing time, and when to halt. A Simulation is
finished when the provided halt_check function returns true, or if an
Agent responds with a special Interrupt to halt the Simulation.
Poisson-distributed example w/ Plotting
Here's an example of an outputted graph from a simulation run. In this
simulation, we show the average waiting time of customers in a line at a
cafe. The customers arrive at a Poisson-distributed arrival rate
(lambda<-60.0) and a Poisson-distributed coffee-serving rate with the
same distribution.
This simulation maps to the real world by assuming one tick of discrete-simulation time is equal to one second.
Basically, the barista serves coffees at around 60 seconds per drink and the customers arrive at about the same rate, both modeled by a stochastic Poisson generator.
This simulation has a halt_check condition of the simulation's time
being equal to 60*60*12, representing a full 12-hour day of the cafe
being open.

Contributing
Issues, bugs, features are tracked in TODO.org