Skip to main content

bulksimulator

This module allows the user to run a simulation which needs to be ran for various combinations of parameters.

The simulations are performed on multiple processes to speed up computation time and the results can be stored as a csv.

Installation

To install, call

pip install bulksimulator

To use then import with

from bulksimulator import bulksimulator
from bulksimulator import csv_to_pgfplots

BulkSimulator

This class takes a function which performs some simulation, requiring a set of parameters. The BulkSimulator can then run this simulation function for a range of multiple parameters, passed as params. The parameters which are constant for all runs of the simulation are passed as kwargs.

Bulksimulator utilitses the multiprocessing module to leverage as many processes as needed to increase speed. Once ran, the any results can be saved to a .csv with their corresponding parameter settings.

Usage

Say you have a simulation function which just performs the following calculation:

def simulation(x,y,r):
    return x**2 + y**2 - r**2

Firstly, create a dictionary with the name of each parameter to be iterated over as the key and the range of values as the dictionary entry. For example,

params = {
'x' : range(10),
'y' : range(10)
}

Any other parameters which are not changed are put into the kwargs dictionary

kwargs = { 'r' : 2 }

Note: ensure the order of the parameters and extra parameters in the dictionaries are in the same order as in the simulation. (A wrapper can be written around an orignal simulation function to ensure this order is correct.)

Set the number of processes the simulations are the be run on with procs.

bulksim = bulksimulator.BulkSimulator(simulation,params,procs,kwargs)

The constructor creates a list of all combinations of the parameters which can now be run with the method

bulksim.run()

These results can then be printed to the screen with the string representation print(bulksim). Or the results can be output to a csv file

bulksim.to_csv('outputs.csv',sep=',')

and the kwargs settings can also be saved with the method save_metadata(filename).

csv_to_pgfplots

This module adds extra functionality for the case where the number of iterated parameters is 2, and there is a single, numerical result. Using the example above, the outputted csv can be changed to a text file which can then be directly used by pgfplots to create a 3D phasespace plot displaying the result due to specific parameter choices.

csv_to_pgfplots.convert(filename,outputname,sep=',',header=True)

Release files for bulksimulator 0.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bulksimulator 0.3.2
File Size Uploaded
bulksimulator-0.3.2.tar.gz 3.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bulksimulator 0.3.2
File Interpreter ABI Platform
bulksimulator-0.3.2-py3-none-any.whl Python 3 none any Details

Total release size: 9.4 kB

Release files / bulksimulator-0.3.2.tar.gz

Download URL bulksimulator-0.3.2.tar.gz
Size 3.9 kB
Tags Source
SHA-256 checksum
How to use checksums
590c8391f0987edf5597c94c489c01cb602584c77e9ea3a55dc1c16b5b2854b0
BLAKE2b-256 checksum
How to use checksums
4921602c18ae755f7c932ff37d423c3ff0961439c38d2c1c31b83f0a9db66f05
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.6.9

Release files / bulksimulator-0.3.2-py3-none-any.whl

Download URL bulksimulator-0.3.2-py3-none-any.whl
Size 5.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
50cb1d2b1c271209d7797e04798b33691a598ce5acc15ed56845315e09203118
BLAKE2b-256 checksum
How to use checksums
fad8351b1b169ccdc32c56dd44a6c3e127494d5ceb1be673a856fb85458f59e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.6.9

Release history Release notifications | RSS feed

This release

0.3.2 This release

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page