@ohtaman/washi 0.7.0 → 0.8.1

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 (162) hide show
  1. package/README.ja.md +60 -23
  2. package/README.md +59 -22
  3. package/README.zh-CN.md +62 -25
  4. package/THIRD_PARTY_LICENSES.md +34 -1
  5. package/dist/browser/solvers/glpk.js +289 -238
  6. package/dist/browser/solvers/glpk.min.js +1 -1
  7. package/dist/browser/solvers/highs-__vite-browser-external-Dn-83hnF.js +7 -0
  8. package/dist/browser/solvers/highs-browser-runtime-0Bgq5ksG.js +2021 -0
  9. package/dist/browser/{loader-DewlSho8.js → solvers/highs-loader-BLY3wzDH.js} +190 -149
  10. package/dist/browser/solvers/highs-worker.js +54 -0
  11. package/dist/browser/solvers/highs.js +1414 -0
  12. package/dist/browser/solvers/highs.wasm +0 -0
  13. package/dist/browser/solvers/pumpkin-_washi-pumpkin-node-runtime-CEKUDK6d.js +9 -0
  14. package/dist/browser/solvers/pumpkin-loader-CvdaKxf4.js +320 -0
  15. package/dist/browser/solvers/pumpkin-worker.js +45 -0
  16. package/dist/browser/solvers/pumpkin.js +1777 -0
  17. package/dist/browser/solvers/pumpkin.wasm +0 -0
  18. package/dist/browser/solvers/pumpkin.wasm.LICENSE +21 -0
  19. package/dist/browser/solvers/z3.js +1600 -1335
  20. package/dist/browser/solvers/z3.min.js +2 -2
  21. package/dist/browser/washi.js +3313 -1699
  22. package/dist/browser/washi.min.js +5 -3
  23. package/dist/lib/solvers/__vite-browser-external-oLchLuMx.js +7 -0
  24. package/dist/lib/solvers/glpk.js +174 -132
  25. package/dist/lib/solvers/highs-browser-runtime.js +2413 -0
  26. package/dist/lib/{highs-node-runtime.js → solvers/highs-node-runtime.js} +1 -1
  27. package/dist/lib/solvers/highs-runtime.js +16 -0
  28. package/dist/lib/solvers/highs-worker.js +54 -0
  29. package/dist/lib/solvers/highs.js +410 -0
  30. package/dist/lib/solvers/highs.wasm +0 -0
  31. package/dist/lib/{loader-BZUQNvh4.js → solvers/loader-CDpPXN_F.js} +138 -116
  32. package/dist/lib/solvers/loader-Ow74Fa1B.js +311 -0
  33. package/dist/lib/solvers/lp-writer-CLScMFbS.js +115 -0
  34. package/dist/lib/solvers/pumpkin-assets.js +1 -0
  35. package/dist/lib/solvers/pumpkin-node-runtime.js +15 -0
  36. package/dist/lib/solvers/pumpkin-worker-factory.js +1 -0
  37. package/dist/lib/solvers/pumpkin-worker.js +45 -0
  38. package/dist/lib/solvers/pumpkin.js +868 -0
  39. package/dist/lib/solvers/pumpkin.wasm +0 -0
  40. package/dist/lib/solvers/pumpkin.wasm.LICENSE +21 -0
  41. package/dist/lib/solvers/registry-CrYRRk9q.js +907 -0
  42. package/dist/lib/solvers/rolldown-runtime-DtPi1Y-2.js +13 -0
  43. package/dist/lib/solvers/types-BGqPkxwu.js +12 -0
  44. package/dist/lib/solvers/z3.js +489 -307
  45. package/dist/lib/washi.js +3905 -1410
  46. package/dist/types/decomposition/benders.d.ts.map +1 -1
  47. package/dist/types/index.d.ts +4 -5
  48. package/dist/types/index.d.ts.map +1 -1
  49. package/dist/types/modeler/boolean-expr.d.ts +137 -29
  50. package/dist/types/modeler/boolean-expr.d.ts.map +1 -1
  51. package/dist/types/modeler/constraint.d.ts +40 -4
  52. package/dist/types/modeler/constraint.d.ts.map +1 -1
  53. package/dist/types/modeler/expression.d.ts +129 -2
  54. package/dist/types/modeler/expression.d.ts.map +1 -1
  55. package/dist/types/modeler/index.d.ts +4 -6
  56. package/dist/types/modeler/index.d.ts.map +1 -1
  57. package/dist/types/modeler/linearizer.d.ts +11 -2
  58. package/dist/types/modeler/linearizer.d.ts.map +1 -1
  59. package/dist/types/modeler/lp-writer.d.ts.map +1 -1
  60. package/dist/types/modeler/model.d.ts +86 -126
  61. package/dist/types/modeler/model.d.ts.map +1 -1
  62. package/dist/types/modeler/parser.d.ts.map +1 -1
  63. package/dist/types/modeler/quad-expr.d.ts +8 -2
  64. package/dist/types/modeler/quad-expr.d.ts.map +1 -1
  65. package/dist/types/modeler/solution-validator.d.ts +12 -12
  66. package/dist/types/modeler/solution-validator.d.ts.map +1 -1
  67. package/dist/types/modeler/solvers/glpk/loader.d.ts +4 -0
  68. package/dist/types/modeler/solvers/glpk/loader.d.ts.map +1 -1
  69. package/dist/types/modeler/solvers/glpk/solver.d.ts +2 -2
  70. package/dist/types/modeler/solvers/glpk/solver.d.ts.map +1 -1
  71. package/dist/types/modeler/solvers/highs/driver.d.ts.map +1 -1
  72. package/dist/types/modeler/solvers/highs/loader.d.ts +8 -6
  73. package/dist/types/modeler/solvers/highs/loader.d.ts.map +1 -1
  74. package/dist/types/modeler/solvers/highs/solver.d.ts.map +1 -1
  75. package/dist/types/modeler/solvers/highs/worker-client.d.ts +16 -0
  76. package/dist/types/modeler/solvers/highs/worker-client.d.ts.map +1 -1
  77. package/dist/types/modeler/solvers/index.d.ts +2 -1
  78. package/dist/types/modeler/solvers/index.d.ts.map +1 -1
  79. package/dist/types/modeler/solvers/mock.d.ts +2 -3
  80. package/dist/types/modeler/solvers/mock.d.ts.map +1 -1
  81. package/dist/types/modeler/solvers/pumpkin/assets.d.ts +2 -0
  82. package/dist/types/modeler/solvers/pumpkin/assets.d.ts.map +1 -0
  83. package/dist/types/modeler/solvers/pumpkin/index.d.ts +6 -0
  84. package/dist/types/modeler/solvers/pumpkin/index.d.ts.map +1 -0
  85. package/dist/types/modeler/solvers/pumpkin/loader.d.ts +40 -0
  86. package/dist/types/modeler/solvers/pumpkin/loader.d.ts.map +1 -0
  87. package/dist/types/modeler/solvers/pumpkin/node-runtime.d.ts +3 -0
  88. package/dist/types/modeler/solvers/pumpkin/node-runtime.d.ts.map +1 -0
  89. package/dist/types/modeler/solvers/pumpkin/solver.d.ts +23 -0
  90. package/dist/types/modeler/solvers/pumpkin/solver.d.ts.map +1 -0
  91. package/dist/types/modeler/solvers/pumpkin/worker-client.d.ts +74 -0
  92. package/dist/types/modeler/solvers/pumpkin/worker-client.d.ts.map +1 -0
  93. package/dist/types/modeler/solvers/pumpkin/worker-factory.d.ts +3 -0
  94. package/dist/types/modeler/solvers/pumpkin/worker-factory.d.ts.map +1 -0
  95. package/dist/types/modeler/solvers/pumpkin/worker.d.ts +7 -0
  96. package/dist/types/modeler/solvers/pumpkin/worker.d.ts.map +1 -0
  97. package/dist/types/modeler/solvers/pumpkin.d.ts +2 -0
  98. package/dist/types/modeler/solvers/pumpkin.d.ts.map +1 -0
  99. package/dist/types/modeler/solvers/types.d.ts +7 -9
  100. package/dist/types/modeler/solvers/types.d.ts.map +1 -1
  101. package/dist/types/modeler/solvers/z3/loader.d.ts +4 -0
  102. package/dist/types/modeler/solvers/z3/loader.d.ts.map +1 -1
  103. package/dist/types/modeler/solvers/z3/solver.d.ts +2 -15
  104. package/dist/types/modeler/solvers/z3/solver.d.ts.map +1 -1
  105. package/dist/types/modeler/types.d.ts +12 -15
  106. package/dist/types/modeler/types.d.ts.map +1 -1
  107. package/dist/types/modeler/validation.d.ts +26 -2
  108. package/dist/types/modeler/validation.d.ts.map +1 -1
  109. package/dist/types/modeler/variable.d.ts +9 -5
  110. package/dist/types/modeler/variable.d.ts.map +1 -1
  111. package/docs/examples/diet-sensitivity.md +33 -14
  112. package/docs/examples/ecommerce-coupons.md +17 -9
  113. package/docs/examples/index.md +36 -27
  114. package/docs/examples/knapsack.md +11 -5
  115. package/docs/examples/portfolio-qp.md +21 -8
  116. package/docs/examples/production.md +10 -5
  117. package/docs/examples/project-scheduling.md +119 -0
  118. package/docs/examples/shift-scheduling.md +29 -18
  119. package/docs/examples/smt-security.md +27 -11
  120. package/docs/examples/transportation.md +23 -13
  121. package/docs/examples/traveling-salesperson.md +34 -22
  122. package/docs/examples/unsat-core.md +27 -14
  123. package/docs/examples/vehicle-routing.md +74 -28
  124. package/docs/getting-started/ai-agents.md +190 -82
  125. package/docs/getting-started/coding-agents.md +177 -0
  126. package/docs/getting-started/cross-origin.md +27 -14
  127. package/docs/getting-started/index.md +49 -43
  128. package/docs/getting-started/runtimes.md +94 -40
  129. package/docs/guide/constraint-programming.md +171 -0
  130. package/docs/guide/constraints.md +115 -33
  131. package/docs/guide/decomposition.md +118 -88
  132. package/docs/guide/expressions.md +106 -43
  133. package/docs/guide/formulation-tips.md +47 -28
  134. package/docs/guide/objectives.md +102 -75
  135. package/docs/guide/unsat-core.md +62 -50
  136. package/docs/guide/variables.md +81 -35
  137. package/docs/solvers/custom-solver.md +163 -122
  138. package/docs/solvers/glpk.md +58 -17
  139. package/docs/solvers/highs.md +124 -57
  140. package/docs/solvers/index.md +33 -20
  141. package/docs/solvers/pumpkin.md +171 -0
  142. package/docs/solvers/z3.md +63 -25
  143. package/llms-full.txt +2232 -932
  144. package/llms.txt +144 -91
  145. package/package.json +55 -19
  146. package/skills/washi/SKILL.md +107 -34
  147. package/dist/browser/_washi-node-only-BvRk9kiK.js +0 -0
  148. package/dist/browser/browser-runtime-TLCY0hkc.js +0 -1793
  149. package/dist/browser/highs-worker.js +0 -39
  150. package/dist/browser/highs.wasm +0 -0
  151. package/dist/lib/_washi-node-only-BvRk9kiK.js +0 -0
  152. package/dist/lib/highs-browser-runtime.js +0 -2185
  153. package/dist/lib/highs-runtime.js +0 -2
  154. package/dist/lib/highs-worker.js +0 -39
  155. package/dist/lib/highs.wasm +0 -0
  156. package/dist/lib/registry-D7TZ3Wh_.js +0 -1034
  157. package/docs/ja/getting-started/ai-agents.md +0 -280
  158. package/docs/zh/getting-started/ai-agents.md +0 -280
  159. /package/dist/browser/{highs.wasm.LICENSE → solvers/highs.wasm.LICENSE} +0 -0
  160. /package/dist/lib/{highs-assets.js → solvers/highs-assets.js} +0 -0
  161. /package/dist/lib/{highs-worker-factory.js → solvers/highs-worker-factory.js} +0 -0
  162. /package/dist/lib/{highs.wasm.LICENSE → solvers/highs.wasm.LICENSE} +0 -0
package/llms.txt CHANGED
@@ -1,8 +1,8 @@
1
1
  # WaSHI (@ohtaman/washi)
2
2
 
3
- > WaSHI: WebAssembly-backed Algebraic Modeler for Mathematical Optimization & Constraint Programming (LP, MIP, QP, SMT)
3
+ > WaSHI: TypeScript & JavaScript algebraic modeler for Mathematical Optimization & Constraint Programming (LP, MILP, QP, CP, SMT) powered by WebAssembly (HiGHS, Pumpkin, Z3, GLPK)
4
4
 
5
- **WaSHI** (WebAssembly-backed, Solver-independent, High-level modeling Interface) brings the algebraic modeling style of Python's **PuLP** to the TypeScript and JavaScript ecosystem.
5
+ **WaSHI** (WebAssembly-backed, Solver-independent, High-level modeling Interface) brings Python PuLP-style algebraic modeling to TypeScript and JavaScript.
6
6
 
7
7
  - Full single-file documentation reference: [llms-full.txt](llms-full.txt)
8
8
  - Canonical AI agent modeling quick-reference: [docs/getting-started/ai-agents.md](docs/getting-started/ai-agents.md)
@@ -11,7 +11,7 @@
11
11
 
12
12
  ## 1. Package Imports & Deployment
13
13
 
14
- ### Node.js / Bundlers (Vite, Webpack, Next.js, Bun)
14
+ ### Node.js, Bun, & Bundlers (Vite, Webpack, Next.js)
15
15
 
16
16
  ```ts
17
17
  import {
@@ -19,6 +19,14 @@ import {
19
19
  expr,
20
20
  sum,
21
21
  dot,
22
+ abs,
23
+ max,
24
+ min,
25
+ at,
26
+ distinct,
27
+ disjoint,
28
+ cumulative,
29
+ allowed,
22
30
  maximize,
23
31
  minimize,
24
32
  and,
@@ -26,9 +34,13 @@ import {
26
34
  not,
27
35
  implies,
28
36
  xor,
29
- setHighsWasmUrl,
30
37
  } from "@ohtaman/washi";
31
38
 
39
+ // Bundled solvers: HiGHS (default) and Pumpkin (`{ solver: "pumpkin" }`) work out of the box with zero extra imports.
40
+ // Import solver subpaths only when configuring engine-specific classes or custom WASM URLs:
41
+ // import { HighsSolver, setHighsWasmUrl } from "@ohtaman/washi/solvers/highs";
42
+ // import { PumpkinSolver, setPumpkinWasmUrl } from "@ohtaman/washi/solvers/pumpkin";
43
+
32
44
  // Optional solver plugins (require installing peer dependencies first):
33
45
  // npm install z3-solver
34
46
  import "@ohtaman/washi/solvers/z3";
@@ -38,31 +50,47 @@ import "@ohtaman/washi/solvers/glpk";
38
50
 
39
51
  ### Browser ESM & Classic Script Tags
40
52
 
41
- - **Browser ESM**:
42
- - Core (HiGHS built-in): `import { Model, expr, maximize } from "./washi/washi.js";`
43
- - GLPK plugin: `import "./washi/solvers/glpk.js";`
44
- - Z3 plugin: `import "./washi/solvers/z3.js";`
45
- - **Classic `<script>` / CodePen (IIFE)**:
46
- - Core: `<script src="./washi/washi.min.js"></script>` (exposes global `Washi`)
47
- - GLPK plugin: `<script src="./washi/solvers/glpk.min.js"></script>` (registers `"glpk"`, exposes `WashiGLPK`)
48
- - Z3 plugin: `<script src="./washi/solvers/z3.min.js"></script>` (registers `"z3"`, exposes `WashiZ3`)
53
+ Classic `<script>` tags load immediately invoked function expression (`IIFE`) bundles that attach a global namespace to `window` (optional solver plugins auto-register when `window.Washi` is present). Assuming `dist/browser/` is hosted at `./washi/`:
54
+
55
+ | Solver | Browser ESM (`<script type="module">`) | Classic `<script>` IIFE |
56
+ | --- | --- | --- |
57
+ | **Core (HiGHS & Pumpkin)** | `import { Model, expr, maximize } from "./washi/washi.js";` | `<script src="./washi/washi.min.js"></script>` (global `Washi`) |
58
+ | **HiGHS** *(subpath API)* | `import { HighsSolver, setHighsWasmUrl } from "./washi/solvers/highs.js";` | Bundled in `washi.min.js` (pass `{ wasmUrl }` per call) |
59
+ | **Pumpkin** *(subpath API)* | `import { PumpkinSolver, setPumpkinWasmUrl } from "./washi/solvers/pumpkin.js";` | Bundled in `washi.min.js` (pass `{ wasmUrl }` per call) |
60
+ | **GLPK** *(optional)* | `import "./washi/solvers/glpk.js";` | `<script src="./washi/solvers/glpk.min.js"></script>` (`WashiGLPK`) |
61
+ | **Z3** *(optional)* | `import "./washi/solvers/z3.js";` | `<script src="./washi/solvers/z3.min.js"></script>` (`WashiZ3`) |
49
62
 
50
63
  ### WebAssembly Asset & Runtime Rules
51
64
 
52
- 1. **Bundled WASM by default (no implicit CDN fallback)**:
53
- - In Node.js and modern bundlers, WebAssembly assets resolve relative to the module automatically.
54
- - In browser deployments, deploy the full `dist/browser/` directory (JS, Worker, and `.wasm` files) together. If a local WASM URL is missing or returns an HTML SPA fallback, initialization fails immediately and reports the attempted URL—it **never** silently switches to a public CDN.
55
- - In browser runtimes, to load `highs.wasm` from a custom location, call `setHighsWasmUrl("https://.../highs.wasm")` or pass `await m.solve({ wasmUrl: "https://.../highs.wasm" })` (ignored in Node.js, which always loads WaSHI's bundled local `highs.wasm` runtime).
56
- 2. **Z3 requires a Secure Context, Cross-Origin Isolation, and CORS in browsers**:
57
- - Z3 WebAssembly uses `SharedArrayBuffer` multithreading. Browser pages running Z3 must run in a secure context (`window.isSecureContext === true`, i.e., HTTPS or `localhost`) and be cross-origin isolated (`window.crossOriginIsolated === true`) by serving:
58
- - `Cross-Origin-Opener-Policy: same-origin` (on the document)
59
- - `Cross-Origin-Embedder-Policy: require-corp` (on the document)
60
- - `Cross-Origin-Resource-Policy: cross-origin` and `Access-Control-Allow-Origin` (on cross-origin script/WASM asset responses)
61
- - Importing `@ohtaman/washi` never auto-injects a Service Worker. When a secure context or cross-origin isolation is absent in a browser, Z3 rejects immediately with a descriptive error.
62
- 3. **Web Workers & Cancellation (`AbortSignal`)**:
63
- - Pre-solve cancellation (`signal.aborted` before execution starts) is supported across all solvers.
64
- - In browsers where `Worker` is available on a non-opaque effective origin (`window.origin !== "null"`), HiGHS runs in a dedicated Web Worker by default (`useWorker: true`). On opaque effective origins (`window.origin === "null"`, such as `file:` URLs or `sandbox="allow-scripts"` `<iframe>` embeds without `allow-same-origin`), HiGHS defaults to main-thread execution (`useWorker: false`). Passing `{ signal }` to `m.solve({ signal })` preemptively terminates an in-flight Worker solve (or cancels queued Worker requests).
65
- - On main-thread HiGHS (`useWorker: false` or in Node.js), cooperative mid-solve cancellation is supported when `abort()` is triggered synchronously inside an `onProgress` callback at a solver interrupt checkpoint; arbitrary asynchronous aborts from outside cannot preempt a blocked synchronous WASM thread until a callback checkpoint or completion. Single-threaded WASM solvers without interrupt hooks (GLPK, Z3) check `signal` before execution starts.
65
+ #### Bundled WASM & Custom Asset URLs
66
+
67
+ - **Automatic resolution**: In Node.js and bundler builds, WaSHI resolves `.wasm` assets under `solvers/` relative to the module with no CDN fallback.
68
+ - **Browser self-hosting**: Deploy `dist/browser/` intact (entry scripts, `solvers/` runtime/worker/WASM assets, and chunks). Requests that hit missing URLs or HTML SPA fallbacks fail immediately and report the attempted URL.
69
+ - **Custom browser URLs**: Call `setHighsWasmUrl(url)` (from `@ohtaman/washi/solvers/highs`) or `setPumpkinWasmUrl(url)` (from `@ohtaman/washi/solvers/pumpkin`), or pass `{ wasmUrl }` to `m.solve()` / `m.check()`. This override is ignored for HiGHS in Node.js, while Pumpkin accepts `file://` URLs in Node.js. For Z3, call `setZ3Assets({ jsUrl, wasmUrl })` (from `@ohtaman/washi/solvers/z3`) or pass `{ z3JsUrl, z3WasmUrl }`.
70
+
71
+ #### Browser Security & Cross-Origin Isolation
72
+
73
+ - **HiGHS, Pumpkin, and GLPK**: Run in standard browser contexts without `SharedArrayBuffer` or isolation headers.
74
+ - **Z3 browser preconditions**: Z3 uses `SharedArrayBuffer` multithreading, so browsers require a Secure Context (`window.isSecureContext === true`, HTTPS or `localhost`) and `window.crossOriginIsolated === true`.
75
+ - **Required Z3 headers**: Serve the document with `Cross-Origin-Opener-Policy: same-origin` and `Cross-Origin-Embedder-Policy: require-corp` (`COOP`/`COEP`). Cross-origin script and WASM assets also require `Cross-Origin-Resource-Policy: cross-origin` (`CORP`) or valid CORS headers (`Access-Control-Allow-Origin`), depending on the request mode.
76
+ - **Fail-fast check & no auto-injected Service Worker**: Importing `@ohtaman/washi` never injects a Service Worker. `m.solve()` and `m.check()` with Z3 reject immediately if a secure context or Cross-Origin Isolation is missing.
77
+
78
+ #### Web Workers & Cancellation (`AbortSignal`)
79
+
80
+ - **Default Workers**: On standard browser origins (`window.origin !== "null"`), HiGHS and Pumpkin default to Web Workers (`useWorker: true`). On opaque origins (`window.origin === "null"`, such as `file://` pages or sandboxed iframes without `allow-same-origin`), both default to `useWorker: false`.
81
+ - **Worker cancellation**: Pre-solve cancellation (`signal.aborted`) works on all solvers, and `{ signal }` terminates in-flight HiGHS and Pumpkin Workers immediately.
82
+ - **Main-thread & Node.js cancellation**: HiGHS checks `signal` during `onProgress` callbacks, Pumpkin polls `signal` at search checkpoints, and GLPK/Z3 only check `signal` before starting.
83
+
84
+ #### Solver Capabilities, Options, & Validation Errors
85
+
86
+ | Solver | Problem Classes | Accepted Options | Throws On |
87
+ | --- | --- | --- | --- |
88
+ | **HiGHS** *(default)* | Linear (`LP`), mixed-integer (`MIP`), and convex quadratic (`QP`) | `timeLimit`, `presolve`, `relativeGap`, `absoluteGap`, `outputFlag`, `relax`, `useWorker`, `wasmUrl`, `signal`, `onProgress` | `threads`, `verbose` (use `outputFlag`), unknown keys, MIQP (quadratic objective with integer/binary/boolean variables) |
89
+ | **Pumpkin** | Constraint Programming (`CP`), bounded discrete `unsatCore` | `timeLimit`, `useWorker`, `wasmUrl`, `signal`, `onProgress` | `relax: true`, `presolve`, `relativeGap`, `absoluteGap`, `threads`, `verbose`, `outputFlag`, unknown keys, `Continuous` variables, unbounded variables or bounds outside `[-(2^30 - 1), 2^30 - 1]`, fractional coefficients/RHS, `QuadExpr` |
90
+ | **Z3** | Satisfiability Modulo Theories (`SMT`), continuous/discrete `unsatCore` | `signal`, `onProgress`, `z3JsUrl`, `z3WasmUrl` | `relax: true`, `useWorker: true`, `timeLimit`, `presolve`, `relativeGap`, `absoluteGap`, `threads`, `verbose`, `outputFlag`, unknown keys, `QuadExpr`, variable `initialValue` |
91
+ | **GLPK** | `LP`, `MIP` | `timeLimit`, `presolve`, `relativeGap`, `verbose`, `relax`, `signal`, `onProgress` | `useWorker: true`, `absoluteGap`, `threads`, `outputFlag` (use `verbose`), unknown keys, `QuadExpr`, variable `initialValue` |
92
+
93
+ Warm-start hints live on variables (`initialValue`), not `solve()`/`check()` options; see Step 1 below for solver support.
66
94
 
67
95
  ---
68
96
 
@@ -80,7 +108,7 @@ const x = m.continuous("x", { lb: 0, ub: 100 });
80
108
  const y = m.continuous("y", { lb: 0, ub: 100 });
81
109
  const n = m.integer("n", { lb: 0, ub: 10 });
82
110
  const b = m.binary("b");
83
- const flag = m.bool("flag"); // Propositional boolean (for Z3 / logical constraints)
111
+ const flag = m.bool("flag"); // Propositional boolean (auto 0-1 MIP on HiGHS/GLPK, native CP/SMT on Pumpkin/Z3)
84
112
 
85
113
  // Indexed variable containers:
86
114
  // - Numeric dimension -> Array
@@ -91,28 +119,40 @@ const byItem = m.integer(["desk", "chair"] as const, { lb: 0 }); // Record<"desk
91
119
  const mixed = m.binary(["A", "B"] as const, 3); // Record<"A" | "B", Var[]>
92
120
  ```
93
121
 
94
- - **Optional Primal Initial Values (`initialValue?: number`)**:
95
- - Numeric variable constructors (`m.continuous`, `m.integer`, `m.binary`, and `new Var`) and the mutable `v.initialValue` property accept an optional finite primal hint (validated with tolerance `1e-6` against bounds `[lb, ub]` and integer/binary domains), kept distinct from the solved `v.value`.
96
- - A start may be complete or partial (e.g., transferred by stable variable names when rebuilding a MIP model). Supplying `initialValue` is a hint only—it does **not** fix the variable, add a hard constraint, or guarantee solver acceptance or a runtime speedup.
97
- - Supported by **HiGHS** (`supportsWarmStart: true`); solvers without warm-start support (**GLPK**, **Z3**) throw an error if any variable has `initialValue !== undefined`.
98
-
99
- ### Step 2: Build Expressions (`expr`, `sum`, `dot`)
100
-
101
- - **Unified `expr` template tag**:
102
- - Linear expression (`LinExpr`): `` expr`30 * ${x} + 50 * ${n} - 10` ``, `` expr`dot(${profit}, ${byItem}) - 20 * ${b}` ``, `` expr`sum((${price} - ${cost}) * ${byItem})` ``
103
- - Quadratic expression (`QuadExpr`): `` expr`${x}^2 + 2 * ${x} * ${y} + ${y}^2` ``, `` expr`sum((${vec} - ${target})^2)` `` (supported for convex QP objectives on purely continuous models using `m.continuous`; built-in HiGHS does not support MIQP models containing integer, binary, or boolean variables).
104
- - Linear constraint (`Constraint`): `` expr`${x} + 2 * ${n} <= 40` ``, `` expr`sum(${byItem}) <= 100` `` (supports `<=`, `>=`, `==`, and `=`).
105
- - **Aggregations & Element-Wise Container Arithmetic**:
106
- - `sum(containerOrItems, mapper?)` (usable inside `` expr`sum(...)` `` or standalone `sum(...)`) sums a 1D/2D `Array`, `Iterable`, or plain `Record` of `Var` / `LinExpr` / `number` (without needing `Object.values(record)`), or maps over items/counts via `sum(items, (item, i) => ...)`. Inside `` expr`sum(...)` ``, element-wise container arithmetic (`+`, `-`, `*`, `/`, `^2`) is also supported.
107
- - `dot(a, b)` (usable inside `` expr`dot(${a}, ${b})` `` or standalone `dot(a, b)`) computes the inner product of matching 1D arrays, 2D arrays (`number[][]` / `Var[][]`, computing the Frobenius inner product $\sum_{i,j} A_{i,j} B_{i,j}$), plain records (`Record<string, ...>`), or mixed Array/Record containers in either operand order.
108
- - **Fluent methods**:
109
- - Arithmetic (on `LinExpr` and `QuadExpr`; `Var` supports `.add()`, `.sub()`, `.mul()`, `.neg()`): `.add(other)`, `.sub(other)`, `.mul(other)`, `.div(scalar)`, `.neg()`
110
- - Comparisons (on `Var` and `LinExpr`): `.le(rhs, name?)`, `.ge(rhs, name?)`, `.eq(rhs, name?)`
111
- - Boolean logic (on `BoolVar`, `BoolExpr`, and `Constraint` for Z3): standalone `and(...)`, `or(...)`, `not(...)`, `implies(a, b)`, `xor(a, b)` and fluent `.and(...)`, `.or(...)`, `.not()`, `.implies(...)`, `.xor(...)`
122
+ - **Primal hints**: Numeric variable constructors and `v.initialValue` accept a finite starting value, validated against `[lb, ub]` and checked for integrality (tolerance `1e-6`), and kept distinct from the solved `v.value`.
123
+ - **Hint semantics**: Complete or partial warm starts do not fix variables, add hard constraints, or guarantee solver acceptance or speedup.
124
+ - **Warm-start support**: Supported by HiGHS and Pumpkin (`supportsWarmStart: true`). GLPK and Z3 throw if any variable has `initialValue` set.
125
+
126
+ ### Step 2: Build Expressions (`expr`, `sum`, `dot`, `max`, `min`, `abs`, `at`)
127
+
128
+ #### Unified `expr` Template Tag
129
+
130
+ | Form | Examples | Notes |
131
+ | --- | --- | --- |
132
+ | Linear (`LinExpr`) | `` expr`30 * ${x} + 50 * ${n} - 10` ``, `` expr`dot(${profit}, ${byItem}) - 20 * ${b}` `` | Also supports `` expr`sum((${price} - ${cost}) * ${byItem})` ``. |
133
+ | Piecewise & element | `` expr`max(${vec}) + sum(abs(${vec} - ${target}))` ``, `` expr`at(${costs}, ${idx})` `` | `at()` enforces `0 <= idx < costs.length` on 0-based integer `idx`. Convex uses (e.g., minimizing `max`/`abs`) stay pure LP on HiGHS/GLPK; non-convex contexts require finite bounds. |
134
+ | Quadratic (`QuadExpr`) | `` expr`${x}^2 + 2 * ${x} * ${y} + ${y}^2` ``, `` expr`sum((${vec} - ${target})^2)` `` | Supported on HiGHS for convex QP objectives over continuous variables (`m.continuous`); MIQP and quadratic constraints are rejected, and other solvers reject `QuadExpr`. |
135
+ | Constraint (`Constraint`) | `` expr`${x} + 2 * ${n} <= 40` ``, `` expr`sum(${byItem}) <= 100` `` | Supports `<=`, `>=`, `==`, `=`, plus integer-only `<`, `>`, `!=`. |
136
+
137
+ #### Aggregations & Fluent Methods
138
+
139
+ - **`sum(containerOrItems, mapper?)`**: Sums a 1D/2D `Array`, `Iterable`, or plain object (`Record`) of variables, expressions, or numbers, optionally transforming each item with `mapper`. Inside `` expr`sum(...)` ``, element-wise `+`, `-`, `*`, `/`, `^2`, and `abs(...)` also work.
140
+ - **`dot(a, b)`**: Computes the inner product of matching 1D arrays, 2D arrays (Frobenius inner product $\sum_{i,j} A_{i,j} B_{i,j}$), plain objects, or mixed `Array`/`Record` containers.
141
+ - **Fluent arithmetic & comparisons**: `.add()`, `.sub()`, `.mul()`, `.div(scalar)`, `.neg()`, plus `.le()`, `.ge()`, `.eq()`, and integer-only `.lt()`, `.gt()`, `.ne()` (all taking `(rhs, name?)`; continuous/fractional operands throw on strict/not-equal comparisons).
142
+
143
+ #### CP Global Constraints & Boolean Logic
144
+
145
+ | Helper | Purpose | Solver Lowering |
146
+ | --- | --- | --- |
147
+ | `distinct(...args)` | All variables take pairwise distinct values | Native on Pumpkin and Z3; pairwise `!=` on HiGHS/GLPK. |
148
+ | `disjoint(tasks)` | Non-overlapping intervals (`{ start, duration }`) | Native scheduling propagator on Pumpkin; linearized on MIP solvers. |
149
+ | `cumulative(tasks, capacity)` | Shared resource capacity (`{ start, duration, demand }`) | Native propagator on Pumpkin; MIP time-indexed encoding enforces a horizon memory guard. |
150
+ | `allowed(vars, tuples)` | Restrict variable tuples to an allowed table | Native table propagator on Pumpkin; linearized on MIP solvers. |
151
+ | `and`, `or`, `not`, `implies`, `xor` | Composable boolean logic (standalone or fluent) | Native on Pumpkin and Z3; linearized to 0-1 MIP on HiGHS/GLPK (negated continuous constraints throw on MIP—use `{ solver: "z3" }` or reformulate with boolean variables). |
112
152
 
113
153
  ### Step 3: Register Objective & Constraints on the Model
114
154
 
115
- Constructing an `expr` or `.le()` object does **not** attach it to the model until you pass it to `m.constraint(...)` or `m.objective(...)`:
155
+ Constructing an expression or constraint via `expr` or `.le()` does **not** attach it to the model until you call `m.constraint(...)` or `m.objective(...)`. In `m.indicator()`, omitting `options.M` derives tight Big-M bounds for MIP solvers while keeping native indicator lowering on Pumpkin and Z3:
116
156
 
117
157
  ```ts
118
158
  // Set objective using maximize() or minimize()
@@ -121,22 +161,29 @@ m.objective(maximize(expr`30 * ${x} + 50 * ${n}`));
121
161
  // Register constraints on the model (returns the registered Constraint / BoolExpr or array)
122
162
  const limit = m.constraint(expr`${x} + 2 * ${n} <= 40`, "resource_limit");
123
163
 
124
- // Indicator constraint (MIP Big-M reformulation: b === 1 => x <= 50)
164
+ // Indicator constraint (b === 1 => x <= 50; Big-M on MIP, native on Pumpkin/Z3)
125
165
  m.indicator(b, expr`${x} <= 50`, { activeValue: 1, name: "cap_when_b" });
126
166
  ```
127
167
 
128
- ### Step 4: Execute (`solve` or `check`) & Verify (`validateSolution`)
168
+ ### Step 4: Execute (`solve` or `check`) & Verify (`verify`)
169
+
170
+ #### Optimization (`await m.solve(options?)`)
171
+
172
+ - **Return value**: Returns `SolverStatus` (`"Optimal"`, `"Feasible"`, `"Infeasible"`, `"Unbounded"`, `"TimeLimit"`, `"IterationLimit"`, `"Error"`, `"Unknown"`, `"NotSolved"`, `"Sat"`, or `"Unsat"`).
173
+ - **Status semantics**: Optimization solvers return `"Feasible"` when a limit or abort terminates the solve with a valid primal incumbent. `"Sat"` and `"Unsat"` apply to satisfiability or custom solver adapters.
174
+ - **Reading results**: Check `m.hasPrimalSolution`, then read `x.value`, `` expr`...`.value ``, `m.objectiveValue`, `constr.dual`, `constr.slack`, and `x.reducedCost`. `m.values` (like `m.variables` and `m.constraints`) is a `ReadonlyMap<string, number | boolean>` (use `.get(name)`), unlike `CheckResult.values` and `m.solution.values` (`Record`).
175
+ - **Independent verification**: `m.verify()` checks primal feasibility—finiteness, bounds, integrality, and constraints—returning `VerificationReport` (`{ valid, complete, maxViolation, violations }`) without recomputing `m.objectiveValue`.
176
+
177
+ #### Satisfiability & Conflict Diagnosis (`await m.check(options?)`)
178
+
179
+ - **Return value**: Returns `CheckResult` (`{ status: "Sat" | "Unsat" | "Unknown", values: Record<string, number | boolean>, conflicts?: readonly string[], unsatCore?: readonly string[], runTime?: number }`).
180
+ - **HiGHS & GLPK**: Diagnose linear and logical conflicts in `conflicts` via slack relaxation, leaving `unsatCore` as `undefined`.
181
+ - **Pumpkin & Z3**: Extract an exact unsatisfiable core into both `unsatCore` and `conflicts`. Use Pumpkin for bounded integer/boolean models and Z3 when continuous or fractional constraints are present.
182
+ - **Bounds caveat**: Variable bounds `lb`/`ub` and binary domains are asserted directly, so `unsatCore` reports constraint names that conflict *together with those variable bounds* (not guaranteed minimal).
183
+
184
+ #### Concurrent Mutation Rule
129
185
 
130
- - **Optimization (`await m.solve(options?)`)**:
131
- - Returns `SolverStatus` (`"Optimal"`, `"Feasible"`, `"Infeasible"`, `"Unbounded"`, `"TimeLimit"`, `"IterationLimit"`, `"Error"`, `"Unknown"`, `"NotSolved"`, `"Sat"`, or `"Unsat"`). Built-in optimization solvers return the optimization statuses (`"Optimal"`, `"Feasible"`, `"Infeasible"`, `"Unbounded"`, `"TimeLimit"`, `"IterationLimit"`, `"Error"`, `"Unknown"`, `"NotSolved"`), where a time-, iteration-, or solution-limited run (or an interrupted solve) that found a valid primal incumbent returns `"Feasible"`; `"Sat"` and `"Unsat"` are included in `SolverStatus` for satisfiability/custom solver adapters (such as `MockSolver`).
132
- - Read values via `x.value`, `expr`...`.value`, `m.getValues(x)`, `m.getValues(container)`, `m.objectiveValue`, `constr.dual`, `constr.slack`, and `x.reducedCost`.
133
- - Call `m.validateSolution()` after solving to independently verify variable finiteness, variable bounds (`lb`/`ub`), integer/binary/boolean domains, linear constraint residuals, and logical constraints (`SolutionValidationReport`: `{ valid, complete, maxViolation, violations, ... }`). Note that `validateSolution()` checks primal feasibility of variables and constraints; it does not recompute or compare `m.objectiveValue`.
134
- - **Satisfiability & Conflict Diagnosis (`await m.check(options?)`)**:
135
- - Returns `CheckResult` (`{ status: "Sat" | "Unsat" | "Unknown", values: Record<string, number | boolean>, conflicts?: readonly string[], unsatCore?: readonly string[], runTime?: number }`), where `conflicts` is populated when the model is proven `"Unsat"`.
136
- - For models containing linear arithmetic constraints or logical constraints (`BoolVar`, `and`, `or`, `implies`, `xor`), `m.check()` works with any solver (including the default HiGHS and GLPK via single-solve elastic slack relaxation, automatically linearizing logical constraints into 0-1 MIP formulation) and diagnoses conflicting constraints as `conflicts` (leaving `unsatCore: undefined` for semantic rigor).
137
- - Exact SMT unsatisfiable-core extraction (`result.unsatCore` and `result.conflicts`) is provided when using an SMT-capable solver (`{ solver: "z3" }`). Because Z3 asserts variable bounds (`lb`/`ub`) and binary `{0, 1}` domains directly while tracking registered constraints, `unsatCore` reports a subset of registered constraint names that conflicts *together with the model's fixed variable bounds/domains* (and is not guaranteed minimal).
138
- - **No concurrent mutation during async solve/check**:
139
- - Mutating variables, constraints, or the objective while `await m.solve()` or `await m.check()` is pending invalidates the in-flight execution and rejects the stale promise.
186
+ - Mutating variables, constraints, or the objective while an `m.solve()` or `m.check()` call is pending invalidates the in-flight run and rejects the stale promise.
140
187
 
141
188
  ---
142
189
 
@@ -145,18 +192,21 @@ m.indicator(b, expr`${x} <= 50`, { activeValue: 1, name: "cap_when_b" });
145
192
  1. DO NOT pass a Constraint to m.objective() or arithmetic methods:
146
193
  - `` WRONG: m.objective(maximize(expr`${x} <= 10` as any)); -> throws Error ``
147
194
  - `` WRONG: expr`${x} + 1`.add(expr`${y} <= 5` as any); -> throws Error ``
148
- 2. DO NOT pass an arithmetic expression without (<=, >=, ==) to m.constraint():
195
+ 2. DO NOT pass a bare arithmetic expression without a comparison operator (<=, >=, ==, etc.) to m.constraint():
149
196
  - `` WRONG: m.constraint(expr`${x} + ${y}` as any); -> throws Error ``
150
- 3. DO NOT use quadratic terms inside linear constraints:
197
+ 3. DO NOT use quadratic terms in constraints:
151
198
  - `` WRONG: expr`${x}^2 <= 10`; -> throws Error ("Quadratic constraints are not supported") ``
152
- 4. DO NOT use retired aliases (removed in #59 / #81):
199
+ 4. DO NOT use retired aliases:
153
200
  - Use `expr` instead of retired `c` template tag
154
201
  - Use `m.constraint(...)` instead of `m.constrain(...)` or `m.add(...)`
155
- - Use `m.objective(maximize(...))` / `m.objective(minimize(...))` instead of `m.maximize(...)` / `m.minimize(...)` / `m.setObjective(...)`
202
+ - Use `m.objective(maximize(...))` / `m.objective(minimize(...))` / `m.objective()` instead of `m.maximize(...)` / `m.minimize(...)` / `m.setObjective(...)` / `m.objectiveExpr`
156
203
  - Use `await m.solve()` instead of `await m.optimize()`
204
+ - Use `m.verify()` instead of `m.validateSolution()` (and rely on automatic integrity validation in `solve()` / `check()` / `toLpString()` instead of `m.validateIntegrity()`)
205
+ - Use `m.column(...)` instead of `m.addColumn(...)`
157
206
  - Use `.le()`, `.ge()`, `.eq()` instead of `.lessThanOrEqual()`, `.greaterThanOrEqual()`, `.equalTo()`
158
- - Use `.value` or `m.getValues(...)` instead of `expr.getValue()`
159
- - Use `m.variables` / `m.constraints` instead of `m.vars` / `m.constrs`
207
+ - Use `.value` instead of `m.getValues(...)` or `expr.getValue()`
208
+ - Use `m.variables` / `m.constraints` (`ReadonlyMap` with `.get()` / `.size`) instead of `m.vars` / `m.constrs` / `m.boolVars` / `m.logicalConstraints` / `m.numVars` / `m.numConstrs` / `get*ByName()`
209
+ - Use `relativeGap` / `absoluteGap` instead of `relGap` / `mipGap` / `absGap`
160
210
 
161
211
  ---
162
212
 
@@ -164,40 +214,43 @@ m.indicator(b, expr`${x} <= 50`, { activeValue: 1, name: "cap_when_b" });
164
214
 
165
215
  ### Getting Started
166
216
 
167
- - [AI Coding Agent Quick-Reference Guide](docs/getting-started/ai-agents.md): This document is the **consumer modeling quick-reference** for AI coding agents and developers building optimization or satisfiability models with `@ohtaman/washi`.
168
- - [Introduction & Installation](docs/getting-started/index.md): **WaSHI** (WebAssembly-backed, Solver-independent, High-level modeling Interface) brings the algebraic modeling style of Python's **PuLP** to the TypeScript and JavaScript ecosystem.
169
- - [Runtime Environments & Deployment](docs/getting-started/runtimes.md): WaSHI runs across JavaScript and TypeScript runtimes—from Node.js, Bun, and Deno to modern bundlers, static hosting, and vanilla browser `<script>` tags—without native C/C++ compilation.
170
- - [Cross-Origin Isolation (Z3 & Browsers)](docs/getting-started/cross-origin.md): When running the **Z3** solver inside a web browser, Cross-Origin Isolation HTTP headers are required so the browser enables `SharedArrayBuffer`.
217
+ - [AI Coding Agent Quick-Reference Guide](docs/getting-started/ai-agents.md): This document is the **modeling quick reference** for AI coding agents and developers building optimization or satisfiability models with `@ohtaman/washi`.
218
+ - [Introduction & Installation](docs/getting-started/index.md): **WaSHI** (WebAssembly-backed, Solver-independent, High-level modeling Interface) brings Python PuLP-style algebraic modeling to TypeScript and JavaScript.
219
+ - [Runtime Environments & Deployment](docs/getting-started/runtimes.md): WaSHI runs across JavaScript and TypeScript runtimes and deployment targets without native solver compilation.
220
+ - [Cross-Origin Isolation (Z3 & Browsers)](docs/getting-started/cross-origin.md): Running the Z3 solver in a browser requires two browser security conditions: a **Secure Context** and **Cross-Origin Isolation**.
171
221
 
172
222
  ### Modeling Guide
173
223
 
174
- - [Variables & Domains](docs/guide/variables.md): Variables represent the mathematical decision variables in your optimization or logical model.
175
- - [Expressions (`expr`, `sum`, `dot`)](docs/guide/expressions.md): Mathematical expressions are linear or quadratic combinations of decision variables and numeric coefficients.
176
- - [Constraints (`m.constraint` & `m.indicator`)](docs/guide/constraints.md): Constraints restrict the feasible solution space of your mathematical or logical model.
177
- - [Objectives & Solving (`m.solve` & `m.check`)](docs/guide/objectives.md): The objective function defines the goal of mathematical optimization—whether to maximize profits, minimize costs, or minimize quadratic risk variance.
178
- - [Conflict Diagnosis (`unsatCore`) & Solution Validation](docs/guide/unsat-core.md): WaSHI provides built-in tools for both: **conflict diagnosis** via built-in HiGHS elastic relaxation or Z3 Unsat Core (`m.check()`), **independent solution validation** (`m.validateSolution()`), **LP formulation export** (`m.toLpString()`), and **fast unit testing** (`MockSolver`).
179
- - [Decomposition Methods (`solveColumnGeneration` & `solveBenders`)](docs/guide/decomposition.md): When monolithic Mixed-Integer Programming (MIP) models have exponentially many candidate patterns or large multi-stage subproblems, WaSHI provides two high-level decomposition orchestrators—`master.solveColumnGeneration()` and `master.solveBenders()`—along with low-level primitives for dual inspection and dynamic model updates.
180
- - [Formulation Patterns & Optimization Tips](docs/guide/formulation-tips.md): While the preceding Modeling Guide pages cover WaSHI's APIs (`Model`, `expr`, `m.constraint`, `m.solve`, etc.), this page collects standard mathematical optimization formulation patterns and solver tuning techniques frequently used in linear and mixed-integer programming (LP/MIP).
224
+ - [Variables & Domains](docs/guide/variables.md): Variables represent the unknown decision quantities in an optimization or logical model.
225
+ - [Expressions (`expr`, `sum`, `dot`)](docs/guide/expressions.md): Mathematical expressions combine decision variables and numeric coefficients into linear, quadratic, or piecewise-linear formulas.
226
+ - [Constraints (`m.constraint` & `m.indicator`)](docs/guide/constraints.md): Constraints define the rules that every valid solution must satisfy.
227
+ - [Objectives & Solving (`m.solve` & `m.check`)](docs/guide/objectives.md): The objective function defines the goal of mathematical optimization, such as maximizing profit, minimizing cost, or minimizing quadratic variance.
228
+ - [Conflict Diagnosis (`unsatCore`), Validation & Debugging](docs/guide/unsat-core.md): When `m.solve()` returns `"Infeasible"`, it proves that no solution satisfies every rule, but does not tell you *which* rules clash.
229
+ - [Constraint Programming (CP) Modeling](docs/guide/constraint-programming.md): WaSHI lets you write both Mathematical Optimization (LP / MIP / QP) and Constraint Programming (CP) models with the same TypeScript API.
230
+ - [Decomposition Methods (`solveColumnGeneration` & `solveBenders`)](docs/guide/decomposition.md): Both helpers are also exported as standalone functions—`solveColumnGeneration({ master, ...
231
+ - [Formulation Patterns & Optimization Tips](docs/guide/formulation-tips.md): The preceding guide pages cover WaSHI's core APIs (`Model`, `expr`, `m.constraint`, `m.solve`).
181
232
 
182
233
  ### Solvers
183
234
 
184
- - [Solvers Overview](docs/solvers/index.md): WaSHI is designed around a pluggable, decoupled solver architecture.
185
- - [HiGHS Solver Engine](docs/solvers/highs.md): **HiGHS** is high-performance mathematical optimization software initiated at the University of Edinburgh (highs.dev · ERGO-Code/HiGHS).
186
- - [Z3 SMT Solver Engine](docs/solvers/z3.md): **Z3** is a theorem prover and Satisfiability Modulo Theories (SMT) solver developed by Microsoft Research.
187
- - [GLPK Solver Engine](docs/solvers/glpk.md): The **GNU Linear Programming Kit (GLPK)** is a long-standing, robust simplex and interior-point solver package intended for solving large-scale linear programming (LP) and mixed integer programming (MIP).
188
- - [WaSHI Custom Solver Developer Guide](docs/solvers/custom-solver.md): This guide describes how to build, test, and distribute custom solver plugins for **WaSHI** (`@ohtaman/washi`).
235
+ - [Solvers Overview](docs/solvers/index.md): WaSHI uses a pluggable solver architecture.
236
+ - [HiGHS Solver Engine](docs/solvers/highs.md): **HiGHS** is an open-source mathematical optimization solver started at the University of Edinburgh (highs.dev · ERGO-Code/HiGHS).
237
+ - [Pumpkin Constraint Programming Solver](docs/solvers/pumpkin.md): **Pumpkin** is an open-source Constraint Programming (CP) solver written in Rust and maintained by ConSol-Lab/Pumpkin.
238
+ - [Z3 SMT Solver Engine](docs/solvers/z3.md): **Z3** is an open-source theorem prover and Satisfiability Modulo Theories (SMT) solver from Microsoft Research.
239
+ - [GLPK Solver Engine](docs/solvers/glpk.md): The **GNU Linear Programming Kit (GLPK)** is an open-source simplex and branch-and-cut solver for Linear Programming (LP) and Mixed-Integer Programming (MIP).
240
+ - [WaSHI Custom Solver Developer Guide](docs/solvers/custom-solver.md): This guide explains how to build, test, and distribute custom solver plugins for **WaSHI** (`@ohtaman/washi`).
189
241
 
190
242
  ### Examples
191
243
 
192
244
  - [Examples & API Finder](docs/examples/index.md): Explore runnable optimization and logic formulations built with WaSHI.
193
- - [Production Planning (LP / MIP)](docs/examples/production.md): Production planning is a classic Linear Programming problem: determine the optimal quantity of each product to manufacture in order to maximize total profit while respecting resource constraints (raw materials, machine time, labor hours).
194
- - [0-1 Knapsack Problem (Binary MIP)](docs/examples/knapsack.md): The 0-1 Knapsack problem is an essential combinatorial optimization problem: given a set of items, each with a weight and a value, determine which items to include in a collection so that the total weight does not exceed a given limit and the total value is maximized.
195
- - [Transportation & Allocation Network (LP)](docs/examples/transportation.md): The transportation problem is one of the most fundamental network optimization models: determine how many units to ship from each supply origin (factory) to each destination (store) to minimize total shipping cost while respecting factory supply limits and meeting store demands.
196
- - [Diet Problem & Sensitivity Analysis (LP Duals & Slacks)](docs/examples/diet-sensitivity.md): When solving a Linear Programming model, the optimal variable values (`var.value`) are only half the story.
197
- - [Staff Shift Scheduling & Conflict Diagnosis (MIP + Z3)](docs/examples/shift-scheduling.md): Staff shift scheduling is a classic real-world application of Mixed-Integer Programming in SaaS and workforce management tools.
198
- - [E-Commerce Cart & Coupon Optimizer (Indicator MIP)](docs/examples/ecommerce-coupons.md): Modern e-commerce checkouts often feature complex promotional rules: minimum spend thresholds, category-specific discounts, stackable vs. mutually exclusive coupons, and maximum coupon limits per order.
199
- - [Portfolio Optimization (QP)](docs/examples/portfolio-qp.md): The Markowitz mean-variance portfolio optimization problem is the foundation of modern quantitative finance: allocate capital across risky assets to minimize overall portfolio variance (risk) subject to achieving a minimum required expected return.
200
- - [SMT Security Policies](docs/examples/smt-security.md): Satisfiability Modulo Theories (SMT) combines propositional logic (Boolean SAT) with first-order theories (linear integer arithmetic, real inequalities).
201
- - [Conflict Diagnosis (Unsat Core)](docs/examples/unsat-core.md): When business rules, budgets, and operational policies grow complex, constraints can easily conflict.
202
- - [Capacitated Vehicle Routing Problem (CVRP, 50 Customers via Column Generation)](docs/examples/vehicle-routing.md): The **Capacitated Vehicle Routing Problem (CVRP)** determines the minimum number of delivery vehicles needed to visit a set of customers, subject to vehicle cargo capacity, maximum customer stops per shift, and route duration limits.
203
- - [Traveling Salesperson Problem (TSP via Benders Decomposition)](docs/examples/traveling-salesperson.md): The **Traveling Salesperson Problem (TSP)** seeks the shortest closed tour that visits every city in a given set once and returns to the starting city.
245
+ - [Production Planning (Integer Programming / MIP)](docs/examples/production.md): Production planning is a classic optimization problem.
246
+ - [0-1 Knapsack Problem (Binary MIP)](docs/examples/knapsack.md): The 0-1 Knapsack problem is a fundamental combinatorial optimization problem.
247
+ - [Transportation & Allocation Network (LP)](docs/examples/transportation.md): The **transportation problem** decides how many units to ship from each factory to each store.
248
+ - [Diet Problem & Sensitivity Analysis (LP Duals & Slacks)](docs/examples/diet-sensitivity.md): We determine daily servings ($0 \le x_i \le 4$, continuous) for each of 6 foods to minimize daily cost.
249
+ - [Staff Shift Scheduling & Conflict Diagnosis (MIP + Z3)](docs/examples/shift-scheduling.md): In staff shift scheduling, vacation requests often collide with minimum headcount or senior coverage rules, causing a Mixed-Integer Programming (MIP) solver to return `"Infeasible"`.
250
+ - [E-Commerce Cart & Coupon Optimizer (Indicator MIP)](docs/examples/ecommerce-coupons.md): E-commerce checkouts often combine minimum spend thresholds, category discounts, mutually exclusive coupons, and per-order coupon caps.
251
+ - [Portfolio Optimization (QP)](docs/examples/portfolio-qp.md): The Markowitz mean-variance model is a classic problem in quantitative finance.
252
+ - [Resource-Constrained Project Scheduling (CP / Pumpkin)](docs/examples/project-scheduling.md): The **Resource-Constrained Project Scheduling Problem (RCPSP)** schedules project tasks to minimize the maximum completion time, known as the **makespan**.
253
+ - [SMT Security Policies](docs/examples/smt-security.md): **Satisfiability Modulo Theories (SMT)** combines Boolean logic with arithmetic inequalities such as integer bounds and linear comparisons.
254
+ - [Conflict Diagnosis (Unsat Core)](docs/examples/unsat-core.md): A standard optimization call (`m.solve()`) only reports `"Infeasible"` when constraints clash.
255
+ - [Capacitated Vehicle Routing Problem (CVRP, 50 Customers via Column Generation)](docs/examples/vehicle-routing.md): This **Capacitated Vehicle Routing Problem (CVRP)** variant minimizes the number of delivery vehicles needed to serve every customer.
256
+ - [Traveling Salesperson Problem (TSP via Benders Decomposition)](docs/examples/traveling-salesperson.md): The **Traveling Salesperson Problem (TSP)** finds the shortest closed tour that visits every city once and returns to the starting city.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ohtaman/washi",
3
- "version": "0.7.0",
4
- "description": "WaSHI: WebAssembly-backed Algebraic Modeler for Mathematical Optimization & Constraint Programming (LP, MIP, QP, SMT)",
3
+ "version": "0.8.1",
4
+ "description": "WaSHI: TypeScript & JavaScript algebraic modeler for Mathematical Optimization & Constraint Programming (LP, MILP, QP, CP, SMT) powered by WebAssembly (HiGHS, Pumpkin, Z3, GLPK)",
5
5
  "type": "module",
6
6
  "main": "./dist/lib/washi.js",
7
7
  "module": "./dist/lib/washi.js",
@@ -12,12 +12,25 @@
12
12
  "import": "./dist/lib/washi.js",
13
13
  "default": "./dist/lib/washi.js"
14
14
  },
15
- "./highs.wasm": "./dist/lib/highs.wasm",
15
+ "./solvers/highs": {
16
+ "types": "./dist/types/modeler/solvers/highs/index.d.ts",
17
+ "import": "./dist/lib/solvers/highs.js",
18
+ "default": "./dist/lib/solvers/highs.js"
19
+ },
20
+ "./solvers/highs.wasm": "./dist/lib/solvers/highs.wasm",
21
+ "./solvers/pumpkin": {
22
+ "types": "./dist/types/modeler/solvers/pumpkin/index.d.ts",
23
+ "import": "./dist/lib/solvers/pumpkin.js",
24
+ "default": "./dist/lib/solvers/pumpkin.js"
25
+ },
26
+ "./solvers/pumpkin.wasm": "./dist/lib/solvers/pumpkin.wasm",
16
27
  "./solvers/z3": {
17
28
  "types": "./dist/types/modeler/solvers/z3/index.d.ts",
18
29
  "import": "./dist/lib/solvers/z3.js",
19
30
  "default": "./dist/lib/solvers/z3.js"
20
31
  },
32
+ "./solvers/z3-built.js": "./dist/lib/solvers/z3-built.js",
33
+ "./solvers/z3-built.wasm": "./dist/lib/solvers/z3-built.wasm",
21
34
  "./solvers/glpk": {
22
35
  "types": "./dist/types/modeler/solvers/glpk/index.d.ts",
23
36
  "import": "./dist/lib/solvers/glpk.js",
@@ -29,28 +42,34 @@
29
42
  "default": "./dist/browser/washi.js"
30
43
  },
31
44
  "./browser/washi.min.js": "./dist/browser/washi.min.js",
32
- "./browser/solvers/glpk": {
33
- "types": "./dist/types/modeler/solvers/glpk/index.d.ts",
34
- "import": "./dist/browser/solvers/glpk.js",
35
- "default": "./dist/browser/solvers/glpk.js"
45
+ "./browser/solvers/highs": {
46
+ "types": "./dist/types/modeler/solvers/highs/index.d.ts",
47
+ "import": "./dist/browser/solvers/highs.js",
48
+ "default": "./dist/browser/solvers/highs.js"
49
+ },
50
+ "./browser/solvers/pumpkin": {
51
+ "types": "./dist/types/modeler/solvers/pumpkin/index.d.ts",
52
+ "import": "./dist/browser/solvers/pumpkin.js",
53
+ "default": "./dist/browser/solvers/pumpkin.js"
36
54
  },
37
- "./browser/solvers/glpk.min.js": "./dist/browser/solvers/glpk.min.js",
38
55
  "./browser/solvers/z3": {
39
56
  "types": "./dist/types/modeler/solvers/z3/index.d.ts",
40
57
  "import": "./dist/browser/solvers/z3.js",
41
58
  "default": "./dist/browser/solvers/z3.js"
42
59
  },
43
60
  "./browser/solvers/z3.min.js": "./dist/browser/solvers/z3.min.js",
44
- "./solvers/z3-built.js": "./dist/lib/solvers/z3-built.js",
45
- "./solvers/z3-built.wasm": "./dist/lib/solvers/z3-built.wasm"
61
+ "./browser/solvers/glpk": {
62
+ "types": "./dist/types/modeler/solvers/glpk/index.d.ts",
63
+ "import": "./dist/browser/solvers/glpk.js",
64
+ "default": "./dist/browser/solvers/glpk.js"
65
+ },
66
+ "./browser/solvers/glpk.min.js": "./dist/browser/solvers/glpk.min.js"
46
67
  },
47
68
  "files": [
48
69
  "dist/lib",
49
70
  "dist/browser",
50
71
  "dist/types",
51
72
  "docs/getting-started/ai-agents.md",
52
- "docs/ja/getting-started/ai-agents.md",
53
- "docs/zh/getting-started/ai-agents.md",
54
73
  "docs/getting-started",
55
74
  "docs/guide",
56
75
  "docs/solvers",
@@ -68,22 +87,25 @@
68
87
  "dev": "vite",
69
88
  "ensure:highs": "node scripts/ensure-highs-wasm.mjs",
70
89
  "build:highs-wasm": "bash scripts/build-highs-wasm.sh",
90
+ "ensure:pumpkin": "node scripts/ensure-pumpkin-wasm.mjs",
91
+ "build:pumpkin-wasm": "bash scripts/build-pumpkin-wasm.sh",
71
92
  "build:demo": "vite build",
72
93
  "build:types": "node -e \"import('node:fs').then(fs => fs.rmSync('dist/types', { recursive: true, force: true }))\" && tsc -p tsconfig.lib.json",
73
- "build:lib": "node scripts/ensure-highs-wasm.mjs && node scripts/build-library.mjs",
94
+ "build:lib": "node scripts/ensure-highs-wasm.mjs && node scripts/ensure-pumpkin-wasm.mjs && node scripts/build-library.mjs",
74
95
  "build:llms": "node scripts/generate-llms.mjs",
75
- "build": "node scripts/ensure-highs-wasm.mjs && npm run build:types && npm run build:lib && npm run build:browser && npm run build:demo",
76
- "build:site": "node scripts/ensure-highs-wasm.mjs && node scripts/build-site.mjs",
96
+ "build": "node scripts/ensure-highs-wasm.mjs && node scripts/ensure-pumpkin-wasm.mjs && npm run build:types && npm run build:lib && npm run build:browser && npm run build:demo",
97
+ "build:site": "node scripts/ensure-highs-wasm.mjs && node scripts/ensure-pumpkin-wasm.mjs && node scripts/build-site.mjs",
77
98
  "docs:dev": "vitepress dev docs",
78
99
  "docs:build": "vitepress build docs && node scripts/generate-llms.mjs",
79
100
  "docs:preview": "vitepress preview docs",
80
101
  "preview": "vite preview",
81
102
  "test": "vitest run",
82
103
  "test:e2e": "RUN_E2E=1 vitest run test/e2e.test.ts",
83
- "prepublishOnly": "node scripts/ensure-highs-wasm.mjs && npm run build:types && npm run build:lib && npm run build:browser && npm run build:llms",
84
- "build:browser": "node scripts/ensure-highs-wasm.mjs && node scripts/build-browser.mjs",
85
- "test:distribution": "node scripts/ensure-highs-wasm.mjs && npm run build:types && npm run build:lib && npm run build:browser && npm run build:llms && node --experimental-vm-modules scripts/check-distribution.mjs",
104
+ "prepublishOnly": "node scripts/ensure-highs-wasm.mjs && node scripts/ensure-pumpkin-wasm.mjs && npm run build:types && npm run build:lib && npm run build:browser && npm run build:llms",
105
+ "build:browser": "node scripts/ensure-highs-wasm.mjs && node scripts/ensure-pumpkin-wasm.mjs && node scripts/build-browser.mjs",
106
+ "test:distribution": "node scripts/ensure-highs-wasm.mjs && node scripts/ensure-pumpkin-wasm.mjs && npm run build:types && npm run build:lib && npm run build:browser && npm run build:llms && node --experimental-vm-modules scripts/check-distribution.mjs",
86
107
  "test:demo": "BASE_URL=/ npm run build:demo && node scripts/check-demo-browser.mjs",
108
+ "test:site": "npm run build:site && REQUIRE_SITE_DIST=1 vitest run test/site-seo.test.ts",
87
109
  "bench": "node scripts/run-benchmarks.mjs"
88
110
  },
89
111
  "keywords": [
@@ -93,15 +115,28 @@
93
115
  "linear-programming",
94
116
  "mixed-integer-programming",
95
117
  "quadratic-programming",
118
+ "milp",
119
+ "lp",
120
+ "mip",
121
+ "qp",
122
+ "cp",
123
+ "solver",
124
+ "modeler",
125
+ "scheduling",
126
+ "timetabling",
96
127
  "smt",
97
128
  "z3",
98
129
  "highs",
130
+ "glpk",
131
+ "pumpkin",
132
+ "lcg",
99
133
  "pulp",
100
134
  "jump",
101
135
  "operations-research",
102
136
  "wasm",
103
137
  "webassembly",
104
- "typescript"
138
+ "typescript",
139
+ "javascript"
105
140
  ],
106
141
  "author": "",
107
142
  "license": "MIT",
@@ -131,6 +166,7 @@
131
166
  }
132
167
  },
133
168
  "devDependencies": {
169
+ "@babel/parser": "^7.29.9",
134
170
  "@types/node": "^26.6.3",
135
171
  "async-mutex": "^0.3.2",
136
172
  "glpk.js": "^5.0.0",