@ohtaman/washi 0.7.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +60 -23
- package/README.md +59 -22
- package/README.zh-CN.md +62 -25
- package/THIRD_PARTY_LICENSES.md +34 -1
- package/dist/browser/solvers/glpk.js +289 -238
- package/dist/browser/solvers/glpk.min.js +1 -1
- package/dist/browser/solvers/highs-__vite-browser-external-Dn-83hnF.js +7 -0
- package/dist/browser/solvers/highs-browser-runtime-0Bgq5ksG.js +2021 -0
- package/dist/browser/{loader-DewlSho8.js → solvers/highs-loader-BLY3wzDH.js} +190 -149
- package/dist/browser/solvers/highs-worker.js +54 -0
- package/dist/browser/solvers/highs.js +1414 -0
- package/dist/browser/solvers/highs.wasm +0 -0
- package/dist/browser/solvers/pumpkin-_washi-pumpkin-node-runtime-CEKUDK6d.js +9 -0
- package/dist/browser/solvers/pumpkin-loader-CvdaKxf4.js +320 -0
- package/dist/browser/solvers/pumpkin-worker.js +45 -0
- package/dist/browser/solvers/pumpkin.js +1777 -0
- package/dist/browser/solvers/pumpkin.wasm +0 -0
- package/dist/browser/solvers/pumpkin.wasm.LICENSE +21 -0
- package/dist/browser/solvers/z3.js +1600 -1335
- package/dist/browser/solvers/z3.min.js +2 -2
- package/dist/browser/washi.js +3313 -1699
- package/dist/browser/washi.min.js +5 -3
- package/dist/lib/solvers/__vite-browser-external-oLchLuMx.js +7 -0
- package/dist/lib/solvers/glpk.js +174 -132
- package/dist/lib/solvers/highs-browser-runtime.js +2413 -0
- package/dist/lib/{highs-node-runtime.js → solvers/highs-node-runtime.js} +1 -1
- package/dist/lib/solvers/highs-runtime.js +16 -0
- package/dist/lib/solvers/highs-worker.js +54 -0
- package/dist/lib/solvers/highs.js +410 -0
- package/dist/lib/solvers/highs.wasm +0 -0
- package/dist/lib/{loader-BZUQNvh4.js → solvers/loader-CDpPXN_F.js} +138 -116
- package/dist/lib/solvers/loader-Ow74Fa1B.js +311 -0
- package/dist/lib/solvers/lp-writer-CLScMFbS.js +115 -0
- package/dist/lib/solvers/pumpkin-assets.js +1 -0
- package/dist/lib/solvers/pumpkin-node-runtime.js +15 -0
- package/dist/lib/solvers/pumpkin-worker-factory.js +1 -0
- package/dist/lib/solvers/pumpkin-worker.js +45 -0
- package/dist/lib/solvers/pumpkin.js +868 -0
- package/dist/lib/solvers/pumpkin.wasm +0 -0
- package/dist/lib/solvers/pumpkin.wasm.LICENSE +21 -0
- package/dist/lib/solvers/registry-CrYRRk9q.js +907 -0
- package/dist/lib/solvers/rolldown-runtime-DtPi1Y-2.js +13 -0
- package/dist/lib/solvers/types-BGqPkxwu.js +12 -0
- package/dist/lib/solvers/z3.js +489 -307
- package/dist/lib/washi.js +3905 -1410
- package/dist/types/decomposition/benders.d.ts.map +1 -1
- package/dist/types/index.d.ts +4 -5
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/modeler/boolean-expr.d.ts +137 -29
- package/dist/types/modeler/boolean-expr.d.ts.map +1 -1
- package/dist/types/modeler/constraint.d.ts +40 -4
- package/dist/types/modeler/constraint.d.ts.map +1 -1
- package/dist/types/modeler/expression.d.ts +129 -2
- package/dist/types/modeler/expression.d.ts.map +1 -1
- package/dist/types/modeler/index.d.ts +4 -6
- package/dist/types/modeler/index.d.ts.map +1 -1
- package/dist/types/modeler/linearizer.d.ts +11 -2
- package/dist/types/modeler/linearizer.d.ts.map +1 -1
- package/dist/types/modeler/lp-writer.d.ts.map +1 -1
- package/dist/types/modeler/model.d.ts +86 -126
- package/dist/types/modeler/model.d.ts.map +1 -1
- package/dist/types/modeler/parser.d.ts.map +1 -1
- package/dist/types/modeler/quad-expr.d.ts +8 -2
- package/dist/types/modeler/quad-expr.d.ts.map +1 -1
- package/dist/types/modeler/solution-validator.d.ts +12 -12
- package/dist/types/modeler/solution-validator.d.ts.map +1 -1
- package/dist/types/modeler/solvers/glpk/loader.d.ts +4 -0
- package/dist/types/modeler/solvers/glpk/loader.d.ts.map +1 -1
- package/dist/types/modeler/solvers/glpk/solver.d.ts +2 -2
- package/dist/types/modeler/solvers/glpk/solver.d.ts.map +1 -1
- package/dist/types/modeler/solvers/highs/driver.d.ts.map +1 -1
- package/dist/types/modeler/solvers/highs/loader.d.ts +8 -6
- package/dist/types/modeler/solvers/highs/loader.d.ts.map +1 -1
- package/dist/types/modeler/solvers/highs/solver.d.ts.map +1 -1
- package/dist/types/modeler/solvers/highs/worker-client.d.ts +16 -0
- package/dist/types/modeler/solvers/highs/worker-client.d.ts.map +1 -1
- package/dist/types/modeler/solvers/index.d.ts +2 -1
- package/dist/types/modeler/solvers/index.d.ts.map +1 -1
- package/dist/types/modeler/solvers/mock.d.ts +2 -3
- package/dist/types/modeler/solvers/mock.d.ts.map +1 -1
- package/dist/types/modeler/solvers/pumpkin/assets.d.ts +2 -0
- package/dist/types/modeler/solvers/pumpkin/assets.d.ts.map +1 -0
- package/dist/types/modeler/solvers/pumpkin/index.d.ts +6 -0
- package/dist/types/modeler/solvers/pumpkin/index.d.ts.map +1 -0
- package/dist/types/modeler/solvers/pumpkin/loader.d.ts +40 -0
- package/dist/types/modeler/solvers/pumpkin/loader.d.ts.map +1 -0
- package/dist/types/modeler/solvers/pumpkin/node-runtime.d.ts +3 -0
- package/dist/types/modeler/solvers/pumpkin/node-runtime.d.ts.map +1 -0
- package/dist/types/modeler/solvers/pumpkin/solver.d.ts +23 -0
- package/dist/types/modeler/solvers/pumpkin/solver.d.ts.map +1 -0
- package/dist/types/modeler/solvers/pumpkin/worker-client.d.ts +74 -0
- package/dist/types/modeler/solvers/pumpkin/worker-client.d.ts.map +1 -0
- package/dist/types/modeler/solvers/pumpkin/worker-factory.d.ts +3 -0
- package/dist/types/modeler/solvers/pumpkin/worker-factory.d.ts.map +1 -0
- package/dist/types/modeler/solvers/pumpkin/worker.d.ts +7 -0
- package/dist/types/modeler/solvers/pumpkin/worker.d.ts.map +1 -0
- package/dist/types/modeler/solvers/pumpkin.d.ts +2 -0
- package/dist/types/modeler/solvers/pumpkin.d.ts.map +1 -0
- package/dist/types/modeler/solvers/types.d.ts +7 -9
- package/dist/types/modeler/solvers/types.d.ts.map +1 -1
- package/dist/types/modeler/solvers/z3/loader.d.ts +4 -0
- package/dist/types/modeler/solvers/z3/loader.d.ts.map +1 -1
- package/dist/types/modeler/solvers/z3/solver.d.ts +2 -15
- package/dist/types/modeler/solvers/z3/solver.d.ts.map +1 -1
- package/dist/types/modeler/types.d.ts +12 -15
- package/dist/types/modeler/types.d.ts.map +1 -1
- package/dist/types/modeler/validation.d.ts +26 -2
- package/dist/types/modeler/validation.d.ts.map +1 -1
- package/dist/types/modeler/variable.d.ts +9 -5
- package/dist/types/modeler/variable.d.ts.map +1 -1
- package/docs/examples/diet-sensitivity.md +33 -14
- package/docs/examples/ecommerce-coupons.md +17 -9
- package/docs/examples/index.md +36 -27
- package/docs/examples/knapsack.md +11 -5
- package/docs/examples/portfolio-qp.md +21 -8
- package/docs/examples/production.md +10 -5
- package/docs/examples/project-scheduling.md +119 -0
- package/docs/examples/shift-scheduling.md +29 -18
- package/docs/examples/smt-security.md +27 -11
- package/docs/examples/transportation.md +23 -13
- package/docs/examples/traveling-salesperson.md +34 -22
- package/docs/examples/unsat-core.md +27 -14
- package/docs/examples/vehicle-routing.md +74 -28
- package/docs/getting-started/ai-agents.md +190 -82
- package/docs/getting-started/coding-agents.md +177 -0
- package/docs/getting-started/cross-origin.md +27 -14
- package/docs/getting-started/index.md +49 -43
- package/docs/getting-started/runtimes.md +94 -40
- package/docs/guide/constraint-programming.md +171 -0
- package/docs/guide/constraints.md +115 -33
- package/docs/guide/decomposition.md +118 -88
- package/docs/guide/expressions.md +106 -43
- package/docs/guide/formulation-tips.md +47 -28
- package/docs/guide/objectives.md +102 -75
- package/docs/guide/unsat-core.md +62 -50
- package/docs/guide/variables.md +81 -35
- package/docs/solvers/custom-solver.md +163 -122
- package/docs/solvers/glpk.md +58 -17
- package/docs/solvers/highs.md +124 -57
- package/docs/solvers/index.md +33 -20
- package/docs/solvers/pumpkin.md +171 -0
- package/docs/solvers/z3.md +63 -25
- package/llms-full.txt +2232 -932
- package/llms.txt +144 -91
- package/package.json +55 -19
- package/skills/washi/SKILL.md +107 -34
- package/dist/browser/_washi-node-only-BvRk9kiK.js +0 -0
- package/dist/browser/browser-runtime-TLCY0hkc.js +0 -1793
- package/dist/browser/highs-worker.js +0 -39
- package/dist/browser/highs.wasm +0 -0
- package/dist/lib/_washi-node-only-BvRk9kiK.js +0 -0
- package/dist/lib/highs-browser-runtime.js +0 -2185
- package/dist/lib/highs-runtime.js +0 -2
- package/dist/lib/highs-worker.js +0 -39
- package/dist/lib/highs.wasm +0 -0
- package/dist/lib/registry-D7TZ3Wh_.js +0 -1034
- package/docs/ja/getting-started/ai-agents.md +0 -280
- package/docs/zh/getting-started/ai-agents.md +0 -280
- /package/dist/browser/{highs.wasm.LICENSE → solvers/highs.wasm.LICENSE} +0 -0
- /package/dist/lib/{highs-assets.js → solvers/highs-assets.js} +0 -0
- /package/dist/lib/{highs-worker-factory.js → solvers/highs-worker-factory.js} +0 -0
- /package/dist/lib/{highs.wasm.LICENSE → solvers/highs.wasm.LICENSE} +0 -0
|
@@ -241,8 +241,9 @@ var c = 0, l = class {
|
|
|
241
241
|
throw new r("Invalid argument to setSolution (expected { colValue } or { indices, values })");
|
|
242
242
|
}
|
|
243
243
|
run(e) {
|
|
244
|
-
let t = 0,
|
|
245
|
-
if (e
|
|
244
|
+
let t = 0, i = [];
|
|
245
|
+
if (e) {
|
|
246
|
+
if (typeof this.module.addFunction != "function") throw new r("HiGHS WebAssembly runtime does not support module.addFunction; progress and interrupt callbacks are unavailable.");
|
|
246
247
|
t = this.module.addFunction((t, r, i, a) => {
|
|
247
248
|
let o = e[t];
|
|
248
249
|
if (!o) return;
|
|
@@ -274,14 +275,14 @@ var c = 0, l = class {
|
|
|
274
275
|
}, "vipppp"), this.bindings.setCallback(this.highs, t, 0);
|
|
275
276
|
for (let t of Object.keys(e)) {
|
|
276
277
|
let e = Number(t);
|
|
277
|
-
this.bindings.startCallback(this.highs, e),
|
|
278
|
+
this.bindings.startCallback(this.highs, e), i.push(e);
|
|
278
279
|
}
|
|
279
280
|
}
|
|
280
281
|
try {
|
|
281
282
|
return this.bindings.run(this.highs);
|
|
282
283
|
} finally {
|
|
283
284
|
if (t) {
|
|
284
|
-
for (let e of
|
|
285
|
+
for (let e of i) try {
|
|
285
286
|
this.bindings.stopCallback(this.highs, e);
|
|
286
287
|
} catch {}
|
|
287
288
|
try {
|
|
@@ -370,9 +371,7 @@ var c = 0, l = class {
|
|
|
370
371
|
format: "lp",
|
|
371
372
|
data: e
|
|
372
373
|
}, (e) => {
|
|
373
|
-
for (let [n, r] of Object.entries(t))
|
|
374
|
-
e.options.set(n, r);
|
|
375
|
-
} catch {}
|
|
374
|
+
for (let [n, r] of Object.entries(t)) e.options.set(n, r);
|
|
376
375
|
e.run();
|
|
377
376
|
let n = e.getModelStatus(), r = e.getDimensions(), i = e.getSolution(), o = {};
|
|
378
377
|
for (let t = 0; t < r.numCols; t++) {
|
|
@@ -392,46 +391,84 @@ var c = 0, l = class {
|
|
|
392
391
|
};
|
|
393
392
|
});
|
|
394
393
|
}
|
|
395
|
-
}, d =
|
|
396
|
-
|
|
397
|
-
|
|
394
|
+
}, d = [
|
|
395
|
+
"mip_max_nodes",
|
|
396
|
+
"mip_max_improving_sols",
|
|
397
|
+
"mip_max_leaves",
|
|
398
|
+
"simplex_iteration_limit",
|
|
399
|
+
"ipm_iteration_limit"
|
|
400
|
+
], f = /* @__PURE__ */ new Set([
|
|
401
|
+
"timeLimit",
|
|
402
|
+
"outputFlag",
|
|
403
|
+
"presolve",
|
|
404
|
+
"solver",
|
|
405
|
+
"relativeGap",
|
|
406
|
+
"absoluteGap",
|
|
407
|
+
"wasmUrl",
|
|
408
|
+
"signal",
|
|
409
|
+
"onProgress",
|
|
410
|
+
"onIncumbent",
|
|
411
|
+
"relax",
|
|
412
|
+
"useWorker",
|
|
413
|
+
"objectiveOffset",
|
|
414
|
+
"initialValues",
|
|
415
|
+
...d
|
|
416
|
+
]);
|
|
417
|
+
function p(e = {}) {
|
|
418
|
+
if (e.threads !== void 0) throw Error("Solver \"HiGHS\" does not support option \"threads\" (HiGHS WebAssembly runs single-threaded).");
|
|
419
|
+
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 && !f.has(t)) throw Error(`Solver "HiGHS" does not support option "${t}".`);
|
|
421
|
+
if (e.useWorker !== void 0 && typeof e.useWorker != "boolean") throw Error(`Invalid HiGHS option "useWorker": expected boolean, got ${typeof e.useWorker}.`);
|
|
422
|
+
if (e.outputFlag !== void 0 && typeof e.outputFlag != "boolean") throw Error(`Invalid HiGHS option "outputFlag": expected boolean, got ${typeof e.outputFlag}.`);
|
|
423
|
+
if (e.relax !== void 0 && typeof e.relax != "boolean") throw Error(`Invalid HiGHS option "relax": expected boolean, got ${typeof e.relax}.`);
|
|
424
|
+
if (e.presolve !== void 0 && e.presolve !== "on" && e.presolve !== "off" && e.presolve !== "choose") throw Error(`Invalid HiGHS option "presolve" (${String(e.presolve)}): expected "on", "off", or "choose".`);
|
|
425
|
+
if (e.timeLimit !== void 0 && (typeof e.timeLimit != "number" || !Number.isFinite(e.timeLimit) || e.timeLimit < 0)) throw Error(`Invalid HiGHS option "timeLimit" (${String(e.timeLimit)}): expected a finite non-negative number of seconds.`);
|
|
426
|
+
if (e.relativeGap !== void 0 && (typeof e.relativeGap != "number" || !Number.isFinite(e.relativeGap) || e.relativeGap < 0)) throw Error(`Invalid HiGHS option "relativeGap" (${String(e.relativeGap)}): expected a finite non-negative number.`);
|
|
427
|
+
if (e.absoluteGap !== void 0 && (typeof e.absoluteGap != "number" || !Number.isFinite(e.absoluteGap) || e.absoluteGap < 0)) throw Error(`Invalid HiGHS option "absoluteGap" (${String(e.absoluteGap)}): expected a finite non-negative number.`);
|
|
428
|
+
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
|
+
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
|
+
}
|
|
431
|
+
var m = null, h = null, g = null, _ = null;
|
|
432
|
+
function v(e) {
|
|
433
|
+
_ = e, m = null, h = null, g = null;
|
|
398
434
|
}
|
|
399
|
-
function
|
|
400
|
-
return
|
|
435
|
+
function y() {
|
|
436
|
+
return _;
|
|
401
437
|
}
|
|
402
|
-
function
|
|
438
|
+
function b(e) {
|
|
403
439
|
return e.length >= 4 && e[0] === 0 && e[1] === 97 && e[2] === 115 && e[3] === 109;
|
|
404
440
|
}
|
|
405
|
-
async function
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
}
|
|
441
|
+
async function x(t) {
|
|
442
|
+
return t || _ || e();
|
|
443
|
+
}
|
|
444
|
+
async function S(e = {}) {
|
|
445
|
+
let t = !!(typeof process < "u" && process.versions?.node && process.type !== "renderer"), n = t ? null : await x(e.wasmUrl);
|
|
446
|
+
return {
|
|
447
|
+
isNode: t,
|
|
448
|
+
wasmUrl: n,
|
|
449
|
+
key: n ?? "node"
|
|
450
|
+
};
|
|
415
451
|
}
|
|
416
|
-
async function
|
|
417
|
-
|
|
452
|
+
async function C(e = {}) {
|
|
453
|
+
let { key: t } = await S(e);
|
|
454
|
+
return g === t;
|
|
418
455
|
}
|
|
419
|
-
async function
|
|
420
|
-
let
|
|
421
|
-
if (
|
|
422
|
-
|
|
423
|
-
let a =
|
|
456
|
+
async function w(e = {}) {
|
|
457
|
+
let { isNode: n, wasmUrl: r, key: i } = await S(e);
|
|
458
|
+
if (m && h === i) return m;
|
|
459
|
+
h = i, g = null;
|
|
460
|
+
let a = null;
|
|
461
|
+
return a = (async () => {
|
|
424
462
|
let e = n ? await t() : (await import("./highs-browser-runtime.js")).default;
|
|
425
463
|
return n ? await e() : await e({ locateFile: (e) => e.endsWith(".wasm") ? r : e });
|
|
426
|
-
})().catch((e) => {
|
|
427
|
-
|
|
464
|
+
})().then((e) => (m === a && (g = i), e)).catch((e) => {
|
|
465
|
+
m === a && (m = null, h = null, g = null);
|
|
428
466
|
let t = e instanceof Error ? e.message : String(e);
|
|
429
467
|
throw Error(`[WaSHI] Failed to initialize HiGHS${r ? ` from "${r}"` : ""}. Deploy the package's WASM asset or explicitly set wasmUrl; no CDN fallback is attempted. ${t}`, { cause: e });
|
|
430
|
-
});
|
|
431
|
-
return f = a, a;
|
|
468
|
+
}), m = a, a;
|
|
432
469
|
}
|
|
433
|
-
async function
|
|
434
|
-
if (t.signal?.aborted) return {
|
|
470
|
+
async function T(e, t = {}) {
|
|
471
|
+
if (p(t), t.signal?.aborted) return {
|
|
435
472
|
result: {
|
|
436
473
|
Status: "Interrupted",
|
|
437
474
|
StatusCode: 17,
|
|
@@ -442,7 +479,7 @@ async function x(e, t = {}) {
|
|
|
442
479
|
},
|
|
443
480
|
runTime: 0
|
|
444
481
|
};
|
|
445
|
-
let n = await
|
|
482
|
+
let n = await w(t);
|
|
446
483
|
if (t.signal?.aborted) return {
|
|
447
484
|
result: {
|
|
448
485
|
Status: "Interrupted",
|
|
@@ -455,39 +492,32 @@ async function x(e, t = {}) {
|
|
|
455
492
|
runTime: 0
|
|
456
493
|
};
|
|
457
494
|
let r = performance.now(), i = { output_flag: t.outputFlag ?? !1 };
|
|
458
|
-
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.
|
|
459
|
-
for (let e of [
|
|
460
|
-
|
|
461
|
-
"mip_max_improving_sols",
|
|
462
|
-
"mip_max_leaves",
|
|
463
|
-
"simplex_iteration_limit",
|
|
464
|
-
"ipm_iteration_limit"
|
|
465
|
-
]) t[e] !== void 0 && (i[e] = t[e]);
|
|
466
|
-
let o = typeof t.objectiveOffset == "number" && Number.isFinite(t.objectiveOffset) ? t.objectiveOffset : 0, s = t.initialValues, c = !1;
|
|
495
|
+
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 d) t[e] !== void 0 && (i[e] = t[e]);
|
|
497
|
+
let o = t.objectiveOffset ?? 0, s = t.initialValues, c = !1;
|
|
467
498
|
if (s) {
|
|
468
499
|
for (let [e, t] of Object.entries(s)) if (t !== void 0) {
|
|
469
500
|
if (typeof t != "number" || !Number.isFinite(t)) throw Error(`Invalid initial value for column "${e}": ${String(t)} (must be a finite number).`);
|
|
470
501
|
c = !0;
|
|
471
502
|
}
|
|
472
503
|
}
|
|
473
|
-
if (typeof n.withModel
|
|
504
|
+
if (typeof n.withModel != "function") throw Error("[WaSHI] HiGHS runtime is missing required withModel() API (legacy highs.solve fallback has been removed).");
|
|
505
|
+
return {
|
|
474
506
|
result: n.withModel({
|
|
475
507
|
format: "lp",
|
|
476
508
|
data: e
|
|
477
509
|
}, (e) => {
|
|
478
|
-
|
|
510
|
+
let l = !1;
|
|
511
|
+
if (o !== 0) {
|
|
512
|
+
if (typeof e.changeObjectiveOffset != "function") throw Error("[WaSHI] HiGHS runtime does not support changeObjectiveOffset() for non-zero objectiveOffset.");
|
|
479
513
|
let t = typeof e.getObjectiveOffset == "function" ? e.getObjectiveOffset() : 0;
|
|
480
|
-
e.changeObjectiveOffset(t + o);
|
|
514
|
+
e.changeObjectiveOffset(t + o), l = !0;
|
|
481
515
|
}
|
|
482
|
-
for (let [t,
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
if (e?.name !== "HighsUnsupportedOptionError" && !(n.errors?.HighsUnsupportedOptionError && e instanceof n.errors.HighsUnsupportedOptionError)) throw e;
|
|
486
|
-
}
|
|
487
|
-
let l = e.getDimensions(), u = [], d = !1;
|
|
488
|
-
for (let t = 0; t < l.numCols; t++) {
|
|
516
|
+
for (let [t, n] of Object.entries(i)) e.options.set(t, n);
|
|
517
|
+
let u = e.getDimensions(), d = [], f = !1;
|
|
518
|
+
for (let t = 0; t < u.numCols; t++) {
|
|
489
519
|
let n = e.getColIntegrality(t);
|
|
490
|
-
n !== 0 && (
|
|
520
|
+
n !== 0 && (f = !0), d.push({
|
|
491
521
|
name: e.getColName(t),
|
|
492
522
|
type: n === 1 ? "Integer" : "Continuous"
|
|
493
523
|
});
|
|
@@ -495,46 +525,43 @@ async function x(e, t = {}) {
|
|
|
495
525
|
if (c && s) {
|
|
496
526
|
if (typeof e.setSolution != "function") throw Error("HiGHS runtime does not support setting primal initial values (setSolution is unavailable).");
|
|
497
527
|
let t = /* @__PURE__ */ new Map();
|
|
498
|
-
for (let e = 0; e <
|
|
528
|
+
for (let e = 0; e < u.numCols; e++) t.set(d[e].name, e);
|
|
499
529
|
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).`);
|
|
500
530
|
let n = [], r = [];
|
|
501
|
-
for (let e = 0; e <
|
|
502
|
-
let t =
|
|
531
|
+
for (let e = 0; e < u.numCols; e++) {
|
|
532
|
+
let t = d[e].name;
|
|
503
533
|
if (Object.prototype.hasOwnProperty.call(s, t)) {
|
|
504
534
|
let i = s[t];
|
|
505
535
|
i !== void 0 && (n.push(e), r.push(i));
|
|
506
536
|
}
|
|
507
537
|
}
|
|
508
|
-
n.length > 0 && (n.length ===
|
|
538
|
+
n.length > 0 && (n.length === u.numCols ? e.setSolution({ colValue: r }) : e.setSolution({
|
|
509
539
|
indices: n,
|
|
510
540
|
values: r
|
|
511
541
|
}));
|
|
512
542
|
}
|
|
513
|
-
let
|
|
543
|
+
let p = null, m = null, h = 0, g = (e) => {
|
|
514
544
|
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 = {
|
|
515
545
|
elapsedTime: n,
|
|
516
546
|
elapsedSeconds: n,
|
|
517
547
|
...i === void 0 ? {} : { objectiveValue: i },
|
|
518
548
|
...a === void 0 ? {} : { objectiveBound: a },
|
|
519
|
-
...o === void 0 ? {} : {
|
|
520
|
-
|
|
521
|
-
mipGap: o
|
|
522
|
-
},
|
|
523
|
-
...s === void 0 ? {} : { absGap: s },
|
|
549
|
+
...o === void 0 ? {} : { relativeGap: o },
|
|
550
|
+
...s === void 0 ? {} : { absoluteGap: s },
|
|
524
551
|
...c === void 0 ? {} : { nodes: c },
|
|
525
552
|
...l === void 0 ? {} : { iterations: l },
|
|
526
553
|
...u === void 0 ? {} : { message: u }
|
|
527
554
|
};
|
|
528
|
-
return
|
|
529
|
-
},
|
|
555
|
+
return m = d, d;
|
|
556
|
+
}, _ = (e) => {
|
|
530
557
|
let n = e?.data;
|
|
531
558
|
if (!n || !(n.mip_solution instanceof Float64Array)) return;
|
|
532
559
|
let r = n.mip_solution, i = {};
|
|
533
|
-
for (let e = 0; e <
|
|
560
|
+
for (let e = 0; e < d.length && e < r.length; e++) Object.defineProperty(i, d[e].name, {
|
|
534
561
|
value: {
|
|
535
562
|
Index: e,
|
|
536
|
-
Type:
|
|
537
|
-
Name:
|
|
563
|
+
Type: d[e].type,
|
|
564
|
+
Name: d[e].name,
|
|
538
565
|
Primal: r[e]
|
|
539
566
|
},
|
|
540
567
|
enumerable: !0,
|
|
@@ -542,13 +569,13 @@ async function x(e, t = {}) {
|
|
|
542
569
|
configurable: !0
|
|
543
570
|
});
|
|
544
571
|
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;
|
|
545
|
-
Number.isFinite(a) && (
|
|
572
|
+
Number.isFinite(a) && (p = {
|
|
546
573
|
objectiveValue: a,
|
|
547
574
|
...typeof n.mip_dual_bound == "number" && Number.isFinite(n.mip_dual_bound) ? { mipDualBound: n.mip_dual_bound } : {},
|
|
548
575
|
...typeof n.mip_gap == "number" && Number.isFinite(n.mip_gap) ? { mipGap: n.mip_gap } : {},
|
|
549
576
|
columns: i
|
|
550
|
-
}, t.onIncumbent?.(
|
|
551
|
-
},
|
|
577
|
+
}, t.onIncumbent?.(p));
|
|
578
|
+
}, v = !1;
|
|
552
579
|
if (t.signal || t.onProgress || t.onIncumbent) {
|
|
553
580
|
let r = n.constants?.callbackType ?? {
|
|
554
581
|
logging: 0,
|
|
@@ -560,90 +587,85 @@ async function x(e, t = {}) {
|
|
|
560
587
|
mipInterrupt: 6
|
|
561
588
|
}, i = (e) => {
|
|
562
589
|
if (t.signal?.aborted) {
|
|
563
|
-
|
|
590
|
+
v = !0, e.interrupt();
|
|
564
591
|
return;
|
|
565
592
|
}
|
|
566
|
-
t.onProgress && (
|
|
593
|
+
t.onProgress && (h++, t.onProgress(g(e)), t.signal?.aborted && (v = !0, e.interrupt()));
|
|
567
594
|
}, a = {
|
|
568
595
|
[r.simplexInterrupt]: i,
|
|
569
596
|
[r.ipmInterrupt]: i,
|
|
570
597
|
[r.mipInterrupt]: i,
|
|
571
598
|
[r.mipImprovingSolution]: (e) => {
|
|
572
|
-
|
|
599
|
+
_(e), t.onProgress && !t.signal?.aborted && (h++, t.onProgress(g(e)));
|
|
573
600
|
},
|
|
574
601
|
[r.mipLogging]: (e) => {
|
|
575
|
-
t.onProgress && !t.signal?.aborted && (
|
|
602
|
+
t.onProgress && !t.signal?.aborted && (h++, t.onProgress(g(e)));
|
|
576
603
|
}
|
|
577
604
|
};
|
|
578
605
|
e.run(a);
|
|
579
606
|
} else e.run();
|
|
580
|
-
let
|
|
581
|
-
|
|
582
|
-
let
|
|
607
|
+
let y = e.getModelStatus();
|
|
608
|
+
v && (y = 17);
|
|
609
|
+
let b = a[y] ?? "Unknown", x = 0, S = 0;
|
|
583
610
|
try {
|
|
584
|
-
|
|
611
|
+
x = Number(e.info.get("primal_solution_status"));
|
|
585
612
|
} catch {}
|
|
586
613
|
try {
|
|
587
|
-
|
|
614
|
+
S = Number(e.info.get("dual_solution_status"));
|
|
588
615
|
} catch {}
|
|
589
|
-
let
|
|
590
|
-
if (!
|
|
591
|
-
else for (let e = 0; e <
|
|
592
|
-
let t =
|
|
616
|
+
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 && p !== null) D = !0, O = p.columns;
|
|
618
|
+
else for (let e = 0; e < u.numCols; e++) {
|
|
619
|
+
let t = d[e], n = {
|
|
593
620
|
Index: e,
|
|
594
621
|
Type: t.type,
|
|
595
622
|
Name: t.name
|
|
596
623
|
};
|
|
597
|
-
|
|
624
|
+
w && E && (n.Primal = E.colValue[e]), !f && T && E && (n.Dual = E.colDual[e]), Object.defineProperty(O, t.name, {
|
|
598
625
|
value: n,
|
|
599
626
|
enumerable: !0,
|
|
600
627
|
writable: !0,
|
|
601
628
|
configurable: !0
|
|
602
629
|
});
|
|
603
630
|
}
|
|
604
|
-
let
|
|
605
|
-
for (let t = 0; t <
|
|
631
|
+
let k = [];
|
|
632
|
+
for (let t = 0; t < u.numRows; t++) {
|
|
606
633
|
let n = e.getRowName(t), r = {
|
|
607
634
|
Index: t,
|
|
608
635
|
Name: n
|
|
609
636
|
};
|
|
610
|
-
|
|
637
|
+
w && E && (r.Primal = E.rowValue[t]), !f && T && E && (r.Dual = E.rowDual[t]), k.push(r);
|
|
611
638
|
}
|
|
612
|
-
let
|
|
613
|
-
if (
|
|
639
|
+
let A = w ? e.getObjectiveValue() : p === null ? NaN : p.objectiveValue, j, M;
|
|
640
|
+
if (f) {
|
|
614
641
|
try {
|
|
615
642
|
let t = Number(e.info.get("mip_dual_bound"));
|
|
616
|
-
Number.isFinite(t) && (
|
|
643
|
+
Number.isFinite(t) && (j = t);
|
|
617
644
|
} catch {}
|
|
618
|
-
|
|
645
|
+
j === void 0 && m && m.objectiveBound !== void 0 && (j = m.objectiveBound);
|
|
619
646
|
try {
|
|
620
647
|
let t = Number(e.info.get("mip_gap"));
|
|
621
|
-
Number.isFinite(t) && (
|
|
648
|
+
Number.isFinite(t) && (M = t);
|
|
622
649
|
} catch {}
|
|
623
|
-
|
|
650
|
+
M === void 0 && m && m.relativeGap !== void 0 && (M = m.relativeGap);
|
|
624
651
|
}
|
|
625
652
|
return {
|
|
626
|
-
Status: a[
|
|
627
|
-
StatusCode:
|
|
628
|
-
PrimalSolutionStatus:
|
|
629
|
-
DualSolutionStatus:
|
|
630
|
-
HasPrimalSolution:
|
|
631
|
-
IsMip:
|
|
632
|
-
ObjectiveValue:
|
|
633
|
-
ObjectiveOffsetApplied:
|
|
634
|
-
MipDualBound:
|
|
635
|
-
MipGap:
|
|
636
|
-
Columns:
|
|
637
|
-
Rows:
|
|
653
|
+
Status: a[y] ?? b,
|
|
654
|
+
StatusCode: y,
|
|
655
|
+
PrimalSolutionStatus: x,
|
|
656
|
+
DualSolutionStatus: S,
|
|
657
|
+
HasPrimalSolution: D,
|
|
658
|
+
IsMip: f,
|
|
659
|
+
ObjectiveValue: A,
|
|
660
|
+
ObjectiveOffsetApplied: l,
|
|
661
|
+
MipDualBound: j,
|
|
662
|
+
MipGap: M,
|
|
663
|
+
Columns: O,
|
|
664
|
+
Rows: k
|
|
638
665
|
};
|
|
639
666
|
}),
|
|
640
667
|
runTime: (performance.now() - r) / 1e3
|
|
641
668
|
};
|
|
642
|
-
if (c) throw Error("HiGHS runtime does not support setting primal initial values (withModel/setSolution is unavailable).");
|
|
643
|
-
return {
|
|
644
|
-
result: n.solve(e, i),
|
|
645
|
-
runTime: (performance.now() - r) / 1e3
|
|
646
|
-
};
|
|
647
669
|
}
|
|
648
670
|
//#endregion
|
|
649
|
-
export {
|
|
671
|
+
export { x as a, p as c, u as d, r as f, s as h, b as i, o as l, i as m, y as n, v as o, l as p, C as r, T as s, w as t, a as u };
|