@ohtaman/washi 0.8.2 → 0.9.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 +3 -0
- package/dist/browser/solvers/{highs-__vite-browser-external-Dn-83hnF.js → highs-__vite-browser-external-xcxOpLMD.js} +1 -1
- package/dist/browser/solvers/{highs-browser-runtime-0Bgq5ksG.js → highs-browser-runtime-ccRmE4qj.js} +1 -1
- package/dist/browser/solvers/highs-inline.js +51 -0
- package/dist/{lib/solvers/loader-CDpPXN_F.js → browser/solvers/highs-loader-Csn3-0tq.js} +241 -149
- package/dist/browser/solvers/highs-worker.js +17 -16
- package/dist/browser/solvers/highs.js +295 -255
- package/dist/browser/solvers/pumpkin-inline.js +51 -0
- package/dist/{lib/solvers/loader-Ow74Fa1B.js → browser/solvers/pumpkin-loader-BI3n3dWO.js} +145 -55
- package/dist/browser/solvers/pumpkin-worker.js +24 -23
- package/dist/browser/solvers/pumpkin.js +307 -288
- package/dist/browser/washi.js +365 -316
- package/dist/browser/washi.min.js +4 -4
- package/dist/lib/solvers/embedded-wasm-CSFlLV5N.js +49 -0
- package/dist/lib/solvers/highs-node-runtime.js +1 -7
- package/dist/lib/solvers/highs-worker.js +19 -17
- package/dist/lib/solvers/highs.js +153 -112
- package/dist/{browser/solvers/highs-loader-BLY3wzDH.js → lib/solvers/loader-DCtyxsfF.js} +56 -36
- package/dist/{browser/solvers/pumpkin-loader-CvdaKxf4.js → lib/solvers/loader-b5PNpCmX.js} +58 -33
- package/dist/lib/solvers/pumpkin-worker.js +25 -23
- package/dist/lib/solvers/pumpkin.js +212 -192
- package/dist/lib/washi.js +365 -316
- package/dist/types/modeler/model.d.ts +7 -0
- package/dist/types/modeler/model.d.ts.map +1 -1
- package/dist/types/modeler/solvers/embedded-wasm.d.ts +36 -0
- package/dist/types/modeler/solvers/embedded-wasm.d.ts.map +1 -0
- package/dist/types/modeler/solvers/highs/loader.d.ts.map +1 -1
- package/dist/types/modeler/solvers/highs/node-runtime.d.ts.map +1 -1
- package/dist/types/modeler/solvers/highs/worker-client.d.ts.map +1 -1
- package/dist/types/modeler/solvers/inline-pack.d.ts +6 -0
- package/dist/types/modeler/solvers/inline-pack.d.ts.map +1 -0
- package/dist/types/modeler/solvers/pumpkin/loader.d.ts +1 -1
- 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.map +1 -1
- package/dist/types/modeler/solvers/pumpkin/worker.d.ts +1 -0
- package/dist/types/modeler/solvers/pumpkin/worker.d.ts.map +1 -1
- package/docs/getting-started/ai-agents.md +56 -1
- package/docs/getting-started/coding-agents.md +38 -5
- package/docs/getting-started/runtimes.md +63 -1
- package/docs/solvers/highs.md +2 -0
- package/docs/solvers/pumpkin.md +2 -0
- package/llms-full.txt +123 -2
- package/llms.txt +56 -1
- package/package.json +12 -1
- package/skills/washi/SKILL.md +75 -14
- package/skills/washi/references/single-html.md +330 -0
|
@@ -1,7 +1,68 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/modeler/solvers/embedded-wasm.ts
|
|
2
|
+
var e = {
|
|
3
|
+
highs: null,
|
|
4
|
+
pumpkin: null
|
|
5
|
+
};
|
|
6
|
+
function t(e) {
|
|
7
|
+
return e === "highs" ? "v1.16.0:d1c2cb62726e24a7:2bd77844c41e9c91" : "0.5.0:fc7ddaf3ae17fcc8:ea94cc1b794de550";
|
|
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
|
|
3
64
|
//#region src/modeler/solvers/highs/driver.ts
|
|
4
|
-
function
|
|
65
|
+
function p(e, t, n) {
|
|
5
66
|
if (n <= 0 || !t) return /* @__PURE__ */ new Float64Array();
|
|
6
67
|
let r = e.wasmMemory ? e.wasmMemory.buffer : e.HEAPF64 ? e.HEAPF64.buffer : e.HEAP8?.buffer;
|
|
7
68
|
if (r) return new Float64Array(r, t, n).slice();
|
|
@@ -9,15 +70,15 @@ function n(e, t, n) {
|
|
|
9
70
|
for (let r = 0; r < n; r++) i[r] = e.getValue(t + r * 8, "double");
|
|
10
71
|
return i;
|
|
11
72
|
}
|
|
12
|
-
var
|
|
73
|
+
var m = class extends Error {
|
|
13
74
|
constructor(e) {
|
|
14
75
|
super(e), this.name = "HighsError";
|
|
15
76
|
}
|
|
16
|
-
},
|
|
77
|
+
}, h = class extends m {
|
|
17
78
|
constructor(e) {
|
|
18
79
|
super(e), this.name = "HighsUnsupportedOptionError";
|
|
19
80
|
}
|
|
20
|
-
},
|
|
81
|
+
}, g = {
|
|
21
82
|
0: "Not Set",
|
|
22
83
|
1: "Load error",
|
|
23
84
|
2: "Model error",
|
|
@@ -37,7 +98,7 @@ var r = class extends Error {
|
|
|
37
98
|
16: "Solution limit reached",
|
|
38
99
|
17: "Interrupted",
|
|
39
100
|
18: "Memory limit reached"
|
|
40
|
-
},
|
|
101
|
+
}, _ = {
|
|
41
102
|
callbackType: {
|
|
42
103
|
logging: 0,
|
|
43
104
|
simplexInterrupt: 1,
|
|
@@ -76,7 +137,7 @@ var r = class extends Error {
|
|
|
76
137
|
interrupt: 17
|
|
77
138
|
}
|
|
78
139
|
};
|
|
79
|
-
function
|
|
140
|
+
function v(e) {
|
|
80
141
|
return {
|
|
81
142
|
create: e.cwrap("Highs_create", "number", []),
|
|
82
143
|
destroy: e.cwrap("Highs_destroy", "void", ["number"]),
|
|
@@ -170,7 +231,7 @@ function s(e) {
|
|
|
170
231
|
stopCallback: e.cwrap("Highs_stopCallback", "number", ["number", "number"])
|
|
171
232
|
};
|
|
172
233
|
}
|
|
173
|
-
var
|
|
234
|
+
var y = 0, b = class {
|
|
174
235
|
highs;
|
|
175
236
|
module;
|
|
176
237
|
bindings;
|
|
@@ -181,7 +242,7 @@ var c = 0, l = class {
|
|
|
181
242
|
}
|
|
182
243
|
changeObjectiveOffset(e) {
|
|
183
244
|
let t = this.bindings.changeObjectiveOffset(this.highs, e);
|
|
184
|
-
if (t !== 0) throw new
|
|
245
|
+
if (t !== 0) throw new m(`Highs_changeObjectiveOffset failed with status ${t}`);
|
|
185
246
|
}
|
|
186
247
|
getObjectiveOffset() {
|
|
187
248
|
let e = this.module._malloc(8);
|
|
@@ -193,7 +254,7 @@ var c = 0, l = class {
|
|
|
193
254
|
}
|
|
194
255
|
options = { set: (e, t) => {
|
|
195
256
|
let n = -1;
|
|
196
|
-
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
|
|
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 h(`Option "${e}" with value ${JSON.stringify(t)} is not supported or invalid in HiGHS`);
|
|
197
258
|
} };
|
|
198
259
|
getDimensions() {
|
|
199
260
|
return {
|
|
@@ -220,69 +281,69 @@ var c = 0, l = class {
|
|
|
220
281
|
let t = e.colValue.length, n = this.module._malloc(t * 8);
|
|
221
282
|
try {
|
|
222
283
|
for (let r = 0; r < t; r++) this.module.setValue(n + r * 8, e.colValue[r], "double");
|
|
223
|
-
let
|
|
224
|
-
if (
|
|
284
|
+
let r = this.bindings.setSolution(this.highs, n, 0, 0, 0);
|
|
285
|
+
if (r !== 0) throw new m(`Highs_setSolution failed with status ${r}`);
|
|
225
286
|
} finally {
|
|
226
287
|
this.module._free(n);
|
|
227
288
|
}
|
|
228
289
|
return;
|
|
229
290
|
}
|
|
230
291
|
if (e.indices && e.values && e.indices.length === e.values.length) {
|
|
231
|
-
let t = e.indices.length, n = this.module._malloc(t * 4),
|
|
292
|
+
let t = e.indices.length, n = this.module._malloc(t * 4), r = this.module._malloc(t * 8);
|
|
232
293
|
try {
|
|
233
|
-
for (let
|
|
234
|
-
let
|
|
235
|
-
if (
|
|
294
|
+
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
|
+
let i = this.bindings.setSparseSolution(this.highs, t, n, r);
|
|
296
|
+
if (i !== 0) throw new m(`Highs_setSparseSolution failed with status ${i}`);
|
|
236
297
|
} finally {
|
|
237
|
-
this.module._free(n), this.module._free(
|
|
298
|
+
this.module._free(n), this.module._free(r);
|
|
238
299
|
}
|
|
239
300
|
return;
|
|
240
301
|
}
|
|
241
|
-
throw new
|
|
302
|
+
throw new m("Invalid argument to setSolution (expected { colValue } or { indices, values })");
|
|
242
303
|
}
|
|
243
304
|
run(e) {
|
|
244
|
-
let t = 0,
|
|
305
|
+
let t = 0, n = [];
|
|
245
306
|
if (e) {
|
|
246
|
-
if (typeof this.module.addFunction != "function") throw new
|
|
247
|
-
t = this.module.addFunction((t, r, i
|
|
248
|
-
let
|
|
249
|
-
if (!
|
|
250
|
-
let
|
|
251
|
-
if (
|
|
252
|
-
let e = this.module.getValue(
|
|
253
|
-
|
|
307
|
+
if (typeof this.module.addFunction != "function") throw new m("HiGHS WebAssembly runtime does not support module.addFunction; progress and interrupt callbacks are unavailable.");
|
|
308
|
+
t = this.module.addFunction((t, n, r, i) => {
|
|
309
|
+
let a = e[t];
|
|
310
|
+
if (!a) return;
|
|
311
|
+
let o = {};
|
|
312
|
+
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"), m = this.module.getValue(r + 84, "i32"), h;
|
|
314
|
+
f && m > 0 && (h = p(this.module, f, m)), o = {
|
|
254
315
|
running_time: e,
|
|
255
316
|
simplex_iteration_count: t,
|
|
256
|
-
ipm_iteration_count:
|
|
257
|
-
pdlp_iteration_count:
|
|
258
|
-
objective_function_value:
|
|
259
|
-
mip_node_count:
|
|
260
|
-
mip_total_lp_iterations:
|
|
261
|
-
mip_primal_bound:
|
|
262
|
-
mip_dual_bound:
|
|
263
|
-
mip_gap:
|
|
317
|
+
ipm_iteration_count: n,
|
|
318
|
+
pdlp_iteration_count: i,
|
|
319
|
+
objective_function_value: a,
|
|
320
|
+
mip_node_count: s,
|
|
321
|
+
mip_total_lp_iterations: c,
|
|
322
|
+
mip_primal_bound: l,
|
|
323
|
+
mip_dual_bound: u,
|
|
324
|
+
mip_gap: d,
|
|
264
325
|
...h ? { mip_solution: h } : {}
|
|
265
326
|
};
|
|
266
327
|
}
|
|
267
|
-
let
|
|
268
|
-
|
|
269
|
-
data:
|
|
270
|
-
message:
|
|
328
|
+
let s = n ? this.module.UTF8ToString(n) : "";
|
|
329
|
+
a({
|
|
330
|
+
data: o,
|
|
331
|
+
message: s,
|
|
271
332
|
interrupt: () => {
|
|
272
|
-
|
|
333
|
+
i && this.module.setValue(i, 1, "i32");
|
|
273
334
|
}
|
|
274
335
|
});
|
|
275
336
|
}, "vipppp"), this.bindings.setCallback(this.highs, t, 0);
|
|
276
337
|
for (let t of Object.keys(e)) {
|
|
277
338
|
let e = Number(t);
|
|
278
|
-
this.bindings.startCallback(this.highs, e),
|
|
339
|
+
this.bindings.startCallback(this.highs, e), n.push(e);
|
|
279
340
|
}
|
|
280
341
|
}
|
|
281
342
|
try {
|
|
282
343
|
return this.bindings.run(this.highs);
|
|
283
344
|
} finally {
|
|
284
345
|
if (t) {
|
|
285
|
-
for (let e of
|
|
346
|
+
for (let e of n) try {
|
|
286
347
|
this.bindings.stopCallback(this.highs, e);
|
|
287
348
|
} catch {}
|
|
288
349
|
try {
|
|
@@ -307,19 +368,19 @@ var c = 0, l = class {
|
|
|
307
368
|
} finally {
|
|
308
369
|
this.module._free(n);
|
|
309
370
|
}
|
|
310
|
-
throw new
|
|
371
|
+
throw new m(`Info item "${e}" not available or unknown in HiGHS`);
|
|
311
372
|
} };
|
|
312
373
|
getSolution() {
|
|
313
|
-
let e = this.getDimensions(), t = e.numCols > 0 ? this.module._malloc(e.numCols * 8) : 0,
|
|
374
|
+
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;
|
|
314
375
|
try {
|
|
315
|
-
return this.bindings.getSolution(this.highs, t, r, i
|
|
316
|
-
colValue:
|
|
317
|
-
colDual:
|
|
318
|
-
rowValue:
|
|
319
|
-
rowDual:
|
|
376
|
+
return this.bindings.getSolution(this.highs, t, n, r, i), {
|
|
377
|
+
colValue: p(this.module, t, e.numCols),
|
|
378
|
+
colDual: p(this.module, n, e.numCols),
|
|
379
|
+
rowValue: p(this.module, r, e.numRows),
|
|
380
|
+
rowDual: p(this.module, i, e.numRows)
|
|
320
381
|
};
|
|
321
382
|
} finally {
|
|
322
|
-
t && this.module._free(t),
|
|
383
|
+
t && this.module._free(t), n && this.module._free(n), r && this.module._free(r), i && this.module._free(i);
|
|
323
384
|
}
|
|
324
385
|
}
|
|
325
386
|
getObjectiveValue() {
|
|
@@ -339,31 +400,31 @@ var c = 0, l = class {
|
|
|
339
400
|
[Symbol.dispose]() {
|
|
340
401
|
this.destroy();
|
|
341
402
|
}
|
|
342
|
-
},
|
|
403
|
+
}, x = class {
|
|
343
404
|
module;
|
|
344
405
|
bindings;
|
|
345
|
-
constants =
|
|
406
|
+
constants = _;
|
|
346
407
|
errors = {
|
|
347
|
-
HighsError:
|
|
348
|
-
HighsUnsupportedOptionError:
|
|
408
|
+
HighsError: m,
|
|
409
|
+
HighsUnsupportedOptionError: h
|
|
349
410
|
};
|
|
350
411
|
constructor(e) {
|
|
351
|
-
this.module = e, this.bindings =
|
|
412
|
+
this.module = e, this.bindings = v(e);
|
|
352
413
|
}
|
|
353
414
|
withModel(e, t) {
|
|
354
|
-
let n = this.bindings.create(),
|
|
355
|
-
if (!this.module.FS) throw new
|
|
356
|
-
let
|
|
415
|
+
let n = this.bindings.create(), r = new b(this.module, this.bindings, n), i = `/model_${++y}.${e.format}`;
|
|
416
|
+
if (!this.module.FS) throw new m("Emscripten FS is not initialized on this HiGHS module instance");
|
|
417
|
+
let a = this.module.FS;
|
|
357
418
|
try {
|
|
358
|
-
|
|
359
|
-
let
|
|
360
|
-
if (
|
|
361
|
-
return t(
|
|
419
|
+
a.writeFile(i, e.data);
|
|
420
|
+
let o = this.bindings.readModel(n, i);
|
|
421
|
+
if (o !== 0) throw new m(`Failed to load ${e.format.toUpperCase()} model into HiGHS (status ${o})`);
|
|
422
|
+
return t(r);
|
|
362
423
|
} finally {
|
|
363
424
|
try {
|
|
364
|
-
|
|
425
|
+
a.unlink(i);
|
|
365
426
|
} catch {}
|
|
366
|
-
|
|
427
|
+
r.destroy();
|
|
367
428
|
}
|
|
368
429
|
}
|
|
369
430
|
solve(e, t = {}) {
|
|
@@ -373,10 +434,10 @@ var c = 0, l = class {
|
|
|
373
434
|
}, (e) => {
|
|
374
435
|
for (let [n, r] of Object.entries(t)) e.options.set(n, r);
|
|
375
436
|
e.run();
|
|
376
|
-
let n = e.getModelStatus(), r = e.getDimensions(), i = e.getSolution(),
|
|
437
|
+
let n = e.getModelStatus(), r = e.getDimensions(), i = e.getSolution(), a = {};
|
|
377
438
|
for (let t = 0; t < r.numCols; t++) {
|
|
378
439
|
let n = e.getColName(t);
|
|
379
|
-
|
|
440
|
+
a[n] = {
|
|
380
441
|
Index: t,
|
|
381
442
|
Name: n,
|
|
382
443
|
Primal: i.colValue[t],
|
|
@@ -384,20 +445,20 @@ var c = 0, l = class {
|
|
|
384
445
|
};
|
|
385
446
|
}
|
|
386
447
|
return {
|
|
387
|
-
Status:
|
|
448
|
+
Status: g[n] ?? "Unknown",
|
|
388
449
|
StatusCode: n,
|
|
389
450
|
ObjectiveValue: e.getObjectiveValue(),
|
|
390
|
-
Columns:
|
|
451
|
+
Columns: a
|
|
391
452
|
};
|
|
392
453
|
});
|
|
393
454
|
}
|
|
394
|
-
},
|
|
455
|
+
}, S = [
|
|
395
456
|
"mip_max_nodes",
|
|
396
457
|
"mip_max_improving_sols",
|
|
397
458
|
"mip_max_leaves",
|
|
398
459
|
"simplex_iteration_limit",
|
|
399
460
|
"ipm_iteration_limit"
|
|
400
|
-
],
|
|
461
|
+
], C = /* @__PURE__ */ new Set([
|
|
401
462
|
"timeLimit",
|
|
402
463
|
"outputFlag",
|
|
403
464
|
"presolve",
|
|
@@ -412,12 +473,12 @@ var c = 0, l = class {
|
|
|
412
473
|
"useWorker",
|
|
413
474
|
"objectiveOffset",
|
|
414
475
|
"initialValues",
|
|
415
|
-
...
|
|
476
|
+
...S
|
|
416
477
|
]);
|
|
417
|
-
function
|
|
478
|
+
function w(e = {}) {
|
|
418
479
|
if (e.threads !== void 0) throw Error("Solver \"HiGHS\" does not support option \"threads\" (HiGHS WebAssembly runs single-threaded).");
|
|
419
480
|
if (e.verbose !== void 0) throw Error("Solver \"HiGHS\" does not support option \"verbose\"; use \"outputFlag\" instead.");
|
|
420
|
-
for (let [t, n] of Object.entries(e)) if (n !== void 0 && !
|
|
481
|
+
for (let [t, n] of Object.entries(e)) if (n !== void 0 && !C.has(t)) throw Error(`Solver "HiGHS" does not support option "${t}".`);
|
|
421
482
|
if (e.useWorker !== void 0 && typeof e.useWorker != "boolean") throw Error(`Invalid HiGHS option "useWorker": expected boolean, got ${typeof e.useWorker}.`);
|
|
422
483
|
if (e.outputFlag !== void 0 && typeof e.outputFlag != "boolean") throw Error(`Invalid HiGHS option "outputFlag": expected boolean, got ${typeof e.outputFlag}.`);
|
|
423
484
|
if (e.relax !== void 0 && typeof e.relax != "boolean") throw Error(`Invalid HiGHS option "relax": expected boolean, got ${typeof e.relax}.`);
|
|
@@ -428,47 +489,78 @@ function p(e = {}) {
|
|
|
428
489
|
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.`);
|
|
429
490
|
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.");
|
|
430
491
|
}
|
|
431
|
-
var
|
|
432
|
-
function
|
|
433
|
-
|
|
492
|
+
var T = null, E = null, D = null, O = null;
|
|
493
|
+
function k(e) {
|
|
494
|
+
O = e, T = null, E = null, D = null;
|
|
434
495
|
}
|
|
435
|
-
function
|
|
436
|
-
return
|
|
496
|
+
function A() {
|
|
497
|
+
return O;
|
|
437
498
|
}
|
|
438
|
-
function
|
|
499
|
+
function j(e) {
|
|
439
500
|
return e.length >= 4 && e[0] === 0 && e[1] === 97 && e[2] === 115 && e[3] === 109;
|
|
440
501
|
}
|
|
441
|
-
async function
|
|
442
|
-
return
|
|
502
|
+
async function M(e) {
|
|
503
|
+
return e || O || d();
|
|
443
504
|
}
|
|
444
|
-
async function
|
|
445
|
-
|
|
505
|
+
async function N(e, t) {
|
|
506
|
+
if (e.wasmUrl) {
|
|
507
|
+
let t = await M(e.wasmUrl);
|
|
508
|
+
return {
|
|
509
|
+
isNode: !1,
|
|
510
|
+
wasmUrl: t,
|
|
511
|
+
wasmBinary: null,
|
|
512
|
+
key: t ? `url:${t}` : "node"
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
if (O) {
|
|
516
|
+
let e = await M();
|
|
517
|
+
return {
|
|
518
|
+
isNode: !1,
|
|
519
|
+
wasmUrl: e,
|
|
520
|
+
wasmBinary: null,
|
|
521
|
+
key: e ? `url:${e}` : "node"
|
|
522
|
+
};
|
|
523
|
+
}
|
|
524
|
+
if (t === null) return null;
|
|
525
|
+
if (t.kind === "embedded") return {
|
|
526
|
+
isNode: !1,
|
|
527
|
+
wasmUrl: null,
|
|
528
|
+
wasmBinary: t.bytes,
|
|
529
|
+
key: "__embedded__"
|
|
530
|
+
};
|
|
531
|
+
let n = await M();
|
|
446
532
|
return {
|
|
447
|
-
isNode:
|
|
533
|
+
isNode: !1,
|
|
448
534
|
wasmUrl: n,
|
|
449
|
-
|
|
535
|
+
wasmBinary: null,
|
|
536
|
+
key: n ? `url:${n}` : "node"
|
|
450
537
|
};
|
|
451
538
|
}
|
|
452
|
-
async function
|
|
453
|
-
let
|
|
454
|
-
return
|
|
539
|
+
async function P(e = {}) {
|
|
540
|
+
let t = await N(e, s("highs"));
|
|
541
|
+
return t !== null && D === t.key;
|
|
455
542
|
}
|
|
456
|
-
async function
|
|
457
|
-
let
|
|
458
|
-
if (
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
543
|
+
async function F(e = {}) {
|
|
544
|
+
let t = await N(e, o("highs"));
|
|
545
|
+
if (!t) throw Error("[WaSHI] Failed to resolve HiGHS WASM target.");
|
|
546
|
+
let { isNode: n, wasmUrl: r, wasmBinary: i, key: a } = t;
|
|
547
|
+
if (T && E === a) return T;
|
|
548
|
+
E = a, D = null;
|
|
549
|
+
let s = null;
|
|
550
|
+
return s = (async () => {
|
|
551
|
+
let e = n ? await f() : (await import("./highs-browser-runtime-ccRmE4qj.js")).default;
|
|
552
|
+
return i ? await e({
|
|
553
|
+
wasmBinary: i.slice(),
|
|
554
|
+
locateFile: (e) => e
|
|
555
|
+
}) : n ? await e() : await e({ locateFile: (e) => e.endsWith(".wasm") ? r : e });
|
|
556
|
+
})().then((e) => (T === s && (D = a), e)).catch((e) => {
|
|
557
|
+
T === s && (T = null, E = null, D = null);
|
|
558
|
+
let t = e instanceof Error ? e.message : String(e), n = i ? " from embedded inline WASM" : r ? ` from "${r}"` : "";
|
|
559
|
+
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
|
+
}), T = s, s;
|
|
469
561
|
}
|
|
470
|
-
async function
|
|
471
|
-
if (
|
|
562
|
+
async function I(e, t = {}) {
|
|
563
|
+
if (w(t), t.signal?.aborted) return {
|
|
472
564
|
result: {
|
|
473
565
|
Status: "Interrupted",
|
|
474
566
|
StatusCode: 17,
|
|
@@ -479,7 +571,7 @@ async function T(e, t = {}) {
|
|
|
479
571
|
},
|
|
480
572
|
runTime: 0
|
|
481
573
|
};
|
|
482
|
-
let n = await
|
|
574
|
+
let n = await F(t);
|
|
483
575
|
if (t.signal?.aborted) return {
|
|
484
576
|
result: {
|
|
485
577
|
Status: "Interrupted",
|
|
@@ -493,12 +585,12 @@ async function T(e, t = {}) {
|
|
|
493
585
|
};
|
|
494
586
|
let r = performance.now(), i = { output_flag: t.outputFlag ?? !1 };
|
|
495
587
|
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);
|
|
496
|
-
for (let e of
|
|
497
|
-
let
|
|
498
|
-
if (
|
|
499
|
-
for (let [e, t] of Object.entries(
|
|
588
|
+
for (let e of S) t[e] !== void 0 && (i[e] = t[e]);
|
|
589
|
+
let a = t.objectiveOffset ?? 0, o = t.initialValues, s = !1;
|
|
590
|
+
if (o) {
|
|
591
|
+
for (let [e, t] of Object.entries(o)) if (t !== void 0) {
|
|
500
592
|
if (typeof t != "number" || !Number.isFinite(t)) throw Error(`Invalid initial value for column "${e}": ${String(t)} (must be a finite number).`);
|
|
501
|
-
|
|
593
|
+
s = !0;
|
|
502
594
|
}
|
|
503
595
|
}
|
|
504
596
|
if (typeof n.withModel != "function") throw Error("[WaSHI] HiGHS runtime is missing required withModel() API (legacy highs.solve fallback has been removed).");
|
|
@@ -507,40 +599,40 @@ async function T(e, t = {}) {
|
|
|
507
599
|
format: "lp",
|
|
508
600
|
data: e
|
|
509
601
|
}, (e) => {
|
|
510
|
-
let
|
|
511
|
-
if (
|
|
602
|
+
let c = !1;
|
|
603
|
+
if (a !== 0) {
|
|
512
604
|
if (typeof e.changeObjectiveOffset != "function") throw Error("[WaSHI] HiGHS runtime does not support changeObjectiveOffset() for non-zero objectiveOffset.");
|
|
513
605
|
let t = typeof e.getObjectiveOffset == "function" ? e.getObjectiveOffset() : 0;
|
|
514
|
-
e.changeObjectiveOffset(t +
|
|
606
|
+
e.changeObjectiveOffset(t + a), c = !0;
|
|
515
607
|
}
|
|
516
608
|
for (let [t, n] of Object.entries(i)) e.options.set(t, n);
|
|
517
|
-
let
|
|
518
|
-
for (let t = 0; t <
|
|
609
|
+
let l = e.getDimensions(), u = [], d = !1;
|
|
610
|
+
for (let t = 0; t < l.numCols; t++) {
|
|
519
611
|
let n = e.getColIntegrality(t);
|
|
520
|
-
n !== 0 && (
|
|
612
|
+
n !== 0 && (d = !0), u.push({
|
|
521
613
|
name: e.getColName(t),
|
|
522
614
|
type: n === 1 ? "Integer" : "Continuous"
|
|
523
615
|
});
|
|
524
616
|
}
|
|
525
|
-
if (
|
|
617
|
+
if (s && o) {
|
|
526
618
|
if (typeof e.setSolution != "function") throw Error("HiGHS runtime does not support setting primal initial values (setSolution is unavailable).");
|
|
527
619
|
let t = /* @__PURE__ */ new Map();
|
|
528
|
-
for (let e = 0; e <
|
|
529
|
-
for (let [e, n] of Object.entries(
|
|
620
|
+
for (let e = 0; e < l.numCols; e++) t.set(u[e].name, e);
|
|
621
|
+
for (let [e, n] of Object.entries(o)) if (n !== void 0 && !t.has(e)) throw Error(`Unknown column "${e}" in initialValues (column does not exist in the HiGHS LP model).`);
|
|
530
622
|
let n = [], r = [];
|
|
531
|
-
for (let e = 0; e <
|
|
532
|
-
let t =
|
|
533
|
-
if (Object.prototype.hasOwnProperty.call(
|
|
534
|
-
let i =
|
|
623
|
+
for (let e = 0; e < l.numCols; e++) {
|
|
624
|
+
let t = u[e].name;
|
|
625
|
+
if (Object.prototype.hasOwnProperty.call(o, t)) {
|
|
626
|
+
let i = o[t];
|
|
535
627
|
i !== void 0 && (n.push(e), r.push(i));
|
|
536
628
|
}
|
|
537
629
|
}
|
|
538
|
-
n.length > 0 && (n.length ===
|
|
630
|
+
n.length > 0 && (n.length === l.numCols ? e.setSolution({ colValue: r }) : e.setSolution({
|
|
539
631
|
indices: n,
|
|
540
632
|
values: r
|
|
541
633
|
}));
|
|
542
634
|
}
|
|
543
|
-
let
|
|
635
|
+
let f = null, p = null, m = 0, h = (e) => {
|
|
544
636
|
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 = {
|
|
545
637
|
elapsedTime: n,
|
|
546
638
|
elapsedSeconds: n,
|
|
@@ -552,16 +644,16 @@ async function T(e, t = {}) {
|
|
|
552
644
|
...l === void 0 ? {} : { iterations: l },
|
|
553
645
|
...u === void 0 ? {} : { message: u }
|
|
554
646
|
};
|
|
555
|
-
return
|
|
647
|
+
return p = d, d;
|
|
556
648
|
}, _ = (e) => {
|
|
557
649
|
let n = e?.data;
|
|
558
650
|
if (!n || !(n.mip_solution instanceof Float64Array)) return;
|
|
559
651
|
let r = n.mip_solution, i = {};
|
|
560
|
-
for (let e = 0; e <
|
|
652
|
+
for (let e = 0; e < u.length && e < r.length; e++) Object.defineProperty(i, u[e].name, {
|
|
561
653
|
value: {
|
|
562
654
|
Index: e,
|
|
563
|
-
Type:
|
|
564
|
-
Name:
|
|
655
|
+
Type: u[e].type,
|
|
656
|
+
Name: u[e].name,
|
|
565
657
|
Primal: r[e]
|
|
566
658
|
},
|
|
567
659
|
enumerable: !0,
|
|
@@ -569,12 +661,12 @@ async function T(e, t = {}) {
|
|
|
569
661
|
configurable: !0
|
|
570
662
|
});
|
|
571
663
|
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;
|
|
572
|
-
Number.isFinite(a) && (
|
|
664
|
+
Number.isFinite(a) && (f = {
|
|
573
665
|
objectiveValue: a,
|
|
574
666
|
...typeof n.mip_dual_bound == "number" && Number.isFinite(n.mip_dual_bound) ? { mipDualBound: n.mip_dual_bound } : {},
|
|
575
667
|
...typeof n.mip_gap == "number" && Number.isFinite(n.mip_gap) ? { mipGap: n.mip_gap } : {},
|
|
576
668
|
columns: i
|
|
577
|
-
}, t.onIncumbent?.(
|
|
669
|
+
}, t.onIncumbent?.(f));
|
|
578
670
|
}, v = !1;
|
|
579
671
|
if (t.signal || t.onProgress || t.onIncumbent) {
|
|
580
672
|
let r = n.constants?.callbackType ?? {
|
|
@@ -590,23 +682,23 @@ async function T(e, t = {}) {
|
|
|
590
682
|
v = !0, e.interrupt();
|
|
591
683
|
return;
|
|
592
684
|
}
|
|
593
|
-
t.onProgress && (
|
|
685
|
+
t.onProgress && (m++, t.onProgress(h(e)), t.signal?.aborted && (v = !0, e.interrupt()));
|
|
594
686
|
}, a = {
|
|
595
687
|
[r.simplexInterrupt]: i,
|
|
596
688
|
[r.ipmInterrupt]: i,
|
|
597
689
|
[r.mipInterrupt]: i,
|
|
598
690
|
[r.mipImprovingSolution]: (e) => {
|
|
599
|
-
_(e), t.onProgress && !t.signal?.aborted && (
|
|
691
|
+
_(e), t.onProgress && !t.signal?.aborted && (m++, t.onProgress(h(e)));
|
|
600
692
|
},
|
|
601
693
|
[r.mipLogging]: (e) => {
|
|
602
|
-
t.onProgress && !t.signal?.aborted && (
|
|
694
|
+
t.onProgress && !t.signal?.aborted && (m++, t.onProgress(h(e)));
|
|
603
695
|
}
|
|
604
696
|
};
|
|
605
697
|
e.run(a);
|
|
606
698
|
} else e.run();
|
|
607
699
|
let y = e.getModelStatus();
|
|
608
700
|
v && (y = 17);
|
|
609
|
-
let b =
|
|
701
|
+
let b = g[y] ?? "Unknown", x = 0, S = 0;
|
|
610
702
|
try {
|
|
611
703
|
x = Number(e.info.get("primal_solution_status"));
|
|
612
704
|
} catch {}
|
|
@@ -614,14 +706,14 @@ async function T(e, t = {}) {
|
|
|
614
706
|
S = Number(e.info.get("dual_solution_status"));
|
|
615
707
|
} catch {}
|
|
616
708
|
let C = n.constants?.solutionStatus?.feasible ?? 2, w = x === C, T = S === C, E = w || T ? e.getSolution() : null, D = w, O = {};
|
|
617
|
-
if (!w &&
|
|
618
|
-
else for (let e = 0; e <
|
|
619
|
-
let t =
|
|
709
|
+
if (!w && f !== null) D = !0, O = f.columns;
|
|
710
|
+
else for (let e = 0; e < l.numCols; e++) {
|
|
711
|
+
let t = u[e], n = {
|
|
620
712
|
Index: e,
|
|
621
713
|
Type: t.type,
|
|
622
714
|
Name: t.name
|
|
623
715
|
};
|
|
624
|
-
w && E && (n.Primal = E.colValue[e]), !
|
|
716
|
+
w && E && (n.Primal = E.colValue[e]), !d && T && E && (n.Dual = E.colDual[e]), Object.defineProperty(O, t.name, {
|
|
625
717
|
value: n,
|
|
626
718
|
enumerable: !0,
|
|
627
719
|
writable: !0,
|
|
@@ -629,35 +721,35 @@ async function T(e, t = {}) {
|
|
|
629
721
|
});
|
|
630
722
|
}
|
|
631
723
|
let k = [];
|
|
632
|
-
for (let t = 0; t <
|
|
724
|
+
for (let t = 0; t < l.numRows; t++) {
|
|
633
725
|
let n = e.getRowName(t), r = {
|
|
634
726
|
Index: t,
|
|
635
727
|
Name: n
|
|
636
728
|
};
|
|
637
|
-
w && E && (r.Primal = E.rowValue[t]), !
|
|
729
|
+
w && E && (r.Primal = E.rowValue[t]), !d && T && E && (r.Dual = E.rowDual[t]), k.push(r);
|
|
638
730
|
}
|
|
639
|
-
let A = w ? e.getObjectiveValue() :
|
|
640
|
-
if (
|
|
731
|
+
let A = w ? e.getObjectiveValue() : f === null ? NaN : f.objectiveValue, j, M;
|
|
732
|
+
if (d) {
|
|
641
733
|
try {
|
|
642
734
|
let t = Number(e.info.get("mip_dual_bound"));
|
|
643
735
|
Number.isFinite(t) && (j = t);
|
|
644
736
|
} catch {}
|
|
645
|
-
j === void 0 &&
|
|
737
|
+
j === void 0 && p && p.objectiveBound !== void 0 && (j = p.objectiveBound);
|
|
646
738
|
try {
|
|
647
739
|
let t = Number(e.info.get("mip_gap"));
|
|
648
740
|
Number.isFinite(t) && (M = t);
|
|
649
741
|
} catch {}
|
|
650
|
-
M === void 0 &&
|
|
742
|
+
M === void 0 && p && p.relativeGap !== void 0 && (M = p.relativeGap);
|
|
651
743
|
}
|
|
652
744
|
return {
|
|
653
|
-
Status:
|
|
745
|
+
Status: g[y] ?? b,
|
|
654
746
|
StatusCode: y,
|
|
655
747
|
PrimalSolutionStatus: x,
|
|
656
748
|
DualSolutionStatus: S,
|
|
657
749
|
HasPrimalSolution: D,
|
|
658
|
-
IsMip:
|
|
750
|
+
IsMip: d,
|
|
659
751
|
ObjectiveValue: A,
|
|
660
|
-
ObjectiveOffsetApplied:
|
|
752
|
+
ObjectiveOffsetApplied: c,
|
|
661
753
|
MipDualBound: j,
|
|
662
754
|
MipGap: M,
|
|
663
755
|
Columns: O,
|
|
@@ -668,4 +760,4 @@ async function T(e, t = {}) {
|
|
|
668
760
|
};
|
|
669
761
|
}
|
|
670
762
|
//#endregion
|
|
671
|
-
export {
|
|
763
|
+
export { d as _, M as a, s as b, w as c, x as d, m as f, u as g, v as h, j as i, _ as l, h as m, A as n, k as o, b as p, P as r, I as s, F as t, g as u, c as v, o as y };
|