@ohtaman/washi 0.0.0-stage → 0.1.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 (65) hide show
  1. package/LICENSE +21 -0
  2. package/README.ja.md +381 -0
  3. package/README.md +380 -2
  4. package/README.zh-CN.md +381 -0
  5. package/THIRD_PARTY_LICENSES.md +83 -0
  6. package/dist/lib/assets/highs-worker-DeDWU6KI.js +3 -0
  7. package/dist/lib/demo/highs.wasm +0 -0
  8. package/dist/lib/glpk-BC32ZaPG.js +126 -0
  9. package/dist/lib/highs.wasm +0 -0
  10. package/dist/lib/highs.wasm.LICENSE +22 -0
  11. package/dist/lib/solvers/glpk.js +2 -0
  12. package/dist/lib/solvers/z3.js +2 -0
  13. package/dist/lib/washi-logo.png +0 -0
  14. package/dist/lib/washi-logo.svg +70 -0
  15. package/dist/lib/washi.js +908 -0
  16. package/dist/lib/z3-C8g-PtmP.js +582 -0
  17. package/dist/types/glpk-loader.d.ts +8 -0
  18. package/dist/types/glpk-loader.d.ts.map +1 -0
  19. package/dist/types/highs-loader.d.ts +55 -0
  20. package/dist/types/highs-loader.d.ts.map +1 -0
  21. package/dist/types/highs-worker-client.d.ts +12 -0
  22. package/dist/types/highs-worker-client.d.ts.map +1 -0
  23. package/dist/types/highs-worker.d.ts +2 -0
  24. package/dist/types/highs-worker.d.ts.map +1 -0
  25. package/dist/types/index.d.ts +14 -0
  26. package/dist/types/index.d.ts.map +1 -0
  27. package/dist/types/modeler/boolean-expr.d.ts +38 -0
  28. package/dist/types/modeler/boolean-expr.d.ts.map +1 -0
  29. package/dist/types/modeler/constraint.d.ts +28 -0
  30. package/dist/types/modeler/constraint.d.ts.map +1 -0
  31. package/dist/types/modeler/expression.d.ts +79 -0
  32. package/dist/types/modeler/expression.d.ts.map +1 -0
  33. package/dist/types/modeler/index.d.ts +14 -0
  34. package/dist/types/modeler/index.d.ts.map +1 -0
  35. package/dist/types/modeler/lp-writer.d.ts +30 -0
  36. package/dist/types/modeler/lp-writer.d.ts.map +1 -0
  37. package/dist/types/modeler/mip-compat.d.ts +43 -0
  38. package/dist/types/modeler/mip-compat.d.ts.map +1 -0
  39. package/dist/types/modeler/model.d.ts +156 -0
  40. package/dist/types/modeler/model.d.ts.map +1 -0
  41. package/dist/types/modeler/parser.d.ts +27 -0
  42. package/dist/types/modeler/parser.d.ts.map +1 -0
  43. package/dist/types/modeler/pulp-compat.d.ts +67 -0
  44. package/dist/types/modeler/pulp-compat.d.ts.map +1 -0
  45. package/dist/types/modeler/quad-expr.d.ts +55 -0
  46. package/dist/types/modeler/quad-expr.d.ts.map +1 -0
  47. package/dist/types/modeler/solvers/glpk.d.ts +22 -0
  48. package/dist/types/modeler/solvers/glpk.d.ts.map +1 -0
  49. package/dist/types/modeler/solvers/highs.d.ts +26 -0
  50. package/dist/types/modeler/solvers/highs.d.ts.map +1 -0
  51. package/dist/types/modeler/solvers/index.d.ts +7 -0
  52. package/dist/types/modeler/solvers/index.d.ts.map +1 -0
  53. package/dist/types/modeler/solvers/mock.d.ts +25 -0
  54. package/dist/types/modeler/solvers/mock.d.ts.map +1 -0
  55. package/dist/types/modeler/solvers/registry.d.ts +20 -0
  56. package/dist/types/modeler/solvers/registry.d.ts.map +1 -0
  57. package/dist/types/modeler/solvers/types.d.ts +86 -0
  58. package/dist/types/modeler/solvers/types.d.ts.map +1 -0
  59. package/dist/types/modeler/solvers/z3.d.ts +37 -0
  60. package/dist/types/modeler/solvers/z3.d.ts.map +1 -0
  61. package/dist/types/modeler/types.d.ts +27 -0
  62. package/dist/types/modeler/types.d.ts.map +1 -0
  63. package/dist/types/modeler/variable.d.ts +52 -0
  64. package/dist/types/modeler/variable.d.ts.map +1 -0
  65. package/package.json +98 -4
@@ -0,0 +1,381 @@
1
+ <div align="center">
2
+ <picture>
3
+ <source media="(prefers-color-scheme: dark)" srcset="./assets/washi-header-dark.png">
4
+ <source media="(prefers-color-scheme: light)" srcset="./assets/washi-header-light.png">
5
+ <img alt="WaSHI - 面向 TypeScript 与 JavaScript 的数学规划与代数建模库" src="./assets/washi-header-light.png" width="420" />
6
+ </picture>
7
+ <p><strong>面向 TypeScript 与 JavaScript 的直观数学规划与代数建模库</strong></p>
8
+ <p>
9
+ <em>线性规划 (LP) • 混合整数规划 (MIP) • 凸二次规划 (QP) • SMT逻辑约束与冲突诊断</em>
10
+ </p>
11
+ <p>
12
+ <a href="./README.md">English</a> •
13
+ <a href="./README.ja.md">日本語</a> •
14
+ <a href="./README.zh-CN.md">简体中文</a>
15
+ </p>
16
+ <p>
17
+ <a href="https://ohtaman.github.io/washi/"><img src="https://img.shields.io/badge/docs-online-blue" alt="docs" /></a>
18
+ <a href="https://ohtaman.github.io/washi/demo/"><img src="https://img.shields.io/badge/demo-playground-brightgreen" alt="live demo" /></a>
19
+ <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>
20
+ <a href="https://bundlephobia.com/package/@ohtaman/washi"><img src="https://img.shields.io/badge/bundle%20size-7.2%20kB%20(gzip)-blue" alt="bundle size" /></a>
21
+ <a href="./LICENSE"><img src="https://img.shields.io/badge/license-MIT-green" alt="license" /></a>
22
+ <img src="https://img.shields.io/badge/types-TypeScript-blue" alt="TypeScript types" />
23
+ <img src="https://img.shields.io/badge/tests-120%2B%20passing-brightgreen" alt="tests" />
24
+ </p>
25
+ </div>
26
+
27
+ ---
28
+
29
+ **WaSHI** 是一个高层代数建模库,将 Python **PuLP** 与 Julia **JuMP** 的优雅表现力引入现代 TypeScript / JavaScript 生态系统。你可以直接使用符合数学直觉的代数公式编写数学模型,并在 Node.js、现代浏览器、Bun、Deno 及 Next.js 中秒级求解——完全依托 WebAssembly 求解器(**HiGHS**、**Z3**、**GLPK**),无需任何本地 C++ 编译环境。
30
+
31
+ ```ts
32
+ import { Model, expr, c } from "@ohtaman/washi";
33
+
34
+ const m = new Model({ sense: "Maximize" });
35
+ const x = m.addVar({ type: "Integer", lb: 0 });
36
+ const y = m.addVar({ type: "Integer", lb: 0 });
37
+
38
+ m.maximize(expr`30 * ${x} + 50 * ${y}`);
39
+ m.addConstraint(c`${x} + 2 * ${y} <= 40`, "wood_limit");
40
+ m.addConstraint(c`2 * ${x} + ${y} <= 50`, "labor_limit");
41
+
42
+ await m.solve();
43
+ console.log(`生产计划: x=${x.value}, y=${y.value} (最大利润: $${m.objectiveValue})`);
44
+ ```
45
+
46
+ ---
47
+
48
+ ## 🎯 为什么选择 WaSHI?
49
+
50
+ 1. 🌐 **100% 客户端运行与零服务器成本**:直接在用户的浏览器、边缘节点(Edge Worker)或 Electron 桌面端运行工业级优化。后端服务器运维成本为零,支持离线运行,且机密业务数据(如排班表、成本数据)永不离开客户端。
51
+ 2. 📦 **零依赖・单一包分发**:告别 Python 环境配置与繁重的跨平台 C/C++ 原生求解器编译绑定。只需 `npm install @ohtaman/washi`,包括 WebAssembly 求解器在内的所有组件即可开箱即用。
52
+ 3. ✍️ **极简现代代数建模 DX(兼容 PuLP / python-mip)**:无需编写晦涩低级的矩阵索引。使用直观的模板字面量(`c`${x} + 2 * ${y} <= 40``)或熟悉的 Python 风格抽象(`LpProblem`, `lpSum`),像在草稿纸上写公式一样自然。
53
+ 4. 🔄 **统一多求解器接口(HiGHS / Z3 / GLPK)**:模型代码一次编写,即可通过统一 API 自由切换:擅长工业级 MIP/QP 的 **HiGHS**、擅长逻辑求解与冲突分析的 **Z3**,以及经典学术求解器 **GLPK**。
54
+ 5. 🔍 **不可行模型(Infeasible)冲突根因诊断**:当业务规则出现矛盾导致无解时,可通过 Z3 引擎快速定位并提取冲突约束的最小子集(Unsat Core)。
55
+ 6. ⚡ **WebAssembly 原生工业级大规模性能**:搭载 $O(N)$ 线性时间高速表达式构建器,仅需约 100ms 即可构建 20,000+ 变量的大规模 MIP,并在浏览器 WebAssembly 中由 HiGHS 在约 15 秒内高效求解。
56
+
57
+ ---
58
+
59
+ ## ⚡ 求解器矩阵
60
+
61
+ | 求解器 | 核心许可证 | 支持的问题类型 | 最佳应用场景 | 在 WaSHI 中的提供方式 |
62
+ | :--- | :--- | :--- | :--- | :--- |
63
+ | **HiGHS** | **MIT** | **LP, MIP, 凸QP** | 工业级生产排程、运筹规划、金融组合优化 | **内置默认**(零配置) |
64
+ | **Z3** | **MIT** | **SMT, SAT, 命题逻辑, MIP** | 业务规则验证、约束冲突诊断 (`unsatCore`)、规则引擎 | 可选插件 (`@ohtaman/washi/solvers/z3`) |
65
+ | **GLPK** | **GPL-3.0** | **LP, MIP** | 学术基准测试、存量 GLPK 模型迁移 | 可选插件 (`@ohtaman/washi/solvers/glpk`) |
66
+ | **Mock** | **MIT** | *任意* | CI/CD 环境下无需加载 WASM 的极速单元测试 | 内置 |
67
+
68
+ ---
69
+
70
+ ## 📦 安装
71
+
72
+ ```bash
73
+ # npm
74
+ npm install @ohtaman/washi
75
+
76
+ # pnpm
77
+ pnpm add @ohtaman/washi
78
+
79
+ # yarn
80
+ yarn add @ohtaman/washi
81
+
82
+ # bun
83
+ bun add @ohtaman/washi
84
+ ```
85
+
86
+ *(可选)* 若需使用 Z3 或 GLPK 求解器,可按需安装对应依赖包:
87
+
88
+ ```bash
89
+ npm install z3-solver # 用于 SMT 与冲突诊断
90
+ npm install glpk.js # 用于 GLPK 求解器 (GPL-3.0)
91
+ ```
92
+
93
+ ---
94
+
95
+ ## 🚀 快速上手指南
96
+
97
+ ### 1. 混合整数线性规划 (MIP: 生产计划问题)
98
+
99
+ 在有限资源约束下实现利润最大化:
100
+
101
+ ```ts
102
+ import { Model, c, expr } from "@ohtaman/washi";
103
+
104
+ const m = new Model({ name: "FactoryPlanning", sense: "Maximize" });
105
+
106
+ // 决策变量(非负整数)
107
+ const chairs = m.addVar({ name: "chairs", type: "Integer", lb: 0 });
108
+ const tables = m.addVar({ name: "tables", type: "Integer", lb: 0 });
109
+
110
+ // 借助标签模板字面量自然表达目标函数与约束
111
+ m.maximize(expr`30 * ${chairs} + 50 * ${tables}`);
112
+ m.addConstraint(c`${chairs} + 2 * ${tables} <= 40`, "wood_limit");
113
+ m.addConstraint(c`2 * ${chairs} + ${tables} <= 50`, "labor_limit");
114
+
115
+ // 使用默认的 HiGHS WASM 引擎求解
116
+ const status = await m.solve();
117
+
118
+ console.log(`求解状态: ${status}`); // "Optimal"
119
+ console.log(`最大利润: $${m.objectiveValue}`); // 1100
120
+ console.log(`生产量: 椅子=${chairs.value}, 桌子=${tables.value}`); // 椅子 20, 桌子 10
121
+ ```
122
+
123
+ #### 🗂 多维变量网格 (`addVars`)
124
+
125
+ 一行代码声明变量字典或多维变量矩阵(类似于 PuLP 的 `LpVariable.dicts`):
126
+
127
+ ```ts
128
+ // 1D 字典形式的布尔变量
129
+ const openCity = m.addVars(["Tokyo", "Osaka", "Nagoya"], { type: "Binary" });
130
+
131
+ // 2D 运输量矩阵: [工厂] x [门店]
132
+ const flow = m.addVars(["F1", "F2"], ["StoreA", "StoreB"], { lb: 0 });
133
+
134
+ // 2D 网格坐标 (例如 8x8 棋盘)
135
+ const board = m.addVars(8, 8, { type: "Binary", prefix: "queen" });
136
+ ```
137
+
138
+ #### 🔀 Big-M 指示约束 (`addIndicator`)
139
+
140
+ 直接表达条件激活与固定成本逻辑,无需手动进行繁琐的 Big-M 代数推导:
141
+
142
+ ```ts
143
+ // "若工厂关闭 (openCity['Tokyo'] == 0),则产量 flow 必须为 0"
144
+ m.addIndicator(openCity["Tokyo"], flow["F1"]["StoreA"].le(0), {
145
+ activeValue: 0,
146
+ M: 1000,
147
+ });
148
+ ```
149
+
150
+ ---
151
+
152
+ ### 2. 投资组合风险最小化 (凸二次规划: QP)
153
+
154
+ 在满足预期收益与预算约束的前提下,基于协方差矩阵最小化投资组合风险:
155
+
156
+ ```ts
157
+ import { Model, QuadExpr, sum } from "@ohtaman/washi";
158
+
159
+ const m = new Model({ name: "MarkowitzPortfolio", sense: "Minimize" });
160
+ const assets = ["Tech", "Bonds", "RealEstate"];
161
+ const returns = [0.14, 0.04, 0.08];
162
+
163
+ // 决策变量: 各资产投资权重 (0.0 ~ 1.0)
164
+ const w = assets.map((a) => m.addVar({ name: `w_${a}`, lb: 0, ub: 1 }));
165
+
166
+ // 1. 预算约束: 资金分配总额 100%
167
+ m.addConstraint(sum(w).eq(1.0), "budget");
168
+
169
+ // 2. 目标回报率: 组合最低回报率 >= 8.5%
170
+ m.addConstraint(sum(w.map((v, i) => v.mul(returns[i]))).ge(0.085), "min_return");
171
+
172
+ // 3. 资产协方差矩阵 (风险与相关性)
173
+ const cov = [
174
+ [0.040, 0.002, 0.015],
175
+ [0.002, 0.005, 0.002],
176
+ [0.015, 0.002, 0.025],
177
+ ];
178
+
179
+ // 二次目标函数: w^T * Cov * w
180
+ let risk = new QuadExpr();
181
+ for (let i = 0; i < assets.length; i++) {
182
+ for (let j = 0; j < assets.length; j++) {
183
+ risk = risk.add(w[i].mul(w[j]).mul(cov[i][j]));
184
+ }
185
+ }
186
+ m.minimize(risk);
187
+
188
+ await m.solve();
189
+ console.log(`最小方差: ${m.objectiveValue?.toFixed(6)}`);
190
+ assets.forEach((name, i) => {
191
+ console.log(` ${name}: ${((w[i].value || 0) * 100).toFixed(2)}%`);
192
+ });
193
+ ```
194
+
195
+ ---
196
+
197
+ ### 3. SMT 逻辑与规则引擎 (集成 Z3)
198
+
199
+ 原生支持布尔命题变量(`BoolVar`)、逻辑连接词(`and`, `or`, `implies`, `not`, `xor`)与数值算术约束的混合表达:
200
+
201
+ ```ts
202
+ import { Model, not } from "@ohtaman/washi";
203
+
204
+ const m = new Model({ name: "SmartSecurityRules" });
205
+
206
+ const isNight = m.addBoolVar("isNight");
207
+ const motion = m.addBoolVar("motion");
208
+ const alarm = m.addBoolVar("alarm");
209
+ const siren = m.addBoolVar("siren");
210
+ const lux = m.addVar({ name: "lux", type: "Integer", lb: 0 });
211
+
212
+ // 规则定义
213
+ m.addConstraint(lux.le(50).implies(isNight), "dark_implies_night");
214
+ m.addConstraint(motion.and(isNight).and(alarm).implies(siren), "alarm_rule");
215
+
216
+ // 传感器当前输入数据
217
+ m.addConstraint(lux.le(10), "sensor_dark");
218
+ m.addConstraint(motion, "sensor_motion");
219
+ m.addConstraint(alarm, "alarm_on");
220
+
221
+ // 无目标函数直接判定可满足性 (SAT)
222
+ const res = await m.check({ solver: "z3" });
223
+
224
+ console.log(`系统状态满足? ${res.status === "Sat"}`); // true
225
+ console.log(`警报响起? ${m.values.get("siren")}`); // true
226
+ ```
227
+
228
+ ---
229
+
230
+ ### 4. 约束冲突根因诊断 (`unsatCore`)
231
+
232
+ 当规则或约束之间存在矛盾时,Z3 能够精准指出引发冲突的**最小冲突约束子集**(需使用 Z3):
233
+
234
+ ```ts
235
+ import { Model } from "@ohtaman/washi";
236
+ import "@ohtaman/washi/solvers/z3";
237
+
238
+ const m = new Model({ name: "ConflictDiagnosis", solver: "z3" });
239
+ const engineers = m.addVar({ name: "engineers", type: "Integer", lb: 0, ub: 20 });
240
+ const budget = m.addVar({ name: "budget", type: "Continuous", lb: 0, ub: 100000 });
241
+ const rushDelivery = m.addBoolVar("rushDelivery");
242
+
243
+ // 规则 1: 每位工程师成本 $8,000
244
+ m.addConstraint(engineers.mul(8000).le(budget), "budget_limit");
245
+
246
+ // 规则 2: 客户要求加急交付
247
+ m.addConstraint(rushDelivery, "rush_required");
248
+
249
+ // 规则 3: 加急交付需至少配备 8 名工程师
250
+ m.addConstraint(rushDelivery.implies(engineers.ge(8)), "rush_staffing_rule");
251
+
252
+ // 规则 4: 董事会严格预算上限 $50,000 (冲突点: 8人 * $8,000 = $64,000 > $50,000!)
253
+ m.addConstraint(budget.le(50000), "strict_board_budget_cap");
254
+
255
+ // 规则 5: 最低 1 名员工用工底线(无关规则)
256
+ m.addConstraint(engineers.ge(1), "minimum_one_employee");
257
+
258
+ const res = await m.check({ solver: "z3" });
259
+
260
+ console.log(`求解状态: ${res.status}`); // "Unsat"
261
+ console.log("冲突约束子集:", res.unsatCore);
262
+ // 输出: ["budget_limit", "rush_required", "rush_staffing_rule", "strict_board_budget_cap"]
263
+ // 注:无关的 "minimum_one_employee" 被准确排除在外!
264
+ ```
265
+
266
+ ---
267
+
268
+ ### 5. Python PuLP 兼容层
269
+
270
+ 若你已有 Python PuLP 代码资产,可零摩擦迁移:
271
+
272
+ ```ts
273
+ import {
274
+ LpProblem,
275
+ LpVariable,
276
+ LpMaximize,
277
+ LpInteger,
278
+ HiGHS,
279
+ value,
280
+ } from "@ohtaman/washi";
281
+
282
+ const prob = new LpProblem("PuLPDemo", LpMaximize);
283
+
284
+ const x = new LpVariable("x", 0, undefined, LpInteger);
285
+ const y = new LpVariable("y", 0, undefined, LpInteger);
286
+
287
+ // 等同于 PuLP 中的 += 语法
288
+ prob.add(x.mul(30).add(y.mul(50)));
289
+ prob.add(x.add(y.mul(2)).le(40));
290
+ prob.add(x.mul(2).add(y).le(50));
291
+
292
+ await prob.solve(new HiGHS());
293
+
294
+ console.log(`状态: ${prob.status}`);
295
+ console.log(`目标函数值: ${value(prob.objective)}`);
296
+ console.log(`x = ${value(x)}, y = ${value(y)}`);
297
+ ```
298
+
299
+ ---
300
+
301
+ ## 🌐 浏览器与 Web Worker 使用指南
302
+
303
+ WaSHI 原生支持在现代网页浏览器、前端主流框架(Vite、Next.js、React、Vue、Svelte)以及 Web Worker 中运行。
304
+
305
+ ### 1. 零配置模式(官方 CDN 智能回退)
306
+ 在浏览器环境下,若当前域名根路径未部署 `highs.wasm`,WaSHI 会自动从官方 jsDelivr 高速 CDN 安全拉取二进制文件。您无需任何额外配置或文件复制:
307
+
308
+ ```typescript
309
+ import { Model } from "@ohtaman/washi";
310
+
311
+ const model = new Model();
312
+ // ... 定义变量与约束
313
+ await model.solve(); // 零配置即可直接运行!
314
+ ```
315
+
316
+ ### 2. 现代打包工具自托管(Vite / Webpack / Rollup)
317
+ 如果您希望将 `highs.wasm` 作为项目打包产物的一部分进行自托管与版本哈希管理:
318
+
319
+ ```typescript
320
+ import wasmUrl from "@ohtaman/washi/highs.wasm?url";
321
+ import { setHighsWasmUrl } from "@ohtaman/washi";
322
+
323
+ // 在应用入口处配置一次
324
+ setHighsWasmUrl(wasmUrl);
325
+ ```
326
+
327
+ ### 3. 企业内网与完全离线(Air-gapped)环境
328
+ 针对严禁外部 CDN 请求的企业内网或纯离线环境:
329
+
330
+ ```typescript
331
+ import { setHighsWasmUrl } from "@ohtaman/washi";
332
+
333
+ // 指定内部静态资源路径(将完全禁用外部 CDN 回退)
334
+ setHighsWasmUrl("/static/highs.wasm");
335
+ ```
336
+
337
+ ---
338
+
339
+ ## 💻 本地脚本与交互式 Web 演示
340
+
341
+ 在 `examples/node/` 中提供了即开即用的独立脚本:
342
+
343
+ ```bash
344
+ npx tsx examples/node/01-production-planning.ts
345
+ npx tsx examples/node/02-knapsack-problem.ts
346
+ npx tsx examples/node/03-portfolio-qp.ts
347
+ npx tsx examples/node/04-smt-security-rules.ts
348
+ npx tsx examples/node/05-unsat-core-diagnosis.ts
349
+ npx tsx examples/node/06-pulp-compatibility.ts
350
+ ```
351
+
352
+ 启动浏览器端交互式可视化演示 (`examples/web-demo`):
353
+
354
+ ```bash
355
+ npm run dev
356
+ # 文档主页: http://localhost:5173/
357
+ # 交互式 Demo: http://localhost:5173/demo/
358
+ ```
359
+
360
+ ---
361
+
362
+ ## 🧪 自动化测试
363
+
364
+ 项目全面贯彻测试驱动开发 (TDD),涵盖 120+ 单元测试、集成测试与大规模基准测试:
365
+
366
+ ```bash
367
+ # 运行全部单元与集成测试
368
+ npm test
369
+
370
+ # 构建生产级依赖包与 TypeScript 类型定义
371
+ npm run build
372
+ ```
373
+
374
+ ---
375
+
376
+ ## 📄 许可证
377
+
378
+ - **`@ohtaman/washi`**: [MIT 许可证](./LICENSE)
379
+ - **HiGHS**(默认求解器): MIT 许可证
380
+ - **Z3**(可选插件): MIT 许可证
381
+ - **GLPK**(可选插件): GPL-3.0 许可证
@@ -0,0 +1,83 @@
1
+ # Third-Party Licenses & Attributions
2
+
3
+ WaSHI (`@ohtaman/washi`) is an open-source mathematical modeling framework distributed under the **MIT License**.
4
+
5
+ Depending on the solver you choose at runtime, WaSHI interacts with the following third-party optimization engines. This document provides copyright notices and license information for these underlying solvers.
6
+
7
+ ---
8
+
9
+ ## 1. HiGHS (Default Solver)
10
+
11
+ - **Role**: Default Linear & Mixed-Integer Programming Engine (WebAssembly)
12
+ - **Package**: [`highs`](https://www.npmjs.com/package/highs)
13
+ - **License**: **MIT License**
14
+ - **Upstream Repository**: [ERGO-Code/HiGHS](https://github.com/ERGO-Code/HiGHS) / [lovasoa/highs-js](https://github.com/lovasoa/highs-js)
15
+
16
+ ```text
17
+ MIT License
18
+
19
+ Copyright (c) 2023 highs-js
20
+ Copyright (c) 2026 HiGHS
21
+
22
+ Permission is hereby granted, free of charge, to any person obtaining a copy
23
+ of this software and associated documentation files (the "Software"), to deal
24
+ in the Software without restriction, including without limitation the rights
25
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
26
+ copies of the Software, and to permit persons to whom the Software is
27
+ furnished to do so, subject to the following conditions:
28
+
29
+ The above copyright notice and this permission notice shall be included in all
30
+ copies or substantial portions of the Software.
31
+
32
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
33
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
34
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
35
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
36
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
37
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
38
+ SOFTWARE.
39
+ ```
40
+
41
+ ---
42
+
43
+ ## 2. Z3 Theorem Prover (Optional Solver)
44
+
45
+ - **Role**: SMT Logic & Unsatisfiable Core Diagnosis Engine (WebAssembly)
46
+ - **Package**: [`z3-solver`](https://www.npmjs.com/package/z3-solver)
47
+ - **License**: **MIT License**
48
+ - **Upstream Repository**: [Z3Prover/z3](https://github.com/Z3Prover/z3)
49
+
50
+ ```text
51
+ Z3
52
+ Copyright (c) Microsoft Corporation
53
+ All rights reserved.
54
+ MIT License
55
+
56
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
57
+
58
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
59
+
60
+ THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
61
+ ```
62
+
63
+ ---
64
+
65
+ ## 3. GLPK / glpk.js (Optional Solver Plugin)
66
+
67
+ - **Role**: Optional Linear Programming Solver
68
+ - **Package**: [`glpk.js`](https://www.npmjs.com/package/glpk.js)
69
+ - **License**: **GNU General Public License v3.0 (GPL-3.0)**
70
+ - **Upstream Repository**: [jvail/glpk.js](https://github.com/jvail/glpk.js)
71
+ - **Notice**: WaSHI isolates GLPK support into an optional subpath export (`@ohtaman/washi/solvers/glpk`). It is loaded dynamically only when explicitly opted in by the user. If your application requires a strictly permissive license (e.g., proprietary enterprise deployments), stick to the default **HiGHS** (MIT) or **Z3** (MIT) engines.
72
+
73
+ ```text
74
+ GNU GENERAL PUBLIC LICENSE
75
+ Version 3, 29 June 2007
76
+
77
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
78
+ Everyone is permitted to copy and distribute verbatim copies
79
+ of this license document, but changing it is not allowed.
80
+
81
+ For the full license text of GPL-3.0, please refer to:
82
+ https://www.gnu.org/licenses/gpl-3.0.txt
83
+ ```