Introduction

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, statistical sampling and monitoring. On top of that real time animation is built in.

The package comes with a number of sample models.

Requirements

Salabim runs on

  • CPython
  • PyPy platform
  • Pythonista (iOS)
  • PyDroid3 (Android)

The package is runs only 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

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. Then issue

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``

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.

Installation

The preferred way to install salabim is from PyPI with

pip install salabim

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.

For Pythonista, the easiest way to download salabim is:

  • Tap ‘Open in…’.
  • Tap ‘Run Pythonista Script’.
  • Pick this script and tap the run button
  • Import file
  • Possibly after short delay, there will be a salabim-master.zip file in the root directory
  • Tap this zip file and Extract files
  • All files are now in a directory called salabim-master
  • Optionally rename this directory to salabim

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/