@ohtaman/washi 0.9.0 → 0.10.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.
- package/README.md +9 -10
- package/THIRD_PARTY_LICENSES.md +4 -4
- package/dist/{browser/washi.js → core-b430-tAc.js} +656 -661
- package/dist/solvers/browser-_washi-browser-node-runtime-BOEcR5J2.js +28 -0
- package/dist/solvers/browser-browser-worker-CT6498Is.js +13 -0
- package/dist/{lib/solvers/loader-b5PNpCmX.js → solvers/browser-loader-D21chr4P.js} +12 -23
- package/dist/{lib/solvers/loader-DCtyxsfF.js → solvers/browser-loader-DWFhT0yY.js} +13 -13
- package/dist/solvers/browser-lp-writer-DH_1sdsF.js +115 -0
- package/dist/solvers/glpk.js +310 -0
- package/dist/{lib/solvers/glpk.js → solvers/glpk.node.js} +5 -9
- package/dist/{lib/solvers/__vite-browser-external-oLchLuMx.js → solvers/highs-browser-__vite-browser-external-Cu-Zq4Hm.js} +1 -1
- package/dist/solvers/highs-browser-runtime.js +2410 -0
- package/dist/{lib/solvers → solvers}/highs-node-runtime.js +1 -1
- package/dist/{lib/solvers → solvers}/highs-worker.js +2 -2
- package/dist/{lib/solvers → solvers}/highs.js +64 -70
- package/dist/{browser/solvers/highs-loader-Csn3-0tq.js → solvers/highs.node.js} +520 -138
- package/dist/solvers/node-browser-worker-CN93BPoO.js +54 -0
- package/dist/{lib/solvers/lp-writer-CLScMFbS.js → solvers/node-lp-writer-CqMLgMIk.js} +1 -1
- package/dist/solvers/node-node-runtime-BUlNfXvx.js +10 -0
- package/dist/solvers/node-registry-CrYRRk9q.js +907 -0
- package/dist/solvers/node-types-BGqPkxwu.js +12 -0
- package/dist/{lib/solvers → solvers}/pumpkin-node-runtime.js +1 -1
- package/dist/{browser/solvers → solvers}/pumpkin-worker.js +2 -1
- package/dist/{lib/solvers → solvers}/pumpkin.js +174 -164
- package/dist/solvers/pumpkin.node.js +1228 -0
- package/dist/{lib/solvers → solvers}/z3.js +123 -120
- package/dist/types/core.d.ts +11 -0
- package/dist/types/core.d.ts.map +1 -0
- package/dist/types/index.d.ts +3 -4
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/modeler/core.d.ts +14 -0
- package/dist/types/modeler/core.d.ts.map +1 -0
- package/dist/types/modeler/index.d.ts +1 -13
- package/dist/types/modeler/index.d.ts.map +1 -1
- package/dist/types/modeler/model.d.ts +1 -1
- package/dist/types/modeler/model.d.ts.map +1 -1
- package/dist/types/modeler/solvers/browser-worker.d.ts +17 -0
- package/dist/types/modeler/solvers/browser-worker.d.ts.map +1 -0
- package/dist/types/modeler/solvers/glpk/loader.d.ts +2 -2
- package/dist/types/modeler/solvers/glpk/node-runtime.d.ts +5 -0
- package/dist/types/modeler/solvers/glpk/node-runtime.d.ts.map +1 -0
- package/dist/types/modeler/solvers/highs/worker-client.d.ts +5 -5
- package/dist/types/modeler/solvers/highs/worker-client.d.ts.map +1 -1
- package/dist/types/modeler/solvers/pumpkin/loader.d.ts +0 -4
- package/dist/types/modeler/solvers/pumpkin/loader.d.ts.map +1 -1
- package/dist/types/modeler/solvers/pumpkin/solver.d.ts.map +1 -1
- package/dist/types/modeler/solvers/pumpkin/worker-client.d.ts +4 -3
- package/dist/types/modeler/solvers/pumpkin/worker-client.d.ts.map +1 -1
- package/dist/types/modeler/solvers/types.d.ts +5 -1
- package/dist/types/modeler/solvers/types.d.ts.map +1 -1
- package/dist/types/modeler/solvers/z3/loader.d.ts +3 -8
- package/dist/types/modeler/solvers/z3/loader.d.ts.map +1 -1
- package/dist/types/modeler/solvers/z3/solver.d.ts +3 -2
- package/dist/types/modeler/solvers/z3/solver.d.ts.map +1 -1
- package/dist/types/modeler/types.d.ts +18 -3
- package/dist/types/modeler/types.d.ts.map +1 -1
- package/dist/washi.js +4 -0
- package/dist/washi.min.js +6 -0
- package/dist/washi.node.js +4 -0
- package/docs/getting-started/ai-agents.md +23 -22
- package/docs/getting-started/coding-agents.md +26 -17
- package/docs/getting-started/cross-origin.md +2 -1
- package/docs/getting-started/index.md +3 -1
- package/docs/getting-started/runtimes.md +53 -63
- package/docs/guide/objectives.md +3 -3
- package/docs/solvers/custom-solver.md +4 -9
- package/docs/solvers/glpk.md +2 -0
- package/docs/solvers/highs.md +8 -10
- package/docs/solvers/index.md +1 -1
- package/docs/solvers/pumpkin.md +7 -7
- package/docs/solvers/z3.md +18 -1
- package/llms-full.txt +124 -118
- package/llms.txt +23 -22
- package/package.json +31 -64
- package/skills/washi/SKILL.md +18 -18
- package/skills/washi/references/single-html.md +7 -12
- package/dist/browser/solvers/glpk.js +0 -1263
- package/dist/browser/solvers/glpk.min.js +0 -1
- package/dist/browser/solvers/highs-__vite-browser-external-xcxOpLMD.js +0 -7
- package/dist/browser/solvers/highs-browser-runtime-ccRmE4qj.js +0 -2021
- package/dist/browser/solvers/highs-worker.js +0 -55
- package/dist/browser/solvers/highs.js +0 -1454
- package/dist/browser/solvers/pumpkin-_washi-pumpkin-node-runtime-CEKUDK6d.js +0 -9
- package/dist/browser/solvers/pumpkin-loader-BI3n3dWO.js +0 -401
- package/dist/browser/solvers/pumpkin.js +0 -1796
- package/dist/browser/solvers/z3-built.js +0 -8245
- package/dist/browser/solvers/z3-built.wasm +0 -4
- package/dist/browser/solvers/z3.js +0 -7842
- package/dist/browser/solvers/z3.min.js +0 -5
- package/dist/browser/washi.min.js +0 -6
- package/dist/lib/solvers/highs-browser-runtime.js +0 -2413
- package/dist/lib/solvers/highs.wasm +0 -0
- package/dist/lib/solvers/highs.wasm.LICENSE +0 -21
- package/dist/lib/solvers/pumpkin-worker.js +0 -47
- package/dist/lib/solvers/pumpkin.wasm +0 -0
- package/dist/lib/solvers/pumpkin.wasm.LICENSE +0 -21
- package/dist/lib/solvers/z3-assets.js +0 -1
- package/dist/lib/solvers/z3-built.js +0 -8245
- package/dist/lib/solvers/z3-built.wasm +0 -4
- package/dist/lib/washi.js +0 -5662
- package/dist/types/modeler/solvers/z3/assets.d.ts +0 -11
- package/dist/types/modeler/solvers/z3/assets.d.ts.map +0 -1
- /package/dist/{lib/solvers/embedded-wasm-CSFlLV5N.js → solvers/browser-embedded-wasm-CSFlLV5N.js} +0 -0
- /package/dist/{lib/solvers/registry-CrYRRk9q.js → solvers/browser-registry-CrYRRk9q.js} +0 -0
- /package/dist/{lib/solvers/types-BGqPkxwu.js → solvers/browser-types-BGqPkxwu.js} +0 -0
- /package/dist/{lib/solvers → solvers}/highs-assets.js +0 -0
- /package/dist/{lib/solvers/rolldown-runtime-DtPi1Y-2.js → solvers/highs-browser-rolldown-runtime-DtPi1Y-2.js} +0 -0
- /package/dist/{browser/solvers → solvers}/highs-inline.js +0 -0
- /package/dist/{lib/solvers → solvers}/highs-runtime.js +0 -0
- /package/dist/{lib/solvers → solvers}/highs-worker-factory.js +0 -0
- /package/dist/{browser/solvers → solvers}/highs.wasm +0 -0
- /package/dist/{browser/solvers → solvers}/highs.wasm.LICENSE +0 -0
- /package/dist/{lib/solvers → solvers}/pumpkin-assets.js +0 -0
- /package/dist/{browser/solvers → solvers}/pumpkin-inline.js +0 -0
- /package/dist/{lib/solvers → solvers}/pumpkin-worker-factory.js +0 -0
- /package/dist/{browser/solvers → solvers}/pumpkin.wasm +0 -0
- /package/dist/{browser/solvers → solvers}/pumpkin.wasm.LICENSE +0 -0
|
@@ -1,68 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
function n(e) {
|
|
10
|
-
return Symbol.for(`washi.embeddedWasm.${e}.${t(e)}`);
|
|
11
|
-
}
|
|
12
|
-
function r(e) {
|
|
13
|
-
return e instanceof Uint8Array || ArrayBuffer.isView(e) && Object.prototype.toString.call(e) === "[object Uint8Array]";
|
|
14
|
-
}
|
|
15
|
-
function i(e, t, n) {
|
|
16
|
-
if (!r(t)) throw Error(`[WaSHI] Invalid ${e} ${n}: expected Uint8Array.`);
|
|
17
|
-
let i = new Uint8Array(t.byteLength);
|
|
18
|
-
if (i.set(new Uint8Array(t.buffer, t.byteOffset, t.byteLength)), i.byteLength < 8 || i[0] !== 0 || i[1] !== 97 || i[2] !== 115 || i[3] !== 109) throw Error(`[WaSHI] Invalid ${e} ${n}: expected at least 8 bytes starting with \\0asm magic header.`);
|
|
19
|
-
return i;
|
|
20
|
-
}
|
|
21
|
-
function a(e) {
|
|
22
|
-
let r = t(e), a = n(e), o = globalThis[a];
|
|
23
|
-
if (o === void 0) return null;
|
|
24
|
-
if (typeof o != "object" || !o) throw Error(`[WaSHI] Invalid embedded WASM pack registered for ${e} (${r}).`);
|
|
25
|
-
let s = o;
|
|
26
|
-
if (s.solver !== e || s.compatId !== r || typeof s.getBytes != "function") throw Error(`[WaSHI] Invalid embedded WASM pack registered for ${e} (${r}).`);
|
|
27
|
-
return i(e, s.getBytes(), "embedded inline WASM binary");
|
|
28
|
-
}
|
|
29
|
-
function o(t) {
|
|
30
|
-
let n = e[t];
|
|
31
|
-
if (n !== null) return n;
|
|
32
|
-
let r = a(t), i = r === null ? { kind: "url" } : {
|
|
33
|
-
kind: "embedded",
|
|
34
|
-
bytes: r
|
|
35
|
-
};
|
|
36
|
-
return e[t] = i, i;
|
|
37
|
-
}
|
|
38
|
-
function s(t) {
|
|
39
|
-
return e[t];
|
|
40
|
-
}
|
|
41
|
-
function c(t, n) {
|
|
42
|
-
let r = i(t, n, "worker embedded WASM binary");
|
|
43
|
-
e[t] === null && (e[t] = {
|
|
44
|
-
kind: "embedded",
|
|
45
|
-
bytes: r
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
//#endregion
|
|
49
|
-
//#region \0washi-browser-assets
|
|
50
|
-
var l = import.meta.url;
|
|
51
|
-
function u(e) {
|
|
52
|
-
if (!l) throw Error("[WaSHI] Load the browser IIFE using an external script src, or use the browser ESM build.");
|
|
53
|
-
return new URL(e, l).href;
|
|
54
|
-
}
|
|
55
|
-
function d() {
|
|
56
|
-
return u("highs.wasm");
|
|
57
|
-
}
|
|
58
|
-
//#endregion
|
|
59
|
-
//#region \0washi-node-runtime
|
|
60
|
-
function f() {
|
|
61
|
-
throw Error("This distribution is for browsers. Use the npm entry in Node.js.");
|
|
62
|
-
}
|
|
63
|
-
//#endregion
|
|
1
|
+
import { a as e, i as t, n, t as r } from "./node-registry-CrYRRk9q.js";
|
|
2
|
+
import { n as i, r as a } from "./node-lp-writer-CqMLgMIk.js";
|
|
3
|
+
import { a as o, i as s, n as c, r as l, t as u } from "./node-browser-worker-CN93BPoO.js";
|
|
4
|
+
import { getBundledWasmUrl as d } from "./highs-assets.js";
|
|
5
|
+
import { loadNodeHighs as f } from "./highs-node-runtime.js";
|
|
6
|
+
import { createHighsWorker as p } from "./highs-worker-factory.js";
|
|
7
|
+
export * from "./highs-assets.js";
|
|
8
|
+
export * from "./highs-worker-factory.js";
|
|
64
9
|
//#region src/modeler/solvers/highs/driver.ts
|
|
65
|
-
function
|
|
10
|
+
function m(e, t, n) {
|
|
66
11
|
if (n <= 0 || !t) return /* @__PURE__ */ new Float64Array();
|
|
67
12
|
let r = e.wasmMemory ? e.wasmMemory.buffer : e.HEAPF64 ? e.HEAPF64.buffer : e.HEAP8?.buffer;
|
|
68
13
|
if (r) return new Float64Array(r, t, n).slice();
|
|
@@ -70,15 +15,15 @@ function p(e, t, n) {
|
|
|
70
15
|
for (let r = 0; r < n; r++) i[r] = e.getValue(t + r * 8, "double");
|
|
71
16
|
return i;
|
|
72
17
|
}
|
|
73
|
-
var
|
|
18
|
+
var h = class extends Error {
|
|
74
19
|
constructor(e) {
|
|
75
20
|
super(e), this.name = "HighsError";
|
|
76
21
|
}
|
|
77
|
-
},
|
|
22
|
+
}, g = class extends h {
|
|
78
23
|
constructor(e) {
|
|
79
24
|
super(e), this.name = "HighsUnsupportedOptionError";
|
|
80
25
|
}
|
|
81
|
-
},
|
|
26
|
+
}, _ = {
|
|
82
27
|
0: "Not Set",
|
|
83
28
|
1: "Load error",
|
|
84
29
|
2: "Model error",
|
|
@@ -98,7 +43,7 @@ var m = class extends Error {
|
|
|
98
43
|
16: "Solution limit reached",
|
|
99
44
|
17: "Interrupted",
|
|
100
45
|
18: "Memory limit reached"
|
|
101
|
-
},
|
|
46
|
+
}, v = {
|
|
102
47
|
callbackType: {
|
|
103
48
|
logging: 0,
|
|
104
49
|
simplexInterrupt: 1,
|
|
@@ -137,7 +82,7 @@ var m = class extends Error {
|
|
|
137
82
|
interrupt: 17
|
|
138
83
|
}
|
|
139
84
|
};
|
|
140
|
-
function
|
|
85
|
+
function y(e) {
|
|
141
86
|
return {
|
|
142
87
|
create: e.cwrap("Highs_create", "number", []),
|
|
143
88
|
destroy: e.cwrap("Highs_destroy", "void", ["number"]),
|
|
@@ -231,7 +176,7 @@ function v(e) {
|
|
|
231
176
|
stopCallback: e.cwrap("Highs_stopCallback", "number", ["number", "number"])
|
|
232
177
|
};
|
|
233
178
|
}
|
|
234
|
-
var
|
|
179
|
+
var b = 0, x = class {
|
|
235
180
|
highs;
|
|
236
181
|
module;
|
|
237
182
|
bindings;
|
|
@@ -242,7 +187,7 @@ var y = 0, b = class {
|
|
|
242
187
|
}
|
|
243
188
|
changeObjectiveOffset(e) {
|
|
244
189
|
let t = this.bindings.changeObjectiveOffset(this.highs, e);
|
|
245
|
-
if (t !== 0) throw new
|
|
190
|
+
if (t !== 0) throw new h(`Highs_changeObjectiveOffset failed with status ${t}`);
|
|
246
191
|
}
|
|
247
192
|
getObjectiveOffset() {
|
|
248
193
|
let e = this.module._malloc(8);
|
|
@@ -254,7 +199,7 @@ var y = 0, b = class {
|
|
|
254
199
|
}
|
|
255
200
|
options = { set: (e, t) => {
|
|
256
201
|
let n = -1;
|
|
257
|
-
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
|
|
202
|
+
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 g(`Option "${e}" with value ${JSON.stringify(t)} is not supported or invalid in HiGHS`);
|
|
258
203
|
} };
|
|
259
204
|
getDimensions() {
|
|
260
205
|
return {
|
|
@@ -282,7 +227,7 @@ var y = 0, b = class {
|
|
|
282
227
|
try {
|
|
283
228
|
for (let r = 0; r < t; r++) this.module.setValue(n + r * 8, e.colValue[r], "double");
|
|
284
229
|
let r = this.bindings.setSolution(this.highs, n, 0, 0, 0);
|
|
285
|
-
if (r !== 0) throw new
|
|
230
|
+
if (r !== 0) throw new h(`Highs_setSolution failed with status ${r}`);
|
|
286
231
|
} finally {
|
|
287
232
|
this.module._free(n);
|
|
288
233
|
}
|
|
@@ -293,25 +238,25 @@ var y = 0, b = class {
|
|
|
293
238
|
try {
|
|
294
239
|
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");
|
|
295
240
|
let i = this.bindings.setSparseSolution(this.highs, t, n, r);
|
|
296
|
-
if (i !== 0) throw new
|
|
241
|
+
if (i !== 0) throw new h(`Highs_setSparseSolution failed with status ${i}`);
|
|
297
242
|
} finally {
|
|
298
243
|
this.module._free(n), this.module._free(r);
|
|
299
244
|
}
|
|
300
245
|
return;
|
|
301
246
|
}
|
|
302
|
-
throw new
|
|
247
|
+
throw new h("Invalid argument to setSolution (expected { colValue } or { indices, values })");
|
|
303
248
|
}
|
|
304
249
|
run(e) {
|
|
305
250
|
let t = 0, n = [];
|
|
306
251
|
if (e) {
|
|
307
|
-
if (typeof this.module.addFunction != "function") throw new
|
|
252
|
+
if (typeof this.module.addFunction != "function") throw new h("HiGHS WebAssembly runtime does not support module.addFunction; progress and interrupt callbacks are unavailable.");
|
|
308
253
|
t = this.module.addFunction((t, n, r, i) => {
|
|
309
254
|
let a = e[t];
|
|
310
255
|
if (!a) return;
|
|
311
256
|
let o = {};
|
|
312
257
|
if (r) {
|
|
313
|
-
let e = this.module.getValue(r + 8, "double"), t = this.module.getValue(r + 16, "i32"), n = this.module.getValue(r + 20, "i32"), i = this.module.getValue(r + 24, "i32"), a = this.module.getValue(r + 32, "double"), s = Number(this.module.getValue(r + 40, "i32")), c = Number(this.module.getValue(r + 48, "i32")), l = this.module.getValue(r + 56, "double"), u = this.module.getValue(r + 64, "double"), d = this.module.getValue(r + 72, "double"), f = this.module.getValue(r + 80, "i32"),
|
|
314
|
-
f &&
|
|
258
|
+
let e = this.module.getValue(r + 8, "double"), t = this.module.getValue(r + 16, "i32"), n = this.module.getValue(r + 20, "i32"), i = this.module.getValue(r + 24, "i32"), a = this.module.getValue(r + 32, "double"), s = Number(this.module.getValue(r + 40, "i32")), c = Number(this.module.getValue(r + 48, "i32")), l = this.module.getValue(r + 56, "double"), u = this.module.getValue(r + 64, "double"), d = this.module.getValue(r + 72, "double"), f = this.module.getValue(r + 80, "i32"), p = this.module.getValue(r + 84, "i32"), h;
|
|
259
|
+
f && p > 0 && (h = m(this.module, f, p)), o = {
|
|
315
260
|
running_time: e,
|
|
316
261
|
simplex_iteration_count: t,
|
|
317
262
|
ipm_iteration_count: n,
|
|
@@ -368,16 +313,16 @@ var y = 0, b = class {
|
|
|
368
313
|
} finally {
|
|
369
314
|
this.module._free(n);
|
|
370
315
|
}
|
|
371
|
-
throw new
|
|
316
|
+
throw new h(`Info item "${e}" not available or unknown in HiGHS`);
|
|
372
317
|
} };
|
|
373
318
|
getSolution() {
|
|
374
319
|
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, r = e.numRows > 0 ? this.module._malloc(e.numRows * 8) : 0, i = e.numRows > 0 ? this.module._malloc(e.numRows * 8) : 0;
|
|
375
320
|
try {
|
|
376
321
|
return this.bindings.getSolution(this.highs, t, n, r, i), {
|
|
377
|
-
colValue:
|
|
378
|
-
colDual:
|
|
379
|
-
rowValue:
|
|
380
|
-
rowDual:
|
|
322
|
+
colValue: m(this.module, t, e.numCols),
|
|
323
|
+
colDual: m(this.module, n, e.numCols),
|
|
324
|
+
rowValue: m(this.module, r, e.numRows),
|
|
325
|
+
rowDual: m(this.module, i, e.numRows)
|
|
381
326
|
};
|
|
382
327
|
} finally {
|
|
383
328
|
t && this.module._free(t), n && this.module._free(n), r && this.module._free(r), i && this.module._free(i);
|
|
@@ -400,25 +345,25 @@ var y = 0, b = class {
|
|
|
400
345
|
[Symbol.dispose]() {
|
|
401
346
|
this.destroy();
|
|
402
347
|
}
|
|
403
|
-
},
|
|
348
|
+
}, S = class {
|
|
404
349
|
module;
|
|
405
350
|
bindings;
|
|
406
|
-
constants =
|
|
351
|
+
constants = v;
|
|
407
352
|
errors = {
|
|
408
|
-
HighsError:
|
|
409
|
-
HighsUnsupportedOptionError:
|
|
353
|
+
HighsError: h,
|
|
354
|
+
HighsUnsupportedOptionError: g
|
|
410
355
|
};
|
|
411
356
|
constructor(e) {
|
|
412
|
-
this.module = e, this.bindings =
|
|
357
|
+
this.module = e, this.bindings = y(e);
|
|
413
358
|
}
|
|
414
359
|
withModel(e, t) {
|
|
415
|
-
let n = this.bindings.create(), r = new
|
|
416
|
-
if (!this.module.FS) throw new
|
|
360
|
+
let n = this.bindings.create(), r = new x(this.module, this.bindings, n), i = `/model_${++b}.${e.format}`;
|
|
361
|
+
if (!this.module.FS) throw new h("Emscripten FS is not initialized on this HiGHS module instance");
|
|
417
362
|
let a = this.module.FS;
|
|
418
363
|
try {
|
|
419
364
|
a.writeFile(i, e.data);
|
|
420
365
|
let o = this.bindings.readModel(n, i);
|
|
421
|
-
if (o !== 0) throw new
|
|
366
|
+
if (o !== 0) throw new h(`Failed to load ${e.format.toUpperCase()} model into HiGHS (status ${o})`);
|
|
422
367
|
return t(r);
|
|
423
368
|
} finally {
|
|
424
369
|
try {
|
|
@@ -445,20 +390,20 @@ var y = 0, b = class {
|
|
|
445
390
|
};
|
|
446
391
|
}
|
|
447
392
|
return {
|
|
448
|
-
Status:
|
|
393
|
+
Status: _[n] ?? "Unknown",
|
|
449
394
|
StatusCode: n,
|
|
450
395
|
ObjectiveValue: e.getObjectiveValue(),
|
|
451
396
|
Columns: a
|
|
452
397
|
};
|
|
453
398
|
});
|
|
454
399
|
}
|
|
455
|
-
},
|
|
400
|
+
}, C = [
|
|
456
401
|
"mip_max_nodes",
|
|
457
402
|
"mip_max_improving_sols",
|
|
458
403
|
"mip_max_leaves",
|
|
459
404
|
"simplex_iteration_limit",
|
|
460
405
|
"ipm_iteration_limit"
|
|
461
|
-
],
|
|
406
|
+
], w = /* @__PURE__ */ new Set([
|
|
462
407
|
"timeLimit",
|
|
463
408
|
"outputFlag",
|
|
464
409
|
"presolve",
|
|
@@ -473,12 +418,12 @@ var y = 0, b = class {
|
|
|
473
418
|
"useWorker",
|
|
474
419
|
"objectiveOffset",
|
|
475
420
|
"initialValues",
|
|
476
|
-
...
|
|
421
|
+
...C
|
|
477
422
|
]);
|
|
478
|
-
function
|
|
423
|
+
function T(e = {}) {
|
|
479
424
|
if (e.threads !== void 0) throw Error("Solver \"HiGHS\" does not support option \"threads\" (HiGHS WebAssembly runs single-threaded).");
|
|
480
425
|
if (e.verbose !== void 0) throw Error("Solver \"HiGHS\" does not support option \"verbose\"; use \"outputFlag\" instead.");
|
|
481
|
-
for (let [t, n] of Object.entries(e)) if (n !== void 0 && !
|
|
426
|
+
for (let [t, n] of Object.entries(e)) if (n !== void 0 && !w.has(t)) throw Error(`Solver "HiGHS" does not support option "${t}".`);
|
|
482
427
|
if (e.useWorker !== void 0 && typeof e.useWorker != "boolean") throw Error(`Invalid HiGHS option "useWorker": expected boolean, got ${typeof e.useWorker}.`);
|
|
483
428
|
if (e.outputFlag !== void 0 && typeof e.outputFlag != "boolean") throw Error(`Invalid HiGHS option "outputFlag": expected boolean, got ${typeof e.outputFlag}.`);
|
|
484
429
|
if (e.relax !== void 0 && typeof e.relax != "boolean") throw Error(`Invalid HiGHS option "relax": expected boolean, got ${typeof e.relax}.`);
|
|
@@ -489,33 +434,34 @@ function w(e = {}) {
|
|
|
489
434
|
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.`);
|
|
490
435
|
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.");
|
|
491
436
|
}
|
|
492
|
-
var
|
|
493
|
-
function
|
|
494
|
-
|
|
437
|
+
var E = null, D = null, O = null, k = null;
|
|
438
|
+
function A(e) {
|
|
439
|
+
k = e, E = null, D = null, O = null;
|
|
495
440
|
}
|
|
496
|
-
function
|
|
497
|
-
return
|
|
441
|
+
function j() {
|
|
442
|
+
return k;
|
|
498
443
|
}
|
|
499
|
-
function
|
|
444
|
+
function M(e) {
|
|
500
445
|
return e.length >= 4 && e[0] === 0 && e[1] === 97 && e[2] === 115 && e[3] === 109;
|
|
501
446
|
}
|
|
502
|
-
async function
|
|
503
|
-
return e ||
|
|
447
|
+
async function N(e) {
|
|
448
|
+
return e || k || d();
|
|
504
449
|
}
|
|
505
|
-
async function
|
|
450
|
+
async function P(e, t) {
|
|
451
|
+
let n = !!(typeof process < "u" && process.versions?.node && process.type !== "renderer");
|
|
506
452
|
if (e.wasmUrl) {
|
|
507
|
-
let t = await
|
|
453
|
+
let t = n ? null : await N(e.wasmUrl);
|
|
508
454
|
return {
|
|
509
|
-
isNode:
|
|
455
|
+
isNode: n,
|
|
510
456
|
wasmUrl: t,
|
|
511
457
|
wasmBinary: null,
|
|
512
458
|
key: t ? `url:${t}` : "node"
|
|
513
459
|
};
|
|
514
460
|
}
|
|
515
|
-
if (
|
|
516
|
-
let e = await
|
|
461
|
+
if (k) {
|
|
462
|
+
let e = n ? null : await N();
|
|
517
463
|
return {
|
|
518
|
-
isNode:
|
|
464
|
+
isNode: n,
|
|
519
465
|
wasmUrl: e,
|
|
520
466
|
wasmBinary: null,
|
|
521
467
|
key: e ? `url:${e}` : "node"
|
|
@@ -523,44 +469,44 @@ async function N(e, t) {
|
|
|
523
469
|
}
|
|
524
470
|
if (t === null) return null;
|
|
525
471
|
if (t.kind === "embedded") return {
|
|
526
|
-
isNode:
|
|
472
|
+
isNode: n,
|
|
527
473
|
wasmUrl: null,
|
|
528
474
|
wasmBinary: t.bytes,
|
|
529
475
|
key: "__embedded__"
|
|
530
476
|
};
|
|
531
|
-
let
|
|
477
|
+
let r = n ? null : await N();
|
|
532
478
|
return {
|
|
533
|
-
isNode:
|
|
534
|
-
wasmUrl:
|
|
479
|
+
isNode: n,
|
|
480
|
+
wasmUrl: r,
|
|
535
481
|
wasmBinary: null,
|
|
536
|
-
key:
|
|
482
|
+
key: r ? `url:${r}` : "node"
|
|
537
483
|
};
|
|
538
484
|
}
|
|
539
|
-
async function P(e = {}) {
|
|
540
|
-
let t = await N(e, s("highs"));
|
|
541
|
-
return t !== null && D === t.key;
|
|
542
|
-
}
|
|
543
485
|
async function F(e = {}) {
|
|
544
|
-
let t = await
|
|
486
|
+
let t = await P(e, o("highs"));
|
|
487
|
+
return t !== null && O === t.key;
|
|
488
|
+
}
|
|
489
|
+
async function I(e = {}) {
|
|
490
|
+
let t = await P(e, s("highs"));
|
|
545
491
|
if (!t) throw Error("[WaSHI] Failed to resolve HiGHS WASM target.");
|
|
546
492
|
let { isNode: n, wasmUrl: r, wasmBinary: i, key: a } = t;
|
|
547
|
-
if (
|
|
548
|
-
|
|
549
|
-
let
|
|
550
|
-
return
|
|
551
|
-
let e = n ? await f() : (await import("./highs-browser-runtime
|
|
493
|
+
if (E && D === a) return E;
|
|
494
|
+
D = a, O = null;
|
|
495
|
+
let o = null;
|
|
496
|
+
return o = (async () => {
|
|
497
|
+
let e = n ? await f() : (await import("./highs-browser-runtime.js")).default;
|
|
552
498
|
return i ? await e({
|
|
553
499
|
wasmBinary: i.slice(),
|
|
554
500
|
locateFile: (e) => e
|
|
555
501
|
}) : n ? await e() : await e({ locateFile: (e) => e.endsWith(".wasm") ? r : e });
|
|
556
|
-
})().then((e) => (
|
|
557
|
-
|
|
502
|
+
})().then((e) => (E === o && (O = a), e)).catch((e) => {
|
|
503
|
+
E === o && (E = null, D = null, O = null);
|
|
558
504
|
let t = e instanceof Error ? e.message : String(e), n = i ? " from embedded inline WASM" : r ? ` from "${r}"` : "";
|
|
559
505
|
throw Error(`[WaSHI] Failed to initialize HiGHS${n}. Deploy the package's WASM asset or explicitly set wasmUrl; no CDN fallback is attempted. ${t}`, { cause: e });
|
|
560
|
-
}),
|
|
506
|
+
}), E = o, o;
|
|
561
507
|
}
|
|
562
|
-
async function
|
|
563
|
-
if (
|
|
508
|
+
async function L(e, t = {}) {
|
|
509
|
+
if (T(t), t.signal?.aborted) return {
|
|
564
510
|
result: {
|
|
565
511
|
Status: "Interrupted",
|
|
566
512
|
StatusCode: 17,
|
|
@@ -571,7 +517,7 @@ async function I(e, t = {}) {
|
|
|
571
517
|
},
|
|
572
518
|
runTime: 0
|
|
573
519
|
};
|
|
574
|
-
let n = await
|
|
520
|
+
let n = await I(t);
|
|
575
521
|
if (t.signal?.aborted) return {
|
|
576
522
|
result: {
|
|
577
523
|
Status: "Interrupted",
|
|
@@ -585,7 +531,7 @@ async function I(e, t = {}) {
|
|
|
585
531
|
};
|
|
586
532
|
let r = performance.now(), i = { output_flag: t.outputFlag ?? !1 };
|
|
587
533
|
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.relativeGap !== void 0 && (i.mip_rel_gap = t.relativeGap), t.absoluteGap !== void 0 && (i.mip_abs_gap = t.absoluteGap);
|
|
588
|
-
for (let e of
|
|
534
|
+
for (let e of C) t[e] !== void 0 && (i[e] = t[e]);
|
|
589
535
|
let a = t.objectiveOffset ?? 0, o = t.initialValues, s = !1;
|
|
590
536
|
if (o) {
|
|
591
537
|
for (let [e, t] of Object.entries(o)) if (t !== void 0) {
|
|
@@ -645,7 +591,7 @@ async function I(e, t = {}) {
|
|
|
645
591
|
...u === void 0 ? {} : { message: u }
|
|
646
592
|
};
|
|
647
593
|
return p = d, d;
|
|
648
|
-
},
|
|
594
|
+
}, g = (e) => {
|
|
649
595
|
let n = e?.data;
|
|
650
596
|
if (!n || !(n.mip_solution instanceof Float64Array)) return;
|
|
651
597
|
let r = n.mip_solution, i = {};
|
|
@@ -688,7 +634,7 @@ async function I(e, t = {}) {
|
|
|
688
634
|
[r.ipmInterrupt]: i,
|
|
689
635
|
[r.mipInterrupt]: i,
|
|
690
636
|
[r.mipImprovingSolution]: (e) => {
|
|
691
|
-
|
|
637
|
+
g(e), t.onProgress && !t.signal?.aborted && (m++, t.onProgress(h(e)));
|
|
692
638
|
},
|
|
693
639
|
[r.mipLogging]: (e) => {
|
|
694
640
|
t.onProgress && !t.signal?.aborted && (m++, t.onProgress(h(e)));
|
|
@@ -698,7 +644,7 @@ async function I(e, t = {}) {
|
|
|
698
644
|
} else e.run();
|
|
699
645
|
let y = e.getModelStatus();
|
|
700
646
|
v && (y = 17);
|
|
701
|
-
let b =
|
|
647
|
+
let b = _[y] ?? "Unknown", x = 0, S = 0;
|
|
702
648
|
try {
|
|
703
649
|
x = Number(e.info.get("primal_solution_status"));
|
|
704
650
|
} catch {}
|
|
@@ -742,7 +688,7 @@ async function I(e, t = {}) {
|
|
|
742
688
|
M === void 0 && p && p.relativeGap !== void 0 && (M = p.relativeGap);
|
|
743
689
|
}
|
|
744
690
|
return {
|
|
745
|
-
Status:
|
|
691
|
+
Status: _[y] ?? b,
|
|
746
692
|
StatusCode: y,
|
|
747
693
|
PrimalSolutionStatus: x,
|
|
748
694
|
DualSolutionStatus: S,
|
|
@@ -760,4 +706,440 @@ async function I(e, t = {}) {
|
|
|
760
706
|
};
|
|
761
707
|
}
|
|
762
708
|
//#endregion
|
|
763
|
-
|
|
709
|
+
//#region src/modeler/solvers/highs/worker-client.ts
|
|
710
|
+
var R = null, z = null, B = null, V = !1, H = 0, U = /* @__PURE__ */ new Map();
|
|
711
|
+
function W(e, t) {
|
|
712
|
+
return e ? {
|
|
713
|
+
Status: "Interrupted",
|
|
714
|
+
StatusCode: 17,
|
|
715
|
+
HasPrimalSolution: !0,
|
|
716
|
+
IsMip: !0,
|
|
717
|
+
ObjectiveValue: e.objectiveValue,
|
|
718
|
+
ObjectiveOffsetApplied: !0,
|
|
719
|
+
...t?.objectiveBound === void 0 ? e.mipDualBound === void 0 ? {} : { MipDualBound: e.mipDualBound } : { MipDualBound: t.objectiveBound },
|
|
720
|
+
...t?.relativeGap === void 0 ? e.mipGap === void 0 ? {} : { MipGap: e.mipGap } : { MipGap: t.relativeGap },
|
|
721
|
+
Columns: e.columns,
|
|
722
|
+
Rows: []
|
|
723
|
+
} : {
|
|
724
|
+
Status: "Interrupted",
|
|
725
|
+
StatusCode: 17,
|
|
726
|
+
HasPrimalSolution: !1,
|
|
727
|
+
ObjectiveValue: NaN,
|
|
728
|
+
ObjectiveOffsetApplied: !0,
|
|
729
|
+
...t?.objectiveBound === void 0 ? {} : { MipDualBound: t.objectiveBound },
|
|
730
|
+
...t?.relativeGap === void 0 ? {} : { MipGap: t.relativeGap },
|
|
731
|
+
Columns: {},
|
|
732
|
+
Rows: []
|
|
733
|
+
};
|
|
734
|
+
}
|
|
735
|
+
function G(e) {
|
|
736
|
+
let t = U.values().next().value;
|
|
737
|
+
if (!t || t.dispatched) return;
|
|
738
|
+
t.dispatched = !0;
|
|
739
|
+
let n = {}, r = !1;
|
|
740
|
+
t.embeddedWasmBinary !== null && !V && (n.embeddedWasmBinary = t.embeddedWasmBinary, r = !0);
|
|
741
|
+
try {
|
|
742
|
+
t.kind === "WARMUP" ? e.postMessage({
|
|
743
|
+
type: "WARMUP",
|
|
744
|
+
id: t.id,
|
|
745
|
+
options: t.workerOptions,
|
|
746
|
+
...n
|
|
747
|
+
}) : e.postMessage({
|
|
748
|
+
type: "SOLVE",
|
|
749
|
+
id: t.id,
|
|
750
|
+
lpString: t.lpString,
|
|
751
|
+
options: t.workerOptions,
|
|
752
|
+
...n,
|
|
753
|
+
...t.reportProgress ? { reportProgress: !0 } : {}
|
|
754
|
+
}), r && (V = !0);
|
|
755
|
+
} catch (n) {
|
|
756
|
+
U.delete(t.id), t.cleanupAbort?.(), t.reject(n), G(e);
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
function K() {
|
|
760
|
+
let e = R;
|
|
761
|
+
e && (R = null, z = null, B = null, V = !1, e.terminate());
|
|
762
|
+
for (let e of U.values()) e.dispatched = !1;
|
|
763
|
+
if (U.size > 0) try {
|
|
764
|
+
let e = q();
|
|
765
|
+
if (e) G(e);
|
|
766
|
+
else {
|
|
767
|
+
let e = /* @__PURE__ */ Error("[WaSHI] Failed to recreate HiGHS Worker after interruption.");
|
|
768
|
+
for (let t of Array.from(U.values())) U.delete(t.id), t.cleanupAbort?.(), t.reject(e);
|
|
769
|
+
}
|
|
770
|
+
} catch (e) {
|
|
771
|
+
for (let t of Array.from(U.values())) U.delete(t.id), t.cleanupAbort?.(), t.reject(e);
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
function q() {
|
|
775
|
+
if (!c()) return null;
|
|
776
|
+
if (!R) {
|
|
777
|
+
let e;
|
|
778
|
+
try {
|
|
779
|
+
e = p(), e.onmessage = (t) => {
|
|
780
|
+
let { type: n, id: r, result: i, runTime: a, error: o, progress: s, incumbent: c } = t.data, l = U.get(r);
|
|
781
|
+
if (l) {
|
|
782
|
+
if (n === "SOLVE_PROGRESS") {
|
|
783
|
+
if (l.kind === "SOLVE" && s) {
|
|
784
|
+
l.lastProgress = s;
|
|
785
|
+
try {
|
|
786
|
+
l.onProgress?.(s);
|
|
787
|
+
} catch (e) {
|
|
788
|
+
let t = U.get(r);
|
|
789
|
+
if (t) {
|
|
790
|
+
let n = U.keys().next().value;
|
|
791
|
+
U.delete(r), t.cleanupAbort?.(), n === r && K(), t.reject(e);
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
return;
|
|
796
|
+
}
|
|
797
|
+
if (n === "SOLVE_INCUMBENT") {
|
|
798
|
+
l.kind === "SOLVE" && c && (l.lastIncumbent = c);
|
|
799
|
+
return;
|
|
800
|
+
}
|
|
801
|
+
U.delete(r), l.cleanupAbort?.(), l.kind === "WARMUP" ? n === "WARMUP_SUCCESS" ? (R === e && (z = e, B = l.targetKey), l.resolve()) : l.reject(Error(o || "Worker warmup failed")) : n === "SOLVE_SUCCESS" ? (R === e && (z = e, B = l.targetKey), l.resolve({
|
|
802
|
+
result: i,
|
|
803
|
+
runTime: a
|
|
804
|
+
})) : l.reject(Error(o || "Worker solve failed")), R === e && G(e);
|
|
805
|
+
}
|
|
806
|
+
};
|
|
807
|
+
let t = (t) => {
|
|
808
|
+
if (R === e) {
|
|
809
|
+
R = null, z = null, B = null, V = !1, e.terminate();
|
|
810
|
+
for (let e of U.values()) e.cleanupAbort?.(), e.reject(t);
|
|
811
|
+
U.clear();
|
|
812
|
+
}
|
|
813
|
+
};
|
|
814
|
+
e.onerror = (e) => t(/* @__PURE__ */ Error(`[WaSHI] HiGHS Worker failed to load or execute. Check Worker assets, CORS and CSP. ${e?.message || ""}`)), e.onmessageerror = () => t(/* @__PURE__ */ Error("[WaSHI] Could not deserialize the HiGHS Worker response.")), R = e;
|
|
815
|
+
} catch (e) {
|
|
816
|
+
throw R = null, l("HiGHS", e);
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
return R;
|
|
820
|
+
}
|
|
821
|
+
async function J(e, t) {
|
|
822
|
+
let n = t ? s("highs") : o("highs"), r = n?.kind === "embedded" ? n.bytes : null;
|
|
823
|
+
if (e.wasmUrl) {
|
|
824
|
+
let t = await N(e.wasmUrl);
|
|
825
|
+
return {
|
|
826
|
+
wasmUrl: t,
|
|
827
|
+
embeddedWasmBinary: r,
|
|
828
|
+
targetKey: `url:${t}`
|
|
829
|
+
};
|
|
830
|
+
}
|
|
831
|
+
if (j()) {
|
|
832
|
+
let e = await N();
|
|
833
|
+
return {
|
|
834
|
+
wasmUrl: e,
|
|
835
|
+
embeddedWasmBinary: r,
|
|
836
|
+
targetKey: `url:${e}`
|
|
837
|
+
};
|
|
838
|
+
}
|
|
839
|
+
if (!n) return {
|
|
840
|
+
wasmUrl: null,
|
|
841
|
+
embeddedWasmBinary: null,
|
|
842
|
+
targetKey: null
|
|
843
|
+
};
|
|
844
|
+
if (n.kind === "embedded") return {
|
|
845
|
+
wasmUrl: null,
|
|
846
|
+
embeddedWasmBinary: r,
|
|
847
|
+
targetKey: "__embedded__"
|
|
848
|
+
};
|
|
849
|
+
let i = await N();
|
|
850
|
+
return {
|
|
851
|
+
wasmUrl: i,
|
|
852
|
+
embeddedWasmBinary: null,
|
|
853
|
+
targetKey: `url:${i}`
|
|
854
|
+
};
|
|
855
|
+
}
|
|
856
|
+
function Y(e, t) {
|
|
857
|
+
let { signal: n, onProgress: r, onIncumbent: i, ...a } = e, o = {};
|
|
858
|
+
for (let [e, t] of Object.entries(a)) {
|
|
859
|
+
if (typeof t == "function") throw Error(`[WaSHI] HiGHS Worker option "${e}" cannot be a function (functions cannot be cloned across Web Worker boundaries).`);
|
|
860
|
+
o[e] = t;
|
|
861
|
+
}
|
|
862
|
+
return t === null ? delete o.wasmUrl : o.wasmUrl = t, o;
|
|
863
|
+
}
|
|
864
|
+
async function ee(e = {}) {
|
|
865
|
+
if (e.useWorker !== void 0 && typeof e.useWorker != "boolean") throw Error(`Invalid HiGHS option "useWorker": expected boolean, got ${typeof e.useWorker}.`);
|
|
866
|
+
if (e.useWorker !== !0) return F(e);
|
|
867
|
+
if (!c() || !R || !z || z !== R) return !1;
|
|
868
|
+
let { targetKey: t } = await J(e, !1);
|
|
869
|
+
return t !== null && B === t;
|
|
870
|
+
}
|
|
871
|
+
function X(e, t, n) {
|
|
872
|
+
if (!e) return;
|
|
873
|
+
let r = () => {
|
|
874
|
+
let e = U.get(t.id);
|
|
875
|
+
if (!e) return;
|
|
876
|
+
let r = U.keys().next().value;
|
|
877
|
+
U.delete(t.id), e.cleanupAbort?.(), r === t.id && K(), n();
|
|
878
|
+
};
|
|
879
|
+
e.addEventListener("abort", r, { once: !0 }), t.cleanupAbort = () => e.removeEventListener("abort", r);
|
|
880
|
+
}
|
|
881
|
+
async function te(e = {}) {
|
|
882
|
+
T(e);
|
|
883
|
+
let { signal: t } = e;
|
|
884
|
+
if (t?.aborted) return { cached: !1 };
|
|
885
|
+
if (e.useWorker !== !0) {
|
|
886
|
+
let n = await F(e);
|
|
887
|
+
return n || t?.aborted ? { cached: n } : t ? (await new Promise((n, r) => {
|
|
888
|
+
let i = !1, a = () => {
|
|
889
|
+
i || (i = !0, n());
|
|
890
|
+
};
|
|
891
|
+
t.addEventListener("abort", a, { once: !0 }), I(e).then(() => {
|
|
892
|
+
t.removeEventListener("abort", a), i || (i = !0, n());
|
|
893
|
+
}, (e) => {
|
|
894
|
+
t.removeEventListener("abort", a), i || (i = !0, r(e));
|
|
895
|
+
});
|
|
896
|
+
}), { cached: n }) : (await I(e), { cached: n });
|
|
897
|
+
}
|
|
898
|
+
u();
|
|
899
|
+
let n = await J(e, !0);
|
|
900
|
+
if (t?.aborted) return { cached: !1 };
|
|
901
|
+
let r = q();
|
|
902
|
+
if (!r) return u(), { cached: !1 };
|
|
903
|
+
if (z === r && B === n.targetKey) return { cached: !0 };
|
|
904
|
+
let i = Y(e, n.wasmUrl), a = `req_${++H}`;
|
|
905
|
+
return await new Promise((e, o) => {
|
|
906
|
+
let s = {
|
|
907
|
+
kind: "WARMUP",
|
|
908
|
+
id: a,
|
|
909
|
+
workerOptions: i,
|
|
910
|
+
embeddedWasmBinary: n.embeddedWasmBinary,
|
|
911
|
+
targetKey: n.targetKey,
|
|
912
|
+
resolve: e,
|
|
913
|
+
reject: o
|
|
914
|
+
};
|
|
915
|
+
X(t, s, e), U.set(a, s), G(r);
|
|
916
|
+
}), { cached: !1 };
|
|
917
|
+
}
|
|
918
|
+
async function Z(e, t = {}) {
|
|
919
|
+
if (T(t), t.signal?.aborted) return {
|
|
920
|
+
result: W(),
|
|
921
|
+
runTime: 0
|
|
922
|
+
};
|
|
923
|
+
if (t.useWorker !== !0) return L(e, t);
|
|
924
|
+
u();
|
|
925
|
+
let n = await J(t, !0);
|
|
926
|
+
if (t.signal?.aborted) return {
|
|
927
|
+
result: W(),
|
|
928
|
+
runTime: 0
|
|
929
|
+
};
|
|
930
|
+
let r = q();
|
|
931
|
+
if (!r) return u(), L(e, t);
|
|
932
|
+
let { signal: i, onProgress: a } = t, o = Y(t, n.wasmUrl), s = !!(a || i), c = `req_${++H}`, l = performance.now();
|
|
933
|
+
return new Promise((t, u) => {
|
|
934
|
+
let d = {
|
|
935
|
+
kind: "SOLVE",
|
|
936
|
+
id: c,
|
|
937
|
+
lpString: e,
|
|
938
|
+
workerOptions: o,
|
|
939
|
+
embeddedWasmBinary: n.embeddedWasmBinary,
|
|
940
|
+
targetKey: n.targetKey,
|
|
941
|
+
reportProgress: s,
|
|
942
|
+
startTime: l,
|
|
943
|
+
onProgress: a,
|
|
944
|
+
resolve: t,
|
|
945
|
+
reject: u
|
|
946
|
+
};
|
|
947
|
+
X(i, d, () => {
|
|
948
|
+
let e = (performance.now() - d.startTime) / 1e3;
|
|
949
|
+
d.resolve({
|
|
950
|
+
result: W(d.lastIncumbent, d.lastProgress),
|
|
951
|
+
runTime: e
|
|
952
|
+
});
|
|
953
|
+
}), U.set(c, d), G(r);
|
|
954
|
+
});
|
|
955
|
+
}
|
|
956
|
+
//#endregion
|
|
957
|
+
//#region src/modeler/solvers/highs/solver.ts
|
|
958
|
+
function Q(e, t) {
|
|
959
|
+
if (typeof t == "number") switch (t) {
|
|
960
|
+
case 0: return "NotSolved";
|
|
961
|
+
case 1:
|
|
962
|
+
case 2:
|
|
963
|
+
case 3:
|
|
964
|
+
case 4:
|
|
965
|
+
case 5: return "Error";
|
|
966
|
+
case 6: return "Unknown";
|
|
967
|
+
case 7: return "Optimal";
|
|
968
|
+
case 8: return "Infeasible";
|
|
969
|
+
case 9: return "InfeasibleOrUnbounded";
|
|
970
|
+
case 10: return "Unbounded";
|
|
971
|
+
case 11: return "ObjectiveBound";
|
|
972
|
+
case 12: return "ObjectiveTarget";
|
|
973
|
+
case 13: return "TimeLimit";
|
|
974
|
+
case 14: return "IterationLimit";
|
|
975
|
+
case 15: return "Unknown";
|
|
976
|
+
case 16: return "SolutionLimit";
|
|
977
|
+
case 17: return "Interrupted";
|
|
978
|
+
case 18: return "MemoryLimit";
|
|
979
|
+
}
|
|
980
|
+
if (typeof e != "string") return "Unknown";
|
|
981
|
+
let n = e.trim();
|
|
982
|
+
if (!n) return "Unknown";
|
|
983
|
+
switch (n) {
|
|
984
|
+
case "Optimal": return "Optimal";
|
|
985
|
+
case "Infeasible": return "Infeasible";
|
|
986
|
+
case "Unbounded": return "Unbounded";
|
|
987
|
+
case "Primal infeasible or unbounded":
|
|
988
|
+
case "InfeasibleOrUnbounded": return "InfeasibleOrUnbounded";
|
|
989
|
+
case "Time limit reached":
|
|
990
|
+
case "TimeLimit": return "TimeLimit";
|
|
991
|
+
case "Iteration limit reached":
|
|
992
|
+
case "IterationLimit": return "IterationLimit";
|
|
993
|
+
case "Solution limit reached":
|
|
994
|
+
case "SolutionLimit": return "SolutionLimit";
|
|
995
|
+
case "Memory limit reached":
|
|
996
|
+
case "MemoryLimit": return "MemoryLimit";
|
|
997
|
+
case "Bound on objective reached":
|
|
998
|
+
case "ObjectiveBound": return "ObjectiveBound";
|
|
999
|
+
case "Target for objective reached":
|
|
1000
|
+
case "ObjectiveTarget": return "ObjectiveTarget";
|
|
1001
|
+
case "Interrupted":
|
|
1002
|
+
case "User interrupt": return "Interrupted";
|
|
1003
|
+
case "Feasible": return "Feasible";
|
|
1004
|
+
case "Not Set": return "NotSolved";
|
|
1005
|
+
case "Load error":
|
|
1006
|
+
case "Model error":
|
|
1007
|
+
case "Presolve error":
|
|
1008
|
+
case "Solve error":
|
|
1009
|
+
case "Postsolve error":
|
|
1010
|
+
case "Error": return "Error";
|
|
1011
|
+
case "Empty":
|
|
1012
|
+
case "Unknown": return "Unknown";
|
|
1013
|
+
}
|
|
1014
|
+
return "Unknown";
|
|
1015
|
+
}
|
|
1016
|
+
function ne(e, t, n) {
|
|
1017
|
+
switch (Q(e, t)) {
|
|
1018
|
+
case "Optimal": return "Optimal";
|
|
1019
|
+
case "Infeasible": return "Infeasible";
|
|
1020
|
+
case "Unbounded": return "Unbounded";
|
|
1021
|
+
case "TimeLimit": return "TimeLimit";
|
|
1022
|
+
case "IterationLimit": return "IterationLimit";
|
|
1023
|
+
case "Feasible": return "Feasible";
|
|
1024
|
+
case "ObjectiveBound":
|
|
1025
|
+
case "ObjectiveTarget":
|
|
1026
|
+
case "SolutionLimit": return n === !1 ? "Unknown" : "Feasible";
|
|
1027
|
+
case "MemoryLimit":
|
|
1028
|
+
case "Interrupted": return n ? "Feasible" : "Unknown";
|
|
1029
|
+
case "NotSolved": return "NotSolved";
|
|
1030
|
+
case "Error": return "Error";
|
|
1031
|
+
default: return "Unknown";
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
var $ = class n {
|
|
1035
|
+
static capabilities = {
|
|
1036
|
+
supportsMIP: !0,
|
|
1037
|
+
supportsQP: !0,
|
|
1038
|
+
supportsWarmStart: !0
|
|
1039
|
+
};
|
|
1040
|
+
name = "HiGHS";
|
|
1041
|
+
version = "1.15.1";
|
|
1042
|
+
capabilities = n.capabilities;
|
|
1043
|
+
options;
|
|
1044
|
+
constructor(e = {}) {
|
|
1045
|
+
this.options = e;
|
|
1046
|
+
}
|
|
1047
|
+
async solve(n, r = {}, o = {}) {
|
|
1048
|
+
let s = a(r), c = s ? o : r, l = {
|
|
1049
|
+
...this.options,
|
|
1050
|
+
...c
|
|
1051
|
+
};
|
|
1052
|
+
T(l);
|
|
1053
|
+
let u = n.objective?.constant ?? 0;
|
|
1054
|
+
if (typeof u != "number" || !Number.isFinite(u)) throw Error(`Solver "${this.name}" encountered non-finite objective constant: ${String(u)}.`);
|
|
1055
|
+
let d = u === 0 ? 0 : u;
|
|
1056
|
+
for (let t of n.variables) e(t);
|
|
1057
|
+
let { lpString: f, nameToVar: p, nameToConstraint: m } = s ? r : i(n, { relax: l.relax }), h = Object.create(null), g = !1, _ = /* @__PURE__ */ new Set();
|
|
1058
|
+
for (let [e, n] of p.entries()) {
|
|
1059
|
+
_.add(n);
|
|
1060
|
+
let r = t(n);
|
|
1061
|
+
r !== void 0 && (h[e] = r, g = !0);
|
|
1062
|
+
}
|
|
1063
|
+
for (let e of n.variables) if (!_.has(e)) throw Error(`LP export symbol map (nameToVar) is missing model variable "${e.name}".`);
|
|
1064
|
+
let v = l;
|
|
1065
|
+
(d !== 0 || g || v.initialValues !== void 0) && (v = {
|
|
1066
|
+
...v,
|
|
1067
|
+
...d === 0 ? {} : { objectiveOffset: d },
|
|
1068
|
+
...g ? { initialValues: h } : {}
|
|
1069
|
+
});
|
|
1070
|
+
let { result: y, runTime: b } = await Z(f, v), x = y?.ObjectiveOffsetApplied ? 0 : d, S = Q(y?.Status, y?.StatusCode), C = l.relax ? !1 : typeof y?.IsMip == "boolean" ? y.IsMip : n.variables.some((e) => e.type === "Integer" || e.type === "Binary"), w = y?.HasPrimalSolution === !0, E = ne(y?.Status, y?.StatusCode, w), D = null;
|
|
1071
|
+
w && typeof y?.ObjectiveValue == "number" && Number.isFinite(y.ObjectiveValue) && (D = y.ObjectiveValue + x);
|
|
1072
|
+
let O, k, A;
|
|
1073
|
+
if (typeof y?.MipDualBound == "number" && Number.isFinite(y.MipDualBound) ? O = y.MipDualBound + x : !C && S === "Optimal" && D !== null && (O = D), D !== null && O !== void 0 && Number.isFinite(O) && (A = Math.abs(D - O)), x !== 0 && C && D !== null && O !== void 0 && A !== void 0) {
|
|
1074
|
+
if (A === 0) k = 0;
|
|
1075
|
+
else if (Math.abs(D) > 0) {
|
|
1076
|
+
let e = A / Math.abs(D);
|
|
1077
|
+
k = Number.isFinite(e) ? e : void 0;
|
|
1078
|
+
} else k = void 0;
|
|
1079
|
+
} else typeof y?.MipGap == "number" && Number.isFinite(y.MipGap) ? k = y.MipGap : C && S === "Optimal" && w && (A === void 0 || A === 0) && (k = 0);
|
|
1080
|
+
if (!w) return {
|
|
1081
|
+
status: E,
|
|
1082
|
+
terminationStatus: S,
|
|
1083
|
+
hasPrimalSolution: !1,
|
|
1084
|
+
objectiveValue: null,
|
|
1085
|
+
...O === void 0 ? {} : { objectiveBound: O },
|
|
1086
|
+
...k === void 0 ? {} : { relativeGap: k },
|
|
1087
|
+
...A === void 0 ? {} : { absoluteGap: A },
|
|
1088
|
+
values: {},
|
|
1089
|
+
reducedCosts: {},
|
|
1090
|
+
duals: {},
|
|
1091
|
+
slacks: {},
|
|
1092
|
+
runTime: b,
|
|
1093
|
+
raw: y
|
|
1094
|
+
};
|
|
1095
|
+
let j = (e, t, n) => {
|
|
1096
|
+
Object.defineProperty(e, t, {
|
|
1097
|
+
value: n,
|
|
1098
|
+
enumerable: !0,
|
|
1099
|
+
writable: !0,
|
|
1100
|
+
configurable: !0
|
|
1101
|
+
});
|
|
1102
|
+
}, M = {}, N = {}, P = {}, F = {};
|
|
1103
|
+
if (y.Columns) for (let [e, t] of Object.entries(y.Columns)) {
|
|
1104
|
+
let n = p.get(e);
|
|
1105
|
+
if (n) {
|
|
1106
|
+
if (typeof t.Primal == "number" && Number.isFinite(t.Primal)) {
|
|
1107
|
+
let e = Math.abs(t.Primal) < 1e-9 ? 0 : t.Primal;
|
|
1108
|
+
!l.relax && (n.type === "Integer" || n.type === "Binary") && Math.abs(e - Math.round(e)) <= 1e-5 && (e = Math.round(e) + 0), j(M, n.name, e);
|
|
1109
|
+
}
|
|
1110
|
+
typeof t.Dual == "number" && Number.isFinite(t.Dual) && j(P, n.name, Math.abs(t.Dual) < 1e-9 ? 0 : t.Dual);
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
if (y.Rows) {
|
|
1114
|
+
let e = Array.isArray(y.Rows) ? y.Rows : Object.values(y.Rows);
|
|
1115
|
+
for (let t of e) {
|
|
1116
|
+
let e = t.Name, n = e ? m.get(e) : void 0;
|
|
1117
|
+
if (n && (typeof t.Dual == "number" && Number.isFinite(t.Dual) && j(N, n.name, Math.abs(t.Dual) < 1e-9 ? 0 : t.Dual), typeof t.Primal == "number" && Number.isFinite(t.Primal))) {
|
|
1118
|
+
let e = n.rhs - t.Primal;
|
|
1119
|
+
j(F, n.name, Math.abs(e) < 1e-9 ? 0 : e);
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
return {
|
|
1124
|
+
status: E,
|
|
1125
|
+
terminationStatus: S,
|
|
1126
|
+
hasPrimalSolution: !0,
|
|
1127
|
+
objectiveValue: D,
|
|
1128
|
+
...O === void 0 ? {} : { objectiveBound: O },
|
|
1129
|
+
...k === void 0 ? {} : { relativeGap: k },
|
|
1130
|
+
...A === void 0 ? {} : { absoluteGap: A },
|
|
1131
|
+
values: M,
|
|
1132
|
+
reducedCosts: P,
|
|
1133
|
+
duals: N,
|
|
1134
|
+
slacks: F,
|
|
1135
|
+
runTime: b,
|
|
1136
|
+
raw: y
|
|
1137
|
+
};
|
|
1138
|
+
}
|
|
1139
|
+
}, re = $;
|
|
1140
|
+
function ie() {
|
|
1141
|
+
r("highs", (e) => new $(e)), n((e) => new $(e));
|
|
1142
|
+
}
|
|
1143
|
+
ie();
|
|
1144
|
+
//#endregion
|
|
1145
|
+
export { v as HIGHS_CONSTANTS, _ as HIGHS_STATUS_NAMES, re as HiGHS, S as Highs, h as HighsError, x as HighsModel, $ as HighsSolver, g as HighsUnsupportedOptionError, y as bindHighsFunctions, I as getHighs, j as getHighsWasmUrl, F as isHighsCached, ee as isHighsWarmed, M as isValidWasmHeader, ne as mapHighsStatus, Q as mapHighsTerminationStatus, ie as registerHighsSolver, N as resolveBrowserWasmUrl, A as setHighsWasmUrl, Z as solveLp, L as solveLpWithHighs, T as validateHighsOptions, te as warmupHighs };
|