PyOR 1.0.0__tar.gz → 1.1.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.
Files changed (29) hide show
  1. {pyor-1.0.0 → pyor-1.1.0}/PKG-INFO +398 -313
  2. {pyor-1.0.0 → pyor-1.1.0}/PyOR.egg-info/PKG-INFO +398 -313
  3. {pyor-1.0.0 → pyor-1.1.0}/PyOR.egg-info/SOURCES.txt +8 -1
  4. {pyor-1.0.0 → pyor-1.1.0}/README.md +85 -0
  5. {pyor-1.0.0 → pyor-1.1.0}/pyOR/__init__.py +38 -1
  6. pyor-1.1.0/pyOR/dynamic_programming.py +215 -0
  7. pyor-1.1.0/pyOR/game_theory.py +353 -0
  8. pyor-1.1.0/pyOR/q_simul.py +359 -0
  9. pyor-1.1.0/pyOR/q_theory.py +297 -0
  10. pyor-1.1.0/pyOR/unconstrained_opt.py +233 -0
  11. {pyor-1.0.0 → pyor-1.1.0}/pyproject.toml +5 -3
  12. {pyor-1.0.0 → pyor-1.1.0}/setup.cfg +4 -4
  13. {pyor-1.0.0 → pyor-1.1.0}/setup.py +1 -1
  14. pyor-1.1.0/tests/test_new_modules.py +100 -0
  15. {pyor-1.0.0 → pyor-1.1.0}/LICENSE +0 -0
  16. {pyor-1.0.0 → pyor-1.1.0}/MANIFEST.in +0 -0
  17. {pyor-1.0.0 → pyor-1.1.0}/PyOR.egg-info/dependency_links.txt +0 -0
  18. {pyor-1.0.0 → pyor-1.1.0}/PyOR.egg-info/requires.txt +0 -0
  19. {pyor-1.0.0 → pyor-1.1.0}/PyOR.egg-info/top_level.txt +0 -0
  20. {pyor-1.0.0 → pyor-1.1.0}/pyOR/assignment.py +0 -0
  21. {pyor-1.0.0 → pyor-1.1.0}/pyOR/big_m.py +0 -0
  22. {pyor-1.0.0 → pyor-1.1.0}/pyOR/curve_fitting.py +0 -0
  23. {pyor-1.0.0 → pyor-1.1.0}/pyOR/dual_simplex.py +0 -0
  24. {pyor-1.0.0 → pyor-1.1.0}/pyOR/graphical_method.py +0 -0
  25. {pyor-1.0.0 → pyor-1.1.0}/pyOR/linear_programming.py +0 -0
  26. {pyor-1.0.0 → pyor-1.1.0}/pyOR/project_management.py +0 -0
  27. {pyor-1.0.0 → pyor-1.1.0}/pyOR/simplex.py +0 -0
  28. {pyor-1.0.0 → pyor-1.1.0}/pyOR/spline_fitting.py +0 -0
  29. {pyor-1.0.0 → pyor-1.1.0}/pyOR/transportation.py +0 -0
@@ -1,313 +1,398 @@
1
- Metadata-Version: 2.4
2
- Name: PyOR
3
- Version: 1.0.0
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
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
- [![PyPI version](https://img.shields.io/pypi/v/PyOR.svg)](https://pypi.org/project/PyOR/)
62
- [![Python](https://img.shields.io/pypi/pyversions/PyOR.svg)](https://pypi.org/project/PyOR/)
63
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](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
-
98
- ---
99
-
100
- ## 🚀 Quick Examples
101
-
102
- ### 1. Linear Programming
103
-
104
- ```python
105
- from pyOR import LinearProgram
106
-
107
- lp = LinearProgram(
108
- c = [-3, -5], # maximise 3x₁ + 5x₂
109
- A_ub = [[1,0],[0,2],[3,2]],
110
- b_ub = [4, 12, 18],
111
- objective = 'max'
112
- )
113
- result = lp.solve()
114
- lp.display()
115
- # → x1=2, x2=6, Z*=36
116
- ```
117
-
118
- ### 2. Graphical Method
119
-
120
- ```python
121
- from pyOR import GraphicalMethod
122
-
123
- gm = GraphicalMethod(
124
- c = [3, 5],
125
- constraints = [(1, 0, '<=', 4),
126
- (0, 2, '<=', 12),
127
- (3, 2, '<=', 18)],
128
- objective = 'max'
129
- )
130
- result = gm.solve()
131
- gm.display()
132
- gm.plot() # requires matplotlib
133
- ```
134
-
135
- ### 3. Simplex Method
136
-
137
- ```python
138
- from pyOR import SimplexMethod
139
-
140
- sm = SimplexMethod(
141
- c = [5, 4, 3],
142
- A = [[6,4,2],[3,2,5],[5,6,5]],
143
- b = [240, 270, 420],
144
- objective = 'max'
145
- )
146
- result = sm.solve()
147
- sm.display(show_tableaux=True)
148
- ```
149
-
150
- ### 4. Dual Simplex Method
151
-
152
- ```python
153
- from pyOR import DualSimplex
154
-
155
- ds = DualSimplex(
156
- c = [2, 3],
157
- A = [[1,1],[1,0],[0,1]],
158
- b = [4, 2, 3],
159
- senses = ['<=','<=','<='],
160
- objective= 'min'
161
- )
162
- ds.solve()
163
- ds.display()
164
- ```
165
-
166
- ### 5. Big-M Method
167
-
168
- ```python
169
- from pyOR import BigMMethod
170
-
171
- bm = BigMMethod(
172
- c = [2, 3],
173
- A = [[1,1],[1,0],[0,1]],
174
- b = [4, 2, 3],
175
- senses = ['<=','>=','>='],
176
- objective= 'min'
177
- )
178
- bm.solve()
179
- bm.display()
180
- ```
181
-
182
- ### 6–9. Transportation Problem
183
-
184
- ```python
185
- from pyOR import north_west_corner, least_cost_method, vogel_approximation, modi_method
186
-
187
- cost = [[2, 3, 1], [5, 4, 8], [5, 6, 8]]
188
- supply = [120, 80, 80]
189
- demand = [150, 70, 60]
190
-
191
- # Initial BFS methods
192
- north_west_corner(cost, supply, demand)
193
- least_cost_method(cost, supply, demand)
194
- vogel_approximation(cost, supply, demand)
195
-
196
- # Optimal solution using MODI
197
- result = modi_method(cost, supply, demand, initial_method='vam')
198
- print("Optimal Cost:", result['total_cost'])
199
- ```
200
-
201
- ### 10. Assignment Problem
202
-
203
- ```python
204
- from pyOR import AssignmentProblem
205
-
206
- ap = AssignmentProblem(
207
- cost_matrix = [[9,2,7,8],
208
- [6,4,3,7],
209
- [5,8,1,8],
210
- [7,6,9,4]],
211
- objective = 'min',
212
- row_names = ['Worker A','Worker B','Worker C','Worker D'],
213
- col_names = ['Job 1','Job 2','Job 3','Job 4']
214
- )
215
- ap.solve()
216
- ap.display()
217
- ```
218
-
219
- ### 11. PERT / CPM
220
-
221
- ```python
222
- from pyOR import PERTCPMNetwork
223
-
224
- # CPM
225
- activities = [
226
- {'name':'A','depends':[], 'duration':4},
227
- {'name':'B','depends':[], 'duration':5},
228
- {'name':'C','depends':['A'], 'duration':3},
229
- {'name':'D','depends':['B'], 'duration':4},
230
- {'name':'E','depends':['C','D'],'duration':6},
231
- ]
232
- net = PERTCPMNetwork(activities)
233
- net.solve()
234
- net.display()
235
-
236
- # PERT with probability
237
- activities_pert = [
238
- {'name':'A','depends':[],'optimistic':2,'most_likely':4,'pessimistic':6},
239
- {'name':'B','depends':['A'],'optimistic':3,'most_likely':5,'pessimistic':9},
240
- ]
241
- net2 = PERTCPMNetwork(activities_pert)
242
- net2.solve()
243
- net2.display(show_probability=15)
244
- print(net2.completion_probability(15))
245
- ```
246
-
247
- ### 12. Curve Fitting
248
-
249
- ```python
250
- from pyOR import CurveFitter
251
-
252
- cf = CurveFitter(x=[1,2,3,4,5], y=[2.1,3.9,6.1,8.1,10.1])
253
-
254
- # Linear
255
- cf.fit('linear')
256
- cf.display()
257
- cf.plot()
258
-
259
- # Polynomial degree 2
260
- cf.fit('polynomial', degree=2)
261
- cf.display()
262
-
263
- # Exponential, Power, Logarithmic, Reciprocal
264
- for model in ['exponential', 'power', 'logarithmic', 'reciprocal']:
265
- cf.fit(model)
266
- print(f"{model}: R² = {cf.result['r_squared']:.4f}")
267
- ```
268
-
269
- ### 13. Cubic Spline
270
-
271
- ```python
272
- from pyOR import CubicSplineFitter
273
-
274
- sf = CubicSplineFitter(
275
- x=[0, 1, 2, 3, 4],
276
- y=[0, 1, 0, 1, 0],
277
- bc_type='natural'
278
- )
279
- sf.fit()
280
- sf.display()
281
-
282
- # Evaluate at a point
283
- y_val = sf.evaluate(1.5)
284
- dy = sf.derivative(1.5, order=1)
285
- print(f"S(1.5) = {y_val}, S'(1.5) = {dy}")
286
-
287
- sf.plot()
288
- ```
289
-
290
- ---
291
-
292
- ## 📐 Dependencies
293
-
294
- | Package | Version |
295
- |---------|---------|
296
- | numpy | ≥ 1.21 |
297
- | scipy | ≥ 1.7 |
298
- | matplotlib | ≥ 3.4 (optional, for plots) |
299
-
300
- ---
301
-
302
- ## 🧪 Running Tests
303
-
304
- ```bash
305
- pip install PyOR[dev]
306
- pytest tests/ -v
307
- ```
308
-
309
- ---
310
-
311
- ## 📜 License
312
-
313
- MIT © 2025 PyOR Contributors
1
+ Metadata-Version: 2.4
2
+ Name: PyOR
3
+ Version: 1.1.0
4
+ Summary: Python Operations Research — LP, Simplex, Transportation, Assignment, PERT/CPM, Game Theory, Queueing, Simulation, Optimisation, DP & 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 theory,simulation,dynamic programming,gradient descent,BFGS
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
+ [![PyPI version](https://img.shields.io/pypi/v/PyOR.svg)](https://pypi.org/project/PyOR/)
62
+ [![Python](https://img.shields.io/pypi/pyversions/PyOR.svg)](https://pypi.org/project/PyOR/)
63
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](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
+ ## 🆕 What's new in 1.1.0
81
+
82
+ New modules: `game_theory`, `q_theory`, `q_simul`, `unconstrained_opt`, `dynamic_programming`.
83
+
84
+ ---
85
+
86
+ ## 🗂️ Modules & Methods
87
+
88
+ | # | Method | Class / Function |
89
+ |---|--------|-----------------|
90
+ | 1 | Linear Programming Formulation | `LinearProgram` |
91
+ | 2 | Graphical Method | `GraphicalMethod` |
92
+ | 3 | Simplex Method | `SimplexMethod` |
93
+ | 4 | Dual Simplex Method | `DualSimplex` |
94
+ | 5 | Big-M Method | `BigMMethod` |
95
+ | 6 | Transportation — North-West Corner | `north_west_corner()` |
96
+ | 7 | Transportation — Least Cost | `least_cost_method()` |
97
+ | 8 | Transportation — Vogel's Approximation | `vogel_approximation()` |
98
+ | 9 | Transportation — MODI (Optimality) | `modi_method()` |
99
+ | 10 | Assignment Problem | `AssignmentProblem` |
100
+ | 11 | Project Management (PERT / CPM) | `PERTCPMNetwork` |
101
+ | 12 | Curve Fitting — Least Squares | `CurveFitter` |
102
+ | 13 | Cubic Spline Interpolation | `CubicSplineFitter` |
103
+ | 14 | Game Theory (saddle, 2x2, graphical, LP) | `GameTheory` — `pyOR.game_theory` |
104
+ | 15 | Queueing Theory (analytical) | `QueueModel`, `erlang_b`, `erlang_c`, `min_servers`, `optimal_servers` — `pyOR.q_theory` |
105
+ | 16 | Queue Simulation (M/M/c, airport counters) | `MMcSimulation`, `AirportSimulation` — `pyOR.q_simul` |
106
+ | 17 | Unconstrained Optimisation (GD, Newton, BFGS) | `UnconstrainedOptimizer` — `pyOR.unconstrained_opt` |
107
+ | 18 | Dynamic Programming (resource allocation) | `ResourceAllocation` — `pyOR.dynamic_programming` |
108
+
109
+ ---
110
+
111
+ ## 🚀 Quick Examples
112
+
113
+ ### 1. Linear Programming
114
+
115
+ ```python
116
+ from pyOR import LinearProgram
117
+
118
+ lp = LinearProgram(
119
+ c = [-3, -5], # maximise 3x₁ + 5x₂
120
+ A_ub = [[1,0],[0,2],[3,2]],
121
+ b_ub = [4, 12, 18],
122
+ objective = 'max'
123
+ )
124
+ result = lp.solve()
125
+ lp.display()
126
+ # → x1=2, x2=6, Z*=36
127
+ ```
128
+
129
+ ### 2. Graphical Method
130
+
131
+ ```python
132
+ from pyOR import GraphicalMethod
133
+
134
+ gm = GraphicalMethod(
135
+ c = [3, 5],
136
+ constraints = [(1, 0, '<=', 4),
137
+ (0, 2, '<=', 12),
138
+ (3, 2, '<=', 18)],
139
+ objective = 'max'
140
+ )
141
+ result = gm.solve()
142
+ gm.display()
143
+ gm.plot() # requires matplotlib
144
+ ```
145
+
146
+ ### 3. Simplex Method
147
+
148
+ ```python
149
+ from pyOR import SimplexMethod
150
+
151
+ sm = SimplexMethod(
152
+ c = [5, 4, 3],
153
+ A = [[6,4,2],[3,2,5],[5,6,5]],
154
+ b = [240, 270, 420],
155
+ objective = 'max'
156
+ )
157
+ result = sm.solve()
158
+ sm.display(show_tableaux=True)
159
+ ```
160
+
161
+ ### 4. Dual Simplex Method
162
+
163
+ ```python
164
+ from pyOR import DualSimplex
165
+
166
+ ds = DualSimplex(
167
+ c = [2, 3],
168
+ A = [[1,1],[1,0],[0,1]],
169
+ b = [4, 2, 3],
170
+ senses = ['<=','<=','<='],
171
+ objective= 'min'
172
+ )
173
+ ds.solve()
174
+ ds.display()
175
+ ```
176
+
177
+ ### 5. Big-M Method
178
+
179
+ ```python
180
+ from pyOR import BigMMethod
181
+
182
+ bm = BigMMethod(
183
+ c = [2, 3],
184
+ A = [[1,1],[1,0],[0,1]],
185
+ b = [4, 2, 3],
186
+ senses = ['<=','>=','>='],
187
+ objective= 'min'
188
+ )
189
+ bm.solve()
190
+ bm.display()
191
+ ```
192
+
193
+ ### 6–9. Transportation Problem
194
+
195
+ ```python
196
+ from pyOR import north_west_corner, least_cost_method, vogel_approximation, modi_method
197
+
198
+ cost = [[2, 3, 1], [5, 4, 8], [5, 6, 8]]
199
+ supply = [120, 80, 80]
200
+ demand = [150, 70, 60]
201
+
202
+ # Initial BFS methods
203
+ north_west_corner(cost, supply, demand)
204
+ least_cost_method(cost, supply, demand)
205
+ vogel_approximation(cost, supply, demand)
206
+
207
+ # Optimal solution using MODI
208
+ result = modi_method(cost, supply, demand, initial_method='vam')
209
+ print("Optimal Cost:", result['total_cost'])
210
+ ```
211
+
212
+ ### 10. Assignment Problem
213
+
214
+ ```python
215
+ from pyOR import AssignmentProblem
216
+
217
+ ap = AssignmentProblem(
218
+ cost_matrix = [[9,2,7,8],
219
+ [6,4,3,7],
220
+ [5,8,1,8],
221
+ [7,6,9,4]],
222
+ objective = 'min',
223
+ row_names = ['Worker A','Worker B','Worker C','Worker D'],
224
+ col_names = ['Job 1','Job 2','Job 3','Job 4']
225
+ )
226
+ ap.solve()
227
+ ap.display()
228
+ ```
229
+
230
+ ### 11. PERT / CPM
231
+
232
+ ```python
233
+ from pyOR import PERTCPMNetwork
234
+
235
+ # CPM
236
+ activities = [
237
+ {'name':'A','depends':[], 'duration':4},
238
+ {'name':'B','depends':[], 'duration':5},
239
+ {'name':'C','depends':['A'], 'duration':3},
240
+ {'name':'D','depends':['B'], 'duration':4},
241
+ {'name':'E','depends':['C','D'],'duration':6},
242
+ ]
243
+ net = PERTCPMNetwork(activities)
244
+ net.solve()
245
+ net.display()
246
+
247
+ # PERT with probability
248
+ activities_pert = [
249
+ {'name':'A','depends':[],'optimistic':2,'most_likely':4,'pessimistic':6},
250
+ {'name':'B','depends':['A'],'optimistic':3,'most_likely':5,'pessimistic':9},
251
+ ]
252
+ net2 = PERTCPMNetwork(activities_pert)
253
+ net2.solve()
254
+ net2.display(show_probability=15)
255
+ print(net2.completion_probability(15))
256
+ ```
257
+
258
+ ### 12. Curve Fitting
259
+
260
+ ```python
261
+ from pyOR import CurveFitter
262
+
263
+ cf = CurveFitter(x=[1,2,3,4,5], y=[2.1,3.9,6.1,8.1,10.1])
264
+
265
+ # Linear
266
+ cf.fit('linear')
267
+ cf.display()
268
+ cf.plot()
269
+
270
+ # Polynomial degree 2
271
+ cf.fit('polynomial', degree=2)
272
+ cf.display()
273
+
274
+ # Exponential, Power, Logarithmic, Reciprocal
275
+ for model in ['exponential', 'power', 'logarithmic', 'reciprocal']:
276
+ cf.fit(model)
277
+ print(f"{model}: R² = {cf.result['r_squared']:.4f}")
278
+ ```
279
+
280
+ ### 13. Cubic Spline
281
+
282
+ ```python
283
+ from pyOR import CubicSplineFitter
284
+
285
+ sf = CubicSplineFitter(
286
+ x=[0, 1, 2, 3, 4],
287
+ y=[0, 1, 0, 1, 0],
288
+ bc_type='natural'
289
+ )
290
+ sf.fit()
291
+ sf.display()
292
+
293
+ # Evaluate at a point
294
+ y_val = sf.evaluate(1.5)
295
+ dy = sf.derivative(1.5, order=1)
296
+ print(f"S(1.5) = {y_val}, S'(1.5) = {dy}")
297
+
298
+ sf.plot()
299
+ ```
300
+
301
+ ### 14. Game Theory
302
+
303
+ ```python
304
+ from pyOR import GameTheory
305
+
306
+ g = GameTheory([[3, -1], [-2, 4]])
307
+ g.solve() # auto: saddle -> 2x2 formula -> graphical -> LP
308
+ g.display() # p=(0.6, 0.4), q=(0.5, 0.5), value = 1
309
+
310
+ g = GameTheory([[1, 3, 11], [8, 5, 2]])
311
+ g.solve(method='graphical'); g.plot()
312
+
313
+ GameTheory([[3,-1,-3],[-2,4,-1],[-5,-6,2]]).solve(method='lp')
314
+ ```
315
+
316
+ ### 15. Queueing Theory
317
+
318
+ ```python
319
+ from pyOR import QueueModel, optimal_servers, min_servers
320
+
321
+ QueueModel('M/M/1', lam=8, mu=10).display() # Wq = 0.4, Lq = 3.2
322
+ QueueModel('M/M/c', lam=24, mu=10, c=3).solve() # Erlang-C
323
+ QueueModel('M/M/c/K', lam=12, mu=10, c=2, K=10).solve()['p_block']
324
+ QueueModel('M/G/1', lam=8, mu=10, service_var=0.01).solve()
325
+
326
+ min_servers(24, 10, max_Wq=0.05) # smallest c meeting a target
327
+ optimal_servers(24, 10, cost_server=50, cost_wait=10)['best_c']
328
+ ```
329
+
330
+ ### 16. Queue Simulation
331
+
332
+ ```python
333
+ from pyOR import MMcSimulation, AirportSimulation
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