simweave 0.7.2__tar.gz → 0.8.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.
Files changed (85) hide show
  1. {simweave-0.7.2/src/simweave.egg-info → simweave-0.8.1}/PKG-INFO +77 -23
  2. {simweave-0.7.2 → simweave-0.8.1}/README.md +71 -21
  3. {simweave-0.7.2 → simweave-0.8.1}/pyproject.toml +5 -2
  4. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/__init__.py +18 -1
  5. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/continuous/control/suspension.py +4 -4
  6. simweave-0.8.1/src/simweave/faults/__init__.py +27 -0
  7. simweave-0.8.1/src/simweave/faults/dataset.py +270 -0
  8. simweave-0.8.1/src/simweave/faults/fault.py +144 -0
  9. simweave-0.8.1/src/simweave/faults/injector.py +147 -0
  10. simweave-0.8.1/src/simweave/faults/recorder.py +64 -0
  11. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/viz/__init__.py +4 -0
  12. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/viz/plots.py +149 -0
  13. {simweave-0.7.2 → simweave-0.8.1/src/simweave.egg-info}/PKG-INFO +77 -23
  14. {simweave-0.7.2 → simweave-0.8.1}/src/simweave.egg-info/SOURCES.txt +5 -0
  15. {simweave-0.7.2 → simweave-0.8.1}/src/simweave.egg-info/requires.txt +5 -0
  16. {simweave-0.7.2 → simweave-0.8.1}/MANIFEST.in +0 -0
  17. {simweave-0.7.2 → simweave-0.8.1}/requirements-dev.txt +0 -0
  18. {simweave-0.7.2 → simweave-0.8.1}/requirements.txt +0 -0
  19. {simweave-0.7.2 → simweave-0.8.1}/setup.cfg +0 -0
  20. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/agents/__init__.py +0 -0
  21. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/agents/agent.py +0 -0
  22. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/agents/compass.py +0 -0
  23. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/agents/routing.py +0 -0
  24. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/analysis/vehicle.py +0 -0
  25. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/continuous/__init__.py +0 -0
  26. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/continuous/control/__init__.py +0 -0
  27. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/continuous/control/pid.py +0 -0
  28. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/continuous/solver.py +0 -0
  29. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/continuous/systems/__init__.py +0 -0
  30. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/continuous/systems/full_car.py +0 -0
  31. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/continuous/systems/half_car.py +0 -0
  32. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/continuous/systems/mass_spring_damper.py +0 -0
  33. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/continuous/systems/pendulum.py +0 -0
  34. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/continuous/systems/quarter_car.py +0 -0
  35. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/continuous/systems/rlc.py +0 -0
  36. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/continuous/systems/roll_car.py +0 -0
  37. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/continuous/systems/thermal.py +0 -0
  38. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/core/__init__.py +0 -0
  39. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/core/clock.py +0 -0
  40. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/core/entity.py +0 -0
  41. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/core/environment.py +0 -0
  42. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/core/logging.py +0 -0
  43. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/core/scheduler.py +0 -0
  44. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/core/time_axis.py +0 -0
  45. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/currency/__init__.py +0 -0
  46. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/currency/codes.py +0 -0
  47. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/currency/format.py +0 -0
  48. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/currency/fx.py +0 -0
  49. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/currency/money.py +0 -0
  50. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/discrete/__init__.py +0 -0
  51. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/discrete/properties.py +0 -0
  52. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/discrete/queues.py +0 -0
  53. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/discrete/resources.py +0 -0
  54. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/discrete/services.py +0 -0
  55. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/mc/__init__.py +0 -0
  56. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/mc/runner.py +0 -0
  57. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/reliability/__init__.py +0 -0
  58. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/reliability/entity.py +0 -0
  59. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/reliability/fleet.py +0 -0
  60. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/reliability/repair.py +0 -0
  61. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/reliability/sensitivity.py +0 -0
  62. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/reliability/subsystem.py +0 -0
  63. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/roads/__init__.py +0 -0
  64. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/roads/intersection.py +0 -0
  65. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/roads/network.py +0 -0
  66. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/roads/recorder.py +0 -0
  67. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/roads/road.py +0 -0
  68. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/roads/roundabout.py +0 -0
  69. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/roads/signal.py +0 -0
  70. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/roads/vehicle.py +0 -0
  71. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/spatial/__init__.py +0 -0
  72. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/spatial/graph.py +0 -0
  73. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/supplychain/__init__.py +0 -0
  74. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/supplychain/inventory.py +0 -0
  75. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/supplychain/optimization.py +0 -0
  76. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/supplychain/warehouse.py +0 -0
  77. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/units/__init__.py +0 -0
  78. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/units/constants.py +0 -0
  79. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/units/si.py +0 -0
  80. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/viz/_plotly.py +0 -0
  81. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/viz/recorders.py +0 -0
  82. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/viz/themes.py +0 -0
  83. {simweave-0.7.2 → simweave-0.8.1}/src/simweave/viz/vehicle_dynamics.py +0 -0
  84. {simweave-0.7.2 → simweave-0.8.1}/src/simweave.egg-info/dependency_links.txt +0 -0
  85. {simweave-0.7.2 → simweave-0.8.1}/src/simweave.egg-info/top_level.txt +0 -0
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: simweave
3
- Version: 0.7.2
4
- Summary: SimWeave: a hybrid discrete/continuous simulation engine with currency, units, agents, supply chains, and Monte Carlo.
3
+ Version: 0.8.1
4
+ Summary: SimWeave: a hybrid discrete/continuous simulation engine with fault injection, currency, units, agents, supply chains, and Monte Carlo.
5
5
  Author: Stuart
6
6
  License: MIT
7
7
  Requires-Python: >=3.10
@@ -22,6 +22,8 @@ Provides-Extra: fast
22
22
  Requires-Dist: numba>=0.58; extra == "fast"
23
23
  Provides-Extra: intl
24
24
  Requires-Dist: babel>=2.14; extra == "intl"
25
+ Provides-Extra: ml
26
+ Requires-Dist: pandas>=2.0; extra == "ml"
25
27
  Provides-Extra: dev
26
28
  Requires-Dist: pytest>=8.0; extra == "dev"
27
29
  Requires-Dist: pytest-cov>=4.1; extra == "dev"
@@ -29,6 +31,7 @@ Requires-Dist: scipy>=1.10; extra == "dev"
29
31
  Requires-Dist: networkx>=3.0; extra == "dev"
30
32
  Requires-Dist: babel>=2.14; extra == "dev"
31
33
  Requires-Dist: plotly>=5.18; extra == "dev"
34
+ Requires-Dist: pandas>=2.0; extra == "dev"
32
35
  Provides-Extra: docs
33
36
  Requires-Dist: mkdocs>=1.6; extra == "docs"
34
37
  Requires-Dist: mkdocs-material>=9.5; extra == "docs"
@@ -46,16 +49,21 @@ Requires-Dist: plotly>=5.18; extra == "all"
46
49
  Requires-Dist: networkx>=3.0; extra == "all"
47
50
  Requires-Dist: numba>=0.58; extra == "all"
48
51
  Requires-Dist: babel>=2.14; extra == "all"
52
+ Requires-Dist: pandas>=2.0; extra == "all"
49
53
 
50
54
  # SimWeave — a hybrid discrete/continuous simulation engine
51
55
  [![CI](https://github.com/Notabot123/simweave/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/Notabot123/simweave/actions/workflows/ci.yml)
56
+ [![codecov](https://codecov.io/gh/Notabot123/simweave/branch/main/graph/badge.svg)](https://codecov.io/gh/Notabot123/simweave)
57
+ [![PyPI](https://img.shields.io/pypi/v/simweave)](https://pypi.org/project/simweave/)
58
+ [![docs](https://img.shields.io/badge/docs-mkdocs-blue)](https://notabot123.github.io/simweave/)
52
59
 
53
- `simweave` (PyPI: [`simweave`](https://pypi.org/project/simweave/)) is a
54
- lightweight Python simulation library built around an **atomic-clock
55
- core** with an **optional heap-based event queue** layered on top. It is
56
- designed for Monte Carlo studies where reproducibility and vectorised
60
+ `simweave` is a lightweight Python simulation library built around an
61
+ **atomic-clock core** with an **optional heap-based event queue** layered on
62
+ top. It is designed for Monte Carlo studies where reproducibility and vectorised
57
63
  aggregation across replicates matter as much as per-event precision.
58
64
 
65
+ **Full documentation:** [notabot123.github.io/simweave](https://notabot123.github.io/simweave/)
66
+
59
67
  Sister project: [EdgeWeave](https://github.com/) — desktop frontend that
60
68
  generates and runs SimWeave scenarios.
61
69
 
@@ -146,6 +154,7 @@ Only `numpy` is a hard dependency. Everything else is optional:
146
154
  | `simweave[geo]` | osmnx — OSM map ingestion | `pip install simweave[geo]` |
147
155
  | `simweave[plot]` | matplotlib — bring-your-own static plotting | `pip install simweave[plot]` |
148
156
  | `simweave[viz]` | plotly — first-class viz module (`simweave.viz`) | `pip install simweave[viz]` |
157
+ | `simweave[ml]` | pandas — `FaultDataset.to_dataframe()` export | `pip install simweave[ml]` |
149
158
  | `simweave[intl]` | babel — locale-aware money formatting | `pip install simweave[intl]` |
150
159
  | `simweave[fast]` | numba — opt-in JIT for MC inner loops | `pip install simweave[fast]` |
151
160
  | `simweave[dev]` | pytest / mypy / plus the optional libs needed for tests | `pip install simweave[dev]` |
@@ -162,13 +171,17 @@ The submodules compose through the shared `Entity` base class:
162
171
  ```
163
172
  simweave/
164
173
  core/ Clock, EventQueue, Entity, SimEnvironment
165
- units/ SI exponent-tagged units (preserved from the original)
174
+ units/ SI exponent-tagged units with dimensional analysis
166
175
  discrete/ Queue, PriorityQueue, Service, ArrivalGenerator, Resource, ResourcePool
167
176
  continuous/ DynamicSystem, RK4/Euler, ContinuousProcess (hybrid)
177
+ faults/ FaultInjector, FaultProfile, FaultDataset — PdM dataset generation
168
178
  spatial/ Graph + A*-friendly adj_view adapter, grid_graph helper
169
179
  agents/ Compass, routing.a_star, Agent (Entity subclass)
170
180
  supplychain/ InventoryItems, Warehouse, steady-state optimisation
181
+ reliability/ ReliableEntity, Fleet, RepairCentre, sensitivity_sweep
182
+ roads/ Road, Intersection, Roundabout, RoadNetwork, traffic signals
171
183
  mc/ run_monte_carlo, run_batched_mc
184
+ viz/ Plotly-based plot helpers; applies themes
172
185
  ```
173
186
 
174
187
  A hybrid sim that moves a pallet (Agent) through a service line (Service
@@ -178,19 +191,38 @@ three separate libraries to do it would be the wrong trade.
178
191
 
179
192
  ## Installation
180
193
 
194
+ ### From PyPI (recommended)
195
+
196
+ ```bash
197
+ pip install simweave
198
+ ```
199
+
200
+ Optional extras (install only what you need):
201
+
202
+ ```bash
203
+ pip install simweave[viz] # plotly charts
204
+ pip install simweave[optim] # scipy optimiser
205
+ pip install simweave[ml] # pandas DataFrame export
206
+ pip install simweave[all] # everything above
207
+ ```
208
+
209
+ ### From source (latest development)
210
+
181
211
  ```bash
182
212
  git clone https://github.com/Notabot123/simweave
183
213
  cd simweave
184
214
  python -m venv .venv && source .venv/bin/activate # or .venv\Scripts\activate on Windows
185
- pip install -e .[dev] # editable install with test deps
215
+ pip install -e .[dev] # editable install with all test deps
186
216
  pytest # should show green
187
217
  ```
188
218
 
189
219
  ## Worked examples
190
220
 
191
- Sixteen runnable scripts live under [`demos/`](demos/):
221
+ 26 runnable scripts live under
222
+ [`demos/`](https://github.com/Notabot123/simweave/tree/main/demos):
192
223
 
193
224
  **Discrete-event / agents / Monte Carlo**
225
+
194
226
  1. `01_simple_queue.py` — M/M/1 queue, Little's law diagnostics
195
227
  2. `02_chained_services.py` — three-stage production line with blocking
196
228
  3. `03_resource_pool.py` — bounded concurrency via a physician pool
@@ -200,25 +232,51 @@ Sixteen runnable scripts live under [`demos/`](demos/):
200
232
  7. `07_monte_carlo.py` — serial vs threads vs processes vs batched numpy
201
233
  8. `08_hybrid_continuous_discrete.py` — queue coupled to an MSD
202
234
 
203
- **Continuous dynamical systems** (added for teaching use)
235
+ **Continuous dynamical systems**
204
236
 
205
237
  9. `09_mass_spring_damper.py` — under-, critical-, over-damped responses
206
238
  10. `10_quarter_car.py` — 2-DOF suspension over a speed bump, three damper setups
207
239
  11. `11_series_rlc.py` — RLC step and resonant drive, reports ω₀, ζ, Q
208
240
  12. `12_thermal_system.py` — single-body RC thermal + CPU/heatsink two-mass model
241
+ 13. `17_half_car_pitch.py` — 4-DOF half-car pitch model
242
+ 14. `18_half_car_roll.py` — 4-DOF half-car roll model
243
+ 15. `19_full_car_dynamics.py` — 7-DOF full-car model
244
+ 16. `20_PID_thermal_system.py` — PID temperature controller
209
245
 
210
246
  **Currency, visualisation, units, optimisation**
211
247
 
212
- 13. `13_money_cashflow.py` — `Money`, FX conversion, locale-aware formatting
213
- 14. `14_viz_tour.py` — every `simweave.viz` plot helper end-to-end, with HTML index
214
- 15. `15_units_dimensional.py` — SI-units algebra (`Distance / TimeUnit → Velocity`)
215
- 16. `16_inventory_optimisation.py` — recover demand rate from a sim, then optimise reorder points
248
+ 17. `13_money_cashflow.py` — `Money`, FX conversion, locale-aware formatting
249
+ 18. `14_viz_tour.py` — every `simweave.viz` plot helper end-to-end
250
+ 19. `15_units_dimensional.py` — SI-units algebra (`Distance / TimeUnit → Velocity`)
251
+ 20. `16_inventory_optimisation.py` — recover demand rate from a sim, then optimise reorder points
252
+ 21. `23_time_axis_calendar.py` — calendar-date x-axes on time-series plots
253
+
254
+ **Reliability and fleet management**
255
+
256
+ 22. `21_reliable_fleet.py` — 8-vehicle taxi fleet with repair centre and spare parts
257
+ 23. `22_sensitivity_analysis.py` — parameter sweep over repair bays and stock level
258
+
259
+ **Traffic and road networks**
260
+
261
+ 24. `24_signalised_intersection.py` — four-way signalised junction with traffic signals
262
+ 25. `25_roundabout.py` — two-lane roundabout with yield logic
263
+
264
+ **Fault injection and predictive maintenance** *(new in v0.8.0)*
265
+
266
+ 26. `26_fault_injection.py` — inject insulation-loss fault into a thermal model; produce
267
+ a labelled dataset with health index, RUL, and failure-mode columns ready for
268
+ LSTM / time-series model training
269
+
270
+ Run any script directly from the repo root, e.g.:
271
+
272
+ ```bash
273
+ python demos/01_simple_queue.py
274
+ python demos/26_fault_injection.py
275
+ ```
216
276
 
217
- Run any of them directly, e.g. `python demos/01_simple_queue.py` from
218
- the repo root. The two-digit prefix is just an ordering hint; the
219
- scripts have no dependency on each other. A small `demos/_bootstrap.py`
220
- shim adds `src/` to `sys.path` if the package isn't installed; with
221
- `pip install -e .` in place, the shim becomes a no-op.
277
+ The two-digit prefix is just an ordering hint; scripts have no dependency on each
278
+ other. A small `demos/_bootstrap.py` shim adds `src/` to `sys.path` when the
279
+ package is not installed; with `pip install -e .` in place the shim is a no-op.
222
280
 
223
281
  ## Monte Carlo performance: picking the right strategy
224
282
 
@@ -342,10 +400,6 @@ sim_engine/
342
400
 
343
401
  ## Next steps on the roadmap
344
402
 
345
- - **PID Controllers.** To extend utility of dynamic simulations, allow
346
- controllers which are easily exposed to EdgeWeave.
347
- - **Fault injection.** This should be suitable for ML datasets with use
348
- cases such as predictive maintenance,
349
403
  - **True sim-based optimisation.** `cost_optimise_stock_sim` already
350
404
  wraps a user callback; a future step is an adaptive surrogate model
351
405
  (kriging / BO) so each evaluation doesn't need a full MC sweep.
@@ -1,12 +1,16 @@
1
1
  # SimWeave — a hybrid discrete/continuous simulation engine
2
2
  [![CI](https://github.com/Notabot123/simweave/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/Notabot123/simweave/actions/workflows/ci.yml)
3
+ [![codecov](https://codecov.io/gh/Notabot123/simweave/branch/main/graph/badge.svg)](https://codecov.io/gh/Notabot123/simweave)
4
+ [![PyPI](https://img.shields.io/pypi/v/simweave)](https://pypi.org/project/simweave/)
5
+ [![docs](https://img.shields.io/badge/docs-mkdocs-blue)](https://notabot123.github.io/simweave/)
3
6
 
4
- `simweave` (PyPI: [`simweave`](https://pypi.org/project/simweave/)) is a
5
- lightweight Python simulation library built around an **atomic-clock
6
- core** with an **optional heap-based event queue** layered on top. It is
7
- designed for Monte Carlo studies where reproducibility and vectorised
7
+ `simweave` is a lightweight Python simulation library built around an
8
+ **atomic-clock core** with an **optional heap-based event queue** layered on
9
+ top. It is designed for Monte Carlo studies where reproducibility and vectorised
8
10
  aggregation across replicates matter as much as per-event precision.
9
11
 
12
+ **Full documentation:** [notabot123.github.io/simweave](https://notabot123.github.io/simweave/)
13
+
10
14
  Sister project: [EdgeWeave](https://github.com/) — desktop frontend that
11
15
  generates and runs SimWeave scenarios.
12
16
 
@@ -97,6 +101,7 @@ Only `numpy` is a hard dependency. Everything else is optional:
97
101
  | `simweave[geo]` | osmnx — OSM map ingestion | `pip install simweave[geo]` |
98
102
  | `simweave[plot]` | matplotlib — bring-your-own static plotting | `pip install simweave[plot]` |
99
103
  | `simweave[viz]` | plotly — first-class viz module (`simweave.viz`) | `pip install simweave[viz]` |
104
+ | `simweave[ml]` | pandas — `FaultDataset.to_dataframe()` export | `pip install simweave[ml]` |
100
105
  | `simweave[intl]` | babel — locale-aware money formatting | `pip install simweave[intl]` |
101
106
  | `simweave[fast]` | numba — opt-in JIT for MC inner loops | `pip install simweave[fast]` |
102
107
  | `simweave[dev]` | pytest / mypy / plus the optional libs needed for tests | `pip install simweave[dev]` |
@@ -113,13 +118,17 @@ The submodules compose through the shared `Entity` base class:
113
118
  ```
114
119
  simweave/
115
120
  core/ Clock, EventQueue, Entity, SimEnvironment
116
- units/ SI exponent-tagged units (preserved from the original)
121
+ units/ SI exponent-tagged units with dimensional analysis
117
122
  discrete/ Queue, PriorityQueue, Service, ArrivalGenerator, Resource, ResourcePool
118
123
  continuous/ DynamicSystem, RK4/Euler, ContinuousProcess (hybrid)
124
+ faults/ FaultInjector, FaultProfile, FaultDataset — PdM dataset generation
119
125
  spatial/ Graph + A*-friendly adj_view adapter, grid_graph helper
120
126
  agents/ Compass, routing.a_star, Agent (Entity subclass)
121
127
  supplychain/ InventoryItems, Warehouse, steady-state optimisation
128
+ reliability/ ReliableEntity, Fleet, RepairCentre, sensitivity_sweep
129
+ roads/ Road, Intersection, Roundabout, RoadNetwork, traffic signals
122
130
  mc/ run_monte_carlo, run_batched_mc
131
+ viz/ Plotly-based plot helpers; applies themes
123
132
  ```
124
133
 
125
134
  A hybrid sim that moves a pallet (Agent) through a service line (Service
@@ -129,19 +138,38 @@ three separate libraries to do it would be the wrong trade.
129
138
 
130
139
  ## Installation
131
140
 
141
+ ### From PyPI (recommended)
142
+
143
+ ```bash
144
+ pip install simweave
145
+ ```
146
+
147
+ Optional extras (install only what you need):
148
+
149
+ ```bash
150
+ pip install simweave[viz] # plotly charts
151
+ pip install simweave[optim] # scipy optimiser
152
+ pip install simweave[ml] # pandas DataFrame export
153
+ pip install simweave[all] # everything above
154
+ ```
155
+
156
+ ### From source (latest development)
157
+
132
158
  ```bash
133
159
  git clone https://github.com/Notabot123/simweave
134
160
  cd simweave
135
161
  python -m venv .venv && source .venv/bin/activate # or .venv\Scripts\activate on Windows
136
- pip install -e .[dev] # editable install with test deps
162
+ pip install -e .[dev] # editable install with all test deps
137
163
  pytest # should show green
138
164
  ```
139
165
 
140
166
  ## Worked examples
141
167
 
142
- Sixteen runnable scripts live under [`demos/`](demos/):
168
+ 26 runnable scripts live under
169
+ [`demos/`](https://github.com/Notabot123/simweave/tree/main/demos):
143
170
 
144
171
  **Discrete-event / agents / Monte Carlo**
172
+
145
173
  1. `01_simple_queue.py` — M/M/1 queue, Little's law diagnostics
146
174
  2. `02_chained_services.py` — three-stage production line with blocking
147
175
  3. `03_resource_pool.py` — bounded concurrency via a physician pool
@@ -151,25 +179,51 @@ Sixteen runnable scripts live under [`demos/`](demos/):
151
179
  7. `07_monte_carlo.py` — serial vs threads vs processes vs batched numpy
152
180
  8. `08_hybrid_continuous_discrete.py` — queue coupled to an MSD
153
181
 
154
- **Continuous dynamical systems** (added for teaching use)
182
+ **Continuous dynamical systems**
155
183
 
156
184
  9. `09_mass_spring_damper.py` — under-, critical-, over-damped responses
157
185
  10. `10_quarter_car.py` — 2-DOF suspension over a speed bump, three damper setups
158
186
  11. `11_series_rlc.py` — RLC step and resonant drive, reports ω₀, ζ, Q
159
187
  12. `12_thermal_system.py` — single-body RC thermal + CPU/heatsink two-mass model
188
+ 13. `17_half_car_pitch.py` — 4-DOF half-car pitch model
189
+ 14. `18_half_car_roll.py` — 4-DOF half-car roll model
190
+ 15. `19_full_car_dynamics.py` — 7-DOF full-car model
191
+ 16. `20_PID_thermal_system.py` — PID temperature controller
160
192
 
161
193
  **Currency, visualisation, units, optimisation**
162
194
 
163
- 13. `13_money_cashflow.py` — `Money`, FX conversion, locale-aware formatting
164
- 14. `14_viz_tour.py` — every `simweave.viz` plot helper end-to-end, with HTML index
165
- 15. `15_units_dimensional.py` — SI-units algebra (`Distance / TimeUnit → Velocity`)
166
- 16. `16_inventory_optimisation.py` — recover demand rate from a sim, then optimise reorder points
195
+ 17. `13_money_cashflow.py` — `Money`, FX conversion, locale-aware formatting
196
+ 18. `14_viz_tour.py` — every `simweave.viz` plot helper end-to-end
197
+ 19. `15_units_dimensional.py` — SI-units algebra (`Distance / TimeUnit → Velocity`)
198
+ 20. `16_inventory_optimisation.py` — recover demand rate from a sim, then optimise reorder points
199
+ 21. `23_time_axis_calendar.py` — calendar-date x-axes on time-series plots
200
+
201
+ **Reliability and fleet management**
202
+
203
+ 22. `21_reliable_fleet.py` — 8-vehicle taxi fleet with repair centre and spare parts
204
+ 23. `22_sensitivity_analysis.py` — parameter sweep over repair bays and stock level
205
+
206
+ **Traffic and road networks**
207
+
208
+ 24. `24_signalised_intersection.py` — four-way signalised junction with traffic signals
209
+ 25. `25_roundabout.py` — two-lane roundabout with yield logic
210
+
211
+ **Fault injection and predictive maintenance** *(new in v0.8.0)*
212
+
213
+ 26. `26_fault_injection.py` — inject insulation-loss fault into a thermal model; produce
214
+ a labelled dataset with health index, RUL, and failure-mode columns ready for
215
+ LSTM / time-series model training
216
+
217
+ Run any script directly from the repo root, e.g.:
218
+
219
+ ```bash
220
+ python demos/01_simple_queue.py
221
+ python demos/26_fault_injection.py
222
+ ```
167
223
 
168
- Run any of them directly, e.g. `python demos/01_simple_queue.py` from
169
- the repo root. The two-digit prefix is just an ordering hint; the
170
- scripts have no dependency on each other. A small `demos/_bootstrap.py`
171
- shim adds `src/` to `sys.path` if the package isn't installed; with
172
- `pip install -e .` in place, the shim becomes a no-op.
224
+ The two-digit prefix is just an ordering hint; scripts have no dependency on each
225
+ other. A small `demos/_bootstrap.py` shim adds `src/` to `sys.path` when the
226
+ package is not installed; with `pip install -e .` in place the shim is a no-op.
173
227
 
174
228
  ## Monte Carlo performance: picking the right strategy
175
229
 
@@ -293,10 +347,6 @@ sim_engine/
293
347
 
294
348
  ## Next steps on the roadmap
295
349
 
296
- - **PID Controllers.** To extend utility of dynamic simulations, allow
297
- controllers which are easily exposed to EdgeWeave.
298
- - **Fault injection.** This should be suitable for ML datasets with use
299
- cases such as predictive maintenance,
300
350
  - **True sim-based optimisation.** `cost_optimise_stock_sim` already
301
351
  wraps a user callback; a future step is an adaptive surrogate model
302
352
  (kriging / BO) so each evaluation doesn't need a full MC sweep.
@@ -4,8 +4,8 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "simweave"
7
- version = "0.7.2"
8
- description = "SimWeave: a hybrid discrete/continuous simulation engine with currency, units, agents, supply chains, and Monte Carlo."
7
+ version = "0.8.1"
8
+ description = "SimWeave: a hybrid discrete/continuous simulation engine with fault injection, currency, units, agents, supply chains, and Monte Carlo."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
11
11
  license = { text = "MIT" }
@@ -22,6 +22,7 @@ graph = ["networkx>=3.0"]
22
22
  geo = ["osmnx>=1.8", "networkx>=3.0"]
23
23
  fast = ["numba>=0.58"]
24
24
  intl = ["babel>=2.14"]
25
+ ml = ["pandas>=2.0"]
25
26
  dev = [
26
27
  "pytest>=8.0",
27
28
  "pytest-cov>=4.1",
@@ -29,6 +30,7 @@ dev = [
29
30
  "networkx>=3.0",
30
31
  "babel>=2.14",
31
32
  "plotly>=5.18",
33
+ "pandas>=2.0",
32
34
  ]
33
35
  docs = [
34
36
  "mkdocs>=1.6",
@@ -50,6 +52,7 @@ all = [
50
52
  "networkx>=3.0",
51
53
  "numba>=0.58",
52
54
  "babel>=2.14",
55
+ "pandas>=2.0",
53
56
  ]
54
57
 
55
58
  [tool.setuptools]
@@ -83,6 +83,13 @@ from simweave.roads import (
83
83
  RoadOccupancyRecorder,
84
84
  IntersectionQueueRecorder,
85
85
  )
86
+ from simweave.faults import (
87
+ FaultProfile,
88
+ ParameterFault,
89
+ FaultInjector,
90
+ FaultRecorder,
91
+ FaultDataset,
92
+ )
86
93
  from simweave.mc import MCResult, run_monte_carlo, run_batched_mc
87
94
  from simweave.units import (
88
95
  SIUnit,
@@ -133,9 +140,11 @@ from simweave.viz import (
133
140
  register_theme,
134
141
  set_default_theme,
135
142
  plot_vehicle_metrics,
143
+ plot_fault_signals,
144
+ plot_health_index,
136
145
  )
137
146
 
138
- __version__ = "0.7.2"
147
+ __version__ = "0.8.1"
139
148
 
140
149
  __all__ = [
141
150
  # Core
@@ -202,6 +211,12 @@ __all__ = [
202
211
  "RoadNetwork",
203
212
  "RoadOccupancyRecorder",
204
213
  "IntersectionQueueRecorder",
214
+ # Faults / predictive maintenance
215
+ "FaultProfile",
216
+ "ParameterFault",
217
+ "FaultInjector",
218
+ "FaultRecorder",
219
+ "FaultDataset",
205
220
  # Reliability
206
221
  "SubsystemSpec",
207
222
  "SubsystemState",
@@ -259,6 +274,8 @@ __all__ = [
259
274
  "plot_road_occupancy",
260
275
  "plot_intersection_queues",
261
276
  "plot_vehicle_metrics",
277
+ "plot_fault_signals",
278
+ "plot_health_index",
262
279
  "register_theme",
263
280
  "set_default_theme",
264
281
  # Meta
@@ -21,7 +21,7 @@ class GroundhookDamper:
21
21
 
22
22
  def force(self, body_velocity: float, wheel_velocity: float) -> float:
23
23
  # For groundhook uses wheel velocity only, but signature makes modular/easy to toggle controller
24
- return -self.c * wheel_velocity
24
+ return self.c * wheel_velocity
25
25
 
26
26
  class HybridActiveDamper:
27
27
  "Hybrid Skyhook & Groundhook."
@@ -30,10 +30,10 @@ class HybridActiveDamper:
30
30
  self.ground = GroundhookDamper(c_ground)
31
31
  self.alpha = float(alpha)
32
32
 
33
- def force(self, body_v: float, wheel_v: float) -> float:
33
+ def force(self, body_velocity: float, wheel_velocity: float) -> float:
34
34
  return (
35
- self.alpha * self.sky.force(body_v)
36
- + (1 - self.alpha) * self.ground.force(wheel_v)
35
+ self.alpha * self.sky.force(body_velocity, 0)
36
+ + (1 - self.alpha) * self.ground.force(0, wheel_velocity)
37
37
  )
38
38
 
39
39
  class SemiActiveWrapper:
@@ -0,0 +1,27 @@
1
+ """Fault injection for predictive-maintenance dataset generation.
2
+
3
+ Inject physically-meaningful parameter faults into continuous dynamic systems
4
+ to produce labelled time-series suitable for training ML models (binary
5
+ classifier, RUL regression, LSTM, etc.).
6
+
7
+ Typical usage
8
+ -------------
9
+ 1. Describe the degradation with :class:`FaultProfile`.
10
+ 2. Map it to a system parameter with :class:`ParameterFault`.
11
+ 3. Wrap the system in a :class:`FaultInjector` and run
12
+ :func:`~simweave.continuous.solver.simulate`.
13
+ 4. Assemble the labelled :class:`FaultDataset` and export to a DataFrame.
14
+ """
15
+
16
+ from simweave.faults.fault import FaultProfile, ParameterFault
17
+ from simweave.faults.injector import FaultInjector
18
+ from simweave.faults.recorder import FaultRecorder
19
+ from simweave.faults.dataset import FaultDataset
20
+
21
+ __all__ = [
22
+ "FaultProfile",
23
+ "ParameterFault",
24
+ "FaultInjector",
25
+ "FaultRecorder",
26
+ "FaultDataset",
27
+ ]