@ohtaman/washi 0.8.0 → 0.8.2
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.md +32 -34
- package/dist/browser/{__vite-browser-external-rTVKos2U.js → solvers/highs-__vite-browser-external-Dn-83hnF.js} +1 -1
- package/dist/browser/{browser-runtime-AG5QFtKf.js → solvers/highs-browser-runtime-0Bgq5ksG.js} +1 -1
- package/dist/browser/{loader-i3FnqMes.js → solvers/highs-loader-BLY3wzDH.js} +25 -18
- package/dist/browser/{highs-worker.js → solvers/highs-worker.js} +1 -1
- package/dist/browser/solvers/highs.js +1414 -0
- package/dist/browser/washi.js +1090 -1473
- package/dist/browser/washi.min.js +4 -4
- package/dist/lib/solvers/glpk.js +34 -32
- package/dist/lib/{highs-node-runtime.js → solvers/highs-node-runtime.js} +1 -1
- package/dist/lib/solvers/highs.js +410 -0
- package/dist/lib/solvers/lp-writer-CLScMFbS.js +115 -0
- package/dist/lib/solvers/pumpkin-node-runtime.js +1 -1
- package/dist/lib/solvers/pumpkin-worker.js +1 -1
- package/dist/lib/solvers/pumpkin.js +247 -1146
- package/dist/lib/solvers/registry-CrYRRk9q.js +907 -0
- package/dist/lib/solvers/types-BGqPkxwu.js +12 -0
- package/dist/lib/solvers/z3.js +125 -123
- package/dist/lib/washi.js +2426 -1340
- package/dist/types/index.d.ts +1 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/modeler/index.d.ts +0 -1
- package/dist/types/modeler/index.d.ts.map +1 -1
- package/dist/types/modeler/model.d.ts +6 -7
- package/dist/types/modeler/model.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/registry.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 +34 -30
- 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 +25 -12
- package/docs/examples/shift-scheduling.md +27 -19
- package/docs/examples/smt-security.md +27 -12
- package/docs/examples/transportation.md +23 -13
- package/docs/examples/traveling-salesperson.md +34 -22
- package/docs/examples/unsat-core.md +27 -15
- package/docs/examples/vehicle-routing.md +74 -28
- package/docs/getting-started/ai-agents.md +129 -90
- package/docs/getting-started/coding-agents.md +60 -41
- package/docs/getting-started/cross-origin.md +27 -14
- package/docs/getting-started/index.md +23 -16
- package/docs/getting-started/runtimes.md +70 -40
- package/docs/guide/constraint-programming.md +74 -44
- package/docs/guide/constraints.md +71 -39
- package/docs/guide/decomposition.md +72 -42
- package/docs/guide/expressions.md +79 -48
- package/docs/guide/formulation-tips.md +46 -27
- package/docs/guide/objectives.md +55 -31
- package/docs/guide/unsat-core.md +56 -53
- package/docs/guide/variables.md +61 -28
- package/docs/solvers/custom-solver.md +155 -119
- package/docs/solvers/glpk.md +58 -17
- package/docs/solvers/highs.md +115 -43
- package/docs/solvers/index.md +33 -26
- package/docs/solvers/pumpkin.md +71 -63
- package/docs/solvers/z3.md +63 -25
- package/llms-full.txt +1623 -953
- package/llms.txt +125 -93
- package/package.json +29 -22
- package/skills/washi/SKILL.md +43 -22
- package/README.ja.md +0 -248
- package/README.zh-CN.md +0 -248
- package/dist/browser/solvers/pumpkin.min.js +0 -1
- package/dist/lib/registry-dx7x4e5c.js +0 -1694
- /package/dist/browser/{highs.wasm → solvers/highs.wasm} +0 -0
- /package/dist/browser/{highs.wasm.LICENSE → solvers/highs.wasm.LICENSE} +0 -0
- /package/dist/lib/{__vite-browser-external-oLchLuMx.js → solvers/__vite-browser-external-oLchLuMx.js} +0 -0
- /package/dist/lib/{highs-assets.js → solvers/highs-assets.js} +0 -0
- /package/dist/lib/{highs-browser-runtime.js → solvers/highs-browser-runtime.js} +0 -0
- /package/dist/lib/{highs-runtime.js → solvers/highs-runtime.js} +0 -0
- /package/dist/lib/{highs-worker-factory.js → solvers/highs-worker-factory.js} +0 -0
- /package/dist/lib/{highs-worker.js → solvers/highs-worker.js} +0 -0
- /package/dist/lib/{highs.wasm → solvers/highs.wasm} +0 -0
- /package/dist/lib/{highs.wasm.LICENSE → solvers/highs.wasm.LICENSE} +0 -0
- /package/dist/lib/{loader-CDpPXN_F.js → solvers/loader-CDpPXN_F.js} +0 -0
- /package/dist/lib/solvers/{pumpkin-loader-Ow74Fa1B.js → loader-Ow74Fa1B.js} +0 -0
- /package/dist/lib/{rolldown-runtime-DtPi1Y-2.js → solvers/rolldown-runtime-DtPi1Y-2.js} +0 -0
package/README.md
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
<picture>
|
|
3
|
-
<source media="(prefers-color-scheme: dark)" srcset="
|
|
4
|
-
<source media="(prefers-color-scheme: light)" srcset="
|
|
5
|
-
<img alt="WaSHI - Mathematical Optimization Modeler in TypeScript" src="
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://washi.ohtaman.dev/washi-header-dark.png">
|
|
4
|
+
<source media="(prefers-color-scheme: light)" srcset="https://washi.ohtaman.dev/washi-header-light.png">
|
|
5
|
+
<img alt="WaSHI - Mathematical Optimization Modeler in TypeScript" src="https://washi.ohtaman.dev/washi-header-light.png" width="420" />
|
|
6
6
|
</picture>
|
|
7
7
|
<p><strong>Mathematical Optimization Modeler in TypeScript</strong></p>
|
|
8
8
|
<p>
|
|
9
9
|
<em>Linear Programming (LP) • Mixed-Integer Programming (MIP) • Convex Quadratic Programming (QP) • Constraint Programming (CP) • SMT & Conflict Diagnosis</em>
|
|
10
10
|
</p>
|
|
11
11
|
<p>
|
|
12
|
-
<a href="
|
|
13
|
-
<a href="
|
|
14
|
-
<a href="
|
|
12
|
+
<a href="https://github.com/ohtaman/washi/blob/main/README.md">English</a> •
|
|
13
|
+
<a href="https://github.com/ohtaman/washi/blob/main/README-ja.md">日本語</a> •
|
|
14
|
+
<a href="https://github.com/ohtaman/washi/blob/main/README-zh-CN.md">简体中文</a>
|
|
15
15
|
</p>
|
|
16
16
|
<p>
|
|
17
17
|
<a href="https://www.npmjs.com/package/@ohtaman/washi"><img src="https://img.shields.io/npm/v/@ohtaman/washi?color=crimson&label=npm" alt="npm version" /></a>
|
|
18
18
|
<a href="https://github.com/ohtaman/washi/actions/workflows/distribution.yml"><img src="https://github.com/ohtaman/washi/actions/workflows/distribution.yml/badge.svg" alt="CI Status" /></a>
|
|
19
19
|
<a href="https://washi.ohtaman.dev/"><img src="https://img.shields.io/badge/docs-online-blue" alt="docs" /></a>
|
|
20
20
|
<a href="https://washi.ohtaman.dev/demo/"><img src="https://img.shields.io/badge/demo-playground-brightgreen" alt="live demo" /></a>
|
|
21
|
-
<a href="
|
|
21
|
+
<a href="https://github.com/ohtaman/washi/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-green" alt="license" /></a>
|
|
22
22
|
</p>
|
|
23
23
|
</div>
|
|
24
24
|
|
|
25
25
|
---
|
|
26
26
|
|
|
27
|
-
**WaSHI** (WebAssembly-backed, Solver-independent, High-level modeling Interface) is an algebraic modeler for mathematical optimization and constraint programming in TypeScript and JavaScript, inspired by Python's **PuLP**. Define variables, objectives, and constraints in application code, and solve them locally in Node.js or the browser using bundled **HiGHS** (default) and **Pumpkin** (
|
|
27
|
+
**WaSHI** (WebAssembly-backed, Solver-independent, High-level modeling Interface) is an algebraic modeler for mathematical optimization and constraint programming in TypeScript and JavaScript, inspired by Python's **PuLP**. Define variables, objectives, and constraints in application code, and solve them locally in Node.js or the browser using bundled **HiGHS** (default) and **Pumpkin** (`{ solver: "pumpkin" }`), or optional **Z3** and **GLPK** plugins.
|
|
28
28
|
|
|
29
29
|
## ✨ Key Features
|
|
30
30
|
|
|
31
31
|
- **Natural Algebraic Syntax**: Write expressions and constraints directly with `` expr`30 * ${x} + 50 * ${y} <= 40` ``, `sum`, and `dot`.
|
|
32
32
|
- **Runs in Node.js & Browsers**: Powered by WebAssembly—no Python service or native C/C++ build required.
|
|
33
|
-
- **Solver-Independent**: Use bundled zero-dependency **HiGHS** (LP/MIP/QP) and **Pumpkin** (CP
|
|
33
|
+
- **Solver-Independent**: Use bundled zero-dependency **HiGHS** (LP/MIP/QP) and **Pumpkin** (CP), optional **Z3** and **GLPK** plugins, or custom solver adapters.
|
|
34
34
|
- **Satisfiability & Conflict Diagnosis**: Check logical/arithmetic feasibility and pinpoint contradictory constraints when a model is infeasible.
|
|
35
35
|
- **Decomposition Methods**: Built-in support for Column Generation and Benders Decomposition on large-scale problems.
|
|
36
36
|
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
|
|
39
39
|
- **[Documentation](https://washi.ohtaman.dev/)**: Modeling guide, solver references, and deployment guides
|
|
40
40
|
- **[Interactive Showcase](https://washi.ohtaman.dev/showcase/) · [Browser Playground](https://washi.ohtaman.dev/demo/) · [Optimization N Exercises](https://washi.ohtaman.dev/exercises/)**: Try live optimization apps, practice interactive modeling workouts, and edit models in the browser
|
|
41
|
-
- **[Examples](https://washi.ohtaman.dev/examples/)**: Problem recipes and runnable Node.js / browser scripts ([`examples/`](examples/README.md))
|
|
42
|
-
- **[Agent Skill (`SKILL.md`)](skills/washi/SKILL.md) · [`llms.txt`](https://washi.ohtaman.dev/llms.txt) / [`llms-full.txt`](https://washi.ohtaman.dev/llms-full.txt)**: Workflow skill and machine-readable docs for AI coding agents
|
|
41
|
+
- **[Examples](https://washi.ohtaman.dev/examples/)**: Problem recipes and runnable Node.js / browser scripts ([`examples/`](https://github.com/ohtaman/washi/blob/main/examples/README.md))
|
|
42
|
+
- **[Agent Skill (`SKILL.md`)](https://github.com/ohtaman/washi/blob/main/skills/washi/SKILL.md) · [`llms.txt`](https://washi.ohtaman.dev/llms.txt) / [`llms-full.txt`](https://washi.ohtaman.dev/llms-full.txt)**: Workflow skill and machine-readable docs for AI coding agents
|
|
43
43
|
|
|
44
44
|
---
|
|
45
45
|
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
|
|
48
48
|
```bash
|
|
49
49
|
npm install @ohtaman/washi
|
|
50
|
-
# HiGHS (LP/MIP/QP) and Pumpkin (CP
|
|
50
|
+
# HiGHS (LP/MIP/QP, default) and Pumpkin (CP, { solver: "pumpkin" }) are bundled with zero extra dependencies or plugin imports
|
|
51
51
|
|
|
52
52
|
# Optional peer-dependency solver plugins
|
|
53
53
|
npm install z3-solver # For SMT logic & exact real/integer unsat core diagnosis
|
|
@@ -78,13 +78,13 @@ console.log(`Produce: x=${x.value}, y=${y.value} (Profit: $${m.objectiveValue})`
|
|
|
78
78
|
|
|
79
79
|
| Solver | License | Problem Classes | Primary Use Case | Setup |
|
|
80
80
|
| :--- | :--- | :--- | :--- | :--- |
|
|
81
|
-
| **[HiGHS](https://github.com/ERGO-Code/HiGHS)** | MIT | LP, MIP, Convex QP | Numerical optimization &
|
|
82
|
-
| **[Pumpkin](https://github.com/ConSol-Lab/Pumpkin)** | MIT | CP
|
|
81
|
+
| **[HiGHS](https://github.com/ERGO-Code/HiGHS)** | MIT | LP, MIP, Convex QP | Numerical optimization & conflict diagnosis (constraint relaxation) | Bundled default (zero deps, no extra import) |
|
|
82
|
+
| **[Pumpkin](https://github.com/ConSol-Lab/Pumpkin)** | MIT | CP (Lazy Clause Generation), Logic, Bounded Integer | Combinatorial scheduling & bounded-integer `unsatCore` | Bundled (`{ solver: "pumpkin" }`, zero deps, no extra import) |
|
|
83
83
|
| **[Z3](https://github.com/Z3Prover/z3)** | MIT | SMT, SAT, Logic, MIP | Logical rules, satisfiability & exact `unsatCore` | `npm install z3-solver` + `import "@ohtaman/washi/solvers/z3"` |
|
|
84
84
|
| **[GLPK](https://www.gnu.org/software/glpk/)** | GPL-3.0 | LP, MIP | Linear & mixed-integer optimization | `npm install glpk.js` + `import "@ohtaman/washi/solvers/glpk"` |
|
|
85
85
|
| **Mock** | MIT | — | Deterministic unit & integration testing | Built-in (`MockSolver`) |
|
|
86
86
|
|
|
87
|
-
|
|
87
|
+
Switch between bundled HiGHS (default) and Pumpkin with `{ solver: "pumpkin" }` out of the box, or pass `{ solver: "z3" }` / `{ solver: "glpk" }` after importing the corresponding optional plugin. Solver-specific classes and loader helpers (`HighsSolver`, `setHighsWasmUrl`, `PumpkinSolver`, `setPumpkinWasmUrl`, etc.) live under `@ohtaman/washi/solvers/{highs,pumpkin,z3,glpk}`.
|
|
88
88
|
|
|
89
89
|
---
|
|
90
90
|
|
|
@@ -139,11 +139,10 @@ console.log(`Tech: ${x.value?.toFixed(2)}, Bonds: ${y.value?.toFixed(2)}`);
|
|
|
139
139
|
|
|
140
140
|
### 3. Constraint Programming & Disjunctive Scheduling (Pumpkin)
|
|
141
141
|
|
|
142
|
-
Use bundled **Pumpkin** (
|
|
142
|
+
Use bundled **Pumpkin** (`{ solver: "pumpkin" }`) for bounded integer scheduling and CP global constraints (`disjoint`, `distinct`, `cumulative`, `allowed`) with zero external dependencies or extra imports:
|
|
143
143
|
|
|
144
144
|
```ts
|
|
145
145
|
import { Model, expr, disjoint, distinct, minimize } from "@ohtaman/washi";
|
|
146
|
-
import "@ohtaman/washi/solvers/pumpkin";
|
|
147
146
|
|
|
148
147
|
const m = new Model("WorkshopCP", { solver: "pumpkin" });
|
|
149
148
|
const start = m.integer(["cut", "weld", "paint"] as const, { lb: 0, ub: 20, prefix: "start" });
|
|
@@ -169,14 +168,14 @@ console.log(`Makespan: ${m.objectiveValue}h (paint starts at ${start.paint.value
|
|
|
169
168
|
### 4. Logic & Conflict Diagnosis (`m.check`)
|
|
170
169
|
|
|
171
170
|
Express logical implications and diagnose why a model is infeasible:
|
|
172
|
-
- **HiGHS (default)**:
|
|
173
|
-
- **Pumpkin (bundled)**: Extracts
|
|
171
|
+
- **HiGHS (default)**: Identifies constraints whose relaxation restores feasibility (`res.conflicts`).
|
|
172
|
+
- **Pumpkin (bundled)**: Extracts an exact **unsatisfiable core** (`res.unsatCore` / `res.conflicts`) for bounded integer and boolean models.
|
|
174
173
|
- **Z3**: Extracts an exact SMT **unsatisfiable core** (`res.unsatCore` / `res.conflicts`) including continuous and rational arithmetic.
|
|
175
174
|
|
|
176
175
|
```ts
|
|
177
176
|
import { Model, implies, expr } from "@ohtaman/washi";
|
|
178
|
-
//
|
|
179
|
-
// import "@ohtaman/washi/solvers/z3";
|
|
177
|
+
// Pass { solver: "pumpkin" } for bundled bounded-int/bool exact unsatCore (no extra import)
|
|
178
|
+
// import "@ohtaman/washi/solvers/z3"; // Optional: exact SMT unsatCore including Continuous vars
|
|
180
179
|
|
|
181
180
|
const m = new Model("StaffingRules");
|
|
182
181
|
const engineers = m.integer("engineers", { lb: 0, ub: 20 });
|
|
@@ -198,35 +197,34 @@ console.log(res.conflicts); // HiGHS: ["rush_required"]
|
|
|
198
197
|
|
|
199
198
|
## 🌐 Browser & Web Worker Usage
|
|
200
199
|
|
|
201
|
-
- **Bundlers (Vite / webpack 5)**: `import { Model } from "@ohtaman/washi"` works out of the box.
|
|
202
|
-
- **Standalone ESM / Script Tag / CDN**: Serve `dist/browser/` (including `highs.wasm`, `solvers/pumpkin.wasm`, and worker chunks) or load from a CDN.
|
|
200
|
+
- **Bundlers (Vite / webpack 5)**: `import { Model } from "@ohtaman/washi"` works out of the box. On standard browser origins (`http://` / `https://`), **HiGHS** and **Pumpkin** run in dedicated Web Workers by default (opaque origins such as `file://` default to `{ useWorker: false }`, and you can pass `{ useWorker: false }` explicitly for main-thread execution).
|
|
201
|
+
- **Standalone ESM / Script Tag / CDN**: Serve `dist/browser/` (including `solvers/highs.wasm`, `solvers/pumpkin.wasm`, and worker chunks) or load from a CDN. `washi.js` and `washi.min.js` both include HiGHS and Pumpkin out of the box.
|
|
203
202
|
|
|
204
203
|
```html
|
|
205
|
-
<!-- Browser ESM -->
|
|
204
|
+
<!-- Browser ESM (includes both HiGHS and Pumpkin) -->
|
|
206
205
|
<script type="module">
|
|
207
206
|
import { Model } from "./washi/washi.js";
|
|
208
|
-
//
|
|
209
|
-
// import "./washi/solvers/pumpkin.js"; // Bundled CP/LCG (zero COOP/COEP)
|
|
207
|
+
// Optional solver plugins:
|
|
210
208
|
// import "./washi/solvers/glpk.js"; // Optional GLPK plugin
|
|
211
|
-
// import "./washi/solvers/z3.js"; // Optional Z3 plugin (
|
|
209
|
+
// import "./washi/solvers/z3.js"; // Optional Z3 plugin (see note below)
|
|
212
210
|
const m = new Model();
|
|
213
211
|
await m.solve();
|
|
214
212
|
</script>
|
|
215
213
|
|
|
216
|
-
<!-- Classic Script / CodePen (exposes global Washi) -->
|
|
214
|
+
<!-- Classic Script / CodePen (exposes global Washi with both HiGHS and Pumpkin) -->
|
|
217
215
|
<script src="https://cdn.jsdelivr.net/npm/@ohtaman/washi/dist/browser/washi.min.js"></script>
|
|
218
216
|
<!-- Optional solver plugin scripts (auto-register on window.Washi): -->
|
|
219
|
-
<!-- <script src="https://cdn.jsdelivr.net/npm/@ohtaman/washi/dist/browser/solvers/
|
|
217
|
+
<!-- <script src="https://cdn.jsdelivr.net/npm/@ohtaman/washi/dist/browser/solvers/glpk.min.js"></script> -->
|
|
220
218
|
```
|
|
221
219
|
|
|
222
220
|
> [!NOTE]
|
|
223
|
-
> **Z3 in the Browser**: Because Z3's WebAssembly build uses `SharedArrayBuffer`, browsers require Cross-Origin Isolation (`
|
|
221
|
+
> **Z3 in the Browser**: Because Z3's WebAssembly build uses `SharedArrayBuffer`, browsers require a **Secure Context** (`HTTPS` or `localhost`) and Cross-Origin Isolation headers (`Cross-Origin-Opener-Policy: same-origin` and `Cross-Origin-Embedder-Policy: require-corp`). See the [Cross-Origin Isolation Guide](https://washi.ohtaman.dev/getting-started/cross-origin) and [`examples/distribution/`](https://github.com/ohtaman/washi/blob/main/examples/distribution/README.md). **HiGHS**, **Pumpkin**, and **GLPK** work without Cross-Origin Isolation headers.
|
|
224
222
|
|
|
225
223
|
---
|
|
226
224
|
|
|
227
225
|
## 🤝 Contributing
|
|
228
226
|
|
|
229
|
-
See [CONTRIBUTING.md](
|
|
227
|
+
See [CONTRIBUTING.md](https://github.com/ohtaman/washi/blob/main/CONTRIBUTING.md) for local development setup, running tests and benchmarks, rebuilding WebAssembly assets, and the release workflow.
|
|
230
228
|
|
|
231
229
|
---
|
|
232
230
|
|
|
@@ -235,7 +233,7 @@ See [CONTRIBUTING.md](./CONTRIBUTING.md) for local development setup, running te
|
|
|
235
233
|
WaSHI stands on the shoulders of the open-source mathematical optimization and automated reasoning communities:
|
|
236
234
|
|
|
237
235
|
- **[HiGHS](https://highs.dev/)** ([`ERGO-Code/HiGHS`](https://github.com/ERGO-Code/HiGHS)) — High-performance open-source optimization software for LP, MIP, and Convex QP initiated at the University of Edinburgh by Julian Hall, Qi Huangfu, Ivet Galabova, Leona Gottwald, Michael Feldmeier, and contributors, which powers WaSHI's built-in default solver (*Huangfu & Hall, Mathematical Programming Computation, 2018*, [DOI: 10.1007/s12532-017-0130-5](https://doi.org/10.1007/s12532-017-0130-5)).
|
|
238
|
-
- **[Pumpkin](https://github.com/ConSol-Lab/Pumpkin)** — Lazy Clause Generation (LCG) constraint programming solver developed in Rust by ConSol Lab (TU Delft), powering WaSHI's bundled CP
|
|
236
|
+
- **[Pumpkin](https://github.com/ConSol-Lab/Pumpkin)** — Lazy Clause Generation (LCG) constraint programming solver developed in Rust by ConSol Lab (TU Delft), powering WaSHI's bundled CP and `unsatCore` engine.
|
|
239
237
|
- **[Z3 Theorem Prover](https://github.com/Z3Prover/z3)** ([`z3-solver`](https://www.npmjs.com/package/z3-solver)) — Developed at Microsoft Research, powering WaSHI's optional SMT satisfiability and exact `unsatCore` conflict diagnosis plugin.
|
|
240
238
|
- **[GLPK](https://www.gnu.org/software/glpk/) & [`glpk.js`](https://github.com/jvail/glpk.js)** — Powering WaSHI's optional GPL-3.0 LP/MIP solver plugin.
|
|
241
239
|
- **[PuLP](https://github.com/coin-or/pulp)** — Inspiring WaSHI's declarative algebraic modeling ergonomics.
|
|
@@ -244,5 +242,5 @@ WaSHI stands on the shoulders of the open-source mathematical optimization and a
|
|
|
244
242
|
|
|
245
243
|
## 📄 License
|
|
246
244
|
|
|
247
|
-
- **`@ohtaman/washi`**: [MIT License](
|
|
248
|
-
- **Bundled / Optional Engines**: HiGHS (MIT), Pumpkin (MIT), Z3 (MIT), GLPK (GPL-3.0). See [THIRD_PARTY_LICENSES.md](
|
|
245
|
+
- **`@ohtaman/washi`**: [MIT License](https://github.com/ohtaman/washi/blob/main/LICENSE)
|
|
246
|
+
- **Bundled / Optional Engines**: HiGHS (MIT), Pumpkin (MIT), Z3 (MIT), GLPK (GPL-3.0). See [THIRD_PARTY_LICENSES.md](https://github.com/ohtaman/washi/blob/main/THIRD_PARTY_LICENSES.md) for full details.
|
|
@@ -441,39 +441,46 @@ function h(e = {}) {
|
|
|
441
441
|
if (e.objectiveOffset !== void 0 && (typeof e.objectiveOffset != "number" || !Number.isFinite(e.objectiveOffset))) throw Error(`Invalid HiGHS option "objectiveOffset" (${String(e.objectiveOffset)}): expected a finite number.`);
|
|
442
442
|
if (e.wasmUrl !== void 0 && e.wasmUrl !== null && (typeof e.wasmUrl != "string" || e.wasmUrl === "")) throw Error("Invalid HiGHS option \"wasmUrl\": expected a non-empty string or null.");
|
|
443
443
|
}
|
|
444
|
-
var g = null, _ = null, v = null;
|
|
445
|
-
function
|
|
446
|
-
|
|
444
|
+
var g = null, _ = null, v = null, y = null;
|
|
445
|
+
function b(e) {
|
|
446
|
+
y = e, g = null, _ = null, v = null;
|
|
447
447
|
}
|
|
448
|
-
function
|
|
449
|
-
return
|
|
448
|
+
function x() {
|
|
449
|
+
return y;
|
|
450
450
|
}
|
|
451
|
-
|
|
452
|
-
return e
|
|
451
|
+
function S(e) {
|
|
452
|
+
return e.length >= 4 && e[0] === 0 && e[1] === 97 && e[2] === 115 && e[3] === 109;
|
|
453
453
|
}
|
|
454
|
-
async function
|
|
455
|
-
|
|
454
|
+
async function C(e) {
|
|
455
|
+
return e || y || n();
|
|
456
|
+
}
|
|
457
|
+
async function w(e = {}) {
|
|
458
|
+
let t = await C(e.wasmUrl);
|
|
456
459
|
return {
|
|
457
460
|
isNode: !1,
|
|
458
461
|
wasmUrl: t,
|
|
459
462
|
key: t ?? "node"
|
|
460
463
|
};
|
|
461
464
|
}
|
|
462
|
-
async function
|
|
463
|
-
let {
|
|
465
|
+
async function T(e = {}) {
|
|
466
|
+
let { key: t } = await w(e);
|
|
467
|
+
return v === t;
|
|
468
|
+
}
|
|
469
|
+
async function E(e = {}) {
|
|
470
|
+
let { isNode: t, wasmUrl: n, key: i } = await w(e);
|
|
464
471
|
if (g && _ === i) return g;
|
|
465
|
-
_ = i;
|
|
472
|
+
_ = i, v = null;
|
|
466
473
|
let a = null;
|
|
467
474
|
return a = (async () => {
|
|
468
|
-
let e = t ? await r() : (await import("./browser-runtime-
|
|
475
|
+
let e = t ? await r() : (await import("./highs-browser-runtime-0Bgq5ksG.js")).default;
|
|
469
476
|
return t ? await e() : await e({ locateFile: (e) => e.endsWith(".wasm") ? n : e });
|
|
470
|
-
})().then((e) => e).catch((e) => {
|
|
471
|
-
g === a && (g = null, _ = null);
|
|
477
|
+
})().then((e) => (g === a && (v = i), e)).catch((e) => {
|
|
478
|
+
g === a && (g = null, _ = null, v = null);
|
|
472
479
|
let t = e instanceof Error ? e.message : String(e);
|
|
473
480
|
throw Error(`[WaSHI] Failed to initialize HiGHS${n ? ` from "${n}"` : ""}. Deploy the package's WASM asset or explicitly set wasmUrl; no CDN fallback is attempted. ${t}`, { cause: e });
|
|
474
481
|
}), g = a, a;
|
|
475
482
|
}
|
|
476
|
-
async function
|
|
483
|
+
async function D(e, t = {}) {
|
|
477
484
|
if (h(t), t.signal?.aborted) return {
|
|
478
485
|
result: {
|
|
479
486
|
Status: "Interrupted",
|
|
@@ -485,7 +492,7 @@ async function w(e, t = {}) {
|
|
|
485
492
|
},
|
|
486
493
|
runTime: 0
|
|
487
494
|
};
|
|
488
|
-
let n = await
|
|
495
|
+
let n = await E(t);
|
|
489
496
|
if (t.signal?.aborted) return {
|
|
490
497
|
result: {
|
|
491
498
|
Status: "Interrupted",
|
|
@@ -674,4 +681,4 @@ async function w(e, t = {}) {
|
|
|
674
681
|
};
|
|
675
682
|
}
|
|
676
683
|
//#endregion
|
|
677
|
-
export {
|
|
684
|
+
export { n as _, C as a, h as c, f as d, a as f, t as g, l as h, S as i, c as l, o as m, x as n, b as o, d as p, T as r, D as s, E as t, s as u };
|