Welcome to the Business Prototyping Toolkit for Python!
What is it?
The Business Prototyping Toolkit for Python (BPTK_Py) is the implementation of a simulation and plotting engine for System Dynamics models.
It gives you the power to simulate System Dynamics models within Python – and create beautiful plots of the simulation results for use in Jupyter Lab/ Notebooks.
Typically System Dynamics models are created using visual modeling environments, such as isee systems’ Stella® .
To address this use case, BPTK_Py ships with transentis’ sdcc parser, which automatically transpiles System Dynamics models into Python code.
Currently sdcc only supports models created using the XMILE format, which is an open XML protocol for sharing interoperable system dynamics models and simulations. The XMILE standard is governed by the OASIS standards consortium. Stella® stores system dynamics models in the XMILE format.
In future we may extend the sdcc transpiler to support other model formats – please let us know if you are interested in using BPTK_Py with other modeling environments.
- Simulate System Dynamics models in Python
- Create and manage simulation scenarios
- Make interactive plots of simulation results
- Retrieve simulation results as Pandas DataFrame timeseries data
- Automatic conversion of XMILE models to Python
BPTK_Py is licensed under the MIT license.
Before you can use the tutorial, you need to install BPTK_Py, including its dependencies.
Assuming you are starting from scratch, you need to perform the following steps:
1. Install Python
2. Install Node
3. Install BPTK_Py
4. Install JupyterLab (optional)
5. Setup a virtual environment (optional)
6. Download our BPTK_Py tutorial (optional)
First of all, you need Python. Download the latest version for your operating system.
BPTK-Py was tested with Python 3.7, 3.6 and 3.4.
Both for our sdcc compiler and also for displaying interactive widgets in Jupyter you need to install Node.js for your operating system.
Make sure you install npm (the node.js package manager) along with node.js. This should be done automatically when downloading and installing from the official site.
Please follow the guide for your operating system.
Install BPTK_Py using Pip
After the prerequisites, we have to install
BPTK_Py into your python environment. BPTK_Py is available on PyPi, the Python package index.
The easiest way to download BPTK_Py from PyPi is to use the command shell.
In windows, press “windows + R“ and type “powershell”. In Mac OS X run the Terminal app. Linux users may use their preferred terminal emulator.
To install the package, just type
pip install BPTK-Py or
pip3 install BPTK-Py. Pip is a package manager that keeps Python packages up-to-date.
Pip installs the package and makes it available system-wide. It downloads all dependencies for the package automatically.
After Pip finished successfully, you are ready for working with the framework.
If for some reason Pip is not available on your system, first download it. Regardless the operating system, this should do:
1. Download get-pip.py. The file may open in your browser tab. Make sure to save it on your hard drive.
2. Install pip: in a terminal, go to the directory of the downloaded script and issue python3 ./get-pip.py and wait a minute or two.
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py python3 get-pip.py
Install JupyterLab (optional)
You can use your simulation model in any Python code. We find it most useful to work on our models interactively to write papers and reports based on the model. JupyerLab is a fantastic environment for creating such computational essays..
pip install jupyterlab jupyter labextension install @jupyter-widgets/jupyterlab-manager
Now you have a functioning version of jupyter lab and can start working interactively using jupyter notebooks. Just type
jupyter lab in the terminal to get started.
Setup a virtual environment (optional)
In order to keep your system clean, you may want to use a virtual environment instead of installing BPTK_PY and its dependencies system-wide.
A virtual environment is a local copy of your Python distribution that stores all packages required and does not interfere with your system’s packages.
Following steps are required to set up the virtual environment and and install BPTK_Py into it:
pip install virtualenv virtualenv bptk_tutorial #this is the name of your virtual environment - change it if you want to # Enter the virtual environment. In the beginning of your prompt you should see "(bptk_tutorial)" source bptk_tutorial/bin/activate # For UNIX/Linux/Mac OS X bptk_tutorial\Scripts\activate.bat # For Windows pip install BPTK-Py pip install jupyterlab jupyter labextension install @jupyter-widgets/jupyterlab-manager
Download our introductory tutorial (optional)
The tutorial comes in a ZIP file. Unzip the package at a temporary location and move the contents of the package into the root folder of your virtual environment.
Currently the BPTK_Py framework is geared towards our own need and has a number of limitations – we are happy to extend the framework if you find something is missing.
Please let us know what you need so that we can prioritize our activities.
Here are the known limitations:
- Currently the simulator only supports the Euler method, Runge-Kutta Integration is not supported.
- The SD model transpiler only supports stocks, flows/biflows and converters. The other modeling elements provided by Stella (such as ovens and conveyors) are not supported.
- The SD model transpiler currently only supports the following builtin functions:
For questions regarding installation, usage and other help please contact us at: email@example.com.