Overview

Salabim is a package for discrete event simulation in Python. It follows the methodology of process description as originally demonstrated in Simula and later in Prosim, Must and Tomas.
The process interaction methods are also quite similar to the Python package SimPy version 2.

The package comprises discrete event simulation, queue handling, resources, stores, statistical sampling and monitoring. And -last but not least- real time 2D- and 3D-animation and video production.

The package comes with a number of sample models.

Two modes, two sets of documentation

Salabim can be used in two ways: yieldless or not yieldless. The difference is in how process interaction methods are used. Up to version 23.2.0 salabim always required yield statements in process descriptions, like

def process(self):
    yield self.hold(3)
    yield self.request(resource)

In the yieldless version, this reads

def process(self):
    self.hold(3)
    self.request(resource)

The latter is more intuitive and less likely to cause uncaught errors in the model code. But, yieldless mode, has a dependency (greenlet) and therefore doesn’t run on some hardware, like Pythonista. The salabim module is the same for both versions. Selection is done, like

sim.yieldless(False)  # selects the yield (classical) version

As all examples are affected by the yieldless state, there are two sets of the documentation.

This is the documentation for the yieldless (default) version.

The non yieldless version documentation can be found here: https://www.salabim.org/manual_yield

Requirements

Salabim runs on

  • CPython

  • PyPy

  • Pythonista (iOS)

  • PyDroid3 (Android)

  • Python in Excel (only in yielded version)

The package runs under Python 3.6 and higher.

The following packages are required:

Platform

Animation

3D animation

Video (mp4, avi)

Animated GIF/PNG

CPython

Pillow

Pillow, pyopengl

opencv, numpy

Pillow

PyPy

Pillow

?

opencv, numpy

Pillow

Pythonista

Pillow

N/A

N/A

Pillow

PyDroid3

Pillow

N/A

opencv, numpy

Pillow

Python in Excel

Pillow

N/A

N/A

Pillow

Several CPython distributions, like WinPython support Pillow out of the box. If not, install with

pip install Pillow

Under Linux, Pillow can be installed with

sudo apt-get purge python3-pil
sudo apt-get install python3-pil python3-pil.imagetk

For 3D animation, installation of OpenGL is required

For Windows

installing PyOPenGL from PyPI won't work, because glut support is missing.

Therefore, to install goto
https://github.com/cgohlke/pyopengl-build/releases/tag/v3.1.8

There, find the right wheel file for the Python version and WIndows platform.
E.g. for Python 3.13 on a 64 bits Intel/AMD platform, download

PyOpenGL-3.1.8-cp313-cp313-win_amd64.whl

and then

pip install PyOpenGL-3.1.8-cp313-cp313-win_amd64.whl

and it should work.

It is recommended to install pyopengl_acceleraten from the same repo  in the same way, like

pip install PPyOpenGL_accelerate-3.1.8-cp313-cp313-win_amd64.whl

Under Linux (at least Debian), use

pip3 install pyopengl
pip3 install pyopengl-accelerate
sudo apt-get install freeglut3-dev

to install PyOpenGL.

In order to use .obj files with 3D animations, pywavefront and pyglet are required

pip install pywavefront
pip install pyglet==1.4.0

The version number for pyglet is important as more recent versions are not compatible with pywavefront !

For video production, installation of opencv and numpy may be required with

pip install opencv-python
pip install numpy

To add audio to a video (Windows only), installation of ffmpeg is required. Refer to www.ffmpeg.org for instructions and download.

Installation

The preferred way to install salabim is from PyPI with

pip install salabim
pip install greenlet

or to upgrade to a new version

pip install salabim --upgrade
pip install greenlet --upgrade

Alternatively, it is possible to install salabim directly from GitHub with the utility install salabim from github.py, which can be found in the GitHub repository.

You can find the package along with some support files and sample models on www.github.com/salabim/salabim. From there you can directly download as a zip file and next extract all files. Alternatively the repository can be cloned.

Salabim itself is provided as one Python script, called salabim.py. You may place that file in any directory where your models reside.

If you want salabim to be available from other directories, without copying the salabim.py script, either install from PyPI (see above) or run the supplied install salabim.py file or install salabim from github.py. In doing so, you will create (or update) a salabim directory in the site-package directory, which will then contain a copy of the salabim package.

Python

Python is a widely used high-level programming object oriented language for general-purpose programming, created by Guido van Rossum and first released in 1991. An interpreted language, Python has a design philosophy that emphasizes code readability (notably using whitespace indentation to delimit code blocks rather than curly brackets or keywords), and a syntax that allows programmers to express concepts in fewer lines of code than might be used in languages such as C++ or Java. The language provides constructs intended to enable writing clear programs on both a small and large scale.

A good way to start learning about Python is https://www.python.org/about/gettingstarted/ .

Manual in pdf format

The pdf manual can be found here:

https://www.salabim.org/manual/salabim.pdf

or for the yield version:

https://www.salabim.org/manual_yield/salabim.pdf

Printed manual

_images/paperback.png

A printed manual is available from your local Amazon site in two formats:

  • full colour premium paper hardcover (ISBN 9798867009403)

  • full colour standard paper paperback (ISBN 9798865131472)

Just search for salabim user and reference manual or the ISBN number.