Skip to main content

A Discrete-Event Simulator in Python

Project description

Simulus - A discrete-event simulator in Python

Simulus is an open-source process-oriented discrete-event simulator in Python. In the near future, simulus will also support parallel and distributed simulation, and real-time simulation.


Run the following to install:

pip install simulus


Simulus works in two ways. One way is through events. You can schedule events and process them. We call it direct event scheduling. The other way is through processes. You can create processes and have them run and interact. We call it process scheduling. Of course, there's a third way, by combining them and having them both.

The following a hello-world example, which simply schedules a function invocation in the simulated future:

import simulus

def print_message(sim, params):
    print("Hello world at time "+str(

sim = simulus.simulator()
sim.sched(print_message, until=10)

The following is an example that uses processes. In this example, a homework process is created and scheduled to run at time 10. Then, five students, each represented also as a process, will spend time working on the homework. The homework process waits until all the student processes finish before it ends.

import simulus

from random import seed, expovariate, gauss

def student(sim, params):
    student_id = params.get("student_id")
    print("student %d starts to work at %g" % 
    sim.sleep(gauss(30, 5)) # work on part one
    sim.sleep(expovariate(1/10.)) # take some rest
    sim.sleep(gauss(60, 10)) # work on part two
    print("student %d finishes working at %g" % 

def homework(sim, params):
    print("homework assigned at "+str(
    # five students working on the homework each starts at a random 
    # time (exponentially distributed with mean of 10)
    students = []
    for i in range(5):
        s = sim.process(student, expovariate(1/10.), student_id=i)
    # wait for all student processes to complete
    print("last student finishes homework at "+str(

sim = simulus.simulator()
sim.process(homework, 10)

Simulus also provides advanced features to make common modeling tasks easier. For example, simulus provides resources and facilities, so that multiple processes can access multi-server queues, and perform producer-consumer synchronization over bounded buffers, among other capabilities. Simulus also supports conditional and timed waits on multiple resources and facilities.




  • Redesigned trappables; the processes, events, semaphores, traps, and resources now work with a more intuitive interface design. [Jason Liu]

  • Added initial implementation of resource and qstats. [Jason Liu]

1.0.4 (2019-07-04)


  • Finished trappables and timed waits implementation and accompanying documents (1.0.4). [Jason Liu]

  • Updated documents for using trappables and timed wait; and a bug fix. [Jason Liu]

  • Added support for conditional wait (wait on multiple trappables and timed wait). [Jason Liu]

1.0.1 (2019-07-04)


  • Pip ready; simulus has been published on pypi (1.0.1, 1.0.2, 1.0.3). [Jason Liu]

0.0.3 (2019-07-04)


  • Updated docs and added examples of using trappables; also some minor changes to interface (0.0.3). [Jason Liu]

  • Adding trapping mechanisms for inter-process communication. [Jason Liu]

0.0.2 (2019-07-04)


  • Added some examples using processes for user document. [Jason Liu]

  • Added useful functions for direct event scheduling (including resched, cancel, peek, step, and show_calendar). [Jason Liu]

  • Added phold example (to test processes). [Jason Liu]


  • Restructured examples directory (0.0.2). [Jason Liu]

  • Minor incremental updates. [Jason Liu]

  • Minor updates on a few interface functions including the sleep function. [Jason Liu]


  • Fixed process scheduling issue. [Jason Liu]

0.0.1 (2019-07-04)


  • First implementation of simulus, with support of events, processes, semaphores, and simulators; and also the jupyter notebook establishing the simple use cases. [Jason Liu]

  • This project got started in the evening on June 14, 2019 with a simple idea of creating an easy-to-use python simulator to replace our somewhat dilapitated Simian simulator and also outdoing the esoteric SimPy simulator. [Jason Liu]


  • Some minor updates (0.0.1). [Jason Liu]

  • Updated the jupyter notebooks. [Jason Liu]

  • Updated (mindless update). [Jason Liu]

  • Updated [Jason Liu]

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simulus-1.0.5.tar.gz (52.3 kB view hashes)

Uploaded Source

Built Distribution

simulus-1.0.5-py3-none-any.whl (26.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page