@ohtaman/washi 0.6.0 → 0.7.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.ja.md +103 -421
- package/README.md +103 -421
- package/README.zh-CN.md +103 -421
- package/THIRD_PARTY_LICENSES.md +5 -3
- package/dist/browser/solvers/glpk.js +2 -2
- package/dist/browser/solvers/glpk.min.js +1 -1
- package/dist/browser/washi.js +777 -261
- package/dist/browser/washi.min.js +3 -3
- package/dist/lib/{registry-C20sxTwm.js → registry-D7TZ3Wh_.js} +88 -18
- package/dist/lib/solvers/glpk.js +3 -3
- package/dist/lib/solvers/z3.js +1 -1
- package/dist/lib/washi.js +864 -421
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/modeler/expression.d.ts +47 -26
- package/dist/types/modeler/expression.d.ts.map +1 -1
- package/dist/types/modeler/index.d.ts +2 -2
- package/dist/types/modeler/index.d.ts.map +1 -1
- package/dist/types/modeler/model.d.ts +12 -6
- package/dist/types/modeler/model.d.ts.map +1 -1
- package/dist/types/modeler/parser.d.ts +25 -5
- package/dist/types/modeler/parser.d.ts.map +1 -1
- package/dist/types/modeler/solvers/glpk/solver.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.map +1 -1
- package/dist/types/modeler/solvers/types.d.ts +2 -0
- package/dist/types/modeler/solvers/types.d.ts.map +1 -1
- package/docs/examples/diet-sensitivity.md +15 -14
- package/docs/examples/ecommerce-coupons.md +15 -22
- package/docs/examples/index.md +14 -12
- package/docs/examples/knapsack.md +8 -7
- package/docs/examples/portfolio-qp.md +11 -4
- package/docs/examples/production.md +4 -4
- package/docs/examples/shift-scheduling.md +20 -7
- package/docs/examples/smt-security.md +16 -4
- package/docs/examples/transportation.md +46 -19
- package/docs/examples/traveling-salesperson.md +28 -44
- package/docs/examples/unsat-core.md +15 -5
- package/docs/examples/vehicle-routing.md +10 -8
- package/docs/getting-started/ai-agents.md +25 -14
- package/docs/getting-started/cross-origin.md +56 -28
- package/docs/getting-started/index.md +40 -69
- package/docs/getting-started/runtimes.md +66 -61
- package/docs/guide/constraints.md +46 -40
- package/docs/guide/decomposition.md +127 -259
- package/docs/guide/expressions.md +90 -39
- package/docs/guide/formulation-tips.md +212 -0
- package/docs/guide/objectives.md +7 -4
- package/docs/guide/unsat-core.md +18 -6
- package/docs/guide/variables.md +33 -38
- package/docs/ja/getting-started/ai-agents.md +24 -14
- package/docs/solvers/highs.md +27 -6
- package/docs/solvers/index.md +1 -1
- package/docs/solvers/z3.md +3 -0
- package/docs/zh/getting-started/ai-agents.md +24 -14
- package/llms-full.txt +929 -687
- package/llms.txt +21 -19
- package/package.json +3 -3
- package/skills/washi/SKILL.md +14 -10
|
@@ -479,37 +479,107 @@ var m = class e {
|
|
|
479
479
|
function g(e, t) {
|
|
480
480
|
let n = /* @__PURE__ */ new Map(), r = 0;
|
|
481
481
|
function i(e) {
|
|
482
|
+
return e instanceof d || e.kind === "constraint" || "sense" in e && (e.sense === "<=" || e.sense === ">=" || e.sense === "==") && "lhs" in e && "rhs" in e && typeof e.rhs == "number" && typeof e.lhs == "object" && e.lhs !== null && "terms" in e.lhs && e.lhs.terms instanceof Map;
|
|
483
|
+
}
|
|
484
|
+
function a(e) {
|
|
485
|
+
return e instanceof m || "quadTerms" in e && e.quadTerms instanceof Map && "linearTerms" in e && e.linearTerms instanceof Map && typeof e.constant == "number";
|
|
486
|
+
}
|
|
487
|
+
function o(e) {
|
|
488
|
+
return e instanceof h || "terms" in e && e.terms instanceof Map && typeof e.constant == "number";
|
|
489
|
+
}
|
|
490
|
+
function s(e) {
|
|
491
|
+
return e instanceof F || !i(e) && typeof e.id == "number" && typeof e.name == "string" && typeof e.lb == "number" && typeof e.ub == "number" && typeof e.type == "string" && typeof e.mul == "function";
|
|
492
|
+
}
|
|
493
|
+
function c(e) {
|
|
494
|
+
return i(e) || a(e) || o(e) || s(e);
|
|
495
|
+
}
|
|
496
|
+
function l(e) {
|
|
497
|
+
if (typeof e != "object" || !e || Array.isArray(e) || c(e)) return !1;
|
|
498
|
+
let t = Object.getPrototypeOf(e);
|
|
499
|
+
return t === Object.prototype || t === null;
|
|
500
|
+
}
|
|
501
|
+
function u(e) {
|
|
482
502
|
if (e != null) {
|
|
483
|
-
if (typeof e == "number")
|
|
484
|
-
|
|
485
|
-
|
|
503
|
+
if (typeof e == "number") {
|
|
504
|
+
if (!Number.isFinite(e)) throw Error(`Invalid non-finite number "${e}" in sum().`);
|
|
505
|
+
let t = r + e;
|
|
506
|
+
if (!Number.isFinite(t)) throw Error("Constant accumulation overflows finite floating-point range in sum().");
|
|
507
|
+
r = t;
|
|
508
|
+
} else if (typeof e == "object" && i(e)) throw Error("Cannot sum a constraint comparison (<=, >=, ==) in sum(): expected a number, Var, or LinExpr.");
|
|
509
|
+
else if (typeof e == "object" && a(e)) {
|
|
486
510
|
let t = e;
|
|
487
511
|
if (t.quadTerms.size > 0) throw Error("Quadratic expressions are not supported in sum(): sum() produces a linear expression (LinExpr).");
|
|
512
|
+
if (!Number.isFinite(t.constant)) throw Error(`Invalid non-finite constant "${t.constant}" in sum().`);
|
|
488
513
|
for (let [e, r] of t.linearTerms) {
|
|
489
|
-
|
|
490
|
-
n.
|
|
514
|
+
if (!Number.isFinite(r)) throw Error(`Invalid non-finite coefficient "${r}" in sum().`);
|
|
515
|
+
let t = (n.get(e) ?? 0) + r;
|
|
516
|
+
if (!Number.isFinite(t)) throw Error("Coefficient accumulation overflows finite floating-point range in sum().");
|
|
517
|
+
n.set(e, t);
|
|
491
518
|
}
|
|
492
|
-
r
|
|
493
|
-
|
|
519
|
+
let i = r + t.constant;
|
|
520
|
+
if (!Number.isFinite(i)) throw Error("Constant accumulation overflows finite floating-point range in sum().");
|
|
521
|
+
r = i;
|
|
522
|
+
} else if (typeof e == "object" && o(e)) {
|
|
494
523
|
let t = e;
|
|
524
|
+
if (!Number.isFinite(t.constant)) throw Error(`Invalid non-finite constant "${t.constant}" in sum().`);
|
|
495
525
|
for (let [e, r] of t.terms) {
|
|
496
|
-
|
|
497
|
-
n.
|
|
526
|
+
if (!Number.isFinite(r)) throw Error(`Invalid non-finite coefficient "${r}" in sum().`);
|
|
527
|
+
let t = (n.get(e) ?? 0) + r;
|
|
528
|
+
if (!Number.isFinite(t)) throw Error("Coefficient accumulation overflows finite floating-point range in sum().");
|
|
529
|
+
n.set(e, t);
|
|
498
530
|
}
|
|
499
|
-
r
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
531
|
+
let i = r + t.constant;
|
|
532
|
+
if (!Number.isFinite(i)) throw Error("Constant accumulation overflows finite floating-point range in sum().");
|
|
533
|
+
r = i;
|
|
534
|
+
} else if (typeof e == "object" && s(e)) {
|
|
535
|
+
let t = e, r = (n.get(t) ?? 0) + 1;
|
|
536
|
+
if (!Number.isFinite(r)) throw Error("Coefficient accumulation overflows finite floating-point range in sum().");
|
|
537
|
+
n.set(t, r);
|
|
503
538
|
} else throw Error("Unsupported item in sum(): expected a number, Var, or LinExpr.");
|
|
504
539
|
}
|
|
505
540
|
}
|
|
541
|
+
function f(e, t = 0) {
|
|
542
|
+
if (e != null) {
|
|
543
|
+
if (typeof e == "number") {
|
|
544
|
+
u(e);
|
|
545
|
+
return;
|
|
546
|
+
}
|
|
547
|
+
if (typeof e == "object") {
|
|
548
|
+
if (c(e)) {
|
|
549
|
+
u(e);
|
|
550
|
+
return;
|
|
551
|
+
}
|
|
552
|
+
if (!(e instanceof String) && !(e instanceof Map) && Symbol.iterator in e && typeof e[Symbol.iterator] == "function") {
|
|
553
|
+
if (t >= 2) throw Error("Nested containers deeper than 2D are not supported in sum().");
|
|
554
|
+
for (let n of e) f(n, t + 1);
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
557
|
+
if (l(e)) {
|
|
558
|
+
if (t >= 2) throw Error("Nested containers deeper than 2D are not supported in sum().");
|
|
559
|
+
if (Object.getOwnPropertySymbols(e).length > 0) throw Error("Symbol keys are not supported in sum().");
|
|
560
|
+
for (let n of Object.keys(e)) f(e[n], t + 1);
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
u(e);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
506
567
|
if (typeof e == "number") {
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
568
|
+
if (typeof t != "function") throw Error("sum(count, mapFn) requires a mapping function as the second argument.");
|
|
569
|
+
if (!Number.isInteger(e) || e < 0) throw Error("sum(count, mapFn) requires a non-negative integer count.");
|
|
570
|
+
let n = e;
|
|
571
|
+
for (let e = 0; e < n; e++) f(t(e, e), 0);
|
|
572
|
+
} else if (typeof e == "object" && e && !(e instanceof String) && (!(e instanceof Map) || typeof t == "function") && Symbol.iterator in e && typeof e[Symbol.iterator] == "function") {
|
|
510
573
|
let n = 0;
|
|
511
|
-
for (let r of e)
|
|
512
|
-
}
|
|
574
|
+
for (let r of e) t ? f(t(r, n++), 0) : f(r, 1);
|
|
575
|
+
} else if (l(e)) {
|
|
576
|
+
if (Object.getOwnPropertySymbols(e).length > 0) throw Error("Symbol keys are not supported in sum().");
|
|
577
|
+
let n = 0;
|
|
578
|
+
for (let r of Object.keys(e)) {
|
|
579
|
+
let i = e[r];
|
|
580
|
+
t ? f(t(i, n++), 0) : f(i, 1);
|
|
581
|
+
}
|
|
582
|
+
} else throw Error("Unsupported item in sum(): expected an Iterable, Record, or (count, mapFn).");
|
|
513
583
|
for (let [e, t] of n) t === 0 && n.delete(e);
|
|
514
584
|
return new h(n, r);
|
|
515
585
|
}
|
package/dist/lib/solvers/glpk.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as e, r as t, s as n } from "../registry-
|
|
1
|
+
import { a as e, r as t, s as n } from "../registry-D7TZ3Wh_.js";
|
|
2
2
|
//#region src/modeler/solvers/glpk/loader.ts
|
|
3
3
|
var r = null, i = null;
|
|
4
4
|
async function a() {
|
|
@@ -211,8 +211,8 @@ var l = class t {
|
|
|
211
211
|
B = !1;
|
|
212
212
|
break;
|
|
213
213
|
}
|
|
214
|
-
let n = f.get(e);
|
|
215
|
-
|
|
214
|
+
let n = f.get(e), r = n ? n.name : e, i = Math.abs(t) < 1e-9 ? 0 : t;
|
|
215
|
+
!l.relax && n && (n.type === "Integer" || n.type === "Binary") && Math.abs(i - Math.round(i)) <= 1e-5 && (i = Math.round(i) + 0), c(z, r, i);
|
|
216
216
|
}
|
|
217
217
|
if (B) for (let e of t.variables) {
|
|
218
218
|
let t = p.get(e) || e.name;
|
package/dist/lib/solvers/z3.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as e, O as t, T as n, r, s as i } from "../registry-
|
|
1
|
+
import { D as e, O as t, T as n, r, s as i } from "../registry-D7TZ3Wh_.js";
|
|
2
2
|
import { getBundledZ3AssetUrls as a } from "./z3-assets.js";
|
|
3
3
|
//#region src/modeler/solvers/z3/loader.ts
|
|
4
4
|
var o = null, s = null, c = null, l = null, u = /* @__PURE__ */ new WeakMap();
|