- Notifications
You must be signed in to change notification settings - Fork8
ProdSim is a process-based discrete event simulation for production environments based on the SimPy framework
License
FuchsTom/ProdSim
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
ProdSim is a process-based discrete event simulation for production environments based on theSimPy framework. The package is designed to generate largehigh-resolution synthetic production data sets.
The characteristics of a production system are represented by three system components, namely machines, workpieces, anda factory. These components interact with one another on the following three system layers:
- logistics
- stations
- processes
The bottom level, namely the process level, models elementary assembly or machining operations in which the propertiesand behavior of the system components can be influenced. The middle level, namely the station level, maps the system’sbuffer 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 ofworkpieces 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 aredefined. In a Python script, the users specify the assembly and processing functions, the behavior of the sources andsinks, 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 ofinput files, and methods for estimating the simulation runtime
The following code displays the typical usage of the package:
fromprodsimimportEnvironmentdefmain():# Create simulation environmentenv=Environment()# Read the input filesenv.read_files('./data/process.json','./data/function.py')# Inspect and visualize the input data (optional)# env.inspect()# env.visualize()# Start the simulationenv.simulate(sim_time=10_000,progress_bar=True,max_memory=5,bit_type=64)# export the output dataenv.data_to_csv("./data/output/",remove_column=['item_id'],keep_original=True)if__name__=='__main__':main()
NOTE
The program, as well as the installation described below, was tested for the operating systems Win10 and macOS. Acurrent Python version (>=3.8.0) is required.
Since the installation of ProdSim includes some additionalpackages, it is recommended to installProdSim in its own (virtual) environment. This environment can be created for example with the standard library venv. Inthe following the recommended and tested installation is described step by step. Of course, the program can also beinstalled in other ways as desired, this is left to the user.
cd to the directory in which the environment should be created
macOS:
cd path
Win10:
cd path
Create a new environment
macOS:
python3 -m venv ProdSim_venv
Win10:
py -m venv ProdSim_venv
Activate the environment
macOS:
source ProdSim_venv/bin/activate
Win10:
ProdSim_venv\Scripts\activate
Install ProdSim
macOS:
pip install path_to_ProdSim/dist/ProdSim-0.1.0.tar.gz
Win10:
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 theProdSim
folder. Thereby the environment in which ProdSim was installed must be active. If the installation was notsuccessful, aModuleNotFoundError
is displayed.
from prodsim import Environment env = Environment()
NOTE
When using an old version of pip, a parse error may occur during installation. It is recommended to use the latestversion of pip.
Since ProdSim (including the required third party libraries) is installed in its own environment, it must be ensuredthat 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/bin/python
, Win10:ProdSim_venv\Scripts\python
). If the script should be executed from theterminal, it is sufficient with MacOS if the corresponding environment is active. With Win10, the path to the desiredinterpreter 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 withpython 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:
Library | Usage | Version |
---|---|---|
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:
https://prodsim.readthedocs.io/en/latest/index.html
Alternatively, the documentation can be downloaded:
- pdf:
/ProdSim/docs/_build/latex/prodsim.pdf
- html:
/ProdSim/docs/_build/html/index.html
In/ProdSim/examples
five ready executable examples are contained. The examples 01 to 04 correspond to the examplesfrom the documentation and offer the possibility to reproduce and execute what is described in the documentation. Theexampleexample_bulb
contains the two input files from the example process described in the bachelor thesis. Thesefiles 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
The folders_estimate_process
and_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 theestimator. In_temp_data
the h5 file with the simulation data is cached during the simulation run.