@pikaa-ai/pikaa 0.3.23 → 0.3.25

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 (191) hide show
  1. package/assets/brand/orbit-logo-option4-whale.jpg +0 -0
  2. package/assets/brand/orbit-logo.jpg +0 -0
  3. package/assets/brand/orbit-logo.png +0 -0
  4. package/assets/brand/orbit-logo.svg +3 -0
  5. package/dist/cli.js +407 -219
  6. package/dist/index.js +7 -2
  7. package/package.json +1 -2
  8. package/skills/adaptyv/SKILL.md +0 -240
  9. package/skills/aeon/SKILL.md +0 -402
  10. package/skills/analytical-method-validation/SKILL.md +0 -299
  11. package/skills/anndata/SKILL.md +0 -431
  12. package/skills/arbor/SKILL.md +0 -152
  13. package/skills/arboreto/SKILL.md +0 -267
  14. package/skills/astropy/SKILL.md +0 -353
  15. package/skills/autoskill/SKILL.md +0 -233
  16. package/skills/benchling-integration/SKILL.md +0 -229
  17. package/skills/bgpt-paper-search/SKILL.md +0 -75
  18. package/skills/bids/SKILL.md +0 -237
  19. package/skills/biopython/SKILL.md +0 -472
  20. package/skills/bioservices/SKILL.md +0 -399
  21. package/skills/bulk-rnaseq/SKILL.md +0 -198
  22. package/skills/cellxgene-census/SKILL.md +0 -283
  23. package/skills/cirq/SKILL.md +0 -370
  24. package/skills/citation-management/SKILL.md +0 -329
  25. package/skills/clinical-decision-support/SKILL.md +0 -238
  26. package/skills/clinical-decision-support/references/README.md +0 -62
  27. package/skills/clinical-reports/SKILL.md +0 -248
  28. package/skills/clinical-reports/references/README.md +0 -34
  29. package/skills/cobrapy/SKILL.md +0 -496
  30. package/skills/consciousness-council/SKILL.md +0 -151
  31. package/skills/dask/SKILL.md +0 -482
  32. package/skills/database-lookup/SKILL.md +0 -386
  33. package/skills/datamol/SKILL.md +0 -200
  34. package/skills/deepchem/SKILL.md +0 -244
  35. package/skills/deepspot-m/SKILL.md +0 -175
  36. package/skills/deeptools/SKILL.md +0 -412
  37. package/skills/depmap/SKILL.md +0 -301
  38. package/skills/dhdna-profiler/SKILL.md +0 -184
  39. package/skills/diffdock/SKILL.md +0 -488
  40. package/skills/dnanexus-integration/SKILL.md +0 -325
  41. package/skills/docx/SKILL.md +0 -99
  42. package/skills/esm/SKILL.md +0 -334
  43. package/skills/etetoolkit/SKILL.md +0 -327
  44. package/skills/exa-search/SKILL.md +0 -102
  45. package/skills/executing-plans/SKILL.md +0 -14
  46. package/skills/experimental-design/SKILL.md +0 -234
  47. package/skills/exploratory-data-analysis/SKILL.md +0 -280
  48. package/skills/flowio/SKILL.md +0 -310
  49. package/skills/fluidsim/SKILL.md +0 -279
  50. package/skills/frontend-design/SKILL.md +0 -100
  51. package/skills/generate-image/SKILL.md +0 -304
  52. package/skills/geniml/SKILL.md +0 -310
  53. package/skills/genomic-coordinates/SKILL.md +0 -189
  54. package/skills/genomic-intelligence/SKILL.md +0 -243
  55. package/skills/geomaster/README.md +0 -105
  56. package/skills/geomaster/SKILL.md +0 -366
  57. package/skills/geopandas/SKILL.md +0 -250
  58. package/skills/get-available-resources/SKILL.md +0 -260
  59. package/skills/gget/SKILL.md +0 -153
  60. package/skills/ginkgo-cloud-lab/SKILL.md +0 -106
  61. package/skills/glycoengineering/SKILL.md +0 -339
  62. package/skills/gtars/SKILL.md +0 -282
  63. package/skills/guardian-rails/SKILL.md +0 -54
  64. package/skills/histolab/SKILL.md +0 -243
  65. package/skills/hugging-science/SKILL.md +0 -132
  66. package/skills/hypogenic/SKILL.md +0 -290
  67. package/skills/hypothesis-generation/SKILL.md +0 -264
  68. package/skills/imaging-data-commons/SKILL.md +0 -496
  69. package/skills/infographics/SKILL.md +0 -315
  70. package/skills/iso-standards-readiness/SKILL.md +0 -352
  71. package/skills/lab-hardware-cad/SKILL.md +0 -372
  72. package/skills/labarchive-integration/SKILL.md +0 -216
  73. package/skills/lamindb/SKILL.md +0 -408
  74. package/skills/latchbio-integration/SKILL.md +0 -227
  75. package/skills/latex-posters/SKILL.md +0 -369
  76. package/skills/latex-posters/references/README.md +0 -439
  77. package/skills/liteparse/SKILL.md +0 -295
  78. package/skills/literature-review/SKILL.md +0 -263
  79. package/skills/markdown-mermaid-writing/SKILL.md +0 -322
  80. package/skills/market-research-reports/SKILL.md +0 -337
  81. package/skills/markitdown/SKILL.md +0 -264
  82. package/skills/matchms/SKILL.md +0 -276
  83. package/skills/matlab/SKILL.md +0 -274
  84. package/skills/matplotlib/SKILL.md +0 -378
  85. package/skills/medchem/SKILL.md +0 -321
  86. package/skills/modal/SKILL.md +0 -468
  87. package/skills/molecular-dynamics/SKILL.md +0 -458
  88. package/skills/molfeat/SKILL.md +0 -348
  89. package/skills/ncats-arax/SKILL.md +0 -178
  90. package/skills/networkx/SKILL.md +0 -440
  91. package/skills/neurokit2/SKILL.md +0 -323
  92. package/skills/neuropixels-analysis/SKILL.md +0 -412
  93. package/skills/nextflow/SKILL.md +0 -195
  94. package/skills/omero-integration/SKILL.md +0 -222
  95. package/skills/onekgpd/SKILL.md +0 -371
  96. package/skills/ontology-term-resolution/SKILL.md +0 -147
  97. package/skills/open-notebook/SKILL.md +0 -297
  98. package/skills/openpiv/SKILL.md +0 -469
  99. package/skills/opentrons-integration/SKILL.md +0 -322
  100. package/skills/optimize-for-gpu/SKILL.md +0 -176
  101. package/skills/owasp-top10/SKILL.md +0 -48
  102. package/skills/pacsomatic/LICENSE +0 -21
  103. package/skills/pacsomatic/SKILL.md +0 -150
  104. package/skills/paper-lookup/SKILL.md +0 -263
  105. package/skills/paperclip/SKILL.md +0 -413
  106. package/skills/paperzilla/SKILL.md +0 -159
  107. package/skills/parallel-web/SKILL.md +0 -128
  108. package/skills/pathml/SKILL.md +0 -222
  109. package/skills/pathogen-variant-surveillance/SKILL.md +0 -208
  110. package/skills/pathway-enrichment/SKILL.md +0 -194
  111. package/skills/pdf/SKILL.md +0 -322
  112. package/skills/peer-review/SKILL.md +0 -288
  113. package/skills/penetration-testing/SKILL.md +0 -31
  114. package/skills/pennylane/SKILL.md +0 -240
  115. package/skills/phylogenetics/SKILL.md +0 -409
  116. package/skills/pi-agent/SKILL.md +0 -83
  117. package/skills/pkpd-modeling/SKILL.md +0 -381
  118. package/skills/polars/SKILL.md +0 -393
  119. package/skills/polars-bio/SKILL.md +0 -379
  120. package/skills/ponytail/SKILL.md +0 -31
  121. package/skills/ponytail-audit/SKILL.md +0 -18
  122. package/skills/pptx/SKILL.md +0 -246
  123. package/skills/pptx-posters/SKILL.md +0 -258
  124. package/skills/primekg/SKILL.md +0 -99
  125. package/skills/protocolsio-integration/SKILL.md +0 -236
  126. package/skills/pufferlib/SKILL.md +0 -328
  127. package/skills/pydeseq2/SKILL.md +0 -369
  128. package/skills/pydicom/SKILL.md +0 -381
  129. package/skills/pyhealth/SKILL.md +0 -124
  130. package/skills/pylabrobot/SKILL.md +0 -216
  131. package/skills/pymatgen/SKILL.md +0 -404
  132. package/skills/pymc/SKILL.md +0 -310
  133. package/skills/pymoo/SKILL.md +0 -276
  134. package/skills/pyopenms/SKILL.md +0 -179
  135. package/skills/pysam/SKILL.md +0 -330
  136. package/skills/pytdc/SKILL.md +0 -297
  137. package/skills/pytorch-lightning/SKILL.md +0 -191
  138. package/skills/pyzotero/SKILL.md +0 -137
  139. package/skills/qiskit/SKILL.md +0 -259
  140. package/skills/qutip/SKILL.md +0 -317
  141. package/skills/rdkit/SKILL.md +0 -94
  142. package/skills/relsa-severity-assessment/SKILL.md +0 -354
  143. package/skills/research-grants/SKILL.md +0 -296
  144. package/skills/research-grants/references/README.md +0 -287
  145. package/skills/research-lookup/README.md +0 -106
  146. package/skills/research-lookup/SKILL.md +0 -338
  147. package/skills/rowan/SKILL.md +0 -398
  148. package/skills/scanpy/SKILL.md +0 -303
  149. package/skills/scholar-evaluation/SKILL.md +0 -296
  150. package/skills/scientific-brainstorming/SKILL.md +0 -282
  151. package/skills/scientific-critical-thinking/SKILL.md +0 -180
  152. package/skills/scientific-schematics/SKILL.md +0 -370
  153. package/skills/scientific-slides/SKILL.md +0 -379
  154. package/skills/scientific-visualization/SKILL.md +0 -285
  155. package/skills/scientific-writing/SKILL.md +0 -356
  156. package/skills/scikit-bio/SKILL.md +0 -470
  157. package/skills/scikit-learn/SKILL.md +0 -324
  158. package/skills/scikit-survival/SKILL.md +0 -313
  159. package/skills/scvelo/SKILL.md +0 -328
  160. package/skills/scvi-tools/SKILL.md +0 -201
  161. package/skills/seaborn/SKILL.md +0 -254
  162. package/skills/security-auditor/SKILL.md +0 -37
  163. package/skills/shap/SKILL.md +0 -282
  164. package/skills/simpy/SKILL.md +0 -283
  165. package/skills/stable-baselines3/SKILL.md +0 -325
  166. package/skills/statistical-analysis/SKILL.md +0 -446
  167. package/skills/statistical-power/SKILL.md +0 -200
  168. package/skills/statsmodels/SKILL.md +0 -238
  169. package/skills/sympy/SKILL.md +0 -354
  170. package/skills/systematic-debugging/SKILL.md +0 -35
  171. package/skills/tamarind/SKILL.md +0 -285
  172. package/skills/tdd/SKILL.md +0 -26
  173. package/skills/tiledbvcf/SKILL.md +0 -456
  174. package/skills/timesfm-forecasting/SKILL.md +0 -408
  175. package/skills/timesfm-forecasting/examples/global-temperature/README.md +0 -178
  176. package/skills/torch-geometric/SKILL.md +0 -458
  177. package/skills/torchdrug/SKILL.md +0 -241
  178. package/skills/transformers/SKILL.md +0 -195
  179. package/skills/treatment-plans/SKILL.md +0 -174
  180. package/skills/treatment-plans/references/README.md +0 -19
  181. package/skills/umap-learn/SKILL.md +0 -488
  182. package/skills/uncertainty-and-units/SKILL.md +0 -384
  183. package/skills/usfiscaldata/SKILL.md +0 -171
  184. package/skills/vaex/SKILL.md +0 -204
  185. package/skills/venue-templates/SKILL.md +0 -269
  186. package/skills/verification-before-completion/SKILL.md +0 -22
  187. package/skills/waypoint-bio/SKILL.md +0 -273
  188. package/skills/what-if-oracle/SKILL.md +0 -184
  189. package/skills/writing-plans/SKILL.md +0 -15
  190. package/skills/xlsx/SKILL.md +0 -110
  191. package/skills/zarr-python/SKILL.md +0 -241
@@ -1,283 +0,0 @@
1
- ---
2
- name: simpy
3
- description: Build, inspect, test, and analyze bounded process-based discrete-event simulations with SimPy, including events, resources, interrupts, monitoring, replications, warm-up, and reproducible output analysis.
4
- license: MIT
5
- compatibility: Upstream SimPy 4.1.2 supports Python 3.8+; bundled CLIs require Python 3.10+, uv, and SimPy 4.1.2. They use only SimPy and the standard library, operate on local bounded inputs, and make no network calls.
6
- allowed-tools: Read Write Edit Bash Glob
7
- metadata:
8
- version: "1.2"
9
- skill-author: K-Dense Inc.
10
- ---
11
-
12
- # SimPy
13
-
14
- ## Scope
15
-
16
- Use this skill for process-based discrete-event models where active entities yield
17
- events and contend for resources: queues, production systems, logistics, networks,
18
- service operations, inventory, and other event-driven systems.
19
-
20
- SimPy supplies an event scheduler and modeling primitives. It does **not** choose a
21
- scientifically valid conceptual model, input distribution, warm-up, run length,
22
- replication count, estimand, or causal interpretation. Treat those as simulation-study
23
- methodology, not SimPy API behavior.
24
-
25
- ## Current release and installation
26
-
27
- Verified **2026-07-23**:
28
-
29
- - Latest stable: **SimPy 4.1.2**, released on PyPI 2026-05-24; source tag
30
- `4.1.2` points to commit `f4381649`.
31
- - Package metadata requires Python **>=3.8** and classifies CPython 3.8-3.14
32
- plus PyPy. SimPy has no runtime dependencies.
33
- - 4.1.2 adds Python 3.13/3.14 support and modern-interpreter test fixes.
34
- - Upstream and this skill are MIT-licensed.
35
-
36
- Create a reproducible environment:
37
-
38
- ```bash
39
- uv venv --python 3.13
40
- source .venv/bin/activate
41
- uv pip install "simpy==4.1.2"
42
- python -c "import importlib.metadata; print(importlib.metadata.version('simpy'))"
43
- ```
44
-
45
- Do not silently substitute the `latest` documentation build: it may describe an
46
- unreleased development revision. Use the versioned 4.1.2 links in
47
- `references/sources.md`.
48
-
49
- ## Model workflow
50
-
51
- 1. **Define purpose and estimands.** State the decision/question, system boundary,
52
- entities, resources, state, outputs, time units, and terminating event or
53
- steady-state target.
54
- 2. **Write a conceptual model first.** Record assumptions, distributions,
55
- routing, priorities, initial conditions, and omitted mechanisms.
56
- 3. **Implement generators.** A SimPy process is an event-yielding Python generator.
57
- Register the generator object with `env.process(...)`.
58
- 4. **Bound execution.** Give every production run explicit time, entity, event, and
59
- replication caps. Never call `env.run()` on a model containing an endless process.
60
- 5. **Separate random streams.** Use local RNG instances for logically distinct
61
- stochastic sources; retain a seed manifest.
62
- 6. **Instrument deliberately.** Observe state after the transition of interest,
63
- close time-weighted intervals at the horizon, and test that monitoring does not
64
- alter event order.
65
- 7. **Verify and validate.** Test deterministic edge cases, conservation identities,
66
- traces, queue discipline, and analytical benchmarks; compare against system or
67
- expert evidence for the stated purpose.
68
- 8. **Run independent replications.** Make intervals from replication-level
69
- estimates, not correlated entities within one run.
70
- 9. **Report limitations.** Include initialization, unfinished entities, run length,
71
- seeds/streams, precision, sensitivity, and validation evidence. Never convert
72
- simulation association into a causal claim.
73
-
74
- Read `references/simulation-methodology.md` before making inferential claims.
75
-
76
- ## Minimal bounded model
77
-
78
- ```python
79
- import random
80
- import simpy
81
-
82
- HORIZON = 480.0
83
- arrival_rng = random.Random(101)
84
- service_rng = random.Random(202)
85
- env = simpy.Environment()
86
- server = simpy.Resource(env, capacity=2)
87
- completed = []
88
-
89
- def customer(arrival):
90
- with server.request() as request:
91
- yield request
92
- wait = env.now - arrival
93
- yield env.timeout(service_rng.expovariate(1 / 6.0))
94
- completed.append((env.now, wait))
95
-
96
- def arrivals():
97
- for _ in range(10_000): # Entity cap.
98
- delay = arrival_rng.expovariate(1 / 4.0)
99
- if env.now + delay >= HORIZON:
100
- return
101
- yield env.timeout(delay)
102
- env.process(customer(env.now))
103
-
104
- env.process(arrivals())
105
- env.run(until=HORIZON)
106
- ```
107
-
108
- The numeric horizon is half-open: normal events scheduled exactly at `480.0` are
109
- not processed. Report unfinished entities rather than silently treating them as
110
- completed observations.
111
-
112
- ## Core semantics
113
-
114
- ### Environment and deterministic ordering
115
-
116
- `Environment` is single-threaded. The queue is ordered by simulation time, event
117
- priority, then a strictly increasing event ID. Same-time, same-priority events are
118
- therefore processed FIFO in scheduling order. Model processes may represent
119
- concurrency, but callbacks execute sequentially and deterministically.
120
-
121
- - `env.now`: unitless simulation clock; choose and document one unit.
122
- - `env.peek()`: next event time or infinity.
123
- - `env.step()`: process one event; raises `EmptySchedule` when empty.
124
- - `env.active_process`: currently executing process, otherwise `None`.
125
- - `env.run()`: drain the queue; unsafe with recurring or endless processes.
126
-
127
- `env.run(until=number)` and `env.run(until=event)` are not interchangeable at
128
- boundaries:
129
-
130
- - A numeric value schedules an urgent stop event and excludes ordinary events at
131
- that exact time.
132
- - An Event criterion returns that event's value when its stop callback fires.
133
- Other same-time ordering depends on priority and scheduling order.
134
- - In 4.1.2, `Environment.step()` preserves callbacks remaining after
135
- `StopSimulation` by rescheduling the target. Consequently, after
136
- `env.run(until=target)`, `target.processed` can remain `False` until one more
137
- `step()`/`run()` even though its value was returned. Do not use `processed` as the
138
- sole post-run completion test.
139
-
140
- See `references/events.md` and `references/monitoring.md`.
141
-
142
- ### Event, Timeout, Process, and Condition
143
-
144
- - An `Event` moves once through not-triggered -> triggered/scheduled -> processed.
145
- `succeed(value)` or `fail(exception)` triggers it once.
146
- - A `Timeout` triggers when created, is scheduled for `now + delay`, and cannot be
147
- manually succeeded again.
148
- - `env.process(generator)` creates a `Process`; the generator resumes with the
149
- yielded event value. Returning from the generator succeeds the Process with that
150
- return value. Uncaught exceptions fail it.
151
- - `AnyOf` / `a | b` and `AllOf` / `a & b` yield a `ConditionValue`: an ordered,
152
- dict-like mapping from **event objects** to their values. Test membership using
153
- the original event objects; do not assume a scalar result.
154
- - `AnyOf` does not cancel losing events. Explicitly cancel pending resource
155
- requests when abandoning them; ordinary timeouts remain scheduled.
156
-
157
- ### Interrupts
158
-
159
- `process.interrupt(cause)` schedules an urgent interruption that throws
160
- `simpy.Interrupt` into the target generator. Catch it around the yielded work that
161
- may be interrupted, inspect `interrupt.cause`, update remaining work, then either
162
- resume, re-yield the original event, or terminate.
163
-
164
- Interrupting a process removes its resume callback from its current target; it does
165
- not cancel that target event. A process cannot interrupt itself or a terminated
166
- process. See `references/process-interaction.md`.
167
-
168
- ## Shared resources
169
-
170
- | Type | Semantics |
171
- |---|---|
172
- | `Resource` | FIFO semaphore-like usage slots |
173
- | `PriorityResource` | Queued requests sorted by lower numeric priority first |
174
- | `PreemptiveResource` | Priority queue plus optional preemption of a current user |
175
- | `Container` | Homogeneous numeric level; `put`/`get` wait for capacity/material |
176
- | `Store` | FIFO Python objects |
177
- | `FilterStore` | First available item satisfying the request's predicate |
178
- | `PriorityStore` | Comparable items returned in priority order |
179
-
180
- Use a request context manager:
181
-
182
- ```python
183
- def job(env, resource):
184
- with resource.request() as request:
185
- yield request
186
- yield env.timeout(3)
187
- ```
188
-
189
- On exit it releases an acquired request or cancels a still-pending one, including
190
- during exception unwinding. For a manually retained pending `put`/`get`/request,
191
- call `cancel()` if an interrupt or timeout makes the process abandon it.
192
-
193
- `PreemptiveResource.request(priority=..., preempt=True)` uses lower numbers as
194
- higher priority. The preempted process receives an `Interrupt` whose cause is a
195
- `Preempted` object: `cause.by` is the preempting Process,
196
- `cause.usage_since` is when use began, and `cause.resource` is the resource.
197
- Queued priority takes precedence over the `preempt` flag; mixing preempting and
198
- non-preempting requests needs explicit tests.
199
-
200
- Read `references/resources.md` for blocked operations, queue rules, and examples.
201
-
202
- ## Monitoring and stepping
203
-
204
- Prefer explicit domain observations at state transitions. For generic resource
205
- monitoring, wrappers or subclasses can inspect `count`, `queue`, `level`, `items`,
206
- `put_queue`, and `get_queue`. For event tracing, `schedule()` and `step()` are the
207
- central hooks.
208
-
209
- Queue measurements are timing-sensitive:
210
-
211
- - A request method's pre-state, post-call state, grant callback, and release
212
- callback can all differ at the same simulation timestamp.
213
- - Sample averages weight event observations, not time. Compute area under the
214
- left-continuous state path and divide by elapsed time.
215
- - Add initial and final samples; close the last interval at the analysis horizon.
216
- - `env._queue`, resource `_env`, and monkey-patching are implementation details.
217
- Pin SimPy, isolate the instrumentation, and regression-test after upgrades.
218
- - Tracing every event changes runtime and memory use; cap trace records.
219
-
220
- Use `scripts/resource_monitor.py` and `references/monitoring.md`.
221
-
222
- ## Real-time execution
223
-
224
- `simpy.rt.RealtimeEnvironment(initial_time=0, factor=1.0, strict=True)` maps one
225
- simulation unit to `factor` wall-clock seconds. In strict mode, `step()`/`run()`
226
- raises `RuntimeError` when computation falls behind. `strict=False` tolerates lag;
227
- it does not restore timing accuracy. Develop logic with `Environment`, then run
228
- separate timing tests with generous platform-aware tolerances. See
229
- `references/real-time.md`.
230
-
231
- ## Bundled safe CLIs
232
-
233
- All CLIs use a fixed built-in queue model or summarize local artifacts. They reject
234
- unknown JSON keys, URLs, symlinks, non-finite numbers, oversized inputs, and
235
- unbounded time/events/entities/replications. They never evaluate config text,
236
- execute user Python, import plugins, or call a network service.
237
-
238
- ```bash
239
- # Inspect all options.
240
- python skills/simpy/scripts/bounded_queue_scenario.py --help
241
- python skills/simpy/scripts/replication_runner.py --help
242
- python skills/simpy/scripts/event_trace_summary.py --help
243
- python skills/simpy/scripts/validate_simulation_config.py --help
244
-
245
- # Deterministic built-in scenario.
246
- python skills/simpy/scripts/bounded_queue_scenario.py
247
-
248
- # Independent replications with replication-level Student-t intervals.
249
- python skills/simpy/scripts/replication_runner.py
250
-
251
- # Validate only; no simulation runs.
252
- python skills/simpy/scripts/validate_simulation_config.py config.json
253
- ```
254
-
255
- The replication runner refuses one-replication intervals. Its intervals quantify
256
- Monte Carlo uncertainty under the configured model; they neither validate the model
257
- nor identify causal effects. See `references/cli-guide.md`.
258
-
259
- ## Testing
260
-
261
- Use deterministic unit tests for ordering, boundary times, conditions, interrupts,
262
- all resource disciplines, conservation, event/entity limits, seed reproducibility,
263
- and monitor non-interference. Add stochastic tests only as broad distributional
264
- checks with fixed seeds; avoid brittle exact sample estimates.
265
-
266
- Run the skill's suite in the exact pinned environment without bytecode artifacts:
267
-
268
- ```bash
269
- PYTHONDONTWRITEBYTECODE=1 uv run --isolated --no-project \
270
- --python 3.13 --with "simpy==4.1.2" \
271
- python -m unittest discover -s tests/simpy -v
272
- ```
273
-
274
- ## References
275
-
276
- - `references/events.md` — scheduler, lifecycle, run boundaries, conditions
277
- - `references/process-interaction.md` — generators, shared events, interrupts
278
- - `references/resources.md` — all Resource, Container, and Store variants
279
- - `references/monitoring.md` — time weighting, queue timing, tracing, stepping
280
- - `references/real-time.md` — factor, strict mode, drift, timing tests
281
- - `references/simulation-methodology.md` — replications, warm-up, validation, CI
282
- - `references/cli-guide.md` — schemas, bounds, outputs, and safe CLI examples
283
- - `references/sources.md` — dated official and primary-method sources
@@ -1,325 +0,0 @@
1
- ---
2
- name: stable-baselines3
3
- description: Production-ready reinforcement learning algorithms (PPO, SAC, DQN, TD3, DDPG, A2C) with scikit-learn-like API. Use for standard RL experiments, quick prototyping, and well-documented algorithm implementations. Best for single-agent RL with Gymnasium environments. For high-performance parallel training, multi-agent systems, or custom vectorized environments, use pufferlib instead.
4
- license: MIT license
5
- allowed-tools: Read Write Edit Bash
6
- compatibility: Requires Python 3.10+, PyTorch >= 2.3, and stable-baselines3 2.8+. Gymnasium environments; optional extras for TensorBoard and Atari (ale-py).
7
- metadata:
8
- version: "1.2"
9
- skill-author: K-Dense Inc.
10
- ---
11
-
12
- # Stable Baselines3
13
-
14
- ## Overview
15
-
16
- Stable Baselines3 (SB3) is a PyTorch-based library providing reliable implementations of reinforcement learning algorithms. This skill provides comprehensive guidance for training RL agents, creating custom environments, implementing callbacks, and optimizing training workflows using SB3's unified API.
17
-
18
- **Current upstream:** SB3 **2.8.0** (April 2026). Docs: [stable-baselines3.readthedocs.io](https://stable-baselines3.readthedocs.io/en/master/).
19
-
20
- ## Installation
21
-
22
- Tested against **stable-baselines3 2.8.0**. Requires **Python 3.10+** (3.9 dropped in 2.8.0) and **PyTorch >= 2.3**.
23
-
24
- ```bash
25
- # Basic installation
26
- uv pip install "stable-baselines3>=2.8"
27
-
28
- # With extra dependencies (TensorBoard, ale-py for Atari, etc.)
29
- uv pip install "stable-baselines3[extra]>=2.8"
30
- ```
31
-
32
- On zsh, quote brackets: `uv pip install 'stable-baselines3[extra]>=2.8'`.
33
-
34
- For MuJoCo continuous-control benchmarks:
35
-
36
- ```bash
37
- uv pip install "gymnasium[mujoco]"
38
- ```
39
-
40
- Check your version:
41
-
42
- ```python
43
- import stable_baselines3
44
- print(stable_baselines3.__version__)
45
- ```
46
-
47
- ## Related Projects
48
-
49
- - **[SB3-Contrib](https://github.com/Stable-Baselines-Team/stable-baselines3-contrib)**: experimental algorithms (MaskablePPO, CrossQ, QR-DQN, RecurrentPPO) — separate `sb3-contrib` package
50
- - **[RL Baselines3 Zoo](https://github.com/DLR-RM/rl-baselines3-zoo)**: pre-trained agents, hyperparameters, training scripts
51
- - **[SBX](https://github.com/araffin/sbx)**: SB3 + JAX implementations for users who prefer JAX over PyTorch
52
-
53
- ## Core Capabilities
54
-
55
- ### 1. Training RL Agents
56
-
57
- **Basic Training Pattern:**
58
-
59
- ```python
60
- import gymnasium as gym
61
- from stable_baselines3 import PPO
62
-
63
- # Create environment
64
- env = gym.make("CartPole-v1")
65
-
66
- # Initialize agent (device="cpu" is often faster for MlpPolicy on small envs)
67
- model = PPO("MlpPolicy", env, verbose=1)
68
-
69
- # Train the agent
70
- model.learn(total_timesteps=10000)
71
-
72
- # Save the model
73
- model.save("ppo_cartpole")
74
-
75
- # Load the model (without prior instantiation)
76
- model = PPO.load("ppo_cartpole", env=env)
77
- ```
78
-
79
- **Important Notes:**
80
- - `total_timesteps` is a lower bound; actual training may exceed this due to batch collection
81
- - Use `model.load()` as a static method, not on an existing instance
82
- - The replay buffer is NOT saved with the model to save space
83
-
84
- **Algorithm Selection:**
85
- Use `references/algorithms.md` for detailed algorithm characteristics and selection guidance. Quick reference:
86
- - **PPO/A2C**: General-purpose, supports all action space types, good for multiprocessing
87
- - **SAC/TD3**: Continuous control, off-policy, sample-efficient
88
- - **DQN**: Discrete actions, off-policy
89
- - **HER**: Goal-conditioned tasks
90
-
91
- See `scripts/train_rl_agent.py` for a complete training template with best practices.
92
-
93
- ### 2. Custom Environments
94
-
95
- **Requirements:**
96
- Custom environments must inherit from `gymnasium.Env` and implement:
97
- - `__init__()`: Define action_space and observation_space
98
- - `reset(seed, options)`: Return initial observation and info dict
99
- - `step(action)`: Return observation, reward, terminated, truncated, info
100
- - `render()`: Visualization (optional)
101
- - `close()`: Cleanup resources
102
-
103
- **Key Constraints:**
104
- - Image observations must be `np.uint8` in range [0, 255]
105
- - Use channel-first format when possible (channels, height, width)
106
- - SB3 normalizes images automatically by dividing by 255
107
- - Set `normalize_images=False` in policy_kwargs if pre-normalized
108
- - SB3 does NOT support `Discrete` or `MultiDiscrete` spaces with `start!=0`
109
-
110
- **Validation:**
111
- ```python
112
- from stable_baselines3.common.env_checker import check_env
113
-
114
- check_env(env, warn=True)
115
- ```
116
-
117
- See `scripts/custom_env_template.py` for a complete custom environment template and `references/custom_environments.md` for comprehensive guidance.
118
-
119
- ### 3. Vectorized Environments
120
-
121
- **Purpose:**
122
- Vectorized environments run multiple environment instances in parallel, accelerating training and enabling certain wrappers (frame-stacking, normalization).
123
-
124
- **Types:**
125
- - **DummyVecEnv**: Sequential execution on current process (for lightweight environments)
126
- - **SubprocVecEnv**: Parallel execution across processes (for compute-heavy environments)
127
-
128
- **Quick Setup:**
129
- ```python
130
- from stable_baselines3.common.env_util import make_vec_env
131
-
132
- # Create 4 parallel environments
133
- env = make_vec_env("CartPole-v1", n_envs=4, vec_env_cls=SubprocVecEnv)
134
-
135
- model = PPO("MlpPolicy", env, verbose=1)
136
- model.learn(total_timesteps=25000)
137
- ```
138
-
139
- **Off-Policy Optimization:**
140
- When using multiple environments with off-policy algorithms (SAC, TD3, DQN), set `gradient_steps=-1` to perform one gradient update per environment step, balancing wall-clock time and sample efficiency.
141
-
142
- **API Differences:**
143
- - `reset()` returns only observations (info available in `vec_env.reset_infos`)
144
- - `step()` returns 4-tuple: `(obs, rewards, dones, infos)` not 5-tuple
145
- - Environments auto-reset after episodes
146
- - Terminal observations available via `infos[env_idx]["terminal_observation"]`
147
-
148
- See `references/vectorized_envs.md` for detailed information on wrappers and advanced usage.
149
-
150
- ### 4. Callbacks for Monitoring and Control
151
-
152
- **Purpose:**
153
- Callbacks enable monitoring metrics, saving checkpoints, implementing early stopping, and custom training logic without modifying core algorithms.
154
-
155
- **Common Callbacks:**
156
- - **EvalCallback**: Evaluate periodically and save best model
157
- - **CheckpointCallback**: Save model checkpoints at intervals
158
- - **StopTrainingOnRewardThreshold**: Stop when target reward reached
159
- - **ProgressBarCallback**: Display training progress with timing
160
-
161
- **Custom Callback Structure:**
162
- ```python
163
- from stable_baselines3.common.callbacks import BaseCallback
164
-
165
- class CustomCallback(BaseCallback):
166
- def _on_training_start(self):
167
- # Called before first rollout
168
- pass
169
-
170
- def _on_step(self):
171
- # Called after each environment step
172
- # Return False to stop training
173
- return True
174
-
175
- def _on_rollout_end(self):
176
- # Called at end of rollout
177
- pass
178
- ```
179
-
180
- **Available Attributes:**
181
- - `self.model`: The RL algorithm instance
182
- - `self.num_timesteps`: Total environment steps
183
- - `self.training_env`: The training environment
184
-
185
- **Chaining Callbacks:**
186
- ```python
187
- from stable_baselines3.common.callbacks import CallbackList
188
-
189
- callback = CallbackList([eval_callback, checkpoint_callback, custom_callback])
190
- model.learn(total_timesteps=10000, callback=callback)
191
- ```
192
-
193
- See `references/callbacks.md` for comprehensive callback documentation.
194
-
195
- ### 5. Model Persistence and Inspection
196
-
197
- **Saving and Loading:**
198
- ```python
199
- # Save model
200
- model.save("model_name")
201
-
202
- # Save normalization statistics (if using VecNormalize)
203
- vec_env.save("vec_normalize.pkl")
204
-
205
- # Load model
206
- model = PPO.load("model_name", env=env)
207
-
208
- # Load normalization statistics
209
- vec_env = VecNormalize.load("vec_normalize.pkl", vec_env)
210
- ```
211
-
212
- **Parameter Access:**
213
- ```python
214
- # Get parameters
215
- params = model.get_parameters()
216
-
217
- # Set parameters
218
- model.set_parameters(params)
219
-
220
- # Access PyTorch state dict
221
- state_dict = model.policy.state_dict()
222
- ```
223
-
224
- ### 6. Evaluation and Recording
225
-
226
- **Evaluation:**
227
- ```python
228
- from stable_baselines3.common.evaluation import evaluate_policy
229
-
230
- mean_reward, std_reward = evaluate_policy(
231
- model,
232
- env,
233
- n_eval_episodes=10,
234
- deterministic=True
235
- )
236
- ```
237
-
238
- **Video Recording:**
239
- ```python
240
- from stable_baselines3.common.vec_env import VecVideoRecorder
241
-
242
- # Wrap environment with video recorder
243
- env = VecVideoRecorder(
244
- env,
245
- "videos/",
246
- record_video_trigger=lambda x: x % 2000 == 0,
247
- video_length=200
248
- )
249
- ```
250
-
251
- See `scripts/evaluate_agent.py` for a complete evaluation and recording template.
252
-
253
- ### 7. Advanced Features
254
-
255
- **Learning Rate Schedules:**
256
- ```python
257
- def linear_schedule(initial_value):
258
- def func(progress_remaining):
259
- # progress_remaining goes from 1 to 0
260
- return progress_remaining * initial_value
261
- return func
262
-
263
- model = PPO("MlpPolicy", env, learning_rate=linear_schedule(0.001))
264
- ```
265
-
266
- **Multi-Input Policies (Dict Observations):**
267
- ```python
268
- model = PPO("MultiInputPolicy", env, verbose=1)
269
- ```
270
- Use when observations are dictionaries (e.g., combining images with sensor data).
271
-
272
- **Hindsight Experience Replay:**
273
- ```python
274
- from stable_baselines3 import SAC, HerReplayBuffer
275
-
276
- model = SAC(
277
- "MultiInputPolicy",
278
- env,
279
- replay_buffer_class=HerReplayBuffer,
280
- replay_buffer_kwargs=dict(
281
- n_sampled_goal=4,
282
- goal_selection_strategy="future",
283
- ),
284
- )
285
- ```
286
-
287
- **TensorBoard Integration:**
288
- ```python
289
- model = PPO("MlpPolicy", env, tensorboard_log="./tensorboard/")
290
- model.learn(total_timesteps=10000)
291
- ```
292
-
293
- ## Workflow Guidance
294
-
295
- **Starting a New RL Project:**
296
-
297
- 1. **Define the problem**: Identify observation space, action space, and reward structure
298
- 2. **Choose algorithm**: Use `references/algorithms.md` for selection guidance
299
- 3. **Create/adapt environment**: Use `scripts/custom_env_template.py` if needed
300
- 4. **Validate environment**: Always run `check_env()` before training
301
- 5. **Set up training**: Use `scripts/train_rl_agent.py` as starting template
302
- 6. **Add monitoring**: Implement callbacks for evaluation and checkpointing
303
- 7. **Optimize performance**: Consider vectorized environments for speed
304
- 8. **Evaluate and iterate**: Use `scripts/evaluate_agent.py` for assessment
305
-
306
- **Common Issues:**
307
-
308
- - **Memory errors**: Reduce `buffer_size` for off-policy algorithms or use fewer parallel environments
309
- - **Slow training**: Consider SubprocVecEnv for parallel environments
310
- - **Unstable training**: Try different algorithms, tune hyperparameters, or check reward scaling
311
- - **Import errors**: Ensure `stable_baselines3` is installed: `uv pip install 'stable-baselines3[extra]>=2.8'`
312
-
313
- ## Resources
314
-
315
- ### scripts/
316
- - `train_rl_agent.py`: Complete training script template with best practices
317
- - `evaluate_agent.py`: Agent evaluation and video recording template
318
- - `custom_env_template.py`: Custom Gym environment template
319
-
320
- ### references/
321
- - `algorithms.md`: Detailed algorithm comparison and selection guide
322
- - `custom_environments.md`: Comprehensive custom environment creation guide
323
- - `callbacks.md`: Complete callback system reference
324
- - `vectorized_envs.md`: Vectorized environment usage and wrappers
325
-