PyOR 1.1.0__tar.gz → 1.1.1__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.
- {pyor-1.1.0 → pyor-1.1.1}/PKG-INFO +333 -398
- {pyor-1.1.0 → pyor-1.1.1}/PyOR.egg-info/PKG-INFO +333 -398
- {pyor-1.1.0 → pyor-1.1.1}/PyOR.egg-info/SOURCES.txt +3 -2
- {pyor-1.1.0 → pyor-1.1.1}/README.md +20 -85
- {pyor-1.1.0 → pyor-1.1.1}/pyOR/__init__.py +44 -38
- pyor-1.1.1/pyOR/_utils.py +45 -0
- pyor-1.1.1/pyOR/dynamic_programming.py +150 -0
- pyor-1.1.1/pyOR/game_theory.py +220 -0
- pyor-1.1.1/pyOR/gradient_methods.py +147 -0
- pyor-1.1.1/pyOR/q_simul.py +152 -0
- pyor-1.1.1/pyOR/q_theory.py +124 -0
- {pyor-1.1.0 → pyor-1.1.1}/pyproject.toml +3 -4
- {pyor-1.1.0 → pyor-1.1.1}/setup.cfg +4 -4
- {pyor-1.1.0 → pyor-1.1.1}/setup.py +1 -1
- pyor-1.1.1/tests/test_lab_modules.py +54 -0
- pyor-1.1.0/pyOR/dynamic_programming.py +0 -215
- pyor-1.1.0/pyOR/game_theory.py +0 -353
- pyor-1.1.0/pyOR/q_simul.py +0 -359
- pyor-1.1.0/pyOR/q_theory.py +0 -297
- pyor-1.1.0/pyOR/unconstrained_opt.py +0 -233
- pyor-1.1.0/tests/test_new_modules.py +0 -100
- {pyor-1.1.0 → pyor-1.1.1}/LICENSE +0 -0
- {pyor-1.1.0 → pyor-1.1.1}/MANIFEST.in +0 -0
- {pyor-1.1.0 → pyor-1.1.1}/PyOR.egg-info/dependency_links.txt +0 -0
- {pyor-1.1.0 → pyor-1.1.1}/PyOR.egg-info/requires.txt +0 -0
- {pyor-1.1.0 → pyor-1.1.1}/PyOR.egg-info/top_level.txt +0 -0
- {pyor-1.1.0 → pyor-1.1.1}/pyOR/assignment.py +0 -0
- {pyor-1.1.0 → pyor-1.1.1}/pyOR/big_m.py +0 -0
- {pyor-1.1.0 → pyor-1.1.1}/pyOR/curve_fitting.py +0 -0
- {pyor-1.1.0 → pyor-1.1.1}/pyOR/dual_simplex.py +0 -0
- {pyor-1.1.0 → pyor-1.1.1}/pyOR/graphical_method.py +0 -0
- {pyor-1.1.0 → pyor-1.1.1}/pyOR/linear_programming.py +0 -0
- {pyor-1.1.0 → pyor-1.1.1}/pyOR/project_management.py +0 -0
- {pyor-1.1.0 → pyor-1.1.1}/pyOR/simplex.py +0 -0
- {pyor-1.1.0 → pyor-1.1.1}/pyOR/spline_fitting.py +0 -0
- {pyor-1.1.0 → pyor-1.1.1}/pyOR/transportation.py +0 -0
|
@@ -1,398 +1,333 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: PyOR
|
|
3
|
-
Version: 1.1.
|
|
4
|
-
Summary: Python Operations Research — LP, Simplex, Transportation, Assignment, PERT/CPM,
|
|
5
|
-
Author: PyOR Contributors
|
|
6
|
-
License: MIT License
|
|
7
|
-
|
|
8
|
-
Copyright (c) 2025 PyOR Contributors
|
|
9
|
-
|
|
10
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
-
in the Software without restriction, including without limitation the rights
|
|
13
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
-
furnished to do so, subject to the following conditions:
|
|
16
|
-
|
|
17
|
-
The above copyright notice and this permission notice shall be included in all
|
|
18
|
-
copies or substantial portions of the Software.
|
|
19
|
-
|
|
20
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
-
SOFTWARE.
|
|
27
|
-
|
|
28
|
-
Project-URL: Homepage, https://github.com/PyOR-dev/PyOR
|
|
29
|
-
Project-URL: Documentation, https://github.com/PyOR-dev/PyOR#readme
|
|
30
|
-
Project-URL: Issues, https://github.com/PyOR-dev/PyOR/issues
|
|
31
|
-
Keywords: operations research,linear programming,simplex,transportation,assignment,PERT,CPM,curve fitting,spline,optimization,game theory,queueing
|
|
32
|
-
Classifier: Development Status :: 4 - Beta
|
|
33
|
-
Classifier: Intended Audience :: Science/Research
|
|
34
|
-
Classifier: Intended Audience :: Education
|
|
35
|
-
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
36
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
37
|
-
Classifier: Programming Language :: Python :: 3
|
|
38
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
39
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
40
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
41
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
42
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
43
|
-
Requires-Python: >=3.8
|
|
44
|
-
Description-Content-Type: text/markdown
|
|
45
|
-
License-File: LICENSE
|
|
46
|
-
Requires-Dist: numpy>=1.21
|
|
47
|
-
Requires-Dist: scipy>=1.7
|
|
48
|
-
Provides-Extra: plot
|
|
49
|
-
Requires-Dist: matplotlib>=3.4; extra == "plot"
|
|
50
|
-
Provides-Extra: dev
|
|
51
|
-
Requires-Dist: pytest>=7; extra == "dev"
|
|
52
|
-
Requires-Dist: pytest-cov; extra == "dev"
|
|
53
|
-
Requires-Dist: matplotlib>=3.4; extra == "dev"
|
|
54
|
-
Requires-Dist: twine; extra == "dev"
|
|
55
|
-
Requires-Dist: build; extra == "dev"
|
|
56
|
-
Dynamic: license-file
|
|
57
|
-
Dynamic: requires-python
|
|
58
|
-
|
|
59
|
-
# PyOR — Python Operations Research Library
|
|
60
|
-
|
|
61
|
-
[](https://pypi.org/project/PyOR/)
|
|
62
|
-
[](https://pypi.org/project/PyOR/)
|
|
63
|
-
[](LICENSE)
|
|
64
|
-
|
|
65
|
-
**PyOR** is a comprehensive, educational Operations Research library for Python.
|
|
66
|
-
It covers all major OR methods with clear docstrings, step-by-step output, and optional plots.
|
|
67
|
-
|
|
68
|
-
---
|
|
69
|
-
|
|
70
|
-
## 📦 Installation
|
|
71
|
-
|
|
72
|
-
```bash
|
|
73
|
-
pip install PyOR
|
|
74
|
-
# With plotting support
|
|
75
|
-
pip install PyOR[plot]
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
---
|
|
79
|
-
|
|
80
|
-
##
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
|
89
|
-
|
|
90
|
-
|
|
|
91
|
-
|
|
|
92
|
-
|
|
|
93
|
-
|
|
|
94
|
-
|
|
|
95
|
-
|
|
|
96
|
-
|
|
|
97
|
-
|
|
|
98
|
-
|
|
|
99
|
-
|
|
|
100
|
-
|
|
|
101
|
-
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
gm
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
ap
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
{'name':'
|
|
250
|
-
{'name':'
|
|
251
|
-
]
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
cf.
|
|
273
|
-
|
|
274
|
-
#
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
MMcSimulation(lam=8, mu=10, c=1).display() # simulation vs theory
|
|
336
|
-
MMcSimulation.compare([("M/M/1", 8, 10, 1), ("M/M/2", 16, 10, 2)])
|
|
337
|
-
MMcSimulation.plot_utilisation()
|
|
338
|
-
|
|
339
|
-
ap = AirportSimulation(lam=1.0, svc_mean=4.0, cap=25, patience=12)
|
|
340
|
-
ap.optimise(k_values=range(2, 11), reps=20,
|
|
341
|
-
cost_counter=160, cost_wait=0.5, cost_lost=30)
|
|
342
|
-
ap.display(); ap.plot() # blocking, balking, reneging
|
|
343
|
-
```
|
|
344
|
-
|
|
345
|
-
### 17. Unconstrained Optimisation
|
|
346
|
-
|
|
347
|
-
```python
|
|
348
|
-
from pyOR import UnconstrainedOptimizer, rosenbrock
|
|
349
|
-
|
|
350
|
-
f, grad, hess, x0 = rosenbrock()
|
|
351
|
-
opt = UnconstrainedOptimizer(f, x0, grad=grad, hess=hess)
|
|
352
|
-
opt.compare() # gradient descent vs Newton vs BFGS
|
|
353
|
-
opt.plot_convergence()
|
|
354
|
-
|
|
355
|
-
# gradient / Hessian optional (finite differences are used)
|
|
356
|
-
UnconstrainedOptimizer(lambda x: (x[0]-3)**2 + (x[1]+1)**2, [0, 0]).solve('bfgs')
|
|
357
|
-
```
|
|
358
|
-
|
|
359
|
-
### 18. Dynamic Programming — Resource Allocation
|
|
360
|
-
|
|
361
|
-
```python
|
|
362
|
-
from pyOR import ResourceAllocation
|
|
363
|
-
|
|
364
|
-
r = [[0,5,9,12,14,15,15],
|
|
365
|
-
[0,4,8,11,13,14,14],
|
|
366
|
-
[0,6,10,13,15,16,16],
|
|
367
|
-
[0,3,7,10,12,13,13]]
|
|
368
|
-
ra = ResourceAllocation(r) # 6 units, 4 activities
|
|
369
|
-
ra.solve(); ra.display() # allocation [2, 2, 2, 0], return 27
|
|
370
|
-
ra.sensitivity() # optimal value for every budget
|
|
371
|
-
ra.brute_force() # verification
|
|
372
|
-
ra.plot_value(); ra.plot_policy()
|
|
373
|
-
```
|
|
374
|
-
|
|
375
|
-
---
|
|
376
|
-
|
|
377
|
-
## 📐 Dependencies
|
|
378
|
-
|
|
379
|
-
| Package | Version |
|
|
380
|
-
|---------|---------|
|
|
381
|
-
| numpy | ≥ 1.21 |
|
|
382
|
-
| scipy | ≥ 1.7 |
|
|
383
|
-
| matplotlib | ≥ 3.4 (optional, for plots) |
|
|
384
|
-
|
|
385
|
-
---
|
|
386
|
-
|
|
387
|
-
## 🧪 Running Tests
|
|
388
|
-
|
|
389
|
-
```bash
|
|
390
|
-
pip install PyOR[dev]
|
|
391
|
-
pytest tests/ -v
|
|
392
|
-
```
|
|
393
|
-
|
|
394
|
-
---
|
|
395
|
-
|
|
396
|
-
## 📜 License
|
|
397
|
-
|
|
398
|
-
MIT © 2025 PyOR Contributors
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: PyOR
|
|
3
|
+
Version: 1.1.1
|
|
4
|
+
Summary: Python Operations Research — LP, Simplex, Transportation, Assignment, PERT/CPM, Curve Fitting & more
|
|
5
|
+
Author: PyOR Contributors
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2025 PyOR Contributors
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
|
|
28
|
+
Project-URL: Homepage, https://github.com/PyOR-dev/PyOR
|
|
29
|
+
Project-URL: Documentation, https://github.com/PyOR-dev/PyOR#readme
|
|
30
|
+
Project-URL: Issues, https://github.com/PyOR-dev/PyOR/issues
|
|
31
|
+
Keywords: operations research,linear programming,simplex,transportation,assignment,PERT,CPM,curve fitting,spline,optimization,game theory,queueing,simulation,dynamic programming,gradient descent
|
|
32
|
+
Classifier: Development Status :: 4 - Beta
|
|
33
|
+
Classifier: Intended Audience :: Science/Research
|
|
34
|
+
Classifier: Intended Audience :: Education
|
|
35
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
36
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
37
|
+
Classifier: Programming Language :: Python :: 3
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
41
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
42
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
43
|
+
Requires-Python: >=3.8
|
|
44
|
+
Description-Content-Type: text/markdown
|
|
45
|
+
License-File: LICENSE
|
|
46
|
+
Requires-Dist: numpy>=1.21
|
|
47
|
+
Requires-Dist: scipy>=1.7
|
|
48
|
+
Provides-Extra: plot
|
|
49
|
+
Requires-Dist: matplotlib>=3.4; extra == "plot"
|
|
50
|
+
Provides-Extra: dev
|
|
51
|
+
Requires-Dist: pytest>=7; extra == "dev"
|
|
52
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
53
|
+
Requires-Dist: matplotlib>=3.4; extra == "dev"
|
|
54
|
+
Requires-Dist: twine; extra == "dev"
|
|
55
|
+
Requires-Dist: build; extra == "dev"
|
|
56
|
+
Dynamic: license-file
|
|
57
|
+
Dynamic: requires-python
|
|
58
|
+
|
|
59
|
+
# PyOR — Python Operations Research Library
|
|
60
|
+
|
|
61
|
+
[](https://pypi.org/project/PyOR/)
|
|
62
|
+
[](https://pypi.org/project/PyOR/)
|
|
63
|
+
[](LICENSE)
|
|
64
|
+
|
|
65
|
+
**PyOR** is a comprehensive, educational Operations Research library for Python.
|
|
66
|
+
It covers all major OR methods with clear docstrings, step-by-step output, and optional plots.
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## 📦 Installation
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
pip install PyOR
|
|
74
|
+
# With plotting support
|
|
75
|
+
pip install PyOR[plot]
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## 🗂️ Modules & Methods
|
|
81
|
+
|
|
82
|
+
| # | Method | Class / Function |
|
|
83
|
+
|---|--------|-----------------|
|
|
84
|
+
| 1 | Linear Programming Formulation | `LinearProgram` |
|
|
85
|
+
| 2 | Graphical Method | `GraphicalMethod` |
|
|
86
|
+
| 3 | Simplex Method | `SimplexMethod` |
|
|
87
|
+
| 4 | Dual Simplex Method | `DualSimplex` |
|
|
88
|
+
| 5 | Big-M Method | `BigMMethod` |
|
|
89
|
+
| 6 | Transportation — North-West Corner | `north_west_corner()` |
|
|
90
|
+
| 7 | Transportation — Least Cost | `least_cost_method()` |
|
|
91
|
+
| 8 | Transportation — Vogel's Approximation | `vogel_approximation()` |
|
|
92
|
+
| 9 | Transportation — MODI (Optimality) | `modi_method()` |
|
|
93
|
+
| 10 | Assignment Problem | `AssignmentProblem` |
|
|
94
|
+
| 11 | Project Management (PERT / CPM) | `PERTCPMNetwork` |
|
|
95
|
+
| 12 | Curve Fitting — Least Squares | `CurveFitter` |
|
|
96
|
+
| 13 | Cubic Spline Interpolation | `CubicSplineFitter` |
|
|
97
|
+
| 14 | Game Theory (saddle, 2x2, graphical, LP) — *new in 1.1.0* | `pyOR.game_theory` · `MatrixGame` |
|
|
98
|
+
| 15 | Queueing theory M/M/1, M/M/k (Erlang-C vs simulation) — *new* | `pyOR.q_theory` |
|
|
99
|
+
| 16 | Airport queue simulation & staffing optimisation — *new* | `pyOR.q_simul` |
|
|
100
|
+
| 17 | Gradient descent, Newton, BFGS — *new* | `pyOR.gradient_methods` |
|
|
101
|
+
| 18 | Multi-stage resource allocation (DP) — *new* | `pyOR.dynamic_programming` · `ResourceAllocationDP` |
|
|
102
|
+
|
|
103
|
+
### New in 1.1.0 — printing the complete code
|
|
104
|
+
|
|
105
|
+
Each new module has `demo()` (runs the lab example) and `code()` (prints the
|
|
106
|
+
module's complete source):
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
import pyOR
|
|
110
|
+
from pyOR import q_theory, q_simul, game_theory, gradient_methods, dynamic_programming
|
|
111
|
+
|
|
112
|
+
q_theory.demo() # run the M/M/k experiment
|
|
113
|
+
q_theory.code() # print the complete source code
|
|
114
|
+
pyOR.code("q_simul") # same thing, by name
|
|
115
|
+
pyOR.list_modules()
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## 🚀 Quick Examples
|
|
121
|
+
|
|
122
|
+
### 1. Linear Programming
|
|
123
|
+
|
|
124
|
+
```python
|
|
125
|
+
from pyOR import LinearProgram
|
|
126
|
+
|
|
127
|
+
lp = LinearProgram(
|
|
128
|
+
c = [-3, -5], # maximise 3x₁ + 5x₂
|
|
129
|
+
A_ub = [[1,0],[0,2],[3,2]],
|
|
130
|
+
b_ub = [4, 12, 18],
|
|
131
|
+
objective = 'max'
|
|
132
|
+
)
|
|
133
|
+
result = lp.solve()
|
|
134
|
+
lp.display()
|
|
135
|
+
# → x1=2, x2=6, Z*=36
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### 2. Graphical Method
|
|
139
|
+
|
|
140
|
+
```python
|
|
141
|
+
from pyOR import GraphicalMethod
|
|
142
|
+
|
|
143
|
+
gm = GraphicalMethod(
|
|
144
|
+
c = [3, 5],
|
|
145
|
+
constraints = [(1, 0, '<=', 4),
|
|
146
|
+
(0, 2, '<=', 12),
|
|
147
|
+
(3, 2, '<=', 18)],
|
|
148
|
+
objective = 'max'
|
|
149
|
+
)
|
|
150
|
+
result = gm.solve()
|
|
151
|
+
gm.display()
|
|
152
|
+
gm.plot() # requires matplotlib
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### 3. Simplex Method
|
|
156
|
+
|
|
157
|
+
```python
|
|
158
|
+
from pyOR import SimplexMethod
|
|
159
|
+
|
|
160
|
+
sm = SimplexMethod(
|
|
161
|
+
c = [5, 4, 3],
|
|
162
|
+
A = [[6,4,2],[3,2,5],[5,6,5]],
|
|
163
|
+
b = [240, 270, 420],
|
|
164
|
+
objective = 'max'
|
|
165
|
+
)
|
|
166
|
+
result = sm.solve()
|
|
167
|
+
sm.display(show_tableaux=True)
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### 4. Dual Simplex Method
|
|
171
|
+
|
|
172
|
+
```python
|
|
173
|
+
from pyOR import DualSimplex
|
|
174
|
+
|
|
175
|
+
ds = DualSimplex(
|
|
176
|
+
c = [2, 3],
|
|
177
|
+
A = [[1,1],[1,0],[0,1]],
|
|
178
|
+
b = [4, 2, 3],
|
|
179
|
+
senses = ['<=','<=','<='],
|
|
180
|
+
objective= 'min'
|
|
181
|
+
)
|
|
182
|
+
ds.solve()
|
|
183
|
+
ds.display()
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### 5. Big-M Method
|
|
187
|
+
|
|
188
|
+
```python
|
|
189
|
+
from pyOR import BigMMethod
|
|
190
|
+
|
|
191
|
+
bm = BigMMethod(
|
|
192
|
+
c = [2, 3],
|
|
193
|
+
A = [[1,1],[1,0],[0,1]],
|
|
194
|
+
b = [4, 2, 3],
|
|
195
|
+
senses = ['<=','>=','>='],
|
|
196
|
+
objective= 'min'
|
|
197
|
+
)
|
|
198
|
+
bm.solve()
|
|
199
|
+
bm.display()
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### 6–9. Transportation Problem
|
|
203
|
+
|
|
204
|
+
```python
|
|
205
|
+
from pyOR import north_west_corner, least_cost_method, vogel_approximation, modi_method
|
|
206
|
+
|
|
207
|
+
cost = [[2, 3, 1], [5, 4, 8], [5, 6, 8]]
|
|
208
|
+
supply = [120, 80, 80]
|
|
209
|
+
demand = [150, 70, 60]
|
|
210
|
+
|
|
211
|
+
# Initial BFS methods
|
|
212
|
+
north_west_corner(cost, supply, demand)
|
|
213
|
+
least_cost_method(cost, supply, demand)
|
|
214
|
+
vogel_approximation(cost, supply, demand)
|
|
215
|
+
|
|
216
|
+
# Optimal solution using MODI
|
|
217
|
+
result = modi_method(cost, supply, demand, initial_method='vam')
|
|
218
|
+
print("Optimal Cost:", result['total_cost'])
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### 10. Assignment Problem
|
|
222
|
+
|
|
223
|
+
```python
|
|
224
|
+
from pyOR import AssignmentProblem
|
|
225
|
+
|
|
226
|
+
ap = AssignmentProblem(
|
|
227
|
+
cost_matrix = [[9,2,7,8],
|
|
228
|
+
[6,4,3,7],
|
|
229
|
+
[5,8,1,8],
|
|
230
|
+
[7,6,9,4]],
|
|
231
|
+
objective = 'min',
|
|
232
|
+
row_names = ['Worker A','Worker B','Worker C','Worker D'],
|
|
233
|
+
col_names = ['Job 1','Job 2','Job 3','Job 4']
|
|
234
|
+
)
|
|
235
|
+
ap.solve()
|
|
236
|
+
ap.display()
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### 11. PERT / CPM
|
|
240
|
+
|
|
241
|
+
```python
|
|
242
|
+
from pyOR import PERTCPMNetwork
|
|
243
|
+
|
|
244
|
+
# CPM
|
|
245
|
+
activities = [
|
|
246
|
+
{'name':'A','depends':[], 'duration':4},
|
|
247
|
+
{'name':'B','depends':[], 'duration':5},
|
|
248
|
+
{'name':'C','depends':['A'], 'duration':3},
|
|
249
|
+
{'name':'D','depends':['B'], 'duration':4},
|
|
250
|
+
{'name':'E','depends':['C','D'],'duration':6},
|
|
251
|
+
]
|
|
252
|
+
net = PERTCPMNetwork(activities)
|
|
253
|
+
net.solve()
|
|
254
|
+
net.display()
|
|
255
|
+
|
|
256
|
+
# PERT with probability
|
|
257
|
+
activities_pert = [
|
|
258
|
+
{'name':'A','depends':[],'optimistic':2,'most_likely':4,'pessimistic':6},
|
|
259
|
+
{'name':'B','depends':['A'],'optimistic':3,'most_likely':5,'pessimistic':9},
|
|
260
|
+
]
|
|
261
|
+
net2 = PERTCPMNetwork(activities_pert)
|
|
262
|
+
net2.solve()
|
|
263
|
+
net2.display(show_probability=15)
|
|
264
|
+
print(net2.completion_probability(15))
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### 12. Curve Fitting
|
|
268
|
+
|
|
269
|
+
```python
|
|
270
|
+
from pyOR import CurveFitter
|
|
271
|
+
|
|
272
|
+
cf = CurveFitter(x=[1,2,3,4,5], y=[2.1,3.9,6.1,8.1,10.1])
|
|
273
|
+
|
|
274
|
+
# Linear
|
|
275
|
+
cf.fit('linear')
|
|
276
|
+
cf.display()
|
|
277
|
+
cf.plot()
|
|
278
|
+
|
|
279
|
+
# Polynomial degree 2
|
|
280
|
+
cf.fit('polynomial', degree=2)
|
|
281
|
+
cf.display()
|
|
282
|
+
|
|
283
|
+
# Exponential, Power, Logarithmic, Reciprocal
|
|
284
|
+
for model in ['exponential', 'power', 'logarithmic', 'reciprocal']:
|
|
285
|
+
cf.fit(model)
|
|
286
|
+
print(f"{model}: R² = {cf.result['r_squared']:.4f}")
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
### 13. Cubic Spline
|
|
290
|
+
|
|
291
|
+
```python
|
|
292
|
+
from pyOR import CubicSplineFitter
|
|
293
|
+
|
|
294
|
+
sf = CubicSplineFitter(
|
|
295
|
+
x=[0, 1, 2, 3, 4],
|
|
296
|
+
y=[0, 1, 0, 1, 0],
|
|
297
|
+
bc_type='natural'
|
|
298
|
+
)
|
|
299
|
+
sf.fit()
|
|
300
|
+
sf.display()
|
|
301
|
+
|
|
302
|
+
# Evaluate at a point
|
|
303
|
+
y_val = sf.evaluate(1.5)
|
|
304
|
+
dy = sf.derivative(1.5, order=1)
|
|
305
|
+
print(f"S(1.5) = {y_val}, S'(1.5) = {dy}")
|
|
306
|
+
|
|
307
|
+
sf.plot()
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
---
|
|
311
|
+
|
|
312
|
+
## 📐 Dependencies
|
|
313
|
+
|
|
314
|
+
| Package | Version |
|
|
315
|
+
|---------|---------|
|
|
316
|
+
| numpy | ≥ 1.21 |
|
|
317
|
+
| scipy | ≥ 1.7 |
|
|
318
|
+
| matplotlib | ≥ 3.4 (optional, for plots) |
|
|
319
|
+
|
|
320
|
+
---
|
|
321
|
+
|
|
322
|
+
## 🧪 Running Tests
|
|
323
|
+
|
|
324
|
+
```bash
|
|
325
|
+
pip install PyOR[dev]
|
|
326
|
+
pytest tests/ -v
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
---
|
|
330
|
+
|
|
331
|
+
## 📜 License
|
|
332
|
+
|
|
333
|
+
MIT © 2025 PyOR Contributors
|