A python simulation engine for System Dynamics & Agent based models
Business Prototyping Toolkit for Python
System Dynamics and Agent-based Modeling in Python
The Business Prototyping Toolkit for Python (BPTK-Py) is a computational modeling framework that enables you to build simulation models using System Dynamics (SD) and/or agent-based modeling (ABM) and manage simulation scenarios with ease.
Next to providing the necessary SD and ABM language constructs to build models directly in Python, the framework also includes a compiler for transpiling System Dynamics models conforming to the XMILE standard into Python code.
This means you can build models in a XMILE-compatible visual modeling environment (such as iseesystems Stella and then use them independently in an Python environment.
The best way to get started with BPTK-Py is our tutorial, which contains a number of simulation models and Jupyter notebooks to get you started – you can clone or download the tutorial from our git repository on Github.
- The BPTK-Py framework supports System Dynamics models in XMILE Format, native SD models using a domain-specific language for System Dynamics (SD DSL) and native Agent-based models. You can also build hybrid SD-ABM-Models natively in Python.
- The objective of the framework is to let the modeller concentrate on building simulation models by providing a seamless interface for managing model settings and scenarios and for plotting simulation results.
- All plotting is done using Matplotlib.
- Simulation results are returned as Pandas dataframes and thus can easily be used for analytics.
- Model settings and scenarios are kept in JSON files. These settings are automatically loaded by the framework upon initialization, as are the model classes themselves. This makes interactive modeling, coding and testing very painless, especially if using the Jupyter notebook environment.
The first place to go to for help and installation instructions is the online documentation.
You should also study the BPTK-Py tutorial, which contains the sample models and Jupyter notebooks referenced in the online documentation. You can clone or download the tutorial from our git repository.
BPTK-Py is developed and maintained by transentis Labs GmbH.
For questions regarding installation, usage and other help please contact us at: firstname.lastname@example.org.
- We are supporting all XMILE operators now. Note that random numbers with seed are never the same as when using Stella Architect's seed! This is due to different random number generators in Python and Stella. We neither support the min / max arguments for the random number operators. Refer to the documentation)
- RUNCOUNT and SENSIRUNCOUNT are not supported and support is not planned.
- Bugfix release: Better support for multidimensional arrays
- Bugfix release: Fixed an issue with plot_lookup
- SD Compiler: Added new operators
- Arrays and Array Operators (MIN, MAX, SUM, MEAN, SELF, SIZE, PROD)
- Statistical operators (COMBINATIONS, BETA, BINOMIAL, FACTORIAL, GAMMA, GAMMALN, EXPRND, GEOMETRIC)
- Trigonometric operators (ARCSIN, ARCCOS, ARCTAN)
plot_scenariosAPI now supports array calls such as
- SD DSL: ABS, DT, PULSE, STARTTIME, STOPTIME
- With the new XMILE Transpiler, we also ship support for the following XMILE operators: SMTH1, TREND
- Added new operators for the SD DSL along with in depth documentation that shows how to use the functions: DELAY, EXP, SMOOTH, STEP, TREND.
- The SD DSL is now stricter, all constant values must be floats, ints are no longer accepted.
- Added a new
register_modelmethod to bptk, to ensure quick setup of scenario managers and scenarios.
- Internal optimizations and bug fixes.
- Extended the
exportfunction, it now also exports data to allow comparison between scenarios
- Fixed an error in requirements.txt
- Added a new export method to the bptk class to simplify the export of simulation results.
- Added some new methods to the bptk class to allow easy access to scenarios - accessing the scenarioManagerFactory is now no longer necessary.
- Updated and simplified the documentation.
- System Dynamics DSL: Extended the operator overrides, to ensure stocks can have more than two inflows or outflows.
- Bug fix to bptk.add_scenario that occurred when adding a new scenario to an existing scenario manager
- Little fix for requirements.txt
- We are working on making BPTK-Py even more flexible. The Scheduler interface now has an attribute
running. You can modify this during runtime in order to cancel long-standing jobs. This may be useful for third-party applications that use BPTK-Py and need to be able to cancel jobs.
- The YAML Model parser now supports custom Model files for ABM simulations!
- Bugfix for agent: Property type can also be of type "Agent".
- Fixed an annoying bug: We forgot to include the threads that watch the scenario JSON files into the
bptk.destroy()method. Now it runs properly and once executed all monitors will stop monitoring.
- YAML Support! Now you can easily define your models using YAML notation. This is much simpler than JSON.
- As a perk, you do not need the model implementation for AB models anymore. When using YAML notation, BPTK will create the necessary objects without requiring code. So now you can concentrate onyour agents without the need of registering agent factories!
- Choose Data collector class within the model file: The YAML file now supports the directive
datacollector. Here you can link to custom data collector classes. Try the included ones such as
BPTK_Py.abm.CSVDAtaCollector. Using custom data collectors reduces simulation time tremendously as
BPTK-Pywill not use its slow mechanism to create dataframes anymore.
- We also included a meta model creator feeding on parser results. You only need to implement the model parser and feed the model creator. The model creator then builds the actual simulation model. This way, you can add modelling languages easily!
- Added Delayed Events in Agent based modelling. Now each agent can send events that trigger in the future. Instantiate a
DelayedEventand set the
trigger_inparameter with the number of periods to wait before trigger. The framework will make sure to trigger the event at the right time.
- Multithreading for scenario execution: Speeding up multi-scenario simulation siginificantly by using one thread per scenario
agent_typeas optional parameter for Agent. Now you do not need to add the agent type in the initialize method anymore if that is what you prefer
- Better handling of progress bar in ABM simulation using
ipywidgets.Outto make bar disappear after executiob. Removed running scheduler as thread because this is not required here.
- ABM: If you still have scenario manager files but deleted the code, execution will not be stopped anymore but faulty scenario is skipped with an Error message.
- Little improvements and bugfixes to data collectors. For Kinesis, you will be warned if
boto(required for AWS access) is not installed as it is not a package dependency.
- We want to make data analysis easy for you. Hence, we added data collectors as standard for model output:
CSVDataCollectoroutputs each agents' events to CSV, one file per agent.
KinesisDataCollectoroutputs the agent statistics to Kinesis, an AWS service. For both, the data output is event-wise
- New methods model.begin_round and model.end_round. Model.act is now obsolete
- Added a bptk.train_simulation method which runs simulation in episodes to allow training
- Small changes to the scenario definition syntax (JSON) for agent-based models
- Renamed the progressBar attribute of bptk.plot_simulation to progress_bar
- Bug fix to bptk.run_simulations: the parameter AgentPropertyTypes was not handled correctly
- Bug fix: all agents were receiving the same properties object on initialization. Fixed by using Python's copy module. Each agent now receives a deep copy. Changes on one agent's properties do not interfere with changes on other agents' properties anymore.
- Bug fix: valuate_function was renamed to evaluate_equation in 0.6.0 , but not everywhere
- New functionality: you can now define a function in Python and use it within an SD model.
- First Release of documentation for Readthedocs. Check it out at: http://bptk.transentis.com
- You can now run AB models with a custom data_collector without plotting using "run_simulations()". This allows you to create custom data collectors that do not emit data back to BPTK, e.g. a streaming data collector
- Fixed an issue regarding absolute and relative imports in the Model class
- Various improvements to ABM module
- Models now have their own act method, to allow updating of dynamic properties.
- Internal changes to event handling in agents
- Fixed a bug regarding lookup handling.
- Bugfix for ABM module
- Large improvements for the Agent Based Modeling component! Main changes:
- Agents can now have properties.
- Agent properties can be set via the JSON config file. Properties can be accessed using dot-notation, i.e. agent.property
- The necessary property get/set methods are added automatically using Python metaprogramming facilities - this keeps the code that needs to implemented by the modeler to a mimimum.The same is true of model properties - these can now also be accessed using dot-notation.
- Statistics for properties are automatically collected and can be plotted using the plot_scenarios method. Currently the following statistics are collected: total, min, max, mean.
- Bugfix in Model class: dt param was not properly instantiated
- Framework for Agent Based models
- Framework for defining System Dynamics models in code with less effort. No need for complex recursive calls anymore. Simply define your equations as easy as element.equation = element * anotherElement. Example in the tutorial!
- Simplify API: use comma-seperated values to specify scenarios/scenario managers or equations, no need for Python lists anymore!
- Many more internal improvements under the hood.
- PULSE functions can now be defined within Jupyter environment. Just use the new pulse_function_create(scenarios,scenario_managers) method and be surprised.
- Cleaner method for strategy simulation. Now running stepwise, not using a complex while loop anymore. Improves readability tremendously!
- Optimize imports using init.py properly.
- Correct handling of decimal dt values within simulator.
- Bugfix to reduce size of the package
- Now interpreting strategies that modify at '0' as constants values and overwrite the constants
- Use DT of simulation model
- Fixed a bug that prevented from plotting properly when giving multiple scenario managers where one of them did not store the given scenario name
- Monitoring of Scenario JSON files:
- Reload scenarios upon change (also works if Scenario manager spreads over multiple files)
- Find added scenarios
- Merge base values spread over multiple files
- horizontal lines in graphs to improve readability
- Improvements to readme file
- Small bug fixes
Release history Release notifications
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size BPTK_Py-1.1.0-py3-none-any.whl (137.7 kB)||File type Wheel||Python version py3||Upload date||Hashes View hashes|
|Filename, size BPTK_Py-1.1.0.tar.gz (103.7 kB)||File type Source||Python version None||Upload date||Hashes View hashes|