sim-tools 0.3.3__tar.gz → 0.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,112 @@
1
+ # jupyter-book build folder for docs
2
+ docs/_build/*
3
+
4
+ # vscode
5
+ .vscode/
6
+
7
+ *.md.backup
8
+
9
+ # Byte-compiled / optimized / DLL files
10
+ __pycache__/
11
+ *.py[cod]
12
+ *$py.class
13
+
14
+ # C extensions
15
+ *.so
16
+
17
+ # Distribution / packaging
18
+ .Python
19
+ build/
20
+ develop-eggs/
21
+ dist/
22
+ downloads/
23
+ eggs/
24
+ .eggs/
25
+ lib/
26
+ lib64/
27
+ parts/
28
+ sdist/
29
+ var/
30
+ wheels/
31
+ *.egg-info/
32
+ .installed.cfg
33
+ *.egg
34
+ MANIFEST
35
+
36
+ # PyInstaller
37
+ # Usually these files are written by a python script from a template
38
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
39
+ *.manifest
40
+ *.spec
41
+
42
+ # Installer logs
43
+ pip-log.txt
44
+ pip-delete-this-directory.txt
45
+
46
+ # Unit test / coverage reports
47
+ htmlcov/
48
+ .tox/
49
+ .coverage
50
+ .coverage.*
51
+ .cache
52
+ nosetests.xml
53
+ coverage.xml
54
+ *.cover
55
+ .hypothesis/
56
+ .pytest_cache/
57
+
58
+ # Translations
59
+ *.mo
60
+ *.pot
61
+
62
+ # Django stuff:
63
+ *.log
64
+ local_settings.py
65
+ db.sqlite3
66
+
67
+ # Flask stuff:
68
+ instance/
69
+ .webassets-cache
70
+
71
+ # Scrapy stuff:
72
+ .scrapy
73
+
74
+ # Sphinx documentation
75
+ docs/_build/
76
+
77
+ # PyBuilder
78
+ target/
79
+
80
+ # Jupyter Notebook
81
+ .ipynb_checkpoints
82
+
83
+ # pyenv
84
+ .python-version
85
+
86
+ # celery beat schedule file
87
+ celerybeat-schedule
88
+
89
+ # SageMath parsed files
90
+ *.sage.py
91
+
92
+ # Environments
93
+ .env
94
+ .venv
95
+ env/
96
+ venv/
97
+ ENV/
98
+ env.bak/
99
+ venv.bak/
100
+
101
+ # Spyder project settings
102
+ .spyderproject
103
+ .spyproject
104
+
105
+ # Rope project settings
106
+ .ropeproject
107
+
108
+ # mkdocs documentation
109
+ /site
110
+
111
+ # mypy
112
+ .mypy_cache/
@@ -1,53 +1,75 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: sim-tools
3
- Version: 0.3.3
3
+ Version: 0.5.0
4
4
  Summary: Simulation Tools for Education and Practice
5
- Home-page: https://github.com/TomMonks/sim-tools
6
- Author: Thomas Monks
7
- Author-email: t.m.w.monks@exeter.ac.uk
8
- License: The MIT License (MIT)
9
- Classifier: Programming Language :: Python :: 3.10
10
- Classifier: Programming Language :: Python :: 3.11
5
+ Project-URL: Homepage, https://github.com/TomMonks/sim-tools
6
+ Project-URL: Bug Tracker, https://github.com/TomMonks/sim-tools/issues
7
+ Project-URL: Documentation, https://tommonks.github.io/sim-tools
8
+ Author-email: Thomas Monks <t.m.w.monks@exeter.ac.uk>
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
11
  Classifier: License :: OSI Approved :: MIT License
12
12
  Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
13
15
  Requires-Python: >=3.10
14
- Description-Content-Type: text/markdown
15
- License-File: LICENSE
16
16
  Requires-Dist: matplotlib>=3.1.3
17
17
  Requires-Dist: numpy>=1.18.1
18
18
  Requires-Dist: pandas>=2.0.0
19
- Requires-Dist: scipy>=1.4.1
20
19
  Requires-Dist: scikit-learn>=1.0.0
20
+ Requires-Dist: scipy>=1.4.1
21
+ Description-Content-Type: text/markdown
21
22
 
22
- # sim-tools: tools to support the simulation process in python.
23
+ # `sim-tools`: tools to support the Discrete-Event Simulation process in python.
23
24
 
24
25
  [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/TomMonks/sim-tools/HEAD)
25
26
  [![DOI](https://zenodo.org/badge/225608065.svg)](https://zenodo.org/badge/latestdoi/225608065)
26
27
  [![PyPI version fury.io](https://badge.fury.io/py/sim-tools.svg)](https://pypi.python.org/pypi/sim-tools/)
28
+ [![Anaconda-Server Badge](https://anaconda.org/conda-forge/sim-tools/badges/version.svg)](https://anaconda.org/conda-forge/sim-tools)
29
+ [![Anaconda-Server Badge](https://anaconda.org/conda-forge/sim-tools/badges/platforms.svg)](https://anaconda.org/conda-forge/sim-tools)
27
30
  [![Read the Docs](https://readthedocs.org/projects/pip/badge/?version=latest)](https://tommonks.github.io/sim-tools)
28
31
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
29
32
  [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/release/python-360+/)
30
33
  [![License: MIT](https://img.shields.io/badge/ORCID-0000--0003--2631--4481-brightgreen)](https://orcid.org/0000-0003-2631-4481)
31
34
 
32
- sim-tools is being developed to support simulation education and applied simulation research. It is MIT licensed and freely available to practitioners, students and researchers via PyPi. There is a longer term plan to make sim-tools available via conda-forge.
35
+
36
+ `sim-tools` is being developed to support Discrete-Event Simulation (DES) education and applied simulation research. It is MIT licensed and freely available to practitioners, students and researchers via [PyPi](https://pypi.org/project/sim-tools/) and [conda-forge](https://anaconda.org/conda-forge/sim-tools)
33
37
 
34
38
  # Vision for sim-tools
35
39
 
36
- 1. Deliver high quality reliable code for simulation education and practice with full documentation.
40
+ 1. Deliver high quality reliable code for DES education and practice with full documentation.
37
41
  2. Provide a simple to use pythonic interface.
38
- 3. To improve the quality of simulation education and encourage the use of best practice.
42
+ 3. To improve the quality of DES education using FOSS tools and encourage the use of best practice.
39
43
 
40
44
  # Features:
41
45
 
42
- 1. Implementation of classic optimisation via Simulation procedures such as KN, KN++, OBCA and OBCA-m
46
+ 1. Implementation of classic Optimisation via Simulation procedures such as KN, KN++, OBCA and OBCA-m
43
47
  2. Distributions module that includes classes that encapsulate a random number stream, seed, and distribution parameters.
44
- 3. Implementation of Thinning to sample from Non-stationary poisson processes in a discrete-event simulation
48
+ 3. Implementation of Thinning to sample from Non-stationary poisson processes in a DES.
49
+
50
+ ## Installation
51
+
52
+ ### Pip and PyPi
53
+
54
+ ```bash
55
+ pip install sim-tools
56
+ ```
57
+
58
+ ### Conda-forge
59
+
60
+ ```bash
61
+ conda install -c conda-forge sim-tools
62
+ ```
63
+
64
+ ### Binder
65
+
66
+ [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/TomMonks/sim-tools/HEAD)
67
+
45
68
 
46
- ## Three simple ways to explore sim-tools
69
+ ## Learn how to use `sim-tools`
47
70
 
48
- 1. `pip install sim-tools`
49
- 2. Click on the launch-binder at the top of this readme. This will open example Jupyter notebooks in the cloud via Binder.
50
- 3. Oneline documentation: https://tommonks.github.io/sim-tools
71
+ * Online documentation: https://tommonks.github.io/sim-tools
72
+ * Introduction to DES in python: https://health-data-science-or.github.io/simpy-streamlit-tutorial/
51
73
 
52
74
  ## Citation
53
75
 
@@ -1,32 +1,53 @@
1
- # sim-tools: tools to support the simulation process in python.
1
+ # `sim-tools`: tools to support the Discrete-Event Simulation process in python.
2
2
 
3
3
  [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/TomMonks/sim-tools/HEAD)
4
4
  [![DOI](https://zenodo.org/badge/225608065.svg)](https://zenodo.org/badge/latestdoi/225608065)
5
5
  [![PyPI version fury.io](https://badge.fury.io/py/sim-tools.svg)](https://pypi.python.org/pypi/sim-tools/)
6
+ [![Anaconda-Server Badge](https://anaconda.org/conda-forge/sim-tools/badges/version.svg)](https://anaconda.org/conda-forge/sim-tools)
7
+ [![Anaconda-Server Badge](https://anaconda.org/conda-forge/sim-tools/badges/platforms.svg)](https://anaconda.org/conda-forge/sim-tools)
6
8
  [![Read the Docs](https://readthedocs.org/projects/pip/badge/?version=latest)](https://tommonks.github.io/sim-tools)
7
9
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
10
  [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/release/python-360+/)
9
11
  [![License: MIT](https://img.shields.io/badge/ORCID-0000--0003--2631--4481-brightgreen)](https://orcid.org/0000-0003-2631-4481)
10
12
 
11
- sim-tools is being developed to support simulation education and applied simulation research. It is MIT licensed and freely available to practitioners, students and researchers via PyPi. There is a longer term plan to make sim-tools available via conda-forge.
13
+
14
+ `sim-tools` is being developed to support Discrete-Event Simulation (DES) education and applied simulation research. It is MIT licensed and freely available to practitioners, students and researchers via [PyPi](https://pypi.org/project/sim-tools/) and [conda-forge](https://anaconda.org/conda-forge/sim-tools)
12
15
 
13
16
  # Vision for sim-tools
14
17
 
15
- 1. Deliver high quality reliable code for simulation education and practice with full documentation.
18
+ 1. Deliver high quality reliable code for DES education and practice with full documentation.
16
19
  2. Provide a simple to use pythonic interface.
17
- 3. To improve the quality of simulation education and encourage the use of best practice.
20
+ 3. To improve the quality of DES education using FOSS tools and encourage the use of best practice.
18
21
 
19
22
  # Features:
20
23
 
21
- 1. Implementation of classic optimisation via Simulation procedures such as KN, KN++, OBCA and OBCA-m
24
+ 1. Implementation of classic Optimisation via Simulation procedures such as KN, KN++, OBCA and OBCA-m
22
25
  2. Distributions module that includes classes that encapsulate a random number stream, seed, and distribution parameters.
23
- 3. Implementation of Thinning to sample from Non-stationary poisson processes in a discrete-event simulation
26
+ 3. Implementation of Thinning to sample from Non-stationary poisson processes in a DES.
27
+
28
+ ## Installation
29
+
30
+ ### Pip and PyPi
31
+
32
+ ```bash
33
+ pip install sim-tools
34
+ ```
35
+
36
+ ### Conda-forge
37
+
38
+ ```bash
39
+ conda install -c conda-forge sim-tools
40
+ ```
41
+
42
+ ### Binder
43
+
44
+ [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/TomMonks/sim-tools/HEAD)
45
+
24
46
 
25
- ## Three simple ways to explore sim-tools
47
+ ## Learn how to use `sim-tools`
26
48
 
27
- 1. `pip install sim-tools`
28
- 2. Click on the launch-binder at the top of this readme. This will open example Jupyter notebooks in the cloud via Binder.
29
- 3. Oneline documentation: https://tommonks.github.io/sim-tools
49
+ * Online documentation: https://tommonks.github.io/sim-tools
50
+ * Introduction to DES in python: https://health-data-science-or.github.io/simpy-streamlit-tutorial/
30
51
 
31
52
  ## Citation
32
53
 
@@ -0,0 +1,40 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "sim-tools"
7
+ dynamic = ["version"]
8
+ description = "Simulation Tools for Education and Practice"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ requires-python = ">=3.10"
12
+ authors = [
13
+ { name = "Thomas Monks", email = "t.m.w.monks@exeter.ac.uk" },
14
+ ]
15
+ classifiers = [
16
+ "License :: OSI Approved :: MIT License",
17
+ "Operating System :: OS Independent",
18
+ "Programming Language :: Python :: 3.10",
19
+ "Programming Language :: Python :: 3.11",
20
+ ]
21
+ dependencies = [
22
+ "matplotlib>=3.1.3",
23
+ "numpy>=1.18.1",
24
+ "pandas>=2.0.0",
25
+ "scikit-learn>=1.0.0",
26
+ "scipy>=1.4.1",
27
+ ]
28
+
29
+ [project.urls]
30
+ Homepage = "https://github.com/TomMonks/sim-tools"
31
+ "Bug Tracker" = "https://github.com/TomMonks/sim-tools/issues"
32
+ Documentation = "https://tommonks.github.io/sim-tools"
33
+
34
+ [tool.hatch.version]
35
+ path = "sim_tools/__init__.py"
36
+
37
+ [tool.hatch.build.targets.sdist]
38
+ include = [
39
+ "/sim_tools",
40
+ ]
@@ -0,0 +1,4 @@
1
+ __version__ = '0.5.0'
2
+ __author__ = 'Thomas Monks'
3
+
4
+ from . import datasets, distributions, time_dependent, ovs
@@ -0,0 +1,10 @@
1
+ t,mean_iat
2
+ 0,15
3
+ 60,12
4
+ 120,7
5
+ 180,5
6
+ 240,8
7
+ 300,10
8
+ 360,15
9
+ 420,20
10
+ 480,20
@@ -169,70 +169,66 @@ class Lognormal(Distribution):
169
169
 
170
170
 
171
171
  class Normal(Distribution):
172
- """
172
+ '''
173
173
  Convenience class for the normal distribution.
174
174
  packages up distribution parameters, seed and random generator.
175
175
 
176
- Option to prevent negative samples by resampling
177
-
178
- """
179
-
176
+ Use the minimum parameter to truncate the distribution
177
+ '''
180
178
  def __init__(
181
179
  self,
182
180
  mean: float,
183
181
  sigma: float,
184
- allow_neg: Optional[bool] = True,
182
+ minimum: Optional[float] = None,
185
183
  random_seed: Optional[int] = None,
186
184
  ):
187
- """
185
+ '''
188
186
  Constructor
189
-
187
+
190
188
  Params:
191
189
  ------
192
190
  mean: float
193
191
  The mean of the normal distribution
194
-
192
+
195
193
  sigma: float
196
194
  The stdev of the normal distribution
197
195
 
198
- allow_neg: bool, optional (default=True)
199
- False = resample on negative values
200
- True = negative samples allowed.
201
-
196
+ minimum: float
197
+ Truncate the normal distribution to a minimum
198
+ value.
199
+
202
200
  random_seed: int, optional (default=None)
203
201
  A random seed to reproduce samples. If set to none then a unique
204
202
  sample is created.
205
- """
206
- super().__init__(random_seed)
203
+ '''
204
+ self.rng = np.random.default_rng(seed=random_seed)
207
205
  self.mean = mean
208
206
  self.sigma = sigma
209
- self.allow_neg = allow_neg
210
-
207
+ self.minimum = minimum
208
+
211
209
  def sample(self, size: Optional[int] = None) -> float | np.ndarray:
212
- """
210
+ '''
213
211
  Generate a sample from the normal distribution
214
-
212
+
215
213
  Params:
216
214
  -------
217
215
  size: int, optional (default=None)
218
216
  the number of samples to return. If size=None then a single
219
217
  sample is returned.
220
- """
221
- # initial sample
218
+ '''
222
219
  samples = self.rng.normal(self.mean, self.sigma, size=size)
223
220
 
224
- # no need to check if neg allowed.
225
- if self.allow_neg:
221
+ if self.minimum is None:
222
+ return samples
223
+ elif size is None:
224
+ return max(self.minimum, samples)
225
+ else:
226
+ # index of samples with negative value
227
+ neg_idx = np.where(samples < 0)[0]
228
+ samples[neg_idx] = self.minimum
226
229
  return samples
227
230
 
228
- # repeatedly resample negative values
229
- negs = np.where(samples < 0)[0]
230
- while len(negs) > 0:
231
- resample = self.rng.normal(self.mean, self.sigma, size=len(negs))
232
- samples[negs] = resample
233
- negs = np.where(samples < 0)[0]
234
231
 
235
- return samples
236
232
 
237
233
 
238
234
  class Uniform(Distribution):
@@ -58,6 +58,7 @@ class NSPPThinning:
58
58
  self.arr_rng = np.random.default_rng(random_seed1)
59
59
  self.thinning_rng = np.random.default_rng(random_seed2)
60
60
  self.lambda_max = data["arrival_rate"].max()
61
+ self.min_iat = data["mean_iat"].min()
61
62
  # assumes all other intervals are equal in length.
62
63
  self.interval = int(data.iloc[1]["t"] - data.iloc[0]["t"])
63
64
  self.rejects_last_sample = None
@@ -94,7 +95,7 @@ class NSPPThinning:
94
95
  # reject samples if u >= lambda_t / lambda_max
95
96
  while u >= (lambda_t / self.lambda_max):
96
97
  self.rejects_last_sample += 1
97
- interarrival_time += self.arr_rng.exponential(1 / self.lambda_max)
98
+ interarrival_time += self.arr_rng.exponential(self.min_iat)
98
99
  u = self.thinning_rng.uniform(0.0, 1.0)
99
100
 
100
101
  return interarrival_time
@@ -0,0 +1,95 @@
1
+ """
2
+ Simple functionality aiming to enhanced a users a
3
+ ability to trace and debug simulation models.
4
+ """
5
+
6
+ from abc import ABC
7
+ from rich.console import Console
8
+
9
+ DEFAULT_DEBUG = False
10
+
11
+ CONFIG_ERROR = ("Your trace has not been initialised. "
12
+ "Call super__init__(debug=True) in class initialiser"
13
+ "or omit debug for default of no trace.")
14
+
15
+
16
+ ## single rich console - module level.
17
+ _console = Console()
18
+
19
+ class Traceable(ABC):
20
+ '''Provides basic trace functionality for a process to subclass
21
+
22
+ Abstract base class Traceable
23
+
24
+ Subclasses must call
25
+
26
+ super().__init__(debug=True) in their __init__() method to
27
+ initialise trace.
28
+
29
+ Subclasses inherit the following methods:
30
+
31
+ trace() - use this function print out a traceable event
32
+
33
+ _trace_config(): use this function to return a dict containing
34
+ the trace configuration for the class.
35
+ '''
36
+ def __init__(self, debug=DEFAULT_DEBUG):
37
+ self.debug = debug
38
+ self._config = self._default_config()
39
+
40
+ def _default_config(self):
41
+ """Returns a default trace configuration"""
42
+ config = {
43
+ "name":None,
44
+ "name_colour":"bold blue",
45
+ "time_colour":'bold blue',
46
+ "time_dp":2,
47
+ "message_colour":'black',
48
+ "tracked":None
49
+ }
50
+ return config
51
+
52
+
53
+ def _trace_config(self):
54
+ config = {
55
+ "name":None,
56
+ "name_colour":"bold blue",
57
+ "time_colour":'bold blue',
58
+ "time_dp":2,
59
+ "message_colour":'black',
60
+ "tracked":None
61
+ }
62
+ return config
63
+
64
+
65
+ def trace(self, time, msg=None, process_id=None):
66
+ '''
67
+ Display a trace of an event
68
+ '''
69
+
70
+ if not hasattr(self, '_config'):
71
+ raise AttributeError(CONFIG_ERROR)
72
+
73
+ # if in debug mode
74
+ if self.debug:
75
+
76
+ # check for override to default configs
77
+ process_config = self._trace_config()
78
+ self._config.update(process_config)
79
+
80
+ # conditional logic to limit tracking to specific processes/entities
81
+ if self._config['tracked'] is None or process_id in self._config['tracked']:
82
+
83
+ # display and format time stamp
84
+ out = f"[{self._config['time_colour']}][{time:.{self._config['time_dp']}f}]:[/{self._config['time_colour']}]"
85
+
86
+ # if provided display and format a process ID
87
+ if self._config['name'] is not None and process_id is not None:
88
+ out += f"[{self._config['name_colour']}]<{self._config['name']} {process_id}>: [/{self._config['name_colour']}]"
89
+
90
+ # format traced event message
91
+ out += f"[{self._config['message_colour']}]{msg}[/{self._config['message_colour']}]"
92
+
93
+ # print to rich console
94
+ _console.print(out)
95
+
sim-tools-0.3.3/PKG-INFO DELETED
@@ -1,84 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: sim-tools
3
- Version: 0.3.3
4
- Summary: Simulation Tools for Education and Practice
5
- Home-page: https://github.com/TomMonks/sim-tools
6
- Author: Thomas Monks
7
- Author-email: t.m.w.monks@exeter.ac.uk
8
- License: The MIT License (MIT)
9
- Classifier: Programming Language :: Python :: 3.10
10
- Classifier: Programming Language :: Python :: 3.11
11
- Classifier: License :: OSI Approved :: MIT License
12
- Classifier: Operating System :: OS Independent
13
- Requires-Python: >=3.10
14
- Description-Content-Type: text/markdown
15
- License-File: LICENSE
16
- Requires-Dist: matplotlib>=3.1.3
17
- Requires-Dist: numpy>=1.18.1
18
- Requires-Dist: pandas>=2.0.0
19
- Requires-Dist: scipy>=1.4.1
20
- Requires-Dist: scikit-learn>=1.0.0
21
-
22
- # sim-tools: tools to support the simulation process in python.
23
-
24
- [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/TomMonks/sim-tools/HEAD)
25
- [![DOI](https://zenodo.org/badge/225608065.svg)](https://zenodo.org/badge/latestdoi/225608065)
26
- [![PyPI version fury.io](https://badge.fury.io/py/sim-tools.svg)](https://pypi.python.org/pypi/sim-tools/)
27
- [![Read the Docs](https://readthedocs.org/projects/pip/badge/?version=latest)](https://tommonks.github.io/sim-tools)
28
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
29
- [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/release/python-360+/)
30
- [![License: MIT](https://img.shields.io/badge/ORCID-0000--0003--2631--4481-brightgreen)](https://orcid.org/0000-0003-2631-4481)
31
-
32
- sim-tools is being developed to support simulation education and applied simulation research. It is MIT licensed and freely available to practitioners, students and researchers via PyPi. There is a longer term plan to make sim-tools available via conda-forge.
33
-
34
- # Vision for sim-tools
35
-
36
- 1. Deliver high quality reliable code for simulation education and practice with full documentation.
37
- 2. Provide a simple to use pythonic interface.
38
- 3. To improve the quality of simulation education and encourage the use of best practice.
39
-
40
- # Features:
41
-
42
- 1. Implementation of classic optimisation via Simulation procedures such as KN, KN++, OBCA and OBCA-m
43
- 2. Distributions module that includes classes that encapsulate a random number stream, seed, and distribution parameters.
44
- 3. Implementation of Thinning to sample from Non-stationary poisson processes in a discrete-event simulation
45
-
46
- ## Three simple ways to explore sim-tools
47
-
48
- 1. `pip install sim-tools`
49
- 2. Click on the launch-binder at the top of this readme. This will open example Jupyter notebooks in the cloud via Binder.
50
- 3. Oneline documentation: https://tommonks.github.io/sim-tools
51
-
52
- ## Citation
53
-
54
- If you use sim0tools for research, a practical report, education or any reason please include the following citation.
55
-
56
- > Monks, Thomas. (2021). sim-tools: tools to support the forecasting process in python. Zenodo. http://doi.org/10.5281/zenodo.4553642
57
-
58
- ```tex
59
- @software{sim_tools,
60
- author = {Thomas Monks},
61
- title = {sim-tools: fundamental tools to support the simulation process in python},
62
- year = {2021},
63
- publisher = {Zenodo},
64
- doi = {10.5281/zenodo.4553642},
65
- url = {http://doi.org/10.5281/zenodo.4553642}
66
- }
67
- ```
68
-
69
- # Online Tutorials
70
-
71
- * Optimisation Via Simulation [![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/TomMonks/sim-tools/blob/master/examples/sw21_tutorial.ipynb)
72
-
73
-
74
- ## Contributing to sim-tools
75
-
76
- Please fork Dev, make your modifications, run the unit tests and submit a pull request for review.
77
-
78
- Development environment:
79
-
80
- * `conda env create -f binder/environment.yml`
81
-
82
- * `conda activate sim_tools`
83
-
84
- **All contributions are welcome!**
sim-tools-0.3.3/setup.cfg DELETED
@@ -1,4 +0,0 @@
1
- [egg_info]
2
- tag_build =
3
- tag_date = 0
4
-
sim-tools-0.3.3/setup.py DELETED
@@ -1,41 +0,0 @@
1
- import setuptools
2
-
3
- # patched - build error due to imporing numpy into __init__
4
- # from sim_tools import __version__
5
- VERSION = "0.3.3"
6
-
7
-
8
- # Read in the requirements.txt file
9
- with open("requirements.txt") as f:
10
- requirements = []
11
- for library in f.read().splitlines():
12
- requirements.append(library)
13
-
14
- with open("README.md", "r") as fh:
15
- long_description = fh.read()
16
-
17
- setuptools.setup(
18
- name="sim-tools",
19
- version=VERSION,
20
- author="Thomas Monks",
21
- author_email="t.m.w.monks@exeter.ac.uk",
22
- license="The MIT License (MIT)",
23
- description="Simulation Tools for Education and Practice",
24
- long_description=long_description,
25
- long_description_content_type="text/markdown",
26
- url="https://github.com/TomMonks/sim-tools",
27
- packages=setuptools.find_packages(),
28
- #if true look in MANIFEST.in for data files to include
29
- include_package_data=False,
30
- #2nd approach to include data is include_package_data=False
31
- #package_data={"test_package": ["data/*.csv"]},
32
- #these are for documentation
33
- classifiers=[
34
- "Programming Language :: Python :: 3.10",
35
- "Programming Language :: Python :: 3.11",
36
- "License :: OSI Approved :: MIT License",
37
- "Operating System :: OS Independent",
38
- ],
39
- python_requires='>=3.10',
40
- install_requires=requirements,
41
- )
@@ -1,4 +0,0 @@
1
- __version__ = '0.3.3'
2
- __author__ = 'Thomas Monks'
3
-
4
- from . import datasets, distributions, time_dependent, ovs
@@ -1,20 +0,0 @@
1
- LICENSE
2
- README.md
3
- setup.py
4
- sim_tools/__init__.py
5
- sim_tools/datasets.py
6
- sim_tools/distributions.py
7
- sim_tools/time_dependent.py
8
- sim_tools.egg-info/PKG-INFO
9
- sim_tools.egg-info/SOURCES.txt
10
- sim_tools.egg-info/dependency_links.txt
11
- sim_tools.egg-info/requires.txt
12
- sim_tools.egg-info/top_level.txt
13
- sim_tools/ovs/__init__.py
14
- sim_tools/ovs/evaluation.py
15
- sim_tools/ovs/fixed_budget.py
16
- sim_tools/ovs/indifference_zone.py
17
- sim_tools/ovs/toy_models.py
18
- tests/__init__.py
19
- tests/test_dists.py
20
- tests/test_time_dep.py
@@ -1,5 +0,0 @@
1
- matplotlib>=3.1.3
2
- numpy>=1.18.1
3
- pandas>=2.0.0
4
- scipy>=1.4.1
5
- scikit-learn>=1.0.0
@@ -1,2 +0,0 @@
1
- sim_tools
2
- tests
File without changes
@@ -1,151 +0,0 @@
1
- """
2
- basic smoke tests
3
- Create objects to check all okay
4
- """
5
- import sim_tools.distributions as dists
6
- import pytest
7
-
8
- SEED_1 = 42
9
-
10
-
11
- def test_exponential():
12
- d = dists.Exponential(10, random_seed=SEED_1)
13
- assert type(d.sample()) == float
14
-
15
-
16
- def test_lognormal():
17
- d = dists.Lognormal(10, 1, random_seed=SEED_1)
18
- assert type(d.sample()) == float
19
-
20
-
21
- def test_normal():
22
- d = dists.Normal(10, 1, random_seed=SEED_1)
23
- assert type(d.sample()) == float
24
-
25
-
26
- def test_uniform():
27
- d = dists.Uniform(1, 10, random_seed=SEED_1)
28
- assert type(d.sample()) == float
29
-
30
-
31
- def test_tri():
32
- d = dists.Triangular(1.0, 10.0, 25.0, random_seed=SEED_1)
33
- assert type(d.sample()) == float
34
-
35
-
36
- def test_bernoulli():
37
- d = dists.Bernoulli(0.3, random_seed=SEED_1)
38
- assert type(d.sample()) == int
39
-
40
-
41
- def test_fixed_type():
42
- d = dists.FixedDistribution(5.0)
43
- assert type(d.sample()) == float
44
-
45
-
46
- def test_fixed_value():
47
- d = dists.FixedDistribution(5.0)
48
- assert d.sample() == 5.0
49
-
50
-
51
- def test_combination():
52
- foo = dists.Exponential(10, random_seed=SEED_1)
53
- bar = dists.Normal(10, 1, random_seed=SEED_1)
54
- d = dists.CombinationDistribution(foo, bar)
55
- sample = d.sample()
56
- assert type(sample) == float
57
-
58
-
59
- def test_erlang():
60
- d = dists.Erlang(10.0, 2.8, random_seed=SEED_1)
61
- assert type(d.sample()) == float
62
-
63
-
64
- def test_erlangk():
65
- d = dists.ErlangK(1, 2.8, random_seed=SEED_1)
66
- assert type(d.sample()) == float
67
-
68
-
69
- def test_gamma():
70
- d = dists.Gamma(1.2, 2.8, random_seed=SEED_1)
71
- assert type(d.sample()) == float
72
-
73
-
74
- def test_weibull():
75
- d = dists.Weibull(1.2, 2.8, random_seed=SEED_1)
76
- assert type(d.sample()) == float
77
-
78
-
79
- def test_beta():
80
- d = dists.Beta(1.2, 2.8, random_seed=SEED_1)
81
- assert type(d.sample()) == float
82
-
83
-
84
- def test_pearsonv():
85
- d = dists.PearsonV(1.2, 2.8, random_seed=SEED_1)
86
- assert type(d.sample()) == float
87
-
88
-
89
- def test_pearsonvi():
90
- d = dists.PearsonVI(1.2, 1.2, 2.8, random_seed=SEED_1)
91
- assert type(d.sample()) == float
92
-
93
-
94
- def test_poisson():
95
- d = dists.Poisson(5.5, random_seed=SEED_1)
96
- assert type(d.sample()) == int
97
-
98
-
99
- def test_continuous_empirical():
100
- dist = dists.ContinuousEmpirical(
101
- lower_bounds=[0, 5, 10, 15, 30, 45, 60, 120, 180, 240, 480],
102
- upper_bounds=[5, 10, 15, 30, 45, 60, 120, 180, 240, 480, 2880],
103
- freq=[34, 4, 8, 13, 15, 13, 19, 13, 9, 12, 73],
104
- random_seed=SEED_1,
105
- )
106
- assert type(dist.sample()) == float
107
-
108
-
109
- def test_continous_empirical_length():
110
- dist = dists.ContinuousEmpirical(
111
- lower_bounds=[0, 5, 10, 15, 30, 45, 60, 120, 180, 240, 480],
112
- upper_bounds=[5, 10, 15, 30, 45, 60, 120, 180, 240, 480, 2880],
113
- freq=[34, 4, 8, 13, 15, 13, 19, 13, 9, 12, 73],
114
- random_seed=SEED_1,
115
- )
116
- expected_size = 10
117
-
118
- assert len(dist.sample(expected_size)) == expected_size
119
-
120
-
121
- def test_discrete():
122
- d = dists.Discrete(values=[1, 2, 3], freq=[95, 3, 2], random_seed=SEED_1)
123
- assert type(d.sample()) == int
124
-
125
-
126
-
127
- def test_discrete_multiple():
128
- d = dists.Discrete(values=[1, 2, 3], freq=[95, 3, 2], random_seed=SEED_1)
129
- assert len(d.sample(size=100)) == 100
130
-
131
- def test_truncated_type():
132
- d1 = dists.Normal(10, 1, random_seed=SEED_1)
133
- d2 = dists.TruncatedDistribution(d1, lower_bound=10.0)
134
- assert type(d2.sample()) == float
135
-
136
-
137
- @pytest.mark.parametrize(
138
- "n, expected",
139
- [
140
- (1, 10.0),
141
- (10, 10.0),
142
- (100, 10.0),
143
- (10_000_000, 10.0),
144
- (10_000_000, 0.0),
145
- (10_000_000, 0.01),
146
- ],
147
- )
148
- def test_truncated_min(n, expected):
149
- d1 = dists.Normal(10, 1, random_seed=SEED_1)
150
- d2 = dists.TruncatedDistribution(d1, lower_bound=expected)
151
- assert min(d2.sample(size=n)) >= expected
@@ -1,26 +0,0 @@
1
- """
2
- basic tests for time dependent module
3
- """
4
-
5
- import sim_tools.time_dependent as td
6
- from sim_tools.datasets import load_banks_et_al_nspp
7
- import pytest
8
-
9
- SEED_1 = 42
10
- SEED_2 = 101
11
-
12
- @pytest.mark.parametrize(
13
- "simulation_time",
14
- [
15
- (0.0),
16
- (10.0),
17
- (55.0),
18
- (10.5),
19
- (2_000.00),
20
- (10_000.00),
21
- ],
22
- )
23
- def test_sample_from_nsppthinning(simulation_time):
24
- data = load_banks_et_al_nspp()
25
- d = td.NSPPThinning(data, SEED_1, SEED_2)
26
- assert type(d.sample(simulation_time)) == float
File without changes