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 SimPy 2.
The package comprises discrete event simulation, queue handling, resources, store, 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 in how process interaction methods are used. Up to version 23.2.0 salabim always required yield statements in process descriptions, like
In the yieldless version, this reads
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 non yieldless
As all examples are affected by the yieldless state, so 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
Salabim runs on
The package runs under Python 3.6 and higher.
The following packages are required:
Video (mp4, avi)
Several CPython packages, 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
pip install pyopengl
pip install pyopengl_accelerate
If, after that you get a runtime error that glutInit is not defined, try to install from the Unofficial Windows Binaries for Python Extension Packages site at https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyopengl
Then, find the right 3.1.5 or later version for you (e.g. for Python 3.7, 64 bits you use
PyOpenGL-3.1.5-cp37-cp37m-win_amd64.whl) and download that.
pip install wheelfile
,like (for the above package)
pip install PyOpenGL-3.1.5-cp37-cp37m-win_amd64.whl
and it should work.
It is recommended to install pyopengl_accelerate in the same way, like
pip install PyOpenGL_accelerate-3.1.5-cp37-cp37m-win_amd64.whl
Under Linux (at least Debian), use
pip3 install pyopengl
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.5.27
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.
Running models under PyPy is highly recommended for production runs, where run time is important. We have found 6 to 7 times faster execution compared to CPython. However, for development, nothing can beat CPython or Pythonista.
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
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 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