@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.
- package/README.ja.md +60 -23
- package/README.md +59 -22
- package/README.zh-CN.md +62 -25
- package/THIRD_PARTY_LICENSES.md +34 -1
- package/dist/browser/solvers/glpk.js +289 -238
- package/dist/browser/solvers/glpk.min.js +1 -1
- package/dist/browser/solvers/highs-__vite-browser-external-Dn-83hnF.js +7 -0
- package/dist/browser/solvers/highs-browser-runtime-0Bgq5ksG.js +2021 -0
- package/dist/browser/{loader-DewlSho8.js → solvers/highs-loader-BLY3wzDH.js} +190 -149
- package/dist/browser/solvers/highs-worker.js +54 -0
- package/dist/browser/solvers/highs.js +1414 -0
- package/dist/browser/solvers/highs.wasm +0 -0
- package/dist/browser/solvers/pumpkin-_washi-pumpkin-node-runtime-CEKUDK6d.js +9 -0
- package/dist/browser/solvers/pumpkin-loader-CvdaKxf4.js +320 -0
- package/dist/browser/solvers/pumpkin-worker.js +45 -0
- package/dist/browser/solvers/pumpkin.js +1777 -0
- package/dist/browser/solvers/pumpkin.wasm +0 -0
- package/dist/browser/solvers/pumpkin.wasm.LICENSE +21 -0
- package/dist/browser/solvers/z3.js +1600 -1335
- package/dist/browser/solvers/z3.min.js +2 -2
- package/dist/browser/washi.js +3313 -1699
- package/dist/browser/washi.min.js +5 -3
- package/dist/lib/solvers/__vite-browser-external-oLchLuMx.js +7 -0
- package/dist/lib/solvers/glpk.js +174 -132
- package/dist/lib/solvers/highs-browser-runtime.js +2413 -0
- package/dist/lib/{highs-node-runtime.js → solvers/highs-node-runtime.js} +1 -1
- package/dist/lib/solvers/highs-runtime.js +16 -0
- package/dist/lib/solvers/highs-worker.js +54 -0
- package/dist/lib/solvers/highs.js +410 -0
- package/dist/lib/solvers/highs.wasm +0 -0
- package/dist/lib/{loader-BZUQNvh4.js → solvers/loader-CDpPXN_F.js} +138 -116
- package/dist/lib/solvers/loader-Ow74Fa1B.js +311 -0
- package/dist/lib/solvers/lp-writer-CLScMFbS.js +115 -0
- package/dist/lib/solvers/pumpkin-assets.js +1 -0
- package/dist/lib/solvers/pumpkin-node-runtime.js +15 -0
- package/dist/lib/solvers/pumpkin-worker-factory.js +1 -0
- package/dist/lib/solvers/pumpkin-worker.js +45 -0
- package/dist/lib/solvers/pumpkin.js +868 -0
- package/dist/lib/solvers/pumpkin.wasm +0 -0
- package/dist/lib/solvers/pumpkin.wasm.LICENSE +21 -0
- package/dist/lib/solvers/registry-CrYRRk9q.js +907 -0
- package/dist/lib/solvers/rolldown-runtime-DtPi1Y-2.js +13 -0
- package/dist/lib/solvers/types-BGqPkxwu.js +12 -0
- package/dist/lib/solvers/z3.js +489 -307
- package/dist/lib/washi.js +3905 -1410
- package/dist/types/decomposition/benders.d.ts.map +1 -1
- package/dist/types/index.d.ts +4 -5
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/modeler/boolean-expr.d.ts +137 -29
- package/dist/types/modeler/boolean-expr.d.ts.map +1 -1
- package/dist/types/modeler/constraint.d.ts +40 -4
- package/dist/types/modeler/constraint.d.ts.map +1 -1
- package/dist/types/modeler/expression.d.ts +129 -2
- package/dist/types/modeler/expression.d.ts.map +1 -1
- package/dist/types/modeler/index.d.ts +4 -6
- package/dist/types/modeler/index.d.ts.map +1 -1
- package/dist/types/modeler/linearizer.d.ts +11 -2
- package/dist/types/modeler/linearizer.d.ts.map +1 -1
- package/dist/types/modeler/lp-writer.d.ts.map +1 -1
- package/dist/types/modeler/model.d.ts +86 -126
- package/dist/types/modeler/model.d.ts.map +1 -1
- package/dist/types/modeler/parser.d.ts.map +1 -1
- package/dist/types/modeler/quad-expr.d.ts +8 -2
- package/dist/types/modeler/quad-expr.d.ts.map +1 -1
- package/dist/types/modeler/solution-validator.d.ts +12 -12
- package/dist/types/modeler/solution-validator.d.ts.map +1 -1
- package/dist/types/modeler/solvers/glpk/loader.d.ts +4 -0
- package/dist/types/modeler/solvers/glpk/loader.d.ts.map +1 -1
- package/dist/types/modeler/solvers/glpk/solver.d.ts +2 -2
- package/dist/types/modeler/solvers/glpk/solver.d.ts.map +1 -1
- package/dist/types/modeler/solvers/highs/driver.d.ts.map +1 -1
- package/dist/types/modeler/solvers/highs/loader.d.ts +8 -6
- package/dist/types/modeler/solvers/highs/loader.d.ts.map +1 -1
- package/dist/types/modeler/solvers/highs/solver.d.ts.map +1 -1
- package/dist/types/modeler/solvers/highs/worker-client.d.ts +16 -0
- package/dist/types/modeler/solvers/highs/worker-client.d.ts.map +1 -1
- package/dist/types/modeler/solvers/index.d.ts +2 -1
- package/dist/types/modeler/solvers/index.d.ts.map +1 -1
- package/dist/types/modeler/solvers/mock.d.ts +2 -3
- package/dist/types/modeler/solvers/mock.d.ts.map +1 -1
- package/dist/types/modeler/solvers/pumpkin/assets.d.ts +2 -0
- package/dist/types/modeler/solvers/pumpkin/assets.d.ts.map +1 -0
- package/dist/types/modeler/solvers/pumpkin/index.d.ts +6 -0
- package/dist/types/modeler/solvers/pumpkin/index.d.ts.map +1 -0
- package/dist/types/modeler/solvers/pumpkin/loader.d.ts +40 -0
- package/dist/types/modeler/solvers/pumpkin/loader.d.ts.map +1 -0
- package/dist/types/modeler/solvers/pumpkin/node-runtime.d.ts +3 -0
- package/dist/types/modeler/solvers/pumpkin/node-runtime.d.ts.map +1 -0
- package/dist/types/modeler/solvers/pumpkin/solver.d.ts +23 -0
- package/dist/types/modeler/solvers/pumpkin/solver.d.ts.map +1 -0
- package/dist/types/modeler/solvers/pumpkin/worker-client.d.ts +74 -0
- package/dist/types/modeler/solvers/pumpkin/worker-client.d.ts.map +1 -0
- package/dist/types/modeler/solvers/pumpkin/worker-factory.d.ts +3 -0
- package/dist/types/modeler/solvers/pumpkin/worker-factory.d.ts.map +1 -0
- package/dist/types/modeler/solvers/pumpkin/worker.d.ts +7 -0
- package/dist/types/modeler/solvers/pumpkin/worker.d.ts.map +1 -0
- package/dist/types/modeler/solvers/pumpkin.d.ts +2 -0
- package/dist/types/modeler/solvers/pumpkin.d.ts.map +1 -0
- package/dist/types/modeler/solvers/types.d.ts +7 -9
- package/dist/types/modeler/solvers/types.d.ts.map +1 -1
- package/dist/types/modeler/solvers/z3/loader.d.ts +4 -0
- package/dist/types/modeler/solvers/z3/loader.d.ts.map +1 -1
- package/dist/types/modeler/solvers/z3/solver.d.ts +2 -15
- package/dist/types/modeler/solvers/z3/solver.d.ts.map +1 -1
- package/dist/types/modeler/types.d.ts +12 -15
- package/dist/types/modeler/types.d.ts.map +1 -1
- package/dist/types/modeler/validation.d.ts +26 -2
- package/dist/types/modeler/validation.d.ts.map +1 -1
- package/dist/types/modeler/variable.d.ts +9 -5
- package/dist/types/modeler/variable.d.ts.map +1 -1
- package/docs/examples/diet-sensitivity.md +33 -14
- package/docs/examples/ecommerce-coupons.md +17 -9
- package/docs/examples/index.md +36 -27
- package/docs/examples/knapsack.md +11 -5
- package/docs/examples/portfolio-qp.md +21 -8
- package/docs/examples/production.md +10 -5
- package/docs/examples/project-scheduling.md +119 -0
- package/docs/examples/shift-scheduling.md +29 -18
- package/docs/examples/smt-security.md +27 -11
- package/docs/examples/transportation.md +23 -13
- package/docs/examples/traveling-salesperson.md +34 -22
- package/docs/examples/unsat-core.md +27 -14
- package/docs/examples/vehicle-routing.md +74 -28
- package/docs/getting-started/ai-agents.md +190 -82
- package/docs/getting-started/coding-agents.md +177 -0
- package/docs/getting-started/cross-origin.md +27 -14
- package/docs/getting-started/index.md +49 -43
- package/docs/getting-started/runtimes.md +94 -40
- package/docs/guide/constraint-programming.md +171 -0
- package/docs/guide/constraints.md +115 -33
- package/docs/guide/decomposition.md +118 -88
- package/docs/guide/expressions.md +106 -43
- package/docs/guide/formulation-tips.md +47 -28
- package/docs/guide/objectives.md +102 -75
- package/docs/guide/unsat-core.md +62 -50
- package/docs/guide/variables.md +81 -35
- package/docs/solvers/custom-solver.md +163 -122
- package/docs/solvers/glpk.md +58 -17
- package/docs/solvers/highs.md +124 -57
- package/docs/solvers/index.md +33 -20
- package/docs/solvers/pumpkin.md +171 -0
- package/docs/solvers/z3.md +63 -25
- package/llms-full.txt +2232 -932
- package/llms.txt +144 -91
- package/package.json +55 -19
- package/skills/washi/SKILL.md +107 -34
- package/dist/browser/_washi-node-only-BvRk9kiK.js +0 -0
- package/dist/browser/browser-runtime-TLCY0hkc.js +0 -1793
- package/dist/browser/highs-worker.js +0 -39
- package/dist/browser/highs.wasm +0 -0
- package/dist/lib/_washi-node-only-BvRk9kiK.js +0 -0
- package/dist/lib/highs-browser-runtime.js +0 -2185
- package/dist/lib/highs-runtime.js +0 -2
- package/dist/lib/highs-worker.js +0 -39
- package/dist/lib/highs.wasm +0 -0
- package/dist/lib/registry-D7TZ3Wh_.js +0 -1034
- package/docs/ja/getting-started/ai-agents.md +0 -280
- package/docs/zh/getting-started/ai-agents.md +0 -280
- /package/dist/browser/{highs.wasm.LICENSE → solvers/highs.wasm.LICENSE} +0 -0
- /package/dist/lib/{highs-assets.js → solvers/highs-assets.js} +0 -0
- /package/dist/lib/{highs-worker-factory.js → solvers/highs-worker-factory.js} +0 -0
- /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:
|
|
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
|
|
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
|
|
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
|
-
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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 (
|
|
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
|
-
- **
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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()`
|
|
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 (
|
|
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 (`
|
|
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
|
-
-
|
|
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
|
|
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
|
|
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
|
|
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`
|
|
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 **
|
|
168
|
-
- [Introduction & Installation](docs/getting-started/index.md): **WaSHI** (WebAssembly-backed, Solver-independent, High-level modeling Interface) brings
|
|
169
|
-
- [Runtime Environments & Deployment](docs/getting-started/runtimes.md): WaSHI runs across JavaScript and TypeScript runtimes
|
|
170
|
-
- [Cross-Origin Isolation (Z3 & Browsers)](docs/getting-started/cross-origin.md):
|
|
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
|
|
175
|
-
- [Expressions (`expr`, `sum`, `dot`)](docs/guide/expressions.md): Mathematical expressions
|
|
176
|
-
- [Constraints (`m.constraint` & `m.indicator`)](docs/guide/constraints.md): Constraints
|
|
177
|
-
- [Objectives & Solving (`m.solve` & `m.check`)](docs/guide/objectives.md): The objective function defines the goal of mathematical optimization
|
|
178
|
-
- [Conflict Diagnosis (`unsatCore`) &
|
|
179
|
-
- [
|
|
180
|
-
- [
|
|
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
|
|
185
|
-
- [HiGHS Solver Engine](docs/solvers/highs.md): **HiGHS** is
|
|
186
|
-
- [
|
|
187
|
-
- [
|
|
188
|
-
- [
|
|
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 (
|
|
194
|
-
- [0-1 Knapsack Problem (Binary MIP)](docs/examples/knapsack.md): The 0-1 Knapsack problem is
|
|
195
|
-
- [Transportation & Allocation Network (LP)](docs/examples/transportation.md): The transportation problem
|
|
196
|
-
- [Diet Problem & Sensitivity Analysis (LP Duals & Slacks)](docs/examples/diet-sensitivity.md):
|
|
197
|
-
- [Staff Shift Scheduling & Conflict Diagnosis (MIP + Z3)](docs/examples/shift-scheduling.md):
|
|
198
|
-
- [E-Commerce Cart & Coupon Optimizer (Indicator MIP)](docs/examples/ecommerce-coupons.md):
|
|
199
|
-
- [Portfolio Optimization (QP)](docs/examples/portfolio-qp.md): The Markowitz mean-variance
|
|
200
|
-
- [
|
|
201
|
-
- [
|
|
202
|
-
- [
|
|
203
|
-
- [
|
|
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.
|
|
4
|
-
"description": "WaSHI:
|
|
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
|
|
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/
|
|
33
|
-
"types": "./dist/types/modeler/solvers/
|
|
34
|
-
"import": "./dist/browser/solvers/
|
|
35
|
-
"default": "./dist/browser/solvers/
|
|
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/
|
|
45
|
-
|
|
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",
|