@ohtaman/washi 0.2.0 → 0.3.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 +131 -115
- package/README.md +131 -115
- package/README.zh-CN.md +133 -117
- package/dist/browser/solvers/glpk.js +10 -2
- package/dist/browser/solvers/glpk.min.js +1 -1
- package/dist/browser/solvers/z3.js +34 -12
- package/dist/browser/solvers/z3.min.js +2 -2
- package/dist/browser/washi.js +368 -306
- package/dist/browser/washi.min.js +4 -4
- package/dist/lib/{constraint-XWdn0ID9.js → constraint-BRuB3ooC.js} +0 -3
- package/dist/lib/solvers/glpk.js +10 -2
- package/dist/lib/solvers/z3.js +35 -10
- package/dist/lib/washi.js +368 -321
- package/dist/types/index.d.ts +5 -7
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/modeler/constraint.d.ts +0 -3
- package/dist/types/modeler/constraint.d.ts.map +1 -1
- package/dist/types/modeler/expression.d.ts +16 -10
- package/dist/types/modeler/expression.d.ts.map +1 -1
- package/dist/types/modeler/index.d.ts +2 -4
- package/dist/types/modeler/index.d.ts.map +1 -1
- package/dist/types/modeler/model.d.ts +90 -11
- package/dist/types/modeler/model.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 +1 -1
- package/dist/types/modeler/solvers/highs/solver.d.ts.map +1 -1
- package/dist/types/modeler/solvers/types.d.ts +1 -1
- package/dist/types/modeler/solvers/z3/loader.d.ts +12 -0
- package/dist/types/modeler/solvers/z3/loader.d.ts.map +1 -1
- package/dist/types/modeler/types.d.ts +8 -3
- package/dist/types/modeler/types.d.ts.map +1 -1
- package/dist/types/modeler/variable.d.ts +1 -6
- package/dist/types/modeler/variable.d.ts.map +1 -1
- package/package.json +10 -2
- package/dist/types/modeler/mip-compat.d.ts +0 -43
- package/dist/types/modeler/mip-compat.d.ts.map +0 -1
- package/dist/types/modeler/pulp-compat.d.ts +0 -67
- package/dist/types/modeler/pulp-compat.d.ts.map +0 -1
package/dist/lib/solvers/glpk.js
CHANGED
|
@@ -109,7 +109,7 @@ var o = class e {
|
|
|
109
109
|
let g = {
|
|
110
110
|
name: e.name || "GLPK_Model",
|
|
111
111
|
objective: {
|
|
112
|
-
direction: e.sense === "
|
|
112
|
+
direction: e.sense && e.sense.toLowerCase() === "maximize" ? a.GLP_MAX : a.GLP_MIN,
|
|
113
113
|
name: "obj",
|
|
114
114
|
vars: u
|
|
115
115
|
},
|
|
@@ -122,7 +122,15 @@ var o = class e {
|
|
|
122
122
|
};
|
|
123
123
|
typeof i.timeLimit == "number" && (_.tmlim = i.timeLimit), typeof i.mipGap == "number" && (_.mipgap = i.mipGap);
|
|
124
124
|
let v = performance.now(), y = await a.solve(g, _), b = (performance.now() - v) / 1e3, x = y?.result?.status, S;
|
|
125
|
-
S = x === a.GLP_OPT ? "Optimal" : x === a.GLP_FEAS ? "Feasible" : x === a.GLP_INFEAS || x === a.GLP_NOFEAS ? "Infeasible" : x === a.GLP_UNBND ? "Unbounded" : "Optimal"
|
|
125
|
+
if (S = x === a.GLP_OPT ? "Optimal" : x === a.GLP_FEAS ? "Feasible" : x === a.GLP_INFEAS || x === a.GLP_NOFEAS ? "Infeasible" : x === a.GLP_UNBND ? "Unbounded" : "Optimal", S === "Infeasible" || S === "Unbounded") return {
|
|
126
|
+
status: S,
|
|
127
|
+
objectiveValue: null,
|
|
128
|
+
values: {},
|
|
129
|
+
duals: {},
|
|
130
|
+
slacks: {},
|
|
131
|
+
runTime: b,
|
|
132
|
+
raw: y
|
|
133
|
+
};
|
|
126
134
|
let C = y?.result?.z, w = typeof C == "number" ? C + e.objective.constant : null, T = {}, E = y?.result?.vars || {};
|
|
127
135
|
for (let [e, t] of Object.entries(E)) {
|
|
128
136
|
let n = o.get(e), r = n ? n.name : e;
|
package/dist/lib/solvers/z3.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as e, r as t, t as n } from "../constraint-
|
|
1
|
+
import { i as e, r as t, t as n } from "../constraint-BRuB3ooC.js";
|
|
2
2
|
import { r } from "../registry-DksqCSjI.js";
|
|
3
3
|
import { getBundledZ3AssetUrls as i } from "./z3-assets.js";
|
|
4
4
|
//#region src/modeler/solvers/z3/loader.ts
|
|
@@ -110,11 +110,16 @@ function b() {
|
|
|
110
110
|
}
|
|
111
111
|
async function x(e, t) {
|
|
112
112
|
try {
|
|
113
|
-
let n =
|
|
113
|
+
let n = null;
|
|
114
|
+
try {
|
|
115
|
+
let t = await fetch(e, { method: "HEAD" });
|
|
116
|
+
t.ok && (n = t);
|
|
117
|
+
} catch {}
|
|
118
|
+
if (n ||= await fetch(e, {
|
|
114
119
|
method: "GET",
|
|
115
|
-
headers: { Range: "bytes=0-3" }
|
|
116
|
-
|
|
117
|
-
|
|
120
|
+
headers: { Range: "bytes=0-3" },
|
|
121
|
+
cache: "no-store"
|
|
122
|
+
}), !n.ok) throw Error(`server responded with HTTP status ${n.status} (${n.statusText || "Not Found"})`);
|
|
118
123
|
if ((n.headers.get("content-type") || "").includes("text/html")) throw Error(`server responded with "text/html" instead of expected ${t} (check SPA fallback routing)`);
|
|
119
124
|
} catch (n) {
|
|
120
125
|
throw Error(`[WaSHI] Failed to load Z3 asset (${t}) from "${e}": ${n.message || String(n)}. Deploy local assets with correct MIME types; no CDN fallback is attempted.`, { cause: n });
|
|
@@ -137,10 +142,30 @@ function S(e = {}) {
|
|
|
137
142
|
}
|
|
138
143
|
async function C(e) {
|
|
139
144
|
let t = globalThis;
|
|
140
|
-
if (typeof t.initZ3 == "function") return t.initZ3;
|
|
141
|
-
if (typeof document < "u") await new Promise((
|
|
142
|
-
let
|
|
143
|
-
|
|
145
|
+
if (t.global === void 0 && (t.global = t), typeof t.initZ3 == "function") return t.initZ3;
|
|
146
|
+
if (typeof document < "u") await new Promise((n, r) => {
|
|
147
|
+
let i = null, a = (e) => {
|
|
148
|
+
try {
|
|
149
|
+
let t = typeof document < "u" && document.baseURI ? document.baseURI : void 0, n = new URL(e, t);
|
|
150
|
+
return n.origin + n.pathname;
|
|
151
|
+
} catch {
|
|
152
|
+
return e;
|
|
153
|
+
}
|
|
154
|
+
}, o = a(e), s = (t) => {
|
|
155
|
+
t.filename && (a(t.filename) === o || t.filename === e || t.filename.endsWith(o) || o.endsWith(t.filename)) && (i = t.error || t.message);
|
|
156
|
+
}, c = typeof window < "u" && typeof window.addEventListener == "function";
|
|
157
|
+
c && window.addEventListener("error", s);
|
|
158
|
+
let l = document.createElement("script");
|
|
159
|
+
l.src = e, l.crossOrigin = "anonymous", l.onload = () => {
|
|
160
|
+
if (c && window.removeEventListener("error", s), typeof t.initZ3 != "function" && i) {
|
|
161
|
+
let t = i instanceof Error ? `${i.name}: ${i.message}` : typeof i == "string" ? i : i?.message ? `${i.name ? i.name + ": " : ""}${i.message}` : String(i);
|
|
162
|
+
r(/* @__PURE__ */ Error(`[WaSHI] Failed to evaluate Z3 runtime script from "${e}": ${t}`));
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
n();
|
|
166
|
+
}, l.onerror = () => {
|
|
167
|
+
c && window.removeEventListener("error", s), r(/* @__PURE__ */ Error(`[WaSHI] Failed to load Z3 runtime script from "${e}".`));
|
|
168
|
+
}, document.head.appendChild(l);
|
|
144
169
|
});
|
|
145
170
|
else if (typeof globalThis.importScripts == "function") globalThis.importScripts(e);
|
|
146
171
|
else throw Error("[WaSHI] Cannot load z3-built.js in this environment: neither document nor importScripts is available.");
|
|
@@ -448,4 +473,4 @@ function D() {
|
|
|
448
473
|
}
|
|
449
474
|
D();
|
|
450
475
|
//#endregion
|
|
451
|
-
export { E as Z3Solver, T as killZ3Threads, w as loadZ3, g as notifyZ3WorkerError, h as registerZ3ErrorHandler, D as registerZ3Solver, y as resetZ3LoaderCache, S as resolveZ3AssetUrls, v as setZ3Assets, p as unlockAllZ3Semaphores, b as validateZ3BrowserEnvironment };
|
|
476
|
+
export { E as Z3Solver, C as ensureInitZ3Loaded, T as killZ3Threads, w as loadZ3, g as notifyZ3WorkerError, x as probeAssetUrl, h as registerZ3ErrorHandler, D as registerZ3Solver, y as resetZ3LoaderCache, S as resolveZ3AssetUrls, v as setZ3Assets, p as unlockAllZ3Semaphores, b as validateZ3BrowserEnvironment };
|