@ohtaman/washi 0.5.0 → 0.6.0

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 (86) hide show
  1. package/README.ja.md +55 -20
  2. package/README.md +55 -20
  3. package/README.zh-CN.md +55 -20
  4. package/THIRD_PARTY_LICENSES.md +3 -4
  5. package/dist/browser/_washi-node-only-BvRk9kiK.js +0 -0
  6. package/dist/browser/browser-runtime-TLCY0hkc.js +1793 -0
  7. package/dist/browser/highs-worker.js +1 -1
  8. package/dist/browser/highs.wasm +0 -0
  9. package/dist/browser/highs.wasm.LICENSE +1 -2
  10. package/dist/browser/loader-DewlSho8.js +643 -0
  11. package/dist/browser/solvers/glpk.js +1 -1
  12. package/dist/browser/solvers/glpk.min.js +1 -1
  13. package/dist/browser/solvers/z3.js +7 -1
  14. package/dist/browser/solvers/z3.min.js +1 -1
  15. package/dist/browser/washi.js +1096 -444
  16. package/dist/browser/washi.min.js +3 -4
  17. package/dist/lib/_washi-node-only-BvRk9kiK.js +0 -0
  18. package/dist/lib/highs-browser-runtime.js +2120 -4124
  19. package/dist/lib/highs-node-runtime.js +24 -1
  20. package/dist/lib/highs-runtime.js +2 -0
  21. package/dist/lib/highs-worker.js +1 -1
  22. package/dist/lib/highs.wasm +0 -0
  23. package/dist/lib/highs.wasm.LICENSE +1 -2
  24. package/dist/lib/loader-BZUQNvh4.js +649 -0
  25. package/dist/lib/{registry-BEfvpZW3.js → registry-C20sxTwm.js} +54 -41
  26. package/dist/lib/solvers/glpk.js +2 -2
  27. package/dist/lib/solvers/z3.js +1 -1
  28. package/dist/lib/washi.js +973 -305
  29. package/dist/types/decomposition/benders.d.ts +32 -0
  30. package/dist/types/decomposition/benders.d.ts.map +1 -0
  31. package/dist/types/decomposition/column-generation.d.ts +34 -0
  32. package/dist/types/decomposition/column-generation.d.ts.map +1 -0
  33. package/dist/types/decomposition/index.d.ts +4 -0
  34. package/dist/types/decomposition/index.d.ts.map +1 -0
  35. package/dist/types/decomposition/types.d.ts +230 -0
  36. package/dist/types/decomposition/types.d.ts.map +1 -0
  37. package/dist/types/index.d.ts +4 -3
  38. package/dist/types/index.d.ts.map +1 -1
  39. package/dist/types/modeler/boolean-expr.d.ts.map +1 -1
  40. package/dist/types/modeler/constraint.d.ts +11 -0
  41. package/dist/types/modeler/constraint.d.ts.map +1 -1
  42. package/dist/types/modeler/expression.d.ts +10 -0
  43. package/dist/types/modeler/expression.d.ts.map +1 -1
  44. package/dist/types/modeler/index.d.ts +2 -1
  45. package/dist/types/modeler/index.d.ts.map +1 -1
  46. package/dist/types/modeler/linearizer.d.ts +15 -0
  47. package/dist/types/modeler/linearizer.d.ts.map +1 -0
  48. package/dist/types/modeler/lp-writer.d.ts +3 -1
  49. package/dist/types/modeler/lp-writer.d.ts.map +1 -1
  50. package/dist/types/modeler/model.d.ts +147 -2
  51. package/dist/types/modeler/model.d.ts.map +1 -1
  52. package/dist/types/modeler/solvers/highs/browser-runtime.d.ts +2 -1
  53. package/dist/types/modeler/solvers/highs/browser-runtime.d.ts.map +1 -1
  54. package/dist/types/modeler/solvers/highs/driver.d.ts +232 -0
  55. package/dist/types/modeler/solvers/highs/driver.d.ts.map +1 -0
  56. package/dist/types/modeler/solvers/highs/index.d.ts +1 -0
  57. package/dist/types/modeler/solvers/highs/index.d.ts.map +1 -1
  58. package/dist/types/modeler/solvers/highs/loader.d.ts +4 -4
  59. package/dist/types/modeler/solvers/highs/loader.d.ts.map +1 -1
  60. package/dist/types/modeler/solvers/highs/node-runtime.d.ts +2 -1
  61. package/dist/types/modeler/solvers/highs/node-runtime.d.ts.map +1 -1
  62. package/dist/types/modeler/solvers/highs/solver.d.ts +1 -1
  63. package/dist/types/modeler/solvers/highs/solver.d.ts.map +1 -1
  64. package/dist/types/modeler/solvers/types.d.ts +2 -0
  65. package/dist/types/modeler/solvers/types.d.ts.map +1 -1
  66. package/dist/types/modeler/types.d.ts +27 -0
  67. package/dist/types/modeler/types.d.ts.map +1 -1
  68. package/docs/examples/index.md +4 -0
  69. package/docs/examples/traveling-salesperson.md +173 -0
  70. package/docs/examples/vehicle-routing.md +206 -0
  71. package/docs/getting-started/ai-agents.md +8 -4
  72. package/docs/guide/constraints.md +1 -1
  73. package/docs/guide/decomposition.md +399 -0
  74. package/docs/guide/unsat-core.md +10 -3
  75. package/docs/ja/getting-started/ai-agents.md +8 -4
  76. package/docs/solvers/custom-solver.md +1 -1
  77. package/docs/solvers/highs.md +25 -3
  78. package/docs/solvers/index.md +3 -3
  79. package/docs/zh/getting-started/ai-agents.md +8 -4
  80. package/llms-full.txt +831 -15
  81. package/llms.txt +9 -5
  82. package/package.json +17 -14
  83. package/skills/washi/SKILL.md +8 -8
  84. package/dist/browser/browser-runtime-D13gHOT5.js +0 -4189
  85. package/dist/browser/loader-CtaDHef_.js +0 -273
  86. package/dist/lib/loader-DmNC_UNk.js +0 -279
@@ -1,4 +1,4 @@
1
- import { a as e } from "./loader-CtaDHef_.js";
1
+ import { a as e } from "./loader-DewlSho8.js";
2
2
  //#region src/modeler/solvers/highs/worker.ts
3
3
  self.onmessage = async (t) => {
4
4
  let { type: n, id: r, lpString: i, options: a, reportProgress: o } = t.data;
Binary file
@@ -1,7 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 highs-js
4
- Copyright (c) 2026 HiGHS
3
+ Copyright (c) 2026 ERGO-Code / HiGHS developers
5
4
 
6
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
7
6
  of this software and associated documentation files (the "Software"), to deal
@@ -0,0 +1,643 @@
1
+ //#region \0washi-browser-assets
2
+ var e = import.meta.url;
3
+ function t(t) {
4
+ if (!e) throw Error("[WaSHI] Load the browser IIFE using an external script src, or use the browser ESM build.");
5
+ return new URL(t, e).href;
6
+ }
7
+ function n() {
8
+ return t("highs.wasm");
9
+ }
10
+ //#endregion
11
+ //#region src/modeler/solvers/highs/driver.ts
12
+ function r(e, t, n) {
13
+ if (n <= 0 || !t) return /* @__PURE__ */ new Float64Array();
14
+ let r = e.wasmMemory ? e.wasmMemory.buffer : e.HEAPF64 ? e.HEAPF64.buffer : e.HEAP8?.buffer;
15
+ if (r) return new Float64Array(r, t, n).slice();
16
+ let i = new Float64Array(n);
17
+ for (let r = 0; r < n; r++) i[r] = e.getValue(t + r * 8, "double");
18
+ return i;
19
+ }
20
+ var i = class extends Error {
21
+ constructor(e) {
22
+ super(e), this.name = "HighsError";
23
+ }
24
+ }, a = class extends i {
25
+ constructor(e) {
26
+ super(e), this.name = "HighsUnsupportedOptionError";
27
+ }
28
+ }, o = {
29
+ 0: "Not Set",
30
+ 1: "Load error",
31
+ 2: "Model error",
32
+ 3: "Presolve error",
33
+ 4: "Solve error",
34
+ 5: "Postsolve error",
35
+ 6: "Empty",
36
+ 7: "Optimal",
37
+ 8: "Infeasible",
38
+ 9: "Primal infeasible or unbounded",
39
+ 10: "Unbounded",
40
+ 11: "Bound on objective reached",
41
+ 12: "Target for objective reached",
42
+ 13: "Time limit reached",
43
+ 14: "Iteration limit reached",
44
+ 15: "Unknown",
45
+ 16: "Solution limit reached",
46
+ 17: "Interrupted",
47
+ 18: "Memory limit reached"
48
+ }, s = {
49
+ callbackType: {
50
+ logging: 0,
51
+ simplexInterrupt: 1,
52
+ ipmInterrupt: 2,
53
+ mipSolution: 3,
54
+ mipImprovingSolution: 4,
55
+ mipLogging: 5,
56
+ mipInterrupt: 6,
57
+ mipGetCutPool: 7,
58
+ mipDefineLazyConstraints: 8,
59
+ mipUserSolution: 9
60
+ },
61
+ solutionStatus: {
62
+ none: 0,
63
+ infeasible: 1,
64
+ feasible: 2
65
+ },
66
+ modelStatus: {
67
+ notSet: 0,
68
+ loadError: 1,
69
+ modelError: 2,
70
+ presolveError: 3,
71
+ solveError: 4,
72
+ postsolveError: 5,
73
+ modelEmpty: 6,
74
+ optimal: 7,
75
+ infeasible: 8,
76
+ unboundedOrInfeasible: 9,
77
+ unbounded: 10,
78
+ objectiveBound: 11,
79
+ objectiveTarget: 12,
80
+ timeLimit: 13,
81
+ iterationLimit: 14,
82
+ unknown: 15,
83
+ solutionLimit: 16,
84
+ interrupt: 17
85
+ }
86
+ };
87
+ function c(e) {
88
+ return {
89
+ create: e.cwrap("Highs_create", "number", []),
90
+ destroy: e.cwrap("Highs_destroy", "void", ["number"]),
91
+ clearModel: e.cwrap("Highs_clearModel", "number", ["number"]),
92
+ version: e.cwrap("Highs_version", "string", []),
93
+ readModel: e.cwrap("Highs_readModel", "number", ["number", "string"]),
94
+ run: e.cwrap("Highs_run", "number", ["number"]),
95
+ getNumCol: e.cwrap("Highs_getNumCol", "number", ["number"]),
96
+ getNumRow: e.cwrap("Highs_getNumRow", "number", ["number"]),
97
+ getNumNz: e.cwrap("Highs_getNumNz", "number", ["number"]),
98
+ getObjectiveValue: e.cwrap("Highs_getObjectiveValue", "number", ["number"]),
99
+ getModelStatus: e.cwrap("Highs_getModelStatus", "number", ["number"]),
100
+ getSolution: e.cwrap("Highs_getSolution", "number", [
101
+ "number",
102
+ "number",
103
+ "number",
104
+ "number",
105
+ "number"
106
+ ]),
107
+ getColName: e.cwrap("Highs_getColName", "number", [
108
+ "number",
109
+ "number",
110
+ "number"
111
+ ]),
112
+ getRowName: e.cwrap("Highs_getRowName", "number", [
113
+ "number",
114
+ "number",
115
+ "number"
116
+ ]),
117
+ getColIntegrality: e.cwrap("Highs_getColIntegrality", "number", [
118
+ "number",
119
+ "number",
120
+ "number"
121
+ ]),
122
+ changeObjectiveOffset: e.cwrap("Highs_changeObjectiveOffset", "number", ["number", "number"]),
123
+ getObjectiveOffset: e.cwrap("Highs_getObjectiveOffset", "number", ["number", "number"]),
124
+ setBoolOptionValue: e.cwrap("Highs_setBoolOptionValue", "number", [
125
+ "number",
126
+ "string",
127
+ "number"
128
+ ]),
129
+ setIntOptionValue: e.cwrap("Highs_setIntOptionValue", "number", [
130
+ "number",
131
+ "string",
132
+ "number"
133
+ ]),
134
+ setDoubleOptionValue: e.cwrap("Highs_setDoubleOptionValue", "number", [
135
+ "number",
136
+ "string",
137
+ "number"
138
+ ]),
139
+ setStringOptionValue: e.cwrap("Highs_setStringOptionValue", "number", [
140
+ "number",
141
+ "string",
142
+ "string"
143
+ ]),
144
+ setSolution: e.cwrap("Highs_setSolution", "number", [
145
+ "number",
146
+ "number",
147
+ "number",
148
+ "number",
149
+ "number"
150
+ ]),
151
+ setSparseSolution: e.cwrap("Highs_setSparseSolution", "number", [
152
+ "number",
153
+ "number",
154
+ "number",
155
+ "number"
156
+ ]),
157
+ getIntInfoValue: e.cwrap("Highs_getIntInfoValue", "number", [
158
+ "number",
159
+ "string",
160
+ "number"
161
+ ]),
162
+ getDoubleInfoValue: e.cwrap("Highs_getDoubleInfoValue", "number", [
163
+ "number",
164
+ "string",
165
+ "number"
166
+ ]),
167
+ getInt64InfoValue: e.cwrap("Highs_getInt64InfoValue", "number", [
168
+ "number",
169
+ "string",
170
+ "number"
171
+ ]),
172
+ setCallback: e.cwrap("Highs_setCallback", "number", [
173
+ "number",
174
+ "number",
175
+ "number"
176
+ ]),
177
+ startCallback: e.cwrap("Highs_startCallback", "number", ["number", "number"]),
178
+ stopCallback: e.cwrap("Highs_stopCallback", "number", ["number", "number"])
179
+ };
180
+ }
181
+ var l = 0, u = class {
182
+ highs;
183
+ module;
184
+ bindings;
185
+ stringBuf;
186
+ isDestroyed = !1;
187
+ constructor(e, t, n) {
188
+ this.module = e, this.bindings = t, this.highs = n ?? t.create(), this.stringBuf = e._malloc(512);
189
+ }
190
+ changeObjectiveOffset(e) {
191
+ let t = this.bindings.changeObjectiveOffset(this.highs, e);
192
+ if (t !== 0) throw new i(`Highs_changeObjectiveOffset failed with status ${t}`);
193
+ }
194
+ getObjectiveOffset() {
195
+ let e = this.module._malloc(8);
196
+ try {
197
+ return this.bindings.getObjectiveOffset(this.highs, e), this.module.getValue(e, "double");
198
+ } finally {
199
+ this.module._free(e);
200
+ }
201
+ }
202
+ options = { set: (e, t) => {
203
+ let n = -1;
204
+ if (typeof t == "boolean" ? n = this.bindings.setBoolOptionValue(this.highs, e, +!!t) : typeof t == "number" ? Number.isInteger(t) ? (n = this.bindings.setIntOptionValue(this.highs, e, t), n !== 0 && (n = this.bindings.setDoubleOptionValue(this.highs, e, t))) : n = this.bindings.setDoubleOptionValue(this.highs, e, t) : typeof t == "string" && (n = this.bindings.setStringOptionValue(this.highs, e, t)), n !== 0) throw new a(`Option "${e}" with value ${JSON.stringify(t)} is not supported or invalid in HiGHS`);
205
+ } };
206
+ getDimensions() {
207
+ return {
208
+ numCols: this.bindings.getNumCol(this.highs),
209
+ numRows: this.bindings.getNumRow(this.highs)
210
+ };
211
+ }
212
+ getColIntegrality(e) {
213
+ let t = this.module._malloc(4);
214
+ try {
215
+ return this.bindings.getColIntegrality(this.highs, e, t), this.module.getValue(t, "i32");
216
+ } finally {
217
+ this.module._free(t);
218
+ }
219
+ }
220
+ getColName(e) {
221
+ return this.bindings.getColName(this.highs, e, this.stringBuf), this.module.UTF8ToString(this.stringBuf);
222
+ }
223
+ getRowName(e) {
224
+ return this.bindings.getRowName(this.highs, e, this.stringBuf), this.module.UTF8ToString(this.stringBuf);
225
+ }
226
+ setSolution(e) {
227
+ if (e.colValue && Array.isArray(e.colValue)) {
228
+ let t = e.colValue.length, n = this.module._malloc(t * 8);
229
+ try {
230
+ for (let r = 0; r < t; r++) this.module.setValue(n + r * 8, e.colValue[r], "double");
231
+ let r = this.bindings.setSolution(this.highs, n, 0, 0, 0);
232
+ if (r !== 0) throw new i(`Highs_setSolution failed with status ${r}`);
233
+ } finally {
234
+ this.module._free(n);
235
+ }
236
+ return;
237
+ }
238
+ if (e.indices && e.values && e.indices.length === e.values.length) {
239
+ let t = e.indices.length, n = this.module._malloc(t * 4), r = this.module._malloc(t * 8);
240
+ try {
241
+ for (let i = 0; i < t; i++) this.module.setValue(n + i * 4, e.indices[i], "i32"), this.module.setValue(r + i * 8, e.values[i], "double");
242
+ let a = this.bindings.setSparseSolution(this.highs, t, n, r);
243
+ if (a !== 0) throw new i(`Highs_setSparseSolution failed with status ${a}`);
244
+ } finally {
245
+ this.module._free(n), this.module._free(r);
246
+ }
247
+ return;
248
+ }
249
+ throw new i("Invalid argument to setSolution (expected { colValue } or { indices, values })");
250
+ }
251
+ run(e) {
252
+ let t = 0, n = [];
253
+ if (e && typeof this.module.addFunction == "function") {
254
+ t = this.module.addFunction((t, n, i, a) => {
255
+ let o = e[t];
256
+ if (!o) return;
257
+ let s = {};
258
+ if (i) {
259
+ let e = this.module.getValue(i + 8, "double"), t = this.module.getValue(i + 16, "i32"), n = this.module.getValue(i + 20, "i32"), a = this.module.getValue(i + 24, "i32"), o = this.module.getValue(i + 32, "double"), c = Number(this.module.getValue(i + 40, "i32")), l = Number(this.module.getValue(i + 48, "i32")), u = this.module.getValue(i + 56, "double"), d = this.module.getValue(i + 64, "double"), f = this.module.getValue(i + 72, "double"), p = this.module.getValue(i + 80, "i32"), m = this.module.getValue(i + 84, "i32"), h;
260
+ p && m > 0 && (h = r(this.module, p, m)), s = {
261
+ running_time: e,
262
+ simplex_iteration_count: t,
263
+ ipm_iteration_count: n,
264
+ pdlp_iteration_count: a,
265
+ objective_function_value: o,
266
+ mip_node_count: c,
267
+ mip_total_lp_iterations: l,
268
+ mip_primal_bound: u,
269
+ mip_dual_bound: d,
270
+ mip_gap: f,
271
+ ...h ? { mip_solution: h } : {}
272
+ };
273
+ }
274
+ let c = n ? this.module.UTF8ToString(n) : "";
275
+ o({
276
+ data: s,
277
+ message: c,
278
+ interrupt: () => {
279
+ a && this.module.setValue(a, 1, "i32");
280
+ }
281
+ });
282
+ }, "vipppp"), this.bindings.setCallback(this.highs, t, 0);
283
+ for (let t of Object.keys(e)) {
284
+ let e = Number(t);
285
+ this.bindings.startCallback(this.highs, e), n.push(e);
286
+ }
287
+ }
288
+ try {
289
+ return this.bindings.run(this.highs);
290
+ } finally {
291
+ if (t) {
292
+ for (let e of n) try {
293
+ this.bindings.stopCallback(this.highs, e);
294
+ } catch {}
295
+ try {
296
+ this.module.removeFunction(t);
297
+ } catch {}
298
+ }
299
+ }
300
+ }
301
+ getModelStatus() {
302
+ return this.bindings.getModelStatus(this.highs);
303
+ }
304
+ info = { get: (e) => {
305
+ let t = this.module._malloc(8);
306
+ try {
307
+ if (this.bindings.getDoubleInfoValue(this.highs, e, t) === 0) return this.module.getValue(t, "double");
308
+ } finally {
309
+ this.module._free(t);
310
+ }
311
+ let n = this.module._malloc(4);
312
+ try {
313
+ if (this.bindings.getIntInfoValue(this.highs, e, n) === 0) return this.module.getValue(n, "i32");
314
+ } finally {
315
+ this.module._free(n);
316
+ }
317
+ throw new i(`Info item "${e}" not available or unknown in HiGHS`);
318
+ } };
319
+ getSolution() {
320
+ let e = this.getDimensions(), t = e.numCols > 0 ? this.module._malloc(e.numCols * 8) : 0, n = e.numCols > 0 ? this.module._malloc(e.numCols * 8) : 0, i = e.numRows > 0 ? this.module._malloc(e.numRows * 8) : 0, a = e.numRows > 0 ? this.module._malloc(e.numRows * 8) : 0;
321
+ try {
322
+ return this.bindings.getSolution(this.highs, t, n, i, a), {
323
+ colValue: r(this.module, t, e.numCols),
324
+ colDual: r(this.module, n, e.numCols),
325
+ rowValue: r(this.module, i, e.numRows),
326
+ rowDual: r(this.module, a, e.numRows)
327
+ };
328
+ } finally {
329
+ t && this.module._free(t), n && this.module._free(n), i && this.module._free(i), a && this.module._free(a);
330
+ }
331
+ }
332
+ getObjectiveValue() {
333
+ return this.bindings.getObjectiveValue(this.highs);
334
+ }
335
+ destroy() {
336
+ if (!this.isDestroyed) {
337
+ this.isDestroyed = !0;
338
+ try {
339
+ this.module._free(this.stringBuf);
340
+ } catch {}
341
+ try {
342
+ this.bindings.destroy(this.highs);
343
+ } catch {}
344
+ }
345
+ }
346
+ [Symbol.dispose]() {
347
+ this.destroy();
348
+ }
349
+ }, d = class {
350
+ module;
351
+ bindings;
352
+ constants = s;
353
+ errors = {
354
+ HighsError: i,
355
+ HighsUnsupportedOptionError: a
356
+ };
357
+ constructor(e) {
358
+ this.module = e, this.bindings = c(e);
359
+ }
360
+ withModel(e, t) {
361
+ let n = this.bindings.create(), r = new u(this.module, this.bindings, n), a = `/model_${++l}.${e.format}`;
362
+ if (!this.module.FS) throw new i("Emscripten FS is not initialized on this HiGHS module instance");
363
+ let o = this.module.FS;
364
+ try {
365
+ o.writeFile(a, e.data);
366
+ let s = this.bindings.readModel(n, a);
367
+ if (s !== 0) throw new i(`Failed to load ${e.format.toUpperCase()} model into HiGHS (status ${s})`);
368
+ return t(r);
369
+ } finally {
370
+ try {
371
+ o.unlink(a);
372
+ } catch {}
373
+ r.destroy();
374
+ }
375
+ }
376
+ solve(e, t = {}) {
377
+ return this.withModel({
378
+ format: "lp",
379
+ data: e
380
+ }, (e) => {
381
+ for (let [n, r] of Object.entries(t)) try {
382
+ e.options.set(n, r);
383
+ } catch {}
384
+ e.run();
385
+ let n = e.getModelStatus(), r = e.getDimensions(), i = e.getSolution(), a = {};
386
+ for (let t = 0; t < r.numCols; t++) {
387
+ let n = e.getColName(t);
388
+ a[n] = {
389
+ Index: t,
390
+ Name: n,
391
+ Primal: i.colValue[t],
392
+ Dual: i.colDual[t]
393
+ };
394
+ }
395
+ return {
396
+ Status: o[n] ?? "Unknown",
397
+ StatusCode: n,
398
+ ObjectiveValue: e.getObjectiveValue(),
399
+ Columns: a
400
+ };
401
+ });
402
+ }
403
+ }, f = null, p = null, m = null;
404
+ function h(e) {
405
+ m = e, f = null, p = null;
406
+ }
407
+ function g() {
408
+ return m;
409
+ }
410
+ async function _(e) {
411
+ return e || m || n();
412
+ }
413
+ async function v(e = {}) {
414
+ let t = await _(e.wasmUrl), n = t ?? "node";
415
+ if (f && p === n) return f;
416
+ p = n;
417
+ let r = (async () => {
418
+ let e = (await import("./browser-runtime-TLCY0hkc.js")).default;
419
+ return await e({ locateFile: (e) => e.endsWith(".wasm") ? t : e });
420
+ })().catch((e) => {
421
+ f === r && (f = null, p = null);
422
+ let n = e instanceof Error ? e.message : String(e);
423
+ throw Error(`[WaSHI] Failed to initialize HiGHS${t ? ` from "${t}"` : ""}. Deploy the package's WASM asset or explicitly set wasmUrl; no CDN fallback is attempted. ${n}`, { cause: e });
424
+ });
425
+ return f = r, r;
426
+ }
427
+ async function y(e, t = {}) {
428
+ if (t.signal?.aborted) return {
429
+ result: {
430
+ Status: "Interrupted",
431
+ StatusCode: 17,
432
+ HasPrimalSolution: !1,
433
+ ObjectiveValue: NaN,
434
+ Columns: {},
435
+ Rows: []
436
+ },
437
+ runTime: 0
438
+ };
439
+ let n = await v(t);
440
+ if (t.signal?.aborted) return {
441
+ result: {
442
+ Status: "Interrupted",
443
+ StatusCode: 17,
444
+ HasPrimalSolution: !1,
445
+ ObjectiveValue: NaN,
446
+ Columns: {},
447
+ Rows: []
448
+ },
449
+ runTime: 0
450
+ };
451
+ let r = performance.now(), i = { output_flag: t.outputFlag ?? !1 };
452
+ t.timeLimit !== void 0 && (i.time_limit = t.timeLimit), t.presolve !== void 0 && (i.presolve = t.presolve), t.solver !== void 0 && (i.solver = t.solver), t.relGap === void 0 ? t.mipGap !== void 0 && (i.mip_rel_gap = t.mipGap) : i.mip_rel_gap = t.relGap, t.absGap !== void 0 && (i.mip_abs_gap = t.absGap);
453
+ for (let e of [
454
+ "mip_max_nodes",
455
+ "mip_max_improving_sols",
456
+ "mip_max_leaves",
457
+ "simplex_iteration_limit",
458
+ "ipm_iteration_limit"
459
+ ]) t[e] !== void 0 && (i[e] = t[e]);
460
+ let a = typeof t.objectiveOffset == "number" && Number.isFinite(t.objectiveOffset) ? t.objectiveOffset : 0, s = t.initialValues, c = !1;
461
+ if (s) {
462
+ for (let [e, t] of Object.entries(s)) if (t !== void 0) {
463
+ if (typeof t != "number" || !Number.isFinite(t)) throw Error(`Invalid initial value for column "${e}": ${String(t)} (must be a finite number).`);
464
+ c = !0;
465
+ }
466
+ }
467
+ if (typeof n.withModel == "function") return {
468
+ result: n.withModel({
469
+ format: "lp",
470
+ data: e
471
+ }, (e) => {
472
+ if (a !== 0 && typeof e.changeObjectiveOffset == "function") {
473
+ let t = typeof e.getObjectiveOffset == "function" ? e.getObjectiveOffset() : 0;
474
+ e.changeObjectiveOffset(t + a);
475
+ }
476
+ for (let [t, r] of Object.entries(i)) try {
477
+ e.options.set(t, r);
478
+ } catch (e) {
479
+ if (e?.name !== "HighsUnsupportedOptionError" && !(n.errors?.HighsUnsupportedOptionError && e instanceof n.errors.HighsUnsupportedOptionError)) throw e;
480
+ }
481
+ let l = e.getDimensions(), u = [], d = !1;
482
+ for (let t = 0; t < l.numCols; t++) {
483
+ let n = e.getColIntegrality(t);
484
+ n !== 0 && (d = !0), u.push({
485
+ name: e.getColName(t),
486
+ type: n === 1 ? "Integer" : "Continuous"
487
+ });
488
+ }
489
+ if (c && s) {
490
+ if (typeof e.setSolution != "function") throw Error("HiGHS runtime does not support setting primal initial values (setSolution is unavailable).");
491
+ let t = /* @__PURE__ */ new Map();
492
+ for (let e = 0; e < l.numCols; e++) t.set(u[e].name, e);
493
+ for (let [e, n] of Object.entries(s)) if (n !== void 0 && !t.has(e)) throw Error(`Unknown column "${e}" in initialValues (column does not exist in the HiGHS LP model).`);
494
+ let n = [], r = [];
495
+ for (let e = 0; e < l.numCols; e++) {
496
+ let t = u[e].name;
497
+ if (Object.prototype.hasOwnProperty.call(s, t)) {
498
+ let i = s[t];
499
+ i !== void 0 && (n.push(e), r.push(i));
500
+ }
501
+ }
502
+ n.length > 0 && (n.length === l.numCols ? e.setSolution({ colValue: r }) : e.setSolution({
503
+ indices: n,
504
+ values: r
505
+ }));
506
+ }
507
+ let f = null, p = null, m = 0, h = (e) => {
508
+ let t = e?.data ?? {}, n = typeof t.running_time == "number" && Number.isFinite(t.running_time) ? t.running_time : (performance.now() - r) / 1e3, i = typeof t.mip_primal_bound == "number" && Number.isFinite(t.mip_primal_bound) ? t.mip_primal_bound : typeof t.objective_function_value == "number" && Number.isFinite(t.objective_function_value) ? t.objective_function_value : void 0, a = typeof t.mip_dual_bound == "number" && Number.isFinite(t.mip_dual_bound) ? t.mip_dual_bound : void 0, o = typeof t.mip_gap == "number" && Number.isFinite(t.mip_gap) ? t.mip_gap : void 0, s = i !== void 0 && a !== void 0 ? Math.abs(i - a) : void 0, c = typeof t.mip_node_count == "bigint" ? Number(t.mip_node_count) : typeof t.mip_node_count == "number" && Number.isFinite(t.mip_node_count) ? t.mip_node_count : void 0, l = typeof t.mip_total_lp_iterations == "bigint" ? Number(t.mip_total_lp_iterations) : typeof t.simplex_iteration_count == "number" && Number.isFinite(t.simplex_iteration_count) ? t.simplex_iteration_count : typeof t.ipm_iteration_count == "number" && Number.isFinite(t.ipm_iteration_count) ? t.ipm_iteration_count : void 0, u = typeof e?.message == "string" && e.message.trim().length > 0 ? e.message.trim() : void 0, d = {
509
+ elapsedTime: n,
510
+ elapsedSeconds: n,
511
+ ...i === void 0 ? {} : { objectiveValue: i },
512
+ ...a === void 0 ? {} : { objectiveBound: a },
513
+ ...o === void 0 ? {} : {
514
+ relGap: o,
515
+ mipGap: o
516
+ },
517
+ ...s === void 0 ? {} : { absGap: s },
518
+ ...c === void 0 ? {} : { nodes: c },
519
+ ...l === void 0 ? {} : { iterations: l },
520
+ ...u === void 0 ? {} : { message: u }
521
+ };
522
+ return p = d, d;
523
+ }, g = (e) => {
524
+ let n = e?.data;
525
+ if (!n || !(n.mip_solution instanceof Float64Array)) return;
526
+ let r = n.mip_solution, i = {};
527
+ for (let e = 0; e < u.length && e < r.length; e++) Object.defineProperty(i, u[e].name, {
528
+ value: {
529
+ Index: e,
530
+ Type: u[e].type,
531
+ Name: u[e].name,
532
+ Primal: r[e]
533
+ },
534
+ enumerable: !0,
535
+ writable: !0,
536
+ configurable: !0
537
+ });
538
+ let a = typeof n.objective_function_value == "number" && Number.isFinite(n.objective_function_value) ? n.objective_function_value : typeof n.mip_primal_bound == "number" && Number.isFinite(n.mip_primal_bound) ? n.mip_primal_bound : NaN;
539
+ Number.isFinite(a) && (f = {
540
+ objectiveValue: a,
541
+ ...typeof n.mip_dual_bound == "number" && Number.isFinite(n.mip_dual_bound) ? { mipDualBound: n.mip_dual_bound } : {},
542
+ ...typeof n.mip_gap == "number" && Number.isFinite(n.mip_gap) ? { mipGap: n.mip_gap } : {},
543
+ columns: i
544
+ }, t.onIncumbent?.(f));
545
+ }, _ = !1;
546
+ if (t.signal || t.onProgress || t.onIncumbent) {
547
+ let r = n.constants?.callbackType ?? {
548
+ logging: 0,
549
+ simplexInterrupt: 1,
550
+ ipmInterrupt: 2,
551
+ mipSolution: 3,
552
+ mipImprovingSolution: 4,
553
+ mipLogging: 5,
554
+ mipInterrupt: 6
555
+ }, i = (e) => {
556
+ if (t.signal?.aborted) {
557
+ _ = !0, e.interrupt();
558
+ return;
559
+ }
560
+ t.onProgress && (m++, t.onProgress(h(e)), t.signal?.aborted && (_ = !0, e.interrupt()));
561
+ }, a = {
562
+ [r.simplexInterrupt]: i,
563
+ [r.ipmInterrupt]: i,
564
+ [r.mipInterrupt]: i,
565
+ [r.mipImprovingSolution]: (e) => {
566
+ g(e), t.onProgress && !t.signal?.aborted && (m++, t.onProgress(h(e)));
567
+ },
568
+ [r.mipLogging]: (e) => {
569
+ t.onProgress && !t.signal?.aborted && (m++, t.onProgress(h(e)));
570
+ }
571
+ };
572
+ e.run(a);
573
+ } else e.run();
574
+ let v = e.getModelStatus();
575
+ _ && (v = 17);
576
+ let y = o[v] ?? "Unknown", b = 0, x = 0;
577
+ try {
578
+ b = Number(e.info.get("primal_solution_status"));
579
+ } catch {}
580
+ try {
581
+ x = Number(e.info.get("dual_solution_status"));
582
+ } catch {}
583
+ let S = n.constants?.solutionStatus?.feasible ?? 2, C = b === S, w = x === S, T = C || w ? e.getSolution() : null, E = C, D = {};
584
+ if (!C && f !== null) E = !0, D = f.columns;
585
+ else for (let e = 0; e < l.numCols; e++) {
586
+ let t = u[e], n = {
587
+ Index: e,
588
+ Type: t.type,
589
+ Name: t.name
590
+ };
591
+ C && T && (n.Primal = T.colValue[e]), !d && w && T && (n.Dual = T.colDual[e]), Object.defineProperty(D, t.name, {
592
+ value: n,
593
+ enumerable: !0,
594
+ writable: !0,
595
+ configurable: !0
596
+ });
597
+ }
598
+ let O = [];
599
+ for (let t = 0; t < l.numRows; t++) {
600
+ let n = e.getRowName(t), r = {
601
+ Index: t,
602
+ Name: n
603
+ };
604
+ C && T && (r.Primal = T.rowValue[t]), !d && w && T && (r.Dual = T.rowDual[t]), O.push(r);
605
+ }
606
+ let k = C ? e.getObjectiveValue() : f === null ? NaN : f.objectiveValue, A, j;
607
+ if (d) {
608
+ try {
609
+ let t = Number(e.info.get("mip_dual_bound"));
610
+ Number.isFinite(t) && (A = t);
611
+ } catch {}
612
+ A === void 0 && p && p.objectiveBound !== void 0 && (A = p.objectiveBound);
613
+ try {
614
+ let t = Number(e.info.get("mip_gap"));
615
+ Number.isFinite(t) && (j = t);
616
+ } catch {}
617
+ j === void 0 && p && p.relGap !== void 0 && (j = p.relGap);
618
+ }
619
+ return {
620
+ Status: o[v] ?? y,
621
+ StatusCode: v,
622
+ PrimalSolutionStatus: b,
623
+ DualSolutionStatus: x,
624
+ HasPrimalSolution: E,
625
+ IsMip: d,
626
+ ObjectiveValue: k,
627
+ ObjectiveOffsetApplied: a !== 0,
628
+ MipDualBound: A,
629
+ MipGap: j,
630
+ Columns: D,
631
+ Rows: O
632
+ };
633
+ }),
634
+ runTime: (performance.now() - r) / 1e3
635
+ };
636
+ if (c) throw Error("HiGHS runtime does not support setting primal initial values (withModel/setSolution is unavailable).");
637
+ return {
638
+ result: n.solve(e, i),
639
+ runTime: (performance.now() - r) / 1e3
640
+ };
641
+ }
642
+ //#endregion
643
+ export { y as a, h as i, g as n, d as o, _ as r, t as s, v as t };
@@ -1074,7 +1074,7 @@ var Re = class e {
1074
1074
  let g = [], _ = [], v = [];
1075
1075
  for (let t of e.variables) {
1076
1076
  let e = u.get(t) || t.name;
1077
- t.type === "Binary" ? g.push(e) : t.type === "Integer" && _.push(e);
1077
+ !s.relax && t.type === "Binary" ? g.push(e) : !s.relax && t.type === "Integer" && _.push(e);
1078
1078
  let n = t.lb, r = t.ub, i;
1079
1079
  i = n === -Infinity && r === Infinity ? c.GLP_FR : n !== -Infinity && r === Infinity ? c.GLP_LO : n === -Infinity && r !== Infinity ? c.GLP_UP : n === r ? c.GLP_FX : c.GLP_DB, v.push({
1080
1080
  name: e,