@ohtaman/washi 0.1.0 → 0.1.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 +42 -2
- package/README.md +42 -2
- package/README.zh-CN.md +42 -2
- package/dist/lib/assets/{highs-worker-D57nd9KC.js → highs-worker-DeDWU6KI.js} +1 -1
- package/dist/lib/demo/highs.wasm +0 -0
- package/dist/lib/solvers/z3.js +1 -1
- package/dist/lib/washi-logo.png +0 -0
- package/dist/lib/washi-logo.svg +70 -0
- package/dist/lib/washi.js +78 -78
- package/dist/lib/{z3-C5DfllfD.js → z3-C8g-PtmP.js} +79 -59
- package/dist/types/highs-loader.d.ts +17 -1
- package/dist/types/highs-loader.d.ts.map +1 -1
- package/dist/types/highs-worker-client.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +3 -2
|
Binary file
|
package/dist/lib/solvers/z3.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as e, t } from "../z3-
|
|
1
|
+
import { n as e, t } from "../z3-C8g-PtmP.js";
|
|
2
2
|
export { t as Z3Solver, e as registerZ3Solver };
|
|
Binary file
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 240 240" fill="none">
|
|
2
|
+
<defs>
|
|
3
|
+
<!-- Facet 1: Crimson Red (Warm / Craft) -->
|
|
4
|
+
<linearGradient id="craneRedTop" x1="0%" y1="0%" x2="100%" y2="100%">
|
|
5
|
+
<stop offset="0%" stop-color="#FF385C" />
|
|
6
|
+
<stop offset="100%" stop-color="#E11D48" />
|
|
7
|
+
</linearGradient>
|
|
8
|
+
<linearGradient id="craneRedBottom" x1="0%" y1="0%" x2="100%" y2="100%">
|
|
9
|
+
<stop offset="0%" stop-color="#BE123C" />
|
|
10
|
+
<stop offset="100%" stop-color="#881337" />
|
|
11
|
+
</linearGradient>
|
|
12
|
+
<linearGradient id="craneRedNeck" x1="0%" y1="0%" x2="100%" y2="100%">
|
|
13
|
+
<stop offset="0%" stop-color="#FB7185" />
|
|
14
|
+
<stop offset="100%" stop-color="#E11D48" />
|
|
15
|
+
</linearGradient>
|
|
16
|
+
|
|
17
|
+
<!-- Facet 2: Center Origami Transition (Purple / Logic) -->
|
|
18
|
+
<linearGradient id="craneBodyLeft" x1="0%" y1="0%" x2="100%" y2="100%">
|
|
19
|
+
<stop offset="0%" stop-color="#E11D48" />
|
|
20
|
+
<stop offset="100%" stop-color="#9333EA" />
|
|
21
|
+
</linearGradient>
|
|
22
|
+
<linearGradient id="craneBodyRight" x1="0%" y1="0%" x2="100%" y2="100%">
|
|
23
|
+
<stop offset="0%" stop-color="#9333EA" />
|
|
24
|
+
<stop offset="100%" stop-color="#4F46E5" />
|
|
25
|
+
</linearGradient>
|
|
26
|
+
|
|
27
|
+
<!-- Facet 3: Electric Indigo (Cool / Tech & Solver) -->
|
|
28
|
+
<linearGradient id="craneIndigoTop" x1="0%" y1="0%" x2="100%" y2="100%">
|
|
29
|
+
<stop offset="0%" stop-color="#6366F1" />
|
|
30
|
+
<stop offset="100%" stop-color="#4F46E5" />
|
|
31
|
+
</linearGradient>
|
|
32
|
+
<linearGradient id="craneIndigoBottom" x1="0%" y1="0%" x2="100%" y2="100%">
|
|
33
|
+
<stop offset="0%" stop-color="#4338CA" />
|
|
34
|
+
<stop offset="100%" stop-color="#312E81" />
|
|
35
|
+
</linearGradient>
|
|
36
|
+
<linearGradient id="craneIndigoTail" x1="0%" y1="0%" x2="100%" y2="100%">
|
|
37
|
+
<stop offset="0%" stop-color="#818CF8" />
|
|
38
|
+
<stop offset="100%" stop-color="#4F46E5" />
|
|
39
|
+
</linearGradient>
|
|
40
|
+
</defs>
|
|
41
|
+
|
|
42
|
+
<g id="washi-origami-symbol" stroke="#FFFFFF" stroke-opacity="0.2" stroke-width="0.8" stroke-linejoin="round">
|
|
43
|
+
<!-- 1. Left Neck & Head (Origami fold) -->
|
|
44
|
+
<polygon points="120,110 75,35 60,50 95,120" fill="url(#craneRedNeck)" />
|
|
45
|
+
<polygon points="75,35 60,50 50,42" fill="#E11D48" />
|
|
46
|
+
|
|
47
|
+
<!-- 2. Right Tail (Origami fold) -->
|
|
48
|
+
<polygon points="120,110 165,35 145,120" fill="url(#craneIndigoTail)" />
|
|
49
|
+
|
|
50
|
+
<!-- 3. Left Wing (Main Upper Facet) -->
|
|
51
|
+
<polygon points="120,110 15,55 95,145" fill="url(#craneRedTop)" />
|
|
52
|
+
<!-- Left Wing (Under Facet) -->
|
|
53
|
+
<polygon points="15,55 95,145 70,170" fill="url(#craneRedBottom)" />
|
|
54
|
+
|
|
55
|
+
<!-- 4. Right Wing (Main Upper Facet) -->
|
|
56
|
+
<polygon points="120,110 225,55 145,145" fill="url(#craneIndigoTop)" />
|
|
57
|
+
<!-- Right Wing (Under Facet) -->
|
|
58
|
+
<polygon points="225,55 145,145 170,170" fill="url(#craneIndigoBottom)" />
|
|
59
|
+
|
|
60
|
+
<!-- 5. Center Diamond Keel (Polytope Core) -->
|
|
61
|
+
<polygon points="120,110 95,145 120,195" fill="url(#craneBodyLeft)" />
|
|
62
|
+
<polygon points="120,110 145,145 120,195" fill="url(#craneBodyRight)" />
|
|
63
|
+
|
|
64
|
+
<!-- 6. Extreme Points / Optimal Mathematical Vertices -->
|
|
65
|
+
<circle cx="15" cy="55" r="4" fill="#FFFFFF" stroke="#E11D48" stroke-width="2" />
|
|
66
|
+
<circle cx="225" cy="55" r="4" fill="#FFFFFF" stroke="#4F46E5" stroke-width="2" />
|
|
67
|
+
<circle cx="120" cy="195" r="4" fill="#FFFFFF" stroke="#9333EA" stroke-width="2" />
|
|
68
|
+
<circle cx="120" cy="110" r="3" fill="#FFFFFF" stroke="#C026D3" stroke-width="1.5" />
|
|
69
|
+
</g>
|
|
70
|
+
</svg>
|
package/dist/lib/washi.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as
|
|
1
|
+
import { C as e, E as t, S as n, T as r, _ as i, a, b as o, c as s, d as c, f as l, g as u, h as d, i as f, l as p, m, n as h, o as g, p as _, r as v, s as ee, t as y, u as b, v as x, w as S, x as C, y as w } from "./z3-C8g-PtmP.js";
|
|
2
|
+
import { n as T, t as E } from "./glpk-BC32ZaPG.js";
|
|
3
3
|
//#region src/modeler/quad-expr.ts
|
|
4
|
-
function
|
|
4
|
+
function D(e, t) {
|
|
5
5
|
let n = e.id, r = t.id;
|
|
6
6
|
return n <= r ? `${n}:${r}` : `${r}:${n}`;
|
|
7
7
|
}
|
|
8
|
-
var
|
|
8
|
+
var O = class e {
|
|
9
9
|
linearTerms;
|
|
10
10
|
quadTerms;
|
|
11
11
|
constant;
|
|
@@ -18,7 +18,7 @@ var T = class e {
|
|
|
18
18
|
return new e(this.linearTerms, this.quadTerms, this.constant);
|
|
19
19
|
}
|
|
20
20
|
getQuadCoeff(e, t) {
|
|
21
|
-
let n =
|
|
21
|
+
let n = D(e, t), r = this.quadTerms.get(n);
|
|
22
22
|
return r ? r.coeff : 0;
|
|
23
23
|
}
|
|
24
24
|
add(t) {
|
|
@@ -91,14 +91,14 @@ var T = class e {
|
|
|
91
91
|
return this.value;
|
|
92
92
|
}
|
|
93
93
|
static fromProduct(t, n, r = 1) {
|
|
94
|
-
let i = new e(), a =
|
|
94
|
+
let i = new e(), a = D(t, n);
|
|
95
95
|
return i.quadTerms.set(a, {
|
|
96
96
|
var1: t.id <= n.id ? t : n,
|
|
97
97
|
var2: t.id <= n.id ? n : t,
|
|
98
98
|
coeff: r
|
|
99
99
|
}), i;
|
|
100
100
|
}
|
|
101
|
-
},
|
|
101
|
+
}, k = class e {
|
|
102
102
|
terms;
|
|
103
103
|
constant;
|
|
104
104
|
constructor(e = /* @__PURE__ */ new Map(), t = 0) {
|
|
@@ -108,7 +108,7 @@ var T = class e {
|
|
|
108
108
|
return new e(this.terms, this.constant);
|
|
109
109
|
}
|
|
110
110
|
add(e) {
|
|
111
|
-
if (e instanceof
|
|
111
|
+
if (e instanceof O) return e.add(this);
|
|
112
112
|
let t = this.clone();
|
|
113
113
|
if (typeof e == "number") t.constant += e;
|
|
114
114
|
else if ("terms" in e) {
|
|
@@ -124,7 +124,7 @@ var T = class e {
|
|
|
124
124
|
return t;
|
|
125
125
|
}
|
|
126
126
|
sub(e) {
|
|
127
|
-
return e instanceof
|
|
127
|
+
return e instanceof O ? e.neg().add(this) : typeof e == "number" ? this.add(-e) : ("terms" in e, this.add(e.mul(-1)));
|
|
128
128
|
}
|
|
129
129
|
mul(t) {
|
|
130
130
|
if (typeof t == "number") {
|
|
@@ -135,9 +135,9 @@ var T = class e {
|
|
|
135
135
|
}
|
|
136
136
|
return n;
|
|
137
137
|
}
|
|
138
|
-
let n = new
|
|
138
|
+
let n = new O();
|
|
139
139
|
Math.abs(this.constant) >= 1e-12 && n.linearTerms.set(t, this.constant);
|
|
140
|
-
for (let [e, r] of this.terms) n = n.add(
|
|
140
|
+
for (let [e, r] of this.terms) n = n.add(O.fromProduct(e, t, r));
|
|
141
141
|
return n;
|
|
142
142
|
}
|
|
143
143
|
div(e) {
|
|
@@ -180,7 +180,7 @@ var T = class e {
|
|
|
180
180
|
let i = this.clone(), a = 0;
|
|
181
181
|
typeof n == "number" ? a = n : "terms" in n ? (i = i.sub(new e(n.terms, 0)), a = n.constant) : i = i.sub(n);
|
|
182
182
|
let o = a - i.constant;
|
|
183
|
-
return i.constant = 0, new
|
|
183
|
+
return i.constant = 0, new x(i, t, o, r);
|
|
184
184
|
}
|
|
185
185
|
toString() {
|
|
186
186
|
let e = [], t = !0;
|
|
@@ -195,7 +195,7 @@ var T = class e {
|
|
|
195
195
|
return e.join(" ") || "0";
|
|
196
196
|
}
|
|
197
197
|
};
|
|
198
|
-
function
|
|
198
|
+
function A(e, t) {
|
|
199
199
|
let n = /* @__PURE__ */ new Map(), r = 0, i = 0;
|
|
200
200
|
for (let a of e) {
|
|
201
201
|
let e = t ? t(a, i++) : a;
|
|
@@ -213,9 +213,9 @@ function D(e, t) {
|
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
215
|
for (let [e, t] of n) Math.abs(t) < 1e-12 && n.delete(e);
|
|
216
|
-
return new
|
|
216
|
+
return new k(n, r);
|
|
217
217
|
}
|
|
218
|
-
var
|
|
218
|
+
var j = A, M = A, N = 0, P = class e {
|
|
219
219
|
id;
|
|
220
220
|
name;
|
|
221
221
|
type;
|
|
@@ -224,7 +224,7 @@ var O = D, k = D, A = 0, j = class e {
|
|
|
224
224
|
value = null;
|
|
225
225
|
reducedCost = null;
|
|
226
226
|
constructor(e = {}) {
|
|
227
|
-
this.id = ++
|
|
227
|
+
this.id = ++N, this.name = e.name || `x_${this.id}`, this.type = e.type || "Continuous", this.type === "Binary" ? (this.lb = 0, this.ub = 1) : (this.lb = e.lb === void 0 ? 0 : e.lb, this.ub = e.ub === void 0 ? Infinity : e.ub);
|
|
228
228
|
}
|
|
229
229
|
get x() {
|
|
230
230
|
return this.value;
|
|
@@ -233,39 +233,39 @@ var O = D, k = D, A = 0, j = class e {
|
|
|
233
233
|
return this.value;
|
|
234
234
|
}
|
|
235
235
|
mul(t) {
|
|
236
|
-
if (typeof t == "number") return new
|
|
237
|
-
if (t instanceof e) return
|
|
238
|
-
let n = new
|
|
236
|
+
if (typeof t == "number") return new k(/* @__PURE__ */ new Map([[this, t]]), 0);
|
|
237
|
+
if (t instanceof e) return O.fromProduct(this, t, 1);
|
|
238
|
+
let n = new O();
|
|
239
239
|
Math.abs(t.constant) >= 1e-12 && n.linearTerms.set(this, t.constant);
|
|
240
240
|
for (let [e, r] of t.terms) {
|
|
241
|
-
let t =
|
|
241
|
+
let t = O.fromProduct(this, e, r);
|
|
242
242
|
n = n.add(t);
|
|
243
243
|
}
|
|
244
244
|
return n;
|
|
245
245
|
}
|
|
246
246
|
add(e) {
|
|
247
|
-
return e instanceof
|
|
247
|
+
return e instanceof O ? e.add(this) : new k(/* @__PURE__ */ new Map([[this, 1]]), 0).add(e);
|
|
248
248
|
}
|
|
249
249
|
sub(e) {
|
|
250
|
-
return e instanceof
|
|
250
|
+
return e instanceof O ? e.neg().add(this) : new k(/* @__PURE__ */ new Map([[this, 1]]), 0).sub(e);
|
|
251
251
|
}
|
|
252
252
|
neg() {
|
|
253
253
|
return this.mul(-1);
|
|
254
254
|
}
|
|
255
255
|
le(e, t) {
|
|
256
|
-
return new
|
|
256
|
+
return new k(/* @__PURE__ */ new Map([[this, 1]]), 0).le(e, t);
|
|
257
257
|
}
|
|
258
258
|
lessThanOrEqual(e, t) {
|
|
259
259
|
return this.le(e, t);
|
|
260
260
|
}
|
|
261
261
|
ge(e, t) {
|
|
262
|
-
return new
|
|
262
|
+
return new k(/* @__PURE__ */ new Map([[this, 1]]), 0).ge(e, t);
|
|
263
263
|
}
|
|
264
264
|
greaterThanOrEqual(e, t) {
|
|
265
265
|
return this.ge(e, t);
|
|
266
266
|
}
|
|
267
267
|
eq(e, t) {
|
|
268
|
-
return new
|
|
268
|
+
return new k(/* @__PURE__ */ new Map([[this, 1]]), 0).eq(e, t);
|
|
269
269
|
}
|
|
270
270
|
equalTo(e, t) {
|
|
271
271
|
return this.eq(e, t);
|
|
@@ -276,7 +276,7 @@ var O = D, k = D, A = 0, j = class e {
|
|
|
276
276
|
};
|
|
277
277
|
//#endregion
|
|
278
278
|
//#region src/modeler/parser.ts
|
|
279
|
-
function
|
|
279
|
+
function F(e) {
|
|
280
280
|
let t = [], n = 0, r = e.length;
|
|
281
281
|
for (; n < r;) {
|
|
282
282
|
let i = e[n];
|
|
@@ -332,7 +332,7 @@ function M(e) {
|
|
|
332
332
|
}
|
|
333
333
|
return t;
|
|
334
334
|
}
|
|
335
|
-
var
|
|
335
|
+
var te = class {
|
|
336
336
|
tokens;
|
|
337
337
|
pos = 0;
|
|
338
338
|
resolver;
|
|
@@ -394,12 +394,12 @@ var N = class {
|
|
|
394
394
|
let e = this.consume();
|
|
395
395
|
return this.resolveVariable(e.value).mul(t);
|
|
396
396
|
}
|
|
397
|
-
return new
|
|
397
|
+
return new k(/* @__PURE__ */ new Map(), t);
|
|
398
398
|
}
|
|
399
399
|
if (e.type === "IDENT") {
|
|
400
400
|
this.consume();
|
|
401
401
|
let t = this.resolveVariable(e.value);
|
|
402
|
-
return new
|
|
402
|
+
return new k(/* @__PURE__ */ new Map([[t, 1]]), 0);
|
|
403
403
|
}
|
|
404
404
|
if (e.type === "LPAREN") {
|
|
405
405
|
this.consume("LPAREN");
|
|
@@ -414,10 +414,10 @@ var N = class {
|
|
|
414
414
|
return t;
|
|
415
415
|
}
|
|
416
416
|
};
|
|
417
|
-
function
|
|
418
|
-
return new
|
|
417
|
+
function I(e, t) {
|
|
418
|
+
return new te(F(e), t).parseExpression();
|
|
419
419
|
}
|
|
420
|
-
function
|
|
420
|
+
function L(e, t, n) {
|
|
421
421
|
let r = e.match(/(<=|>=|==|=<|=>|=)/);
|
|
422
422
|
if (!r) throw Error(`Constraint must contain a comparison operator (<=, >=, ==, =): "${e}"`);
|
|
423
423
|
let i = r[0], a = r.index, o = e.substring(0, a).trim(), s = e.substring(a + i.length).trim(), c;
|
|
@@ -425,18 +425,18 @@ function F(e, t, n) {
|
|
|
425
425
|
else if (i === ">=" || i === "=>") c = ">=";
|
|
426
426
|
else if (i === "==" || i === "=") c = "==";
|
|
427
427
|
else throw Error(`Unsupported operator "${i}"`);
|
|
428
|
-
let l =
|
|
428
|
+
let l = I(o, t), u = I(s, t);
|
|
429
429
|
return c === "<=" ? l.le(u, n) : c === ">=" ? l.ge(u, n) : l.eq(u, n);
|
|
430
430
|
}
|
|
431
|
-
function
|
|
431
|
+
function R(e, t) {
|
|
432
432
|
let n = /* @__PURE__ */ new Map(), r = "";
|
|
433
433
|
for (let i = 0; i < e.length; i++) if (r += e[i], i < t.length) {
|
|
434
434
|
let e = t[i];
|
|
435
435
|
if (typeof e == "number") r += `(${e})`;
|
|
436
|
-
else if (e instanceof
|
|
436
|
+
else if (e instanceof P) {
|
|
437
437
|
let t = `__v_${i}__`;
|
|
438
438
|
n.set(t, e), r += t;
|
|
439
|
-
} else if (e instanceof
|
|
439
|
+
} else if (e instanceof k) {
|
|
440
440
|
`${i}`, r += `(${e.toString()})`;
|
|
441
441
|
for (let [t] of e.terms) n.set(t.name, t);
|
|
442
442
|
}
|
|
@@ -446,42 +446,42 @@ function I(e, t) {
|
|
|
446
446
|
resolver: (e) => n.get(e)
|
|
447
447
|
};
|
|
448
448
|
}
|
|
449
|
-
function
|
|
450
|
-
let { fullText: n, resolver: r } =
|
|
451
|
-
return
|
|
449
|
+
function z(e, ...t) {
|
|
450
|
+
let { fullText: n, resolver: r } = R(e, t);
|
|
451
|
+
return L(n, r);
|
|
452
452
|
}
|
|
453
|
-
function
|
|
454
|
-
let { fullText: n, resolver: r } =
|
|
455
|
-
return /(<=|>=|==|=<|=>|=)/.test(n) ?
|
|
453
|
+
function B(e, ...t) {
|
|
454
|
+
let { fullText: n, resolver: r } = R(e, t);
|
|
455
|
+
return /(<=|>=|==|=<|=>|=)/.test(n) ? L(n, r) : I(n, r);
|
|
456
456
|
}
|
|
457
457
|
//#endregion
|
|
458
458
|
//#region src/modeler/lp-writer.ts
|
|
459
|
-
function
|
|
459
|
+
function V(e, t, n) {
|
|
460
460
|
let r = e.replace(/[^a-zA-Z0-9_]/g, "_");
|
|
461
461
|
return /^[0-9]/.test(r) && (r = `${t}_${r}`), (!r || r.length === 0) && (r = `${t}_${n}`), r;
|
|
462
462
|
}
|
|
463
|
-
function
|
|
463
|
+
function H(e) {
|
|
464
464
|
let { sense: t, objective: n, constraints: r, variables: i } = e, a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Set();
|
|
465
465
|
for (let e of i) {
|
|
466
|
-
let t =
|
|
466
|
+
let t = V(e.name, "x", e.id), n = t, r = 1;
|
|
467
467
|
for (; c.has(n);) n = `${t}_${r++}`;
|
|
468
468
|
c.add(n), o.set(e, n), a.set(n, e);
|
|
469
469
|
}
|
|
470
470
|
let l = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Map();
|
|
471
471
|
for (let e of r) {
|
|
472
|
-
let t =
|
|
472
|
+
let t = V(e.name, "c", e.id), n = t, r = 1;
|
|
473
473
|
for (; l.has(n);) n = `${t}_${r++}`;
|
|
474
474
|
l.add(n), u.set(e, n), s.set(n, e);
|
|
475
475
|
}
|
|
476
476
|
let d = [];
|
|
477
477
|
d.push(t === "Maximize" ? "Maximize" : "Minimize");
|
|
478
|
-
let f = [], p = !0, m = n instanceof
|
|
478
|
+
let f = [], p = !0, m = n instanceof O ? n.linearTerms : n.terms;
|
|
479
479
|
if (m) for (let [e, t] of m) {
|
|
480
480
|
if (Math.abs(t) < 1e-12) continue;
|
|
481
481
|
let n = o.get(e), r = t >= 0 ? p ? "" : "+ " : "- ", i = Math.abs(t), a = i === 1 ? "" : `${i} `;
|
|
482
482
|
f.push(`${r}${a}${n}`), p = !1;
|
|
483
483
|
}
|
|
484
|
-
if (n instanceof
|
|
484
|
+
if (n instanceof O && n.quadTerms.size > 0) {
|
|
485
485
|
let e = [], t = !0;
|
|
486
486
|
for (let r of n.quadTerms.values()) {
|
|
487
487
|
if (Math.abs(r.coeff) < 1e-12) continue;
|
|
@@ -533,7 +533,7 @@ function B(e) {
|
|
|
533
533
|
}
|
|
534
534
|
//#endregion
|
|
535
535
|
//#region src/modeler/model.ts
|
|
536
|
-
var
|
|
536
|
+
var U = class {
|
|
537
537
|
name;
|
|
538
538
|
sense;
|
|
539
539
|
objective;
|
|
@@ -551,7 +551,7 @@ var V = class {
|
|
|
551
551
|
solution = null;
|
|
552
552
|
solver = null;
|
|
553
553
|
constructor(e = {}) {
|
|
554
|
-
this.name = e.name || "OptimizationModel", this.sense = e.sense || "Minimize", this.objective = new
|
|
554
|
+
this.name = e.name || "OptimizationModel", this.sense = e.sense || "Minimize", this.objective = new k(), e.solver && (this.solver = v(e.solver));
|
|
555
555
|
}
|
|
556
556
|
get vars() {
|
|
557
557
|
return this.variables;
|
|
@@ -573,7 +573,7 @@ var V = class {
|
|
|
573
573
|
lb: n,
|
|
574
574
|
ub: r
|
|
575
575
|
} : e || {};
|
|
576
|
-
let a = new
|
|
576
|
+
let a = new P(i);
|
|
577
577
|
if (this.varMapByName.has(a.name)) throw Error(`Variable with name '${a.name}' already exists in model`);
|
|
578
578
|
return this.variables.push(a), this.varMapByName.set(a.name, a), a;
|
|
579
579
|
}
|
|
@@ -628,7 +628,7 @@ var V = class {
|
|
|
628
628
|
return this.constrMapByName.get(e);
|
|
629
629
|
}
|
|
630
630
|
setObjective(e, t) {
|
|
631
|
-
t && (this.sense = t), this.objective = typeof e == "string" ?
|
|
631
|
+
t && (this.sense = t), this.objective = typeof e == "string" ? I(e, (e) => this.getVarByName(e)) : typeof e == "number" ? new k(/* @__PURE__ */ new Map(), e) : e instanceof O || "terms" in e ? e.clone() : new k(/* @__PURE__ */ new Map([[e, 1]]), 0);
|
|
632
632
|
}
|
|
633
633
|
maximize(e) {
|
|
634
634
|
this.setObjective(e, "Maximize");
|
|
@@ -637,11 +637,11 @@ var V = class {
|
|
|
637
637
|
this.setObjective(e, "Minimize");
|
|
638
638
|
}
|
|
639
639
|
addBoolVar(e) {
|
|
640
|
-
let
|
|
641
|
-
return this.boolVars.push(
|
|
640
|
+
let t = new C(e);
|
|
641
|
+
return this.boolVars.push(t), t;
|
|
642
642
|
}
|
|
643
643
|
addConstraint(e, t) {
|
|
644
|
-
if (e instanceof
|
|
644
|
+
if (e instanceof w) {
|
|
645
645
|
let n = t || `lc_${this.logicalConstraints.length + 1}`;
|
|
646
646
|
return this.logicalConstraints.push({
|
|
647
647
|
name: n,
|
|
@@ -649,7 +649,7 @@ var V = class {
|
|
|
649
649
|
}), e;
|
|
650
650
|
}
|
|
651
651
|
let n;
|
|
652
|
-
if (typeof e == "string" ? n =
|
|
652
|
+
if (typeof e == "string" ? n = L(e, (e) => this.getVarByName(e), t) : (n = e, t && (n.name = t)), this.constrMapByName.has(n.name)) throw Error(`Constraint with name '${n.name}' already exists in model`);
|
|
653
653
|
return this.constraints.push(n), this.constrMapByName.set(n.name, n), n;
|
|
654
654
|
}
|
|
655
655
|
addConstr(e, t) {
|
|
@@ -663,7 +663,7 @@ var V = class {
|
|
|
663
663
|
for (let t of e) this.add(t);
|
|
664
664
|
return this;
|
|
665
665
|
}
|
|
666
|
-
return e instanceof
|
|
666
|
+
return e instanceof P ? (this.varMapByName.has(e.name) || (this.variables.push(e), this.varMapByName.set(e.name, e)), this) : (this.addConstraint(e, t), this);
|
|
667
667
|
}
|
|
668
668
|
addIndicator(e, t, n = {}) {
|
|
669
669
|
let r = n.activeValue === void 0 ? 1 : n.activeValue, i = n.M === void 0 ? 1e5 : n.M, a = n.name || `ind_${e.name}_${t.name}`, o = [], { lhs: s, sense: c, rhs: l } = t;
|
|
@@ -689,7 +689,7 @@ var V = class {
|
|
|
689
689
|
return o;
|
|
690
690
|
}
|
|
691
691
|
toLpString() {
|
|
692
|
-
let { lpString: e } =
|
|
692
|
+
let { lpString: e } = H({
|
|
693
693
|
name: this.name,
|
|
694
694
|
sense: this.sense,
|
|
695
695
|
objective: this.objective,
|
|
@@ -700,7 +700,7 @@ var V = class {
|
|
|
700
700
|
}
|
|
701
701
|
async optimize(e, t) {
|
|
702
702
|
let n, r;
|
|
703
|
-
if (e && typeof e == "object" && "solve" in e && typeof e.solve == "function" ? (n = e, r = t || {}) : typeof e == "function" ? (n = new e(t), r = t || {}) : typeof e == "string" ? (n =
|
|
703
|
+
if (e && typeof e == "object" && "solve" in e && typeof e.solve == "function" ? (n = e, r = t || {}) : typeof e == "function" ? (n = new e(t), r = t || {}) : typeof e == "string" ? (n = v(e, t), r = t || {}) : (r = { ...e }, r.solver ? (n = v(r.solver, r), delete r.solver) : n = this.solver || v()), this.objective instanceof O && this.objective.quadTerms.size > 0 && n.capabilities?.supportsQP === !1) throw Error(`Solver "${n.name}" does not support quadratic objectives (QP). Please use a QP-capable solver such as HiGHS or Clarabel.`);
|
|
704
704
|
let i = {
|
|
705
705
|
name: this.name,
|
|
706
706
|
sense: this.sense,
|
|
@@ -709,7 +709,7 @@ var V = class {
|
|
|
709
709
|
variables: this.variables,
|
|
710
710
|
logicalConstraints: this.logicalConstraints,
|
|
711
711
|
boolVars: this.boolVars
|
|
712
|
-
}, a =
|
|
712
|
+
}, a = H(i), o = await n.solve(i, a, r);
|
|
713
713
|
this.runTime = o.runTime ?? 0, this.status = o.status, this.objectiveValue = o.objectiveValue ?? null;
|
|
714
714
|
let s = {}, c = {}, l = {}, u = {};
|
|
715
715
|
if (this.values.clear(), o.values) for (let [e, t] of Object.entries(o.values)) {
|
|
@@ -745,7 +745,7 @@ var V = class {
|
|
|
745
745
|
}
|
|
746
746
|
async check(e, t) {
|
|
747
747
|
let n, r;
|
|
748
|
-
if (e && typeof e == "object" && "solve" in e && typeof e.solve == "function" ? (n = e, r = t || {}) : typeof e == "function" ? (n = new e(t), r = t || {}) : typeof e == "string" ? (n =
|
|
748
|
+
if (e && typeof e == "object" && "solve" in e && typeof e.solve == "function" ? (n = e, r = t || {}) : typeof e == "function" ? (n = new e(t), r = t || {}) : typeof e == "string" ? (n = v(e, t), r = t || {}) : (r = { ...e }, r.solver ? (n = v(r.solver, r), delete r.solver) : n = this.solver || v()), this.logicalConstraints.length > 0 && n.capabilities?.supportsSMT !== !0) throw Error(`Solver "${n.name}" does not support SMT / logical constraints (or, implies, not, xor). Please use an SMT-capable solver such as Z3.`);
|
|
749
749
|
if (typeof n.check == "function") {
|
|
750
750
|
let e = await n.check({
|
|
751
751
|
name: this.name,
|
|
@@ -766,7 +766,7 @@ var V = class {
|
|
|
766
766
|
}
|
|
767
767
|
let i = this.objective, a = this.sense;
|
|
768
768
|
try {
|
|
769
|
-
this.objective = new
|
|
769
|
+
this.objective = new k(), this.sense = "Minimize";
|
|
770
770
|
let e = await this.optimize(n, r), t = e === "Optimal" || e === "Feasible", i = e === "Infeasible", a = {};
|
|
771
771
|
for (let e of this.variables) a[e.name] = e.value ?? 0;
|
|
772
772
|
return {
|
|
@@ -778,7 +778,7 @@ var V = class {
|
|
|
778
778
|
this.objective = i, this.sense = a;
|
|
779
779
|
}
|
|
780
780
|
}
|
|
781
|
-
},
|
|
781
|
+
}, W = "Minimize", G = "Maximize", K = "Continuous", q = "Integer", J = "Binary", Y = {
|
|
782
782
|
Optimal: "Optimal",
|
|
783
783
|
Feasible: "Feasible",
|
|
784
784
|
Infeasible: "Infeasible",
|
|
@@ -790,7 +790,7 @@ var V = class {
|
|
|
790
790
|
Sat: "Sat",
|
|
791
791
|
Unsat: "Unsat",
|
|
792
792
|
Unknown: "Unknown"
|
|
793
|
-
},
|
|
793
|
+
}, X = class e extends P {
|
|
794
794
|
constructor(e, t, n, r = "Continuous") {
|
|
795
795
|
super({
|
|
796
796
|
name: e,
|
|
@@ -808,13 +808,13 @@ var V = class {
|
|
|
808
808
|
return o;
|
|
809
809
|
}
|
|
810
810
|
};
|
|
811
|
-
function
|
|
811
|
+
function Z(e) {
|
|
812
812
|
return e == null ? null : typeof e == "number" ? e : e.value;
|
|
813
813
|
}
|
|
814
|
-
var
|
|
814
|
+
var ne = class {
|
|
815
815
|
model;
|
|
816
|
-
constructor(e = "NoName", t =
|
|
817
|
-
this.model = new
|
|
816
|
+
constructor(e = "NoName", t = W) {
|
|
817
|
+
this.model = new U({
|
|
818
818
|
name: e,
|
|
819
819
|
sense: t
|
|
820
820
|
});
|
|
@@ -849,7 +849,7 @@ var X = class {
|
|
|
849
849
|
setObjective(e) {
|
|
850
850
|
if (typeof e == "object" && e) {
|
|
851
851
|
if ("terms" in e) for (let [t] of e.terms) this.addVariable(t);
|
|
852
|
-
else e instanceof
|
|
852
|
+
else e instanceof P && this.addVariable(e);
|
|
853
853
|
}
|
|
854
854
|
this.model.setObjective(e);
|
|
855
855
|
}
|
|
@@ -858,7 +858,7 @@ var X = class {
|
|
|
858
858
|
return this.model.addConstraint(e, t);
|
|
859
859
|
}
|
|
860
860
|
add(e, t) {
|
|
861
|
-
typeof e == "string" ? /(<=|>=|==|=<|=>|=)/.test(e) ? this.addConstraint(e, t) : this.setObjective(e) : e instanceof
|
|
861
|
+
typeof e == "string" ? /(<=|>=|==|=<|=>|=)/.test(e) ? this.addConstraint(e, t) : this.setObjective(e) : e instanceof x ? this.addConstraint(e, t) : this.setObjective(e);
|
|
862
862
|
}
|
|
863
863
|
async solve(e, t) {
|
|
864
864
|
return this.model.optimize(e, t);
|
|
@@ -866,21 +866,21 @@ var X = class {
|
|
|
866
866
|
toLpString() {
|
|
867
867
|
return this.model.toLpString();
|
|
868
868
|
}
|
|
869
|
-
},
|
|
870
|
-
function
|
|
869
|
+
}, Q = "Minimize", $ = "Maximize", re = "Binary", ie = "Integer", ae = "Continuous";
|
|
870
|
+
function oe(e) {
|
|
871
871
|
return {
|
|
872
872
|
expr: e,
|
|
873
|
-
sense:
|
|
873
|
+
sense: $
|
|
874
874
|
};
|
|
875
875
|
}
|
|
876
|
-
function
|
|
876
|
+
function se(e) {
|
|
877
877
|
return {
|
|
878
878
|
expr: e,
|
|
879
|
-
sense:
|
|
879
|
+
sense: Q
|
|
880
880
|
};
|
|
881
881
|
}
|
|
882
|
-
var
|
|
883
|
-
constructor(e = "MipModel", t =
|
|
882
|
+
var ce = class extends U {
|
|
883
|
+
constructor(e = "MipModel", t = Q) {
|
|
884
884
|
super({
|
|
885
885
|
name: e,
|
|
886
886
|
sense: t
|
|
@@ -905,4 +905,4 @@ var ie = class extends V {
|
|
|
905
905
|
}
|
|
906
906
|
};
|
|
907
907
|
//#endregion
|
|
908
|
-
export {
|
|
908
|
+
export { re as BINARY, w as BoolExpr, o as BoolOp, C as BoolVar, ae as CONTINUOUS, x as Constraint, E as GLPKSolver, s as HiGHS, p as HighsSolver, ie as INTEGER, k as LinExpr, J as LpBinary, K as LpContinuous, q as LpInteger, G as LpMaximize, W as LpMinimize, ne as LpProblem, Y as LpStatus, X as LpVariable, $ as MAXIMIZE, Q as MINIMIZE, ce as MipModel, ee as MockSolver, U as Model, b as OFFICIAL_HIGHS_CDN_WASM_URL, O as QuadExpr, P as Var, y as Z3Solver, n as and, z as c, B as expr, H as generateLpString, T as getGlpk, c as getHighs, l as getHighsWasmUrl, v as getSolver, e as implies, _ as isValidWasmHeader, f as listAvailableSolvers, M as lpSum, oe as maximize, se as minimize, S as not, r as or, L as parseConstraint, I as parseExpr, m as probeWasmUrl, a as registerSolver, h as registerZ3Solver, d as resolveBrowserWasmUrl, g as setDefaultSolver, u as setHighsWasmUrl, i as solveLpWithHighs, A as sum, Z as value, t as xor, j as xsum };
|