ProdSim - ReadMe
Table of contents
ProdSim is a process-based discrete event simulation for production environments based on the SimPy framework. The package is designed to generate large high-resolution synthetic production data sets.
The characteristics of a production system are represented by three system components, namely machines, workpieces, and a factory. These components interact with one another on the following three system layers:
The bottom level, namely the process level, models elementary assembly or machining operations in which the properties and behavior of the system components can be influenced. The middle level, namely the station level, maps the system’s buffer stores and groups machines together into stations according to a workshop or line production. At the top level, namely the layout level, workpieces are created by sources and removed by sinks. In addition, the material flow of workpieces through the production process is described.
Users must define production processes in two input files. In a JSON file, all orders, stations, and the factory are defined. In a Python script, the users specify the assembly and processing functions, the behavior of the sources and sinks, as well as global functions and user-defined distributions for attribute values.
Additionally, the package offers functionalities for the visualization of passed production processes, verification of input files, and methods for estimating the simulation runtime
The following code displays the typical usage of the package:
from prodsim import Environment def main(): # Create simulation environment env = Environment() # Read the input files env.read_files('./data/process.json', './data/function.py') # Inspect and visualize the input data (optional) # env.inspect() # env.visualize() # Start the simulation env.simulate(sim_time=10_000, progress_bar=True, max_memory=5, bit_type=64) # export the output data env.data_to_csv("./data/output/", remove_column=['item_id'], keep_original=True) if __name__ == '__main__': main()
The program, as well as the installation described below, was tested for the operating systems Win10 and macOS. A current Python version (>=3.8.0) is required.
Since the installation of ProdSim includes some additional packages, it is recommended to install ProdSim in its own (virtual) environment. This environment can be created for example with the standard library venv. In the following the recommended and tested installation is described step by step. Of course, the program can also be installed in other ways as desired, this is left to the user.
cd to the directory in which the environment should be created
Create a new environment
python3 -m venv ProdSim_venv
py -m venv ProdSim_venv
Activate the environment
pip install path_to_ProdSim/dist/ProdSim-0.1.0.tar.gz
pip install path_to_ProdSim\dist\ProdSim-0.1.0.tar.gz
To check if the installation was successful, the following Python script can be created and executed outside the
ProdSim folder. Thereby the environment in which ProdSim was installed must be active. If the installation was not
ModuleNotFoundError is displayed.
from prodsim import Environment env = Environment()
When using an old version of pip, a parse error may occur during installation. It is recommended to use the latest version of pip.
Since ProdSim (including the required third party libraries) is installed in its own environment, it must be ensured that the correct interpreter is selected when executing a script.
The easiest way is to run the script from an IDE and specify the interpreter in the settings (MacOS:
ProdSim_venv\Scripts\python). If the script should be executed from the
terminal, it is sufficient with MacOS if the corresponding environment is active. With Win10, the path to the desired
interpreter must be specified for each call:
> ProdSim_venv\Scripts\python path_to_script\script.py
Alternatively it is also possible to install ProdSim without the package manager pip with
python setup.py install.
This is not recommended since external libraries may not be installed correctly automatically.
The following packages are automatically installed in the current environment when ProdSim is installed via pip:
|simpy||simulation kernel||>= 4.0.1|
|numpy||internal tracking of simulation objects||>= 1.21.2|
|dill||plotting the simulation data||>= 0.3.4|
|h5py||internal caching of simulation data||>= 3.4.0|
|dash, dash_cytoscape||visualization of the production process||>= 2.0.0, >= 0.3.0|
The documentation is hosted via read the docs:
Alternatively, the documentation can be downloaded:
/ProdSim/examples five ready executable examples are contained. The examples 01 to 04 correspond to the examples
from the documentation and offer the possibility to reproduce and execute what is described in the documentation. The
example_bulb contains the two input files from the example process described in the bachelor thesis. These
files can be used to fill the light bulb production with process functions and to analyze them as needed.
The complete source code can be found at
/ProdSim/prodsim/ and contains the following files:
. /ProdSim/prodsim/ |--__init__.py |--__pychache__/ |--_estimate_process/ |--_temp_data/ |--app/ |--components.py |--environment.py |--estimator.py |--exception.py |--filehandler.py |--helper.py |--inspector.py |--simulator.py |--tracker.py |--visualizer.py
_temp_data are also installed during the installation.
_estimate_process contains a set of input files which are used to perform the estimation measurements of the
_temp_data the h5 file with the simulation data is cached during the simulation run.