@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
package/dist/browser/washi.js
CHANGED
|
@@ -14,7 +14,7 @@ function e(e) {
|
|
|
14
14
|
//#region src/modeler/boolean-expr.ts
|
|
15
15
|
var t = 0;
|
|
16
16
|
function n(e, t) {
|
|
17
|
-
if (e instanceof r || e instanceof
|
|
17
|
+
if (e instanceof r || e instanceof R) return e;
|
|
18
18
|
throw typeof e == "object" && e && ("terms" in e || "quadTerms" in e) ? Error(`Cannot use an arithmetic expression without a comparison operator (<=, >=, ==) in logical operator "${t}". Use a comparison constraint such as expr\`\${x} <= 10\` or a BoolVar/BoolExpr.`) : typeof e == "object" && e && "id" in e && "name" in e && "lb" in e && "ub" in e && !("sense" in e) ? Error(`Invalid operand passed to logical operator "${t}": expected a BoolVar, BoolExpr, or Constraint, but received numeric variable "${e.name}". Use m.bool() for propositional variables, add a comparison such as expr\`\${x} == 1\`, or use m.indicator(binVar, constraint) for 0-1 Big-M indicator constraints.`) : Error(`Invalid operand passed to logical operator "${t}": expected a BoolVar, BoolExpr, or Constraint.`);
|
|
19
19
|
}
|
|
20
20
|
var r = class {
|
|
@@ -88,12 +88,12 @@ var d = class extends r {
|
|
|
88
88
|
}
|
|
89
89
|
};
|
|
90
90
|
function f(e) {
|
|
91
|
-
if (typeof e != "object" || !e || Array.isArray(e) || e instanceof
|
|
91
|
+
if (typeof e != "object" || !e || Array.isArray(e) || e instanceof R || e instanceof r || e instanceof G) return !1;
|
|
92
92
|
let t = Object.getPrototypeOf(e);
|
|
93
93
|
return t === Object.prototype || t === null;
|
|
94
94
|
}
|
|
95
95
|
function p(e) {
|
|
96
|
-
return typeof e == "number" || e instanceof
|
|
96
|
+
return typeof e == "number" || e instanceof R || e instanceof G || typeof e == "object" && !!e && ("terms" in e && e.terms instanceof Map || "quadTerms" in e && e.quadTerms instanceof Map || "id" in e && "name" in e && "lb" in e && "ub" in e && !("sense" in e));
|
|
97
97
|
}
|
|
98
98
|
function m(...e) {
|
|
99
99
|
if (e.length === 0) throw Error("distinct() requires at least one expression or container.");
|
|
@@ -230,7 +230,7 @@ var b = class e {
|
|
|
230
230
|
this.linearTerms = new Map(e), this.quadTerms = /* @__PURE__ */ new Map();
|
|
231
231
|
for (let [e, n] of t) this.quadTerms.set(e, { ...n });
|
|
232
232
|
this.constant = n, this.nonlinearTerms = r.filter((e) => e.coeff !== 0).map((e) => ({
|
|
233
|
-
atom:
|
|
233
|
+
atom: B(e.atom),
|
|
234
234
|
coeff: e.coeff
|
|
235
235
|
}));
|
|
236
236
|
}
|
|
@@ -245,7 +245,7 @@ var b = class e {
|
|
|
245
245
|
return r ? r.coeff : 0;
|
|
246
246
|
}
|
|
247
247
|
add(t) {
|
|
248
|
-
if (
|
|
248
|
+
if (z(t)) throw Error("Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.");
|
|
249
249
|
let n = this.clone();
|
|
250
250
|
if (typeof t == "number") return n.constant += t, n;
|
|
251
251
|
if (t instanceof e) {
|
|
@@ -262,7 +262,7 @@ var b = class e {
|
|
|
262
262
|
t === 0 ? n.linearTerms.delete(e) : n.linearTerms.set(e, t);
|
|
263
263
|
}
|
|
264
264
|
if (n.constant += t.constant, Array.isArray(t.nonlinearTerms)) for (let e of t.nonlinearTerms) e.coeff !== 0 && n.nonlinearTerms.push({
|
|
265
|
-
atom:
|
|
265
|
+
atom: B(e.atom),
|
|
266
266
|
coeff: e.coeff
|
|
267
267
|
});
|
|
268
268
|
return n;
|
|
@@ -273,7 +273,7 @@ var b = class e {
|
|
|
273
273
|
t === 0 ? n.linearTerms.delete(e) : n.linearTerms.set(e, t);
|
|
274
274
|
}
|
|
275
275
|
if (n.constant += t.constant, Array.isArray(t.nonlinearTerms)) for (let e of t.nonlinearTerms) e.coeff !== 0 && n.nonlinearTerms.push({
|
|
276
|
-
atom:
|
|
276
|
+
atom: B(e.atom),
|
|
277
277
|
coeff: e.coeff
|
|
278
278
|
});
|
|
279
279
|
return n;
|
|
@@ -282,11 +282,11 @@ var b = class e {
|
|
|
282
282
|
return i === 0 ? n.linearTerms.delete(r) : n.linearTerms.set(r, i), n;
|
|
283
283
|
}
|
|
284
284
|
sub(e) {
|
|
285
|
-
if (
|
|
285
|
+
if (z(e)) throw Error("Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.");
|
|
286
286
|
return typeof e == "number" ? this.add(-e) : this.add(e.mul(-1));
|
|
287
287
|
}
|
|
288
288
|
mul(t) {
|
|
289
|
-
if (
|
|
289
|
+
if (z(t)) throw Error("Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.");
|
|
290
290
|
if (typeof t == "number") {
|
|
291
291
|
let n = this.linearTerms.size > 0 || this.quadTerms.size > 0 || this.nonlinearTerms.length > 0, r = this.constant === 0 && n ? 0 : this.constant * t;
|
|
292
292
|
if (this.constant !== 0 && t !== 0 && r === 0) throw Error("Constant multiplication underflows to zero.");
|
|
@@ -309,7 +309,7 @@ var b = class e {
|
|
|
309
309
|
let n = e.coeff * t;
|
|
310
310
|
if (e.coeff !== 0 && n === 0) throw Error("Coefficient multiplication underflows to zero.");
|
|
311
311
|
n !== 0 && i.nonlinearTerms.push({
|
|
312
|
-
atom:
|
|
312
|
+
atom: B(e.atom),
|
|
313
313
|
coeff: n
|
|
314
314
|
});
|
|
315
315
|
}
|
|
@@ -353,7 +353,7 @@ var b = class e {
|
|
|
353
353
|
e += t.coeff * t.var1.value * t.var2.value;
|
|
354
354
|
}
|
|
355
355
|
for (let t of this.nonlinearTerms) {
|
|
356
|
-
let n =
|
|
356
|
+
let n = H(t.atom);
|
|
357
357
|
if (n === null) return null;
|
|
358
358
|
e += t.coeff * n;
|
|
359
359
|
}
|
|
@@ -455,7 +455,7 @@ var b = class e {
|
|
|
455
455
|
return s;
|
|
456
456
|
}
|
|
457
457
|
static extractScalarDivisor(e, t) {
|
|
458
|
-
if (
|
|
458
|
+
if (z(e)) throw Error("Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.");
|
|
459
459
|
if (typeof e == "number") {
|
|
460
460
|
if (e === 0) throw Error(`Division by zero in ${t}`);
|
|
461
461
|
return e;
|
|
@@ -474,7 +474,7 @@ function E(e) {
|
|
|
474
474
|
}
|
|
475
475
|
function D(e, t, n) {
|
|
476
476
|
if (e instanceof a) for (let r of e.children) D(r, t, n);
|
|
477
|
-
else if (e instanceof
|
|
477
|
+
else if (e instanceof R) {
|
|
478
478
|
let r = e.ownerModel, i = S.get(e);
|
|
479
479
|
(r !== t || i !== t) && (n && n.push(() => {
|
|
480
480
|
e.ownerModel = r, i ? S.set(e, i) : S.delete(e);
|
|
@@ -499,8 +499,8 @@ function te(e, t) {
|
|
|
499
499
|
function k(e, t, n) {
|
|
500
500
|
C.get(e) === t && C.delete(e), S.get(e) === t && (n ? S.set(e, n) : S.delete(e));
|
|
501
501
|
}
|
|
502
|
-
var
|
|
503
|
-
function
|
|
502
|
+
var ne = 1e-6;
|
|
503
|
+
function A(e) {
|
|
504
504
|
if (typeof e.lb != "number" || Number.isNaN(e.lb)) throw Error(`Variable "${e.name}" has invalid lower bound: ${e.lb} (NaN or non-numeric bound is not allowed).`);
|
|
505
505
|
if (e.lb === Infinity) throw Error(`Variable "${e.name}" has invalid lower bound: +Infinity is not allowed as a lower bound.`);
|
|
506
506
|
if (typeof e.ub != "number" || Number.isNaN(e.ub)) throw Error(`Variable "${e.name}" has invalid upper bound: ${e.ub} (NaN or non-numeric bound is not allowed).`);
|
|
@@ -509,31 +509,31 @@ function j(e) {
|
|
|
509
509
|
if (e.initialValue !== void 0) {
|
|
510
510
|
if (typeof e.initialValue != "number" || !Number.isFinite(e.initialValue)) throw Error(`Variable "${e.name}" has invalid initialValue: ${String(e.initialValue)} (initialValue must be a finite number).`);
|
|
511
511
|
let t = e.type === "Binary" ? Math.max(0, e.lb) : e.lb, n = e.type === "Binary" ? Math.min(1, e.ub) : e.ub;
|
|
512
|
-
if (e.initialValue < t - 1e-6 || e.initialValue > n + 1e-6) throw Error(`Variable "${e.name}" has initialValue (${e.initialValue}) outside its bounds [${t}, ${n}] (tolerance ${
|
|
512
|
+
if (e.initialValue < t - 1e-6 || e.initialValue > n + 1e-6) throw Error(`Variable "${e.name}" has initialValue (${e.initialValue}) outside its bounds [${t}, ${n}] (tolerance ${ne}).`);
|
|
513
513
|
if (e.type === "Integer" || e.type === "Binary") {
|
|
514
514
|
let r = Math.round(e.initialValue);
|
|
515
|
-
if (Math.abs(e.initialValue - r) > 1e-6 || r < t || r > n) throw Error(`Variable "${e.name}" of type "${e.type}" has non-integral or out-of-domain initialValue: ${e.initialValue} (must be within ${
|
|
515
|
+
if (Math.abs(e.initialValue - r) > 1e-6 || r < t || r > n) throw Error(`Variable "${e.name}" of type "${e.type}" has non-integral or out-of-domain initialValue: ${e.initialValue} (must be within ${ne} of an integer in [${t}, ${n}]).`);
|
|
516
516
|
}
|
|
517
517
|
}
|
|
518
518
|
}
|
|
519
|
-
function
|
|
519
|
+
function j(e, t) {
|
|
520
520
|
if (e) {
|
|
521
521
|
for (let n of e) if (n.type !== "Integer" && n.type !== "Binary") throw Error(`${t} requires Integer or Binary variables, but variable "${n.name}" has type "${n.type}".`);
|
|
522
522
|
}
|
|
523
523
|
}
|
|
524
|
-
function
|
|
524
|
+
function M(e, t, n, r) {
|
|
525
525
|
if (e && e.length !== 0) for (let i of e) {
|
|
526
526
|
if (!Number.isFinite(i.coeff)) throw Error(`Nonlinear expression in ${t} has invalid coefficient: ${i.coeff}. Coefficients must be finite numbers.`);
|
|
527
527
|
let e = i.atom;
|
|
528
|
-
if (e.kind === "abs")
|
|
529
|
-
else if (e.kind === "max" || e.kind === "min") for (let i of e.args)
|
|
528
|
+
if (e.kind === "abs") N(e.arg, t, n, r);
|
|
529
|
+
else if (e.kind === "max" || e.kind === "min") for (let i of e.args) N(i, t, n, r);
|
|
530
530
|
else if (e.kind === "at") {
|
|
531
|
-
|
|
532
|
-
for (let i of e.array)
|
|
531
|
+
j(e.discreteVars, `at() index in ${t}`), N(e.index, t, n, r);
|
|
532
|
+
for (let i of e.array) N(i, t, n, r);
|
|
533
533
|
}
|
|
534
534
|
}
|
|
535
535
|
}
|
|
536
|
-
function
|
|
536
|
+
function N(e, t, n, r, i) {
|
|
537
537
|
if (e.constant !== void 0 && !Number.isFinite(e.constant)) {
|
|
538
538
|
let n = i?.constantPrefix ?? t, r = i?.constantKind ?? "constant";
|
|
539
539
|
throw Error(`${n} has invalid ${r}: ${e.constant}. Constant must be a finite number.`);
|
|
@@ -543,9 +543,9 @@ function P(e, t, n, r, i) {
|
|
|
543
543
|
if (!r(i)) throw Error(`Variable "${i.name}" ${a} does not belong to model "${n}". All variables must belong to the model by object identity.`);
|
|
544
544
|
if (!Number.isFinite(o)) throw Error(`Variable "${i.name}" in ${t} has invalid coefficient: ${o}. Coefficients must be finite numbers.`);
|
|
545
545
|
}
|
|
546
|
-
|
|
546
|
+
M(e.nonlinearTerms, t, n, r);
|
|
547
547
|
}
|
|
548
|
-
function
|
|
548
|
+
function P(e, t, n) {
|
|
549
549
|
if (e instanceof b) {
|
|
550
550
|
if (!Number.isFinite(e.constant)) throw Error(`Objective function has invalid constant: ${e.constant}. Constant must be a finite number.`);
|
|
551
551
|
for (let [r, i] of e.linearTerms) {
|
|
@@ -557,12 +557,12 @@ function F(e, t, n) {
|
|
|
557
557
|
if (!n(r.var2)) throw Error(`Variable "${r.var2.name}" in quadratic objective function does not belong to model "${t}". All variables must belong to the model by object identity.`);
|
|
558
558
|
if (!Number.isFinite(r.coeff) || !Number.isFinite(r.coeff * 2)) throw Error(`Quadratic term (${r.var1.name} * ${r.var2.name}) in objective function has invalid coefficient: ${r.coeff}.`);
|
|
559
559
|
}
|
|
560
|
-
|
|
561
|
-
} else "terms" in e &&
|
|
560
|
+
M(e.nonlinearTerms, "objective function", t, n);
|
|
561
|
+
} else "terms" in e && N(e, "objective function", t, n, { constantPrefix: "Objective function" });
|
|
562
562
|
}
|
|
563
|
-
function
|
|
563
|
+
function F(e, t, n, r = e.name) {
|
|
564
564
|
if (!Number.isFinite(e.rhs)) throw Error(`Constraint "${r}" has invalid right-hand side (RHS): ${e.rhs}. RHS must be a finite number.`);
|
|
565
|
-
if (
|
|
565
|
+
if (j(e._requiredDiscreteVars, `Discrete constraint "${r}"`), N(e.lhs, `constraint "${r}"`, t, n), e.sense === "!=") {
|
|
566
566
|
if (!Number.isSafeInteger(e.rhs)) throw Error(`Discrete "!=" in constraint "${r}" requires a safe integer RHS, received ${e.rhs}.`);
|
|
567
567
|
U(e.lhs, `Discrete "!=" in constraint "${r}"`);
|
|
568
568
|
}
|
|
@@ -572,32 +572,32 @@ function I(e, t, n, r = e.name) {
|
|
|
572
572
|
if (!(i.type === "Binary" || i.type === "Integer" && i.lb === 0 && i.ub === 1)) throw Error(`Indicator variable "${i.name}" in constraint "${r}" has invalid type "${i.type}" or bounds [${i.lb}, ${i.ub}]: expected Binary or Integer [0, 1].`);
|
|
573
573
|
}
|
|
574
574
|
}
|
|
575
|
-
function
|
|
575
|
+
function I(e, t, n, r, o, s) {
|
|
576
576
|
if (e instanceof i) {
|
|
577
577
|
if (!o(e)) throw Error(`Boolean variable "${e.name}" in logical constraint "${t}" does not belong to model "${n}".`);
|
|
578
|
-
} else if (e instanceof a) for (let i of e.children)
|
|
578
|
+
} else if (e instanceof a) for (let i of e.children) I(i, t, n, r, o, s);
|
|
579
579
|
else if (e instanceof d) {
|
|
580
|
-
|
|
580
|
+
j(e.discreteVars, `Global constraint "${t}"`);
|
|
581
581
|
let i = `logical constraint "${t}"`;
|
|
582
582
|
switch (e.spec.kind) {
|
|
583
583
|
case "distinct":
|
|
584
|
-
for (let t of e.spec.args)
|
|
584
|
+
for (let t of e.spec.args) N(t, i, n, r);
|
|
585
585
|
break;
|
|
586
586
|
case "disjoint":
|
|
587
|
-
for (let t of e.spec.tasks)
|
|
587
|
+
for (let t of e.spec.tasks) N(t.start, i, n, r);
|
|
588
588
|
break;
|
|
589
589
|
case "cumulative":
|
|
590
|
-
for (let t of e.spec.tasks)
|
|
590
|
+
for (let t of e.spec.tasks) N(t.start, i, n, r);
|
|
591
591
|
break;
|
|
592
|
-
case "allowed": for (let t of e.spec.vars)
|
|
592
|
+
case "allowed": for (let t of e.spec.vars) N(t, i, n, r);
|
|
593
593
|
}
|
|
594
|
-
} else if (e instanceof
|
|
594
|
+
} else if (e instanceof R) {
|
|
595
595
|
if (s) {
|
|
596
596
|
let r = S.get(e) ?? e.ownerModel ?? void 0;
|
|
597
597
|
if (r && r !== s) throw Error(`Constraint "${e.name}" embedded in logical constraint "${t}" already belongs to model "${r.name ?? "another model"}" and cannot be added to model "${n}".`);
|
|
598
598
|
}
|
|
599
599
|
if (!Number.isFinite(e.rhs)) throw Error(`Constraint "${e.name}" embedded in logical constraint "${t}" has invalid RHS: ${e.rhs}.`);
|
|
600
|
-
if (
|
|
600
|
+
if (j(e._requiredDiscreteVars, `Discrete constraint "${e.name}" embedded in logical constraint "${t}"`), N(e.lhs, `constraint "${e.name}" embedded in logical constraint "${t}"`, n, r, {
|
|
601
601
|
constantPrefix: `Constraint "${e.name}" embedded in logical constraint "${t}"`,
|
|
602
602
|
constantKind: "LHS constant",
|
|
603
603
|
varLocationPhrase: `embedded in logical constraint "${t}"`
|
|
@@ -607,10 +607,10 @@ function L(e, t, n, r, o, s) {
|
|
|
607
607
|
}
|
|
608
608
|
}
|
|
609
609
|
}
|
|
610
|
-
function
|
|
610
|
+
function re(e) {
|
|
611
611
|
let { model: t } = e, n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set();
|
|
612
612
|
for (let i of e.variables) {
|
|
613
|
-
|
|
613
|
+
A(i);
|
|
614
614
|
let a = x.get(i);
|
|
615
615
|
if (a && a !== t || n.has(i.name) || e.getVarByName(i.name) !== i) throw Error(`Variable "${i.name}" is duplicated or not canonically registered in model "${e.name}".`);
|
|
616
616
|
n.add(i.name), r.add(i);
|
|
@@ -636,13 +636,13 @@ function ne(e) {
|
|
|
636
636
|
if (r && r !== t || e.getConstraintByName(n.name) !== n) throw Error(`Constraint "${n.name}" is duplicated or not canonically registered in model "${e.name}".`);
|
|
637
637
|
}
|
|
638
638
|
for (let t of e.logicalConstraints) if (e.getLogicalConstraintByName(t.name) !== t) throw Error(`Logical constraint "${t.name}" is duplicated or not canonically registered in model "${e.name}".`);
|
|
639
|
-
e.objectiveExpr &&
|
|
640
|
-
for (let t of e.constraints)
|
|
641
|
-
for (let n of e.logicalConstraints)
|
|
639
|
+
e.objectiveExpr && P(e.objectiveExpr, e.name, (e) => r.has(e));
|
|
640
|
+
for (let t of e.constraints) F(t, e.name, (e) => r.has(e));
|
|
641
|
+
for (let n of e.logicalConstraints) I(n.expr, n.name, e.name, (e) => r.has(e), (e) => a.has(e), t);
|
|
642
642
|
}
|
|
643
643
|
//#endregion
|
|
644
644
|
//#region src/modeler/constraint.ts
|
|
645
|
-
var
|
|
645
|
+
var L = 0, R = class e {
|
|
646
646
|
kind = "constraint";
|
|
647
647
|
id;
|
|
648
648
|
_lhs;
|
|
@@ -663,7 +663,7 @@ var R = 0, z = class e {
|
|
|
663
663
|
return this._indicatorOrigin = void 0, this._indicatorSnapshot = void 0, this._lhs.setTerm(e, t), E(this.ownerModel), this;
|
|
664
664
|
}
|
|
665
665
|
constructor(e, t, n, r) {
|
|
666
|
-
this.id = ++
|
|
666
|
+
this.id = ++L, this._lhs = e, this._sense = t, this._rhs = n;
|
|
667
667
|
let i = typeof r == "string" ? r.trim() : void 0;
|
|
668
668
|
i && i.length > 0 ? (this._name = i, this.hasExplicitName = !0) : (this._name = `c_${this.id}`, this.hasExplicitName = !1);
|
|
669
669
|
}
|
|
@@ -797,12 +797,12 @@ var R = 0, z = class e {
|
|
|
797
797
|
return `${this.name}: ${this.lhs.toString()} ${e} ${this.rhs}`;
|
|
798
798
|
}
|
|
799
799
|
};
|
|
800
|
-
function
|
|
801
|
-
return e instanceof
|
|
800
|
+
function z(e) {
|
|
801
|
+
return e instanceof R || typeof e == "object" && !!e && "sense" in e && "lhs" in e && "rhs" in e;
|
|
802
802
|
}
|
|
803
803
|
//#endregion
|
|
804
804
|
//#region src/modeler/expression.ts
|
|
805
|
-
function
|
|
805
|
+
function B(e) {
|
|
806
806
|
switch (e.kind) {
|
|
807
807
|
case "abs": return {
|
|
808
808
|
kind: "abs",
|
|
@@ -824,7 +824,7 @@ function V(e) {
|
|
|
824
824
|
};
|
|
825
825
|
}
|
|
826
826
|
}
|
|
827
|
-
function
|
|
827
|
+
function V(e) {
|
|
828
828
|
switch (e.kind) {
|
|
829
829
|
case "abs": return `abs(${e.arg.toString()})`;
|
|
830
830
|
case "max": return `max(${e.args.map((e) => e.toString()).join(", ")})`;
|
|
@@ -832,7 +832,7 @@ function H(e) {
|
|
|
832
832
|
case "at": return `at([${e.array.map((e) => e.toString()).join(", ")}], ${e.index.toString()})`;
|
|
833
833
|
}
|
|
834
834
|
}
|
|
835
|
-
function
|
|
835
|
+
function H(e) {
|
|
836
836
|
switch (e.kind) {
|
|
837
837
|
case "abs": {
|
|
838
838
|
let t = e.arg.value;
|
|
@@ -865,14 +865,14 @@ function re(e) {
|
|
|
865
865
|
}
|
|
866
866
|
}
|
|
867
867
|
function ie(e) {
|
|
868
|
-
return e instanceof K || typeof e == "object" && !!e && !
|
|
868
|
+
return e instanceof K || typeof e == "object" && !!e && !z(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";
|
|
869
869
|
}
|
|
870
870
|
function U(e, t, n = /* @__PURE__ */ new Set()) {
|
|
871
871
|
if (typeof e == "number") {
|
|
872
872
|
if (!Number.isSafeInteger(e)) throw Error(`${t} requires Integer or Binary variables and integer constants/coefficients, but received constant ${e}.`);
|
|
873
873
|
return n;
|
|
874
874
|
}
|
|
875
|
-
if (
|
|
875
|
+
if (z(e)) throw Error(`${t} cannot accept a Constraint comparison.`);
|
|
876
876
|
if (e instanceof b || "quadTerms" in e && e.quadTerms instanceof Map && "linearTerms" in e && e.linearTerms instanceof Map && typeof e.constant == "number") {
|
|
877
877
|
let r = e;
|
|
878
878
|
if (r.quadTerms.size > 0) throw Error(`${t} does not support quadratic expressions.`);
|
|
@@ -910,7 +910,7 @@ function W(e, t) {
|
|
|
910
910
|
if (!Number.isFinite(e)) throw Error(`Invalid non-finite number "${e}" in ${t}.`);
|
|
911
911
|
return new G(/* @__PURE__ */ new Map(), Object.is(e, -0) ? 0 : e);
|
|
912
912
|
}
|
|
913
|
-
if (
|
|
913
|
+
if (z(e)) throw t.startsWith("sum") ? Error(`Cannot sum a constraint comparison (<=, >=, ==, !=, <, >): expected arithmetic expressions in ${t}.`) : Error(`Cannot use a constraint comparison (<=, >=, ==, !=, <, >) in ${t}: expected a finite number, Var, or LinExpr.`);
|
|
914
914
|
if (e instanceof b || typeof e == "object" && e && "quadTerms" in e && e.quadTerms instanceof Map && "linearTerms" in e && e.linearTerms instanceof Map) {
|
|
915
915
|
let n = e;
|
|
916
916
|
if (n.quadTerms.size > 0) throw Error(`Quadratic expressions are not supported in ${t}.`);
|
|
@@ -934,7 +934,7 @@ var G = class e {
|
|
|
934
934
|
nonlinearTerms;
|
|
935
935
|
constructor(e = /* @__PURE__ */ new Map(), t = 0, n = []) {
|
|
936
936
|
this.terms = new Map(e), this.constant = t, this.nonlinearTerms = n.filter((e) => e.coeff !== 0).map((e) => ({
|
|
937
|
-
atom:
|
|
937
|
+
atom: B(e.atom),
|
|
938
938
|
coeff: e.coeff
|
|
939
939
|
}));
|
|
940
940
|
}
|
|
@@ -952,7 +952,7 @@ var G = class e {
|
|
|
952
952
|
return new e(this.terms, this.constant, this.nonlinearTerms);
|
|
953
953
|
}
|
|
954
954
|
add(e) {
|
|
955
|
-
if (
|
|
955
|
+
if (z(e)) throw Error("Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.");
|
|
956
956
|
if (e instanceof b) return e.add(this);
|
|
957
957
|
let t = this.clone();
|
|
958
958
|
if (typeof e == "number") t.constant += e;
|
|
@@ -962,7 +962,7 @@ var G = class e {
|
|
|
962
962
|
e === 0 ? t.terms.delete(n) : t.terms.set(n, e);
|
|
963
963
|
}
|
|
964
964
|
if (t.constant += e.constant, Array.isArray(e.nonlinearTerms)) for (let n of e.nonlinearTerms) n.coeff !== 0 && t.nonlinearTerms.push({
|
|
965
|
-
atom:
|
|
965
|
+
atom: B(n.atom),
|
|
966
966
|
coeff: n.coeff
|
|
967
967
|
});
|
|
968
968
|
} else {
|
|
@@ -972,11 +972,11 @@ var G = class e {
|
|
|
972
972
|
return t;
|
|
973
973
|
}
|
|
974
974
|
sub(e) {
|
|
975
|
-
if (
|
|
975
|
+
if (z(e)) throw Error("Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.");
|
|
976
976
|
return e instanceof b ? e.neg().add(this) : typeof e == "number" ? this.add(-e) : this.add(e.mul(-1));
|
|
977
977
|
}
|
|
978
978
|
mul(t) {
|
|
979
|
-
if (
|
|
979
|
+
if (z(t)) throw Error("Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.");
|
|
980
980
|
if (typeof t == "number") {
|
|
981
981
|
let n = this.terms.size > 0 || this.nonlinearTerms.length > 0, r = this.constant === 0 && n ? 0 : this.constant * t;
|
|
982
982
|
if (this.constant !== 0 && t !== 0 && r === 0) throw Error("Constant multiplication underflows to zero.");
|
|
@@ -990,7 +990,7 @@ var G = class e {
|
|
|
990
990
|
let n = e.coeff * t;
|
|
991
991
|
if (e.coeff !== 0 && n === 0) throw Error("Coefficient multiplication underflows to zero.");
|
|
992
992
|
n !== 0 && i.nonlinearTerms.push({
|
|
993
|
-
atom:
|
|
993
|
+
atom: B(e.atom),
|
|
994
994
|
coeff: n
|
|
995
995
|
});
|
|
996
996
|
}
|
|
@@ -1037,7 +1037,7 @@ var G = class e {
|
|
|
1037
1037
|
e += n * t.value;
|
|
1038
1038
|
}
|
|
1039
1039
|
for (let t of this.nonlinearTerms) {
|
|
1040
|
-
let n =
|
|
1040
|
+
let n = H(t.atom);
|
|
1041
1041
|
if (n === null) return null;
|
|
1042
1042
|
e += t.coeff * n;
|
|
1043
1043
|
}
|
|
@@ -1062,7 +1062,7 @@ var G = class e {
|
|
|
1062
1062
|
return this.toDiscreteComparison("!=", e, t);
|
|
1063
1063
|
}
|
|
1064
1064
|
toDiscreteComparison(e, t, n) {
|
|
1065
|
-
if (t instanceof
|
|
1065
|
+
if (t instanceof R || typeof t == "object" && t && "sense" in t && "lhs" in t) throw Error(`Cannot compare against a Constraint in (${e}): expected a finite integer, discrete Var, or discrete LinExpr.`);
|
|
1066
1066
|
let r = `discrete ${e}`, i = /* @__PURE__ */ new Set();
|
|
1067
1067
|
U(this, r, i), U(t, r, i);
|
|
1068
1068
|
let a = this.toConstraint(e === "<" ? "<=" : e === ">" ? ">=" : "!=", t, n);
|
|
@@ -1080,14 +1080,14 @@ var G = class e {
|
|
|
1080
1080
|
toConstraint(t, n, r) {
|
|
1081
1081
|
let i = this.clone(), a = 0;
|
|
1082
1082
|
if (typeof n == "number") a = n;
|
|
1083
|
-
else if (n instanceof
|
|
1083
|
+
else if (n instanceof R || typeof n == "object" && n && "sense" in n && "lhs" in n) throw Error(`Cannot compare against a Constraint in (${t}): expected a number, Var, or LinExpr.`);
|
|
1084
1084
|
else if (n instanceof b || typeof n == "object" && n && "quadTerms" in n) {
|
|
1085
1085
|
let r = n;
|
|
1086
1086
|
if (r.quadTerms.size > 0) throw Error(`Quadratic expressions are not supported in linear constraints (${t}): quadratic terms are only allowed in objectives.`);
|
|
1087
1087
|
i = i.sub(new e(r.linearTerms, 0, r.nonlinearTerms ?? [])), a = r.constant;
|
|
1088
1088
|
} else "terms" in n ? (i = i.sub(new e(n.terms, 0, n.nonlinearTerms ?? [])), a = n.constant) : i = i.sub(n);
|
|
1089
1089
|
let o = a - i.constant;
|
|
1090
|
-
return i.constant = 0, new
|
|
1090
|
+
return i.constant = 0, new R(i, t, o, r);
|
|
1091
1091
|
}
|
|
1092
1092
|
and(e) {
|
|
1093
1093
|
throw Error("Cannot use an arithmetic expression without a comparison operator (<=, >=, ==, !=, <, >) in logical 'and': expected a BoolVar, Constraint, or BoolOp.");
|
|
@@ -1112,7 +1112,7 @@ var G = class e {
|
|
|
1112
1112
|
}
|
|
1113
1113
|
for (let n of this.nonlinearTerms) {
|
|
1114
1114
|
let r = n.coeff, i = r >= 0 ? t ? "" : "+ " : "- ", a = Math.abs(r), o = a === 1 ? "" : `${a} `;
|
|
1115
|
-
e.push(`${i}${o}${
|
|
1115
|
+
e.push(`${i}${o}${V(n.atom)}`), t = !1;
|
|
1116
1116
|
}
|
|
1117
1117
|
if (this.constant !== 0 || e.length === 0) {
|
|
1118
1118
|
let n = this.constant >= 0 ? t ? "" : "+ " : "- ";
|
|
@@ -1124,7 +1124,7 @@ var G = class e {
|
|
|
1124
1124
|
function ae(e, t) {
|
|
1125
1125
|
let n = /* @__PURE__ */ new Map(), r = [], i = 0;
|
|
1126
1126
|
function a(e) {
|
|
1127
|
-
return e instanceof
|
|
1127
|
+
return e instanceof R || e.kind === "constraint" || "sense" in e && (e.sense === "<=" || 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;
|
|
1128
1128
|
}
|
|
1129
1129
|
function o(e) {
|
|
1130
1130
|
return e instanceof b || "quadTerms" in e && e.quadTerms instanceof Map && "linearTerms" in e && e.linearTerms instanceof Map && typeof e.constant == "number";
|
|
@@ -1166,7 +1166,7 @@ function ae(e, t) {
|
|
|
1166
1166
|
if (i = a, Array.isArray(t.nonlinearTerms)) for (let e of t.nonlinearTerms) {
|
|
1167
1167
|
if (!Number.isFinite(e.coeff)) throw Error(`Invalid non-finite coefficient "${e.coeff}" in sum().`);
|
|
1168
1168
|
e.coeff !== 0 && r.push({
|
|
1169
|
-
atom:
|
|
1169
|
+
atom: B(e.atom),
|
|
1170
1170
|
coeff: e.coeff
|
|
1171
1171
|
});
|
|
1172
1172
|
}
|
|
@@ -1184,7 +1184,7 @@ function ae(e, t) {
|
|
|
1184
1184
|
if (i = a, Array.isArray(t.nonlinearTerms)) for (let e of t.nonlinearTerms) {
|
|
1185
1185
|
if (!Number.isFinite(e.coeff)) throw Error(`Invalid non-finite coefficient "${e.coeff}" in sum().`);
|
|
1186
1186
|
e.coeff !== 0 && r.push({
|
|
1187
|
-
atom:
|
|
1187
|
+
atom: B(e.atom),
|
|
1188
1188
|
coeff: e.coeff
|
|
1189
1189
|
});
|
|
1190
1190
|
}
|
|
@@ -1243,7 +1243,7 @@ function ae(e, t) {
|
|
|
1243
1243
|
function oe(e, t) {
|
|
1244
1244
|
let n = /* @__PURE__ */ new Map(), r = [], i = 0;
|
|
1245
1245
|
function a(e) {
|
|
1246
|
-
return typeof e == "object" && !!e && !(e instanceof
|
|
1246
|
+
return typeof e == "object" && !!e && !(e instanceof R) && typeof e.id == "number" && typeof e.name == "string" && typeof e.lb == "number" && typeof e.ub == "number" && typeof e.type == "string" && typeof e.mul == "function" && typeof e.le == "function";
|
|
1247
1247
|
}
|
|
1248
1248
|
function o(e) {
|
|
1249
1249
|
return a(e) || e instanceof G || e instanceof b;
|
|
@@ -1274,7 +1274,7 @@ function oe(e, t) {
|
|
|
1274
1274
|
if (n.coeff !== 0 && t === 0) throw Error("Coefficient multiplication underflows to zero.");
|
|
1275
1275
|
if (!Number.isFinite(t)) throw Error(`Coefficient multiplication overflows finite floating-point range in dot() at '${o || "root"}'.`);
|
|
1276
1276
|
t !== 0 && r.push({
|
|
1277
|
-
atom:
|
|
1277
|
+
atom: B(n.atom),
|
|
1278
1278
|
coeff: t
|
|
1279
1279
|
});
|
|
1280
1280
|
}
|
|
@@ -1285,7 +1285,7 @@ function oe(e, t) {
|
|
|
1285
1285
|
} else throw Error(`Cannot multiply number by non-variable/expression operand in dot() at '${o || "root"}'.`);
|
|
1286
1286
|
}
|
|
1287
1287
|
function c(e) {
|
|
1288
|
-
return typeof e == "object" && !!e && !Array.isArray(e) && !o(e) && !(e instanceof
|
|
1288
|
+
return typeof e == "object" && !!e && !Array.isArray(e) && !o(e) && !(e instanceof R) && e.kind !== "constraint";
|
|
1289
1289
|
}
|
|
1290
1290
|
function l(e, t, n = "") {
|
|
1291
1291
|
if (e === void 0 || t === void 0 || e === null || t === null) throw Error(`Nullish or undefined operand encountered in dot() at '${n || "root"}'.`);
|
|
@@ -1347,7 +1347,7 @@ function se(e) {
|
|
|
1347
1347
|
}
|
|
1348
1348
|
function ce(e, t) {
|
|
1349
1349
|
if (t.length === 0) throw Error(`${e}() requires at least one expression.`);
|
|
1350
|
-
let n = [], r = (e) => typeof e == "number" ||
|
|
1350
|
+
let n = [], r = (e) => typeof e == "number" || z(e) || ie(e) || e instanceof G || e instanceof b || typeof e == "object" && !!e && ("terms" in e && e.terms instanceof Map || "quadTerms" in e && e.quadTerms instanceof Map), i = (e) => {
|
|
1351
1351
|
if (typeof e != "object" || !e || Array.isArray(e) || r(e)) return !1;
|
|
1352
1352
|
let t = Object.getPrototypeOf(e);
|
|
1353
1353
|
return t === Object.prototype || t === null;
|
|
@@ -1471,7 +1471,7 @@ var K = class {
|
|
|
1471
1471
|
constructor(e = {}) {
|
|
1472
1472
|
this.id = ++pe;
|
|
1473
1473
|
let t = typeof e.name == "string" ? e.name.trim() : "", n = typeof e.prefix == "string" ? e.prefix.trim() : "";
|
|
1474
|
-
this.prefix = n.length > 0 ? n : "x", this.hasExplicitName = t.length > 0, this._name = this.hasExplicitName ? t : `${this.prefix}_${this.id}`, this._type = me(e.type), 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), this._initialValue = e.initialValue === void 0 ? void 0 : Object.is(e.initialValue, -0) ? 0 : e.initialValue, this._initialValue !== void 0 &&
|
|
1474
|
+
this.prefix = n.length > 0 ? n : "x", this.hasExplicitName = t.length > 0, this._name = this.hasExplicitName ? t : `${this.prefix}_${this.id}`, this._type = me(e.type), 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), this._initialValue = e.initialValue === void 0 ? void 0 : Object.is(e.initialValue, -0) ? 0 : e.initialValue, this._initialValue !== void 0 && A(this);
|
|
1475
1475
|
}
|
|
1476
1476
|
get name() {
|
|
1477
1477
|
return this._name;
|
|
@@ -2059,7 +2059,7 @@ var De = class {
|
|
|
2059
2059
|
});
|
|
2060
2060
|
}
|
|
2061
2061
|
if (Array.isArray(a.nonlinearTerms)) for (let e of a.nonlinearTerms) e.coeff !== 0 && r.push({
|
|
2062
|
-
atom:
|
|
2062
|
+
atom: B(e.atom),
|
|
2063
2063
|
coeff: e.coeff
|
|
2064
2064
|
});
|
|
2065
2065
|
return;
|
|
@@ -2076,7 +2076,7 @@ var De = class {
|
|
|
2076
2076
|
t.set(e, n);
|
|
2077
2077
|
}
|
|
2078
2078
|
if (Array.isArray(n.nonlinearTerms)) for (let e of n.nonlinearTerms) e.coeff !== 0 && r.push({
|
|
2079
|
-
atom:
|
|
2079
|
+
atom: B(e.atom),
|
|
2080
2080
|
coeff: e.coeff
|
|
2081
2081
|
});
|
|
2082
2082
|
return;
|
|
@@ -2280,7 +2280,7 @@ function Z(e) {
|
|
|
2280
2280
|
}
|
|
2281
2281
|
}
|
|
2282
2282
|
function Pe(e) {
|
|
2283
|
-
return e instanceof
|
|
2283
|
+
return e instanceof R ? !0 : typeof e != "object" || !e ? !1 : e.kind === "constraint" || "sense" in e && (e.sense === "<=" || 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;
|
|
2284
2284
|
}
|
|
2285
2285
|
function Fe(e, t) {
|
|
2286
2286
|
let n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), o = e.join(""), s = "__washi_";
|
|
@@ -2568,7 +2568,7 @@ function Qe(e, t = {}) {
|
|
|
2568
2568
|
}, _ = [], v = [];
|
|
2569
2569
|
for (let t of e.variables.values()) t.type === "Boolean" ? v.push(t) : _.push(t);
|
|
2570
2570
|
let y = [], x = [];
|
|
2571
|
-
for (let t of e.constraints.values()) t instanceof
|
|
2571
|
+
for (let t of e.constraints.values()) t instanceof R ? y.push(t) : x.push(t);
|
|
2572
2572
|
let S = /* @__PURE__ */ new Map(), C = /* @__PURE__ */ new Map(), w = 0, T = 0, E = 0, D = 0;
|
|
2573
2573
|
for (let e of _) {
|
|
2574
2574
|
let t = s ? Object.prototype.hasOwnProperty.call(c, e.name) ? c[e.name] : void 0 : e.value;
|
|
@@ -2845,9 +2845,9 @@ function Qe(e, t = {}) {
|
|
|
2845
2845
|
ok: !0,
|
|
2846
2846
|
errors: t
|
|
2847
2847
|
};
|
|
2848
|
-
},
|
|
2848
|
+
}, ne = (e) => {
|
|
2849
2849
|
if (e instanceof i) return { ok: !0 };
|
|
2850
|
-
if (e instanceof
|
|
2850
|
+
if (e instanceof R) {
|
|
2851
2851
|
let t = k(e.lhs);
|
|
2852
2852
|
return t.ok ? {
|
|
2853
2853
|
ok: !0,
|
|
@@ -2869,7 +2869,7 @@ function Qe(e, t = {}) {
|
|
|
2869
2869
|
if (e instanceof a) {
|
|
2870
2870
|
let t;
|
|
2871
2871
|
for (let n of e.children) {
|
|
2872
|
-
let e =
|
|
2872
|
+
let e = ne(n);
|
|
2873
2873
|
if (!e.ok) return e;
|
|
2874
2874
|
!t && e.firstError && (t = e.firstError);
|
|
2875
2875
|
}
|
|
@@ -2879,7 +2879,7 @@ function Qe(e, t = {}) {
|
|
|
2879
2879
|
};
|
|
2880
2880
|
}
|
|
2881
2881
|
return { ok: !0 };
|
|
2882
|
-
},
|
|
2882
|
+
}, A = (e, t = n) => {
|
|
2883
2883
|
if (typeof e.rhs != "number" || !Number.isFinite(e.rhs)) return {
|
|
2884
2884
|
status: "unchecked",
|
|
2885
2885
|
reason: `non-finite right-hand side (${String(e.rhs)})`
|
|
@@ -2922,9 +2922,9 @@ function Qe(e, t = {}) {
|
|
|
2922
2922
|
signed: o,
|
|
2923
2923
|
violation: s
|
|
2924
2924
|
};
|
|
2925
|
-
},
|
|
2926
|
-
if ((
|
|
2927
|
-
let e = k(new G(/* @__PURE__ */ new Map(), 0,
|
|
2925
|
+
}, j = e.objective();
|
|
2926
|
+
if ((j instanceof b || j instanceof G) && j.nonlinearTerms.length > 0) {
|
|
2927
|
+
let e = k(new G(/* @__PURE__ */ new Map(), 0, j.nonlinearTerms));
|
|
2928
2928
|
if (e.ok) for (let t of e.errors) g({
|
|
2929
2929
|
type: "linear_constraint",
|
|
2930
2930
|
target: "constraint",
|
|
@@ -2934,7 +2934,7 @@ function Qe(e, t = {}) {
|
|
|
2934
2934
|
});
|
|
2935
2935
|
}
|
|
2936
2936
|
for (let e of y) {
|
|
2937
|
-
let t =
|
|
2937
|
+
let t = A(e);
|
|
2938
2938
|
t.status === "unchecked" ? (f.push(e.name), g({
|
|
2939
2939
|
type: "unchecked_constraint",
|
|
2940
2940
|
target: "constraint",
|
|
@@ -2957,7 +2957,7 @@ function Qe(e, t = {}) {
|
|
|
2957
2957
|
message: t.message
|
|
2958
2958
|
})) : (E++, h(t.violation));
|
|
2959
2959
|
}
|
|
2960
|
-
let
|
|
2960
|
+
let M = (e) => {
|
|
2961
2961
|
if (e instanceof i) return C.has(e) ? {
|
|
2962
2962
|
ok: !0,
|
|
2963
2963
|
value: C.get(e),
|
|
@@ -2966,7 +2966,7 @@ function Qe(e, t = {}) {
|
|
|
2966
2966
|
ok: !1,
|
|
2967
2967
|
reason: `missing or invalid value for Boolean variable "${e.name}"`
|
|
2968
2968
|
};
|
|
2969
|
-
if (e instanceof
|
|
2969
|
+
if (e instanceof R) {
|
|
2970
2970
|
if (e.sense === "!=") {
|
|
2971
2971
|
let t = O(e.lhs);
|
|
2972
2972
|
if (!t.ok) return {
|
|
@@ -2991,7 +2991,7 @@ function Qe(e, t = {}) {
|
|
|
2991
2991
|
reason: `discrete comparison "${e.name}" lies between 0 and 1 (${t.value} != ${e.rhs})`
|
|
2992
2992
|
};
|
|
2993
2993
|
}
|
|
2994
|
-
let t =
|
|
2994
|
+
let t = A(e, 0);
|
|
2995
2995
|
if (t.status === "unchecked") return {
|
|
2996
2996
|
ok: !1,
|
|
2997
2997
|
reason: t.reason
|
|
@@ -3130,7 +3130,7 @@ function Qe(e, t = {}) {
|
|
|
3130
3130
|
}
|
|
3131
3131
|
if (e instanceof a) switch (e.op) {
|
|
3132
3132
|
case "not": {
|
|
3133
|
-
let t =
|
|
3133
|
+
let t = M(e.children[0]);
|
|
3134
3134
|
return t.ok ? {
|
|
3135
3135
|
ok: !0,
|
|
3136
3136
|
value: !t.value,
|
|
@@ -3140,7 +3140,7 @@ function Qe(e, t = {}) {
|
|
|
3140
3140
|
case "and": {
|
|
3141
3141
|
let t = 0;
|
|
3142
3142
|
for (let n of e.children) {
|
|
3143
|
-
let e =
|
|
3143
|
+
let e = M(n);
|
|
3144
3144
|
if (!e.ok) return e;
|
|
3145
3145
|
if (!e.value) return {
|
|
3146
3146
|
ok: !0,
|
|
@@ -3158,7 +3158,7 @@ function Qe(e, t = {}) {
|
|
|
3158
3158
|
case "or": {
|
|
3159
3159
|
let t = !1, n = Infinity;
|
|
3160
3160
|
for (let r of e.children) {
|
|
3161
|
-
let e =
|
|
3161
|
+
let e = M(r);
|
|
3162
3162
|
if (!e.ok) return e;
|
|
3163
3163
|
e.value && (t = !0, e.violation < n && (n = e.violation));
|
|
3164
3164
|
}
|
|
@@ -3169,14 +3169,14 @@ function Qe(e, t = {}) {
|
|
|
3169
3169
|
};
|
|
3170
3170
|
}
|
|
3171
3171
|
case "implies": {
|
|
3172
|
-
let t =
|
|
3172
|
+
let t = M(e.children[0]);
|
|
3173
3173
|
if (!t.ok) return t;
|
|
3174
3174
|
if (!t.value) return {
|
|
3175
3175
|
ok: !0,
|
|
3176
3176
|
value: !0,
|
|
3177
3177
|
violation: 0
|
|
3178
3178
|
};
|
|
3179
|
-
let n =
|
|
3179
|
+
let n = M(e.children[1]);
|
|
3180
3180
|
return n.ok ? {
|
|
3181
3181
|
ok: !0,
|
|
3182
3182
|
value: n.value,
|
|
@@ -3186,7 +3186,7 @@ function Qe(e, t = {}) {
|
|
|
3186
3186
|
case "xor": {
|
|
3187
3187
|
let t = !1, n = 0;
|
|
3188
3188
|
for (let r of e.children) {
|
|
3189
|
-
let e =
|
|
3189
|
+
let e = M(r);
|
|
3190
3190
|
if (!e.ok) return e;
|
|
3191
3191
|
e.value && (t = !t, e.violation > n && (n = e.violation));
|
|
3192
3192
|
}
|
|
@@ -3218,7 +3218,7 @@ function Qe(e, t = {}) {
|
|
|
3218
3218
|
});
|
|
3219
3219
|
continue;
|
|
3220
3220
|
}
|
|
3221
|
-
let r =
|
|
3221
|
+
let r = ne(t.expr);
|
|
3222
3222
|
if (!r.ok) {
|
|
3223
3223
|
f.push(n), g({
|
|
3224
3224
|
type: "unchecked_constraint",
|
|
@@ -3242,7 +3242,7 @@ function Qe(e, t = {}) {
|
|
|
3242
3242
|
});
|
|
3243
3243
|
continue;
|
|
3244
3244
|
}
|
|
3245
|
-
let i =
|
|
3245
|
+
let i = M(t.expr);
|
|
3246
3246
|
if (!i.ok) {
|
|
3247
3247
|
f.push(n), g({
|
|
3248
3248
|
type: "unchecked_constraint",
|
|
@@ -3264,10 +3264,10 @@ function Qe(e, t = {}) {
|
|
|
3264
3264
|
message: `Logical constraint "${n}" evaluated to false.`
|
|
3265
3265
|
});
|
|
3266
3266
|
}
|
|
3267
|
-
let
|
|
3267
|
+
let N = w === _.length && T === v.length && E === y.length && D === x.length && f.length === 0 && p.length === 0;
|
|
3268
3268
|
return {
|
|
3269
|
-
valid:
|
|
3270
|
-
complete:
|
|
3269
|
+
valid: N && l.length === 0,
|
|
3270
|
+
complete: N,
|
|
3271
3271
|
violations: l,
|
|
3272
3272
|
violationsByName: u,
|
|
3273
3273
|
uncheckedConstraints: f,
|
|
@@ -3387,7 +3387,7 @@ function st(t, n, r, o, s) {
|
|
|
3387
3387
|
if (p.has(t.name)) {
|
|
3388
3388
|
let n = 1;
|
|
3389
3389
|
for (; p.has(`${e.name}_${n}`);) n++;
|
|
3390
|
-
t = new
|
|
3390
|
+
t = new R(e.lhs, e.sense, e.rhs, `${e.name}_${n}`);
|
|
3391
3391
|
}
|
|
3392
3392
|
p.add(t.name), l.push(t), f.set(t, e.name);
|
|
3393
3393
|
}
|
|
@@ -3404,7 +3404,7 @@ function st(t, n, r, o, s) {
|
|
|
3404
3404
|
if (p.has(r)) {
|
|
3405
3405
|
let t = 1;
|
|
3406
3406
|
for (; p.has(`${n}_${t}`);) t++;
|
|
3407
|
-
r = `${n}_${t}`, e = new
|
|
3407
|
+
r = `${n}_${t}`, e = new R(e.lhs, e.sense, e.rhs, r);
|
|
3408
3408
|
}
|
|
3409
3409
|
p.add(r), l.push(e), f.set(e, t);
|
|
3410
3410
|
}
|
|
@@ -3469,7 +3469,7 @@ function st(t, n, r, o, s) {
|
|
|
3469
3469
|
});
|
|
3470
3470
|
c.push(s, l);
|
|
3471
3471
|
let u = Q([[s, 1]], 0);
|
|
3472
|
-
return
|
|
3472
|
+
return z(new R(n.sub(u), "<=", 0, `${t}_abs_pos`), t), z(new R(n.mul(-1).sub(u), "<=", 0, `${t}_abs_neg`), t), z(new R(u.sub(n).add(Q([[l, 2 * -r]], 0)), "<=", 2 * -r, `${t}_abs_hi_pos`), t), z(new R(u.add(n).sub(Q([[l, 2 * i]], 0)), "<=", 0, `${t}_abs_hi_neg`), t), u;
|
|
3473
3473
|
}
|
|
3474
3474
|
case "max": {
|
|
3475
3475
|
let n = e.args.map((e) => x(e, t));
|
|
@@ -3489,11 +3489,11 @@ function st(t, n, r, o, s) {
|
|
|
3489
3489
|
lb: 0,
|
|
3490
3490
|
ub: 1
|
|
3491
3491
|
});
|
|
3492
|
-
c.push(i), u.push(i),
|
|
3492
|
+
c.push(i), u.push(i), z(new R(n[e].sub(l), "<=", 0, `${t}_max_lb_${e}`), t);
|
|
3493
3493
|
let o = a - r[e].lb;
|
|
3494
|
-
|
|
3494
|
+
z(new R(l.sub(n[e]).add(Q([[i, o]], 0)), "<=", o, `${t}_max_ub_${e}`), t);
|
|
3495
3495
|
}
|
|
3496
|
-
return v(new
|
|
3496
|
+
return v(new R(Q(u.map((e) => [e, 1]), 0), "==", 1, `${t}_max_sos`), t), l;
|
|
3497
3497
|
}
|
|
3498
3498
|
case "min": {
|
|
3499
3499
|
let n = e.args.map((e) => x(e, t));
|
|
@@ -3513,11 +3513,11 @@ function st(t, n, r, o, s) {
|
|
|
3513
3513
|
lb: 0,
|
|
3514
3514
|
ub: 1
|
|
3515
3515
|
});
|
|
3516
|
-
c.push(a), u.push(a),
|
|
3516
|
+
c.push(a), u.push(a), z(new R(n[e].sub(l), ">=", 0, `${t}_min_ub_${e}`), t);
|
|
3517
3517
|
let o = r[e].ub - i;
|
|
3518
|
-
|
|
3518
|
+
z(new R(n[e].sub(l).add(Q([[a, o]], 0)), "<=", o, `${t}_min_lb_${e}`), t);
|
|
3519
3519
|
}
|
|
3520
|
-
return v(new
|
|
3520
|
+
return v(new R(Q(u.map((e) => [e, 1]), 0), "==", 1, `${t}_min_sos`), t), l;
|
|
3521
3521
|
}
|
|
3522
3522
|
case "at": {
|
|
3523
3523
|
let n = e.array.length, r = x(e.index, t), i = e.array.map((e) => x(e, t)), a = [];
|
|
@@ -3530,10 +3530,10 @@ function st(t, n, r, o, s) {
|
|
|
3530
3530
|
});
|
|
3531
3531
|
c.push(t), a.push(t);
|
|
3532
3532
|
}
|
|
3533
|
-
v(new
|
|
3533
|
+
v(new R(Q(a.map((e) => [e, 1]), 0), "==", 1, `${t}_at_sos`), t);
|
|
3534
3534
|
let o = r.clone();
|
|
3535
3535
|
for (let e = 1; e < n; e++) o.addTerm(a[e], -e);
|
|
3536
|
-
|
|
3536
|
+
z(new R(o, "==", 0, `${t}_at_idx`), t);
|
|
3537
3537
|
let s = new G(/* @__PURE__ */ new Map(), 0);
|
|
3538
3538
|
for (let e = 0; e < n; e++) {
|
|
3539
3539
|
let n = i[e];
|
|
@@ -3547,7 +3547,7 @@ function st(t, n, r, o, s) {
|
|
|
3547
3547
|
});
|
|
3548
3548
|
c.push(l);
|
|
3549
3549
|
let u = Q([[l, 1]], 0);
|
|
3550
|
-
|
|
3550
|
+
z(new R(Q([[l, 1], [a[e], -r]], 0), ">=", 0, `${t}_at_mc1_${e}`), t), z(new R(Q([[l, 1], [a[e], -i]], 0), "<=", 0, `${t}_at_mc2_${e}`), t), z(new R(u.sub(n).add(Q([[a[e], -i]], 0)), ">=", -i, `${t}_at_mc3_${e}`), t), z(new R(u.sub(n).add(Q([[a[e], -r]], 0)), "<=", -r, `${t}_at_mc4_${e}`), t), s.addTerm(l, 1);
|
|
3551
3551
|
}
|
|
3552
3552
|
}
|
|
3553
3553
|
return s;
|
|
@@ -3576,7 +3576,7 @@ function st(t, n, r, o, s) {
|
|
|
3576
3576
|
});
|
|
3577
3577
|
c.push(r);
|
|
3578
3578
|
let i = Q([[r, 1]], 0);
|
|
3579
|
-
return
|
|
3579
|
+
return z(new R(t.sub(i), "<=", 0, `${n}_epi_abs_pos`), n), z(new R(t.mul(-1).sub(i), "<=", 0, `${n}_epi_abs_neg`), n), i;
|
|
3580
3580
|
}
|
|
3581
3581
|
if (t === "lower" && e.kind === "min") {
|
|
3582
3582
|
let t = new K({
|
|
@@ -3606,13 +3606,13 @@ function st(t, n, r, o, s) {
|
|
|
3606
3606
|
function T(e, t, n, r, i) {
|
|
3607
3607
|
let a = w(e, t, i);
|
|
3608
3608
|
if (t === "!=") {
|
|
3609
|
-
|
|
3609
|
+
B(new R(a, "==", n, r), i);
|
|
3610
3610
|
return;
|
|
3611
3611
|
}
|
|
3612
|
-
|
|
3612
|
+
z(new R(a, t, n, r), i);
|
|
3613
3613
|
}
|
|
3614
3614
|
function E(e, t) {
|
|
3615
|
-
return e.lhs.hasNonlinearTerms() ? new
|
|
3615
|
+
return e.lhs.hasNonlinearTerms() ? new R(x(e.lhs, t), e.sense, e.rhs, e.name) : e;
|
|
3616
3616
|
}
|
|
3617
3617
|
function D(e, t) {
|
|
3618
3618
|
if (e instanceof i) {
|
|
@@ -3629,19 +3629,19 @@ function st(t, n, r, o, s) {
|
|
|
3629
3629
|
return c.push(n), O(n, e, t), n;
|
|
3630
3630
|
}
|
|
3631
3631
|
function ee(e, t, n, r) {
|
|
3632
|
-
v(new
|
|
3632
|
+
v(new R(Q([
|
|
3633
3633
|
[e, 1],
|
|
3634
3634
|
[t, -1],
|
|
3635
3635
|
[n, -1]
|
|
3636
|
-
], 0), "<=", 0, `${r}_xor_1`), r), v(new
|
|
3636
|
+
], 0), "<=", 0, `${r}_xor_1`), r), v(new R(Q([
|
|
3637
3637
|
[e, 1],
|
|
3638
3638
|
[t, -1],
|
|
3639
3639
|
[n, 1]
|
|
3640
|
-
], 0), ">=", 0, `${r}_xor_2`), r), v(new
|
|
3640
|
+
], 0), ">=", 0, `${r}_xor_2`), r), v(new R(Q([
|
|
3641
3641
|
[e, 1],
|
|
3642
3642
|
[n, -1],
|
|
3643
3643
|
[t, 1]
|
|
3644
|
-
], 0), ">=", 0, `${r}_xor_3`), r), v(new
|
|
3644
|
+
], 0), ">=", 0, `${r}_xor_3`), r), v(new R(Q([
|
|
3645
3645
|
[e, 1],
|
|
3646
3646
|
[t, 1],
|
|
3647
3647
|
[n, 1]
|
|
@@ -3650,39 +3650,39 @@ function st(t, n, r, o, s) {
|
|
|
3650
3650
|
function O(e, t, n) {
|
|
3651
3651
|
if (t instanceof i) {
|
|
3652
3652
|
let r = u.get(t);
|
|
3653
|
-
v(new
|
|
3653
|
+
v(new R(Q([[e, 1], [r, -1]], 0), "==", 0, `${n}_equiv`), n);
|
|
3654
3654
|
return;
|
|
3655
3655
|
}
|
|
3656
|
-
if (t instanceof
|
|
3656
|
+
if (t instanceof R) {
|
|
3657
3657
|
let r = E(t, n);
|
|
3658
|
-
|
|
3658
|
+
V(e, r, 0, `${n}_c_neg`, n), re(e, r, 1, `${n}_c_pos`, n);
|
|
3659
3659
|
return;
|
|
3660
3660
|
}
|
|
3661
3661
|
if (t instanceof d) {
|
|
3662
|
-
|
|
3662
|
+
A(e, t, n);
|
|
3663
3663
|
return;
|
|
3664
3664
|
}
|
|
3665
3665
|
if (t instanceof a) {
|
|
3666
3666
|
if (t.op === "not") {
|
|
3667
3667
|
let r = D(t.children[0], n);
|
|
3668
|
-
v(new
|
|
3668
|
+
v(new R(Q([[e, 1], [r, 1]], 0), "==", 1, `${n}_not`), n);
|
|
3669
3669
|
return;
|
|
3670
3670
|
}
|
|
3671
3671
|
if (t.op === "and") {
|
|
3672
3672
|
let r = t.children.map((e) => D(e, n));
|
|
3673
|
-
for (let t = 0; t < r.length; t++) v(new
|
|
3674
|
-
v(new
|
|
3673
|
+
for (let t = 0; t < r.length; t++) v(new R(Q([[e, 1], [r[t], -1]], 0), "<=", 0, `${n}_and_ub_${t}`), n);
|
|
3674
|
+
v(new R(Q([[e, 1], ...r.map((e) => [e, -1])], 0), ">=", 1 - r.length, `${n}_and_lb`), n);
|
|
3675
3675
|
return;
|
|
3676
3676
|
}
|
|
3677
3677
|
if (t.op === "or") {
|
|
3678
3678
|
let r = t.children.map((e) => D(e, n));
|
|
3679
|
-
for (let t = 0; t < r.length; t++) v(new
|
|
3680
|
-
v(new
|
|
3679
|
+
for (let t = 0; t < r.length; t++) v(new R(Q([[e, 1], [r[t], -1]], 0), ">=", 0, `${n}_or_lb_${t}`), n);
|
|
3680
|
+
v(new R(Q([[e, 1], ...r.map((e) => [e, -1])], 0), "<=", 0, `${n}_or_ub`), n);
|
|
3681
3681
|
return;
|
|
3682
3682
|
}
|
|
3683
3683
|
if (t.op === "implies") {
|
|
3684
3684
|
let r = D(t.children[0], n), i = D(t.children[1], n);
|
|
3685
|
-
v(new
|
|
3685
|
+
v(new R(Q([[e, 1], [r, 1]], 0), ">=", 1, `${n}_imp_1`), n), v(new R(Q([[e, 1], [i, -1]], 0), ">=", 0, `${n}_imp_2`), n), v(new R(Q([
|
|
3686
3686
|
[e, 1],
|
|
3687
3687
|
[r, 1],
|
|
3688
3688
|
[i, -1]
|
|
@@ -3691,12 +3691,12 @@ function st(t, n, r, o, s) {
|
|
|
3691
3691
|
}
|
|
3692
3692
|
if (t.op === "xor") {
|
|
3693
3693
|
if (t.children.length === 0) {
|
|
3694
|
-
v(new
|
|
3694
|
+
v(new R(Q([[e, 1]], 0), "==", 0, `${n}_xor_empty`), n);
|
|
3695
3695
|
return;
|
|
3696
3696
|
}
|
|
3697
3697
|
if (t.children.length === 1) {
|
|
3698
3698
|
let r = D(t.children[0], n);
|
|
3699
|
-
v(new
|
|
3699
|
+
v(new R(Q([[e, 1], [r, -1]], 0), "==", 0, `${n}_xor_single`), n);
|
|
3700
3700
|
return;
|
|
3701
3701
|
}
|
|
3702
3702
|
let r = t.children.map((e) => D(e, n)), i = r[0];
|
|
@@ -3768,27 +3768,27 @@ function st(t, n, r, o, s) {
|
|
|
3768
3768
|
active: i
|
|
3769
3769
|
};
|
|
3770
3770
|
}
|
|
3771
|
-
function
|
|
3771
|
+
function ne(e, t, n) {
|
|
3772
3772
|
let r = e.spec;
|
|
3773
3773
|
switch (r.kind) {
|
|
3774
3774
|
case "distinct": {
|
|
3775
3775
|
let e = r.args.map((e) => x(e, n));
|
|
3776
3776
|
if (e.length <= 1) {
|
|
3777
|
-
t ||
|
|
3777
|
+
t || L(n);
|
|
3778
3778
|
return;
|
|
3779
3779
|
}
|
|
3780
3780
|
if (t) for (let t = 0; t < e.length; t++) for (let r = t + 1; r < e.length; r++) T(e[t].sub(e[r]), "!=", 0, `${n}_neq_${t}_${r}`, n);
|
|
3781
3781
|
else {
|
|
3782
3782
|
let t = [];
|
|
3783
|
-
for (let r = 0; r < e.length; r++) for (let i = r + 1; i < e.length; i++) t.push(new
|
|
3784
|
-
|
|
3783
|
+
for (let r = 0; r < e.length; r++) for (let i = r + 1; i < e.length; i++) t.push(new R(e[r].sub(e[i]), "==", 0, `${n}_eq_${r}_${i}`));
|
|
3784
|
+
P(new a("or", t), n);
|
|
3785
3785
|
}
|
|
3786
3786
|
return;
|
|
3787
3787
|
}
|
|
3788
3788
|
case "disjoint": {
|
|
3789
3789
|
let e = te(r.tasks, n);
|
|
3790
3790
|
if (e.length === 0) {
|
|
3791
|
-
t ||
|
|
3791
|
+
t || L(n);
|
|
3792
3792
|
return;
|
|
3793
3793
|
}
|
|
3794
3794
|
if (t) for (let { i: t, j: r, sI: i, dI: a, sJ: o, dJ: s } of e) {
|
|
@@ -3798,19 +3798,19 @@ function st(t, n, r, o, s) {
|
|
|
3798
3798
|
lb: 0,
|
|
3799
3799
|
ub: 1
|
|
3800
3800
|
});
|
|
3801
|
-
c.push(e),
|
|
3801
|
+
c.push(e), F(e, i.sub(o), "<=", -a, 1, `${n}_p_${t}_${r}`, n), F(e, o.sub(i), "<=", -s, 0, `${n}_q_${t}_${r}`, n);
|
|
3802
3802
|
}
|
|
3803
|
-
else
|
|
3803
|
+
else P(new a("or", e.map(({ i: e, j: t, sI: r, dI: i, sJ: o, dJ: s }) => new a("and", [new R(r.sub(o), ">=", 1 - i, `${n}_ov1_${e}_${t}`), new R(o.sub(r), ">=", 1 - s, `${n}_ov2_${e}_${t}`)]))), n);
|
|
3804
3804
|
return;
|
|
3805
3805
|
}
|
|
3806
3806
|
case "cumulative": {
|
|
3807
3807
|
let e = k(r.tasks, r.capacity, n);
|
|
3808
3808
|
if (e.kind === "empty_domain") {
|
|
3809
|
-
|
|
3809
|
+
L(n);
|
|
3810
3810
|
return;
|
|
3811
3811
|
}
|
|
3812
3812
|
if (e.kind === "constant") {
|
|
3813
|
-
e.value !== t &&
|
|
3813
|
+
e.value !== t && L(n);
|
|
3814
3814
|
return;
|
|
3815
3815
|
}
|
|
3816
3816
|
let { active: i } = e;
|
|
@@ -3832,10 +3832,10 @@ function st(t, n, r, o, s) {
|
|
|
3832
3832
|
c.push(t), r.set(n, t), a.push([t, 1]), n !== 0 && o.addTerm(t, -n);
|
|
3833
3833
|
}
|
|
3834
3834
|
if (a.length === 0) {
|
|
3835
|
-
|
|
3835
|
+
L(n);
|
|
3836
3836
|
return;
|
|
3837
3837
|
}
|
|
3838
|
-
v(new
|
|
3838
|
+
v(new R(Q(a, 0), "==", 1, `${n}_cum_sos_${e}`), n), z(new R(o, "==", 0, `${n}_cum_start_${e}`), n), s.push(r);
|
|
3839
3839
|
}
|
|
3840
3840
|
for (let a = e; a < t; a++) {
|
|
3841
3841
|
let e = [], t = 0;
|
|
@@ -3850,7 +3850,7 @@ function st(t, n, r, o, s) {
|
|
|
3850
3850
|
}
|
|
3851
3851
|
}
|
|
3852
3852
|
}
|
|
3853
|
-
t > r.capacity && e.length > 0 && v(new
|
|
3853
|
+
t > r.capacity && e.length > 0 && v(new R(Q(e, 0), "<=", r.capacity, `${n}_cum_t_${a}`), n);
|
|
3854
3854
|
}
|
|
3855
3855
|
return;
|
|
3856
3856
|
}
|
|
@@ -3865,18 +3865,18 @@ function st(t, n, r, o, s) {
|
|
|
3865
3865
|
lb: 0,
|
|
3866
3866
|
ub: 1
|
|
3867
3867
|
});
|
|
3868
|
-
c.push(l), O(l, new a("and", [new
|
|
3868
|
+
c.push(l), O(l, new a("and", [new R(o.start.sub(t.start), "<=", 0, `${n}_act_le_${r}_${e}`), new R(t.start.sub(o.start), "<=", o.duration - 1, `${n}_act_ge_${r}_${e}`)]), n), s.push([l, o.demand]);
|
|
3869
3869
|
}
|
|
3870
|
-
let l = new
|
|
3870
|
+
let l = new R(Q(s, 0), ">=", r.capacity - t.demand + 1, `${n}_overload_${e}`);
|
|
3871
3871
|
o.push(new a("and", [l]));
|
|
3872
3872
|
}
|
|
3873
|
-
|
|
3873
|
+
P(new a("or", o), n);
|
|
3874
3874
|
return;
|
|
3875
3875
|
}
|
|
3876
3876
|
case "allowed": {
|
|
3877
3877
|
let e = r.vars.map((e) => x(e, n));
|
|
3878
3878
|
if (r.tuples.length === 0) {
|
|
3879
|
-
t &&
|
|
3879
|
+
t && L(n);
|
|
3880
3880
|
return;
|
|
3881
3881
|
}
|
|
3882
3882
|
if (t) {
|
|
@@ -3890,14 +3890,14 @@ function st(t, n, r, o, s) {
|
|
|
3890
3890
|
});
|
|
3891
3891
|
c.push(n), t.push(n);
|
|
3892
3892
|
}
|
|
3893
|
-
v(new
|
|
3893
|
+
v(new R(Q(t.map((e) => [e, 1]), 0), "==", 1, `${n}_tbl_sos`), n);
|
|
3894
3894
|
for (let i = 0; i < e.length; i++) {
|
|
3895
3895
|
let a = e[i].clone();
|
|
3896
3896
|
for (let e = 0; e < r.tuples.length; e++) {
|
|
3897
3897
|
let n = r.tuples[e][i];
|
|
3898
3898
|
n !== 0 && a.addTerm(t[e], -n);
|
|
3899
3899
|
}
|
|
3900
|
-
|
|
3900
|
+
z(new R(a, "==", 0, `${n}_tbl_col_${i}`), n);
|
|
3901
3901
|
}
|
|
3902
3902
|
return;
|
|
3903
3903
|
}
|
|
@@ -3935,45 +3935,45 @@ function st(t, n, r, o, s) {
|
|
|
3935
3935
|
let n = i[t];
|
|
3936
3936
|
o[t] === n.lo ? it(e, n.expr.sub(n.lo), 1) : it(e, Q([], n.hi).sub(n.expr), 1);
|
|
3937
3937
|
}
|
|
3938
|
-
|
|
3939
|
-
} else
|
|
3938
|
+
z(new R(e, ">=", 1, `${n}_nogood_${t}`), n);
|
|
3939
|
+
} else P(new a("or", o.map((r, i) => new R(e[i], "!=", r, `${n}_ntbl_${t}_${i}`))), n, `${n}_ntbl_${t}`);
|
|
3940
3940
|
}
|
|
3941
3941
|
}
|
|
3942
3942
|
return;
|
|
3943
3943
|
}
|
|
3944
3944
|
}
|
|
3945
3945
|
}
|
|
3946
|
-
function
|
|
3946
|
+
function A(e, t, n) {
|
|
3947
3947
|
let r = t.spec;
|
|
3948
3948
|
switch (r.kind) {
|
|
3949
3949
|
case "distinct": {
|
|
3950
3950
|
let t = r.args.map((e) => x(e, n));
|
|
3951
3951
|
if (t.length <= 1) {
|
|
3952
|
-
v(new
|
|
3952
|
+
v(new R(Q([[e, 1]], 0), "==", 1, `${n}_distinct_triv`), n);
|
|
3953
3953
|
return;
|
|
3954
3954
|
}
|
|
3955
3955
|
let i = [];
|
|
3956
|
-
for (let e = 0; e < t.length; e++) for (let r = e + 1; r < t.length; r++) i.push(new
|
|
3956
|
+
for (let e = 0; e < t.length; e++) for (let r = e + 1; r < t.length; r++) i.push(new R(t[e].sub(t[r]), "!=", 0, `${n}_d_${e}_${r}`));
|
|
3957
3957
|
O(e, new a("and", i), n);
|
|
3958
3958
|
return;
|
|
3959
3959
|
}
|
|
3960
3960
|
case "disjoint": {
|
|
3961
3961
|
let t = te(r.tasks, n);
|
|
3962
3962
|
if (t.length === 0) {
|
|
3963
|
-
v(new
|
|
3963
|
+
v(new R(Q([[e, 1]], 0), "==", 1, `${n}_disjoint_triv`), n);
|
|
3964
3964
|
return;
|
|
3965
3965
|
}
|
|
3966
|
-
O(e, new a("and", t.map(({ i: e, j: t, sI: r, dI: i, sJ: o, dJ: s }) => new a("or", [new
|
|
3966
|
+
O(e, new a("and", t.map(({ i: e, j: t, sI: r, dI: i, sJ: o, dJ: s }) => new a("or", [new R(r.sub(o), "<=", -i, `${n}_dj1_${e}_${t}`), new R(o.sub(r), "<=", -s, `${n}_dj2_${e}_${t}`)]))), n);
|
|
3967
3967
|
return;
|
|
3968
3968
|
}
|
|
3969
3969
|
case "cumulative": {
|
|
3970
3970
|
let t = k(r.tasks, r.capacity, n);
|
|
3971
3971
|
if (t.kind === "empty_domain") {
|
|
3972
|
-
|
|
3972
|
+
L(n);
|
|
3973
3973
|
return;
|
|
3974
3974
|
}
|
|
3975
3975
|
if (t.kind === "constant") {
|
|
3976
|
-
v(new
|
|
3976
|
+
v(new R(Q([[e, 1]], 0), "==", +!!t.value, `${n}_cum_triv`), n);
|
|
3977
3977
|
return;
|
|
3978
3978
|
}
|
|
3979
3979
|
let { active: i } = t, o = [];
|
|
@@ -3987,9 +3987,9 @@ function st(t, n, r, o, s) {
|
|
|
3987
3987
|
lb: 0,
|
|
3988
3988
|
ub: 1
|
|
3989
3989
|
});
|
|
3990
|
-
c.push(l), O(l, new a("and", [new
|
|
3990
|
+
c.push(l), O(l, new a("and", [new R(o.start.sub(t.start), "<=", 0, `${n}_eq_le_${r}_${e}`), new R(t.start.sub(o.start), "<=", o.duration - 1, `${n}_eq_ge_${r}_${e}`)]), n), s.push([l, o.demand]);
|
|
3991
3991
|
}
|
|
3992
|
-
o.push(new
|
|
3992
|
+
o.push(new R(Q(s, 0), "<=", r.capacity - t.demand, `${n}_ev_${e}`));
|
|
3993
3993
|
}
|
|
3994
3994
|
O(e, new a("and", o), n);
|
|
3995
3995
|
return;
|
|
@@ -3997,19 +3997,19 @@ function st(t, n, r, o, s) {
|
|
|
3997
3997
|
case "allowed": {
|
|
3998
3998
|
let t = r.vars.map((e) => x(e, n));
|
|
3999
3999
|
if (r.tuples.length === 0) {
|
|
4000
|
-
v(new
|
|
4000
|
+
v(new R(Q([[e, 1]], 0), "==", 0, `${n}_allowed_empty`), n);
|
|
4001
4001
|
return;
|
|
4002
4002
|
}
|
|
4003
|
-
O(e, new a("or", r.tuples.map((e, r) => new a("and", e.map((e, i) => new
|
|
4003
|
+
O(e, new a("or", r.tuples.map((e, r) => new a("and", e.map((e, i) => new R(t[i], "==", e, `${n}_eq_tbl_${r}_${i}`))))), n);
|
|
4004
4004
|
return;
|
|
4005
4005
|
}
|
|
4006
4006
|
}
|
|
4007
4007
|
}
|
|
4008
|
-
function
|
|
4009
|
-
return e instanceof
|
|
4008
|
+
function j(e) {
|
|
4009
|
+
return e instanceof R || e instanceof a && e.children.some((e) => j(e));
|
|
4010
4010
|
}
|
|
4011
|
-
function
|
|
4012
|
-
if (e instanceof
|
|
4011
|
+
function M(e, t) {
|
|
4012
|
+
if (e instanceof R) {
|
|
4013
4013
|
if ((e.lhs.terms.get(t) ?? 0) !== 0) return !0;
|
|
4014
4014
|
for (let n of e.lhs.nonlinearTerms) {
|
|
4015
4015
|
if (n.coeff === 0) continue;
|
|
@@ -4018,62 +4018,62 @@ function st(t, n, r, o, s) {
|
|
|
4018
4018
|
}
|
|
4019
4019
|
return !1;
|
|
4020
4020
|
}
|
|
4021
|
-
return e instanceof a && e.children.some((e) =>
|
|
4021
|
+
return e instanceof a && e.children.some((e) => M(e, t));
|
|
4022
4022
|
}
|
|
4023
|
-
function
|
|
4024
|
-
if (t instanceof
|
|
4025
|
-
|
|
4023
|
+
function N(e, t, n, r) {
|
|
4024
|
+
if (t instanceof R) {
|
|
4025
|
+
re(e, E(t, n), 1, r, n);
|
|
4026
4026
|
return;
|
|
4027
4027
|
}
|
|
4028
4028
|
if (t instanceof i || t instanceof d) {
|
|
4029
|
-
v(new
|
|
4029
|
+
v(new R(Q([[D(t, n), 1], [e, -1]], 0), ">=", 0, r), n);
|
|
4030
4030
|
return;
|
|
4031
4031
|
}
|
|
4032
4032
|
if (t instanceof a) {
|
|
4033
4033
|
if (t.op === "and") {
|
|
4034
|
-
for (let i = 0; i < t.children.length; i++)
|
|
4034
|
+
for (let i = 0; i < t.children.length; i++) N(e, t.children[i], n, `${r}_and_${i}`);
|
|
4035
4035
|
return;
|
|
4036
4036
|
}
|
|
4037
4037
|
if (t.op === "not") {
|
|
4038
4038
|
let i = t.children[0];
|
|
4039
|
-
if (i instanceof
|
|
4040
|
-
|
|
4039
|
+
if (i instanceof R) {
|
|
4040
|
+
V(e, E(i, n), 1, r, n);
|
|
4041
4041
|
return;
|
|
4042
4042
|
}
|
|
4043
4043
|
if (i instanceof a) {
|
|
4044
4044
|
if (i.op === "not") {
|
|
4045
|
-
|
|
4045
|
+
N(e, i.children[0], n, r);
|
|
4046
4046
|
return;
|
|
4047
4047
|
}
|
|
4048
4048
|
if (i.op === "or") {
|
|
4049
|
-
for (let t = 0; t < i.children.length; t++)
|
|
4049
|
+
for (let t = 0; t < i.children.length; t++) N(e, new a("not", [i.children[t]]), n, `${r}_not_or_${t}`);
|
|
4050
4050
|
return;
|
|
4051
4051
|
}
|
|
4052
4052
|
if (i.op === "and") {
|
|
4053
|
-
|
|
4053
|
+
N(e, new a("or", i.children.map((e) => new a("not", [e]))), n, r);
|
|
4054
4054
|
return;
|
|
4055
4055
|
}
|
|
4056
4056
|
if (i.op === "implies") {
|
|
4057
|
-
|
|
4057
|
+
N(e, i.children[0], n, `${r}_not_imp_0`), N(e, new a("not", [i.children[1]]), n, `${r}_not_imp_1`);
|
|
4058
4058
|
return;
|
|
4059
4059
|
}
|
|
4060
4060
|
}
|
|
4061
4061
|
let o = D(i, n);
|
|
4062
|
-
v(new
|
|
4062
|
+
v(new R(Q([[e, 1], [o, 1]], 0), "<=", 1, r), n);
|
|
4063
4063
|
return;
|
|
4064
4064
|
}
|
|
4065
4065
|
if (t.op === "or") {
|
|
4066
4066
|
if (t.children.length === 0) {
|
|
4067
|
-
v(new
|
|
4067
|
+
v(new R(Q([[e, 1]], 0), "<=", 0, r), n);
|
|
4068
4068
|
return;
|
|
4069
4069
|
}
|
|
4070
4070
|
if (t.children.length === 1) {
|
|
4071
|
-
|
|
4071
|
+
N(e, t.children[0], n, r);
|
|
4072
4072
|
return;
|
|
4073
4073
|
}
|
|
4074
|
-
if (!t.children.some((e) =>
|
|
4074
|
+
if (!t.children.some((e) => j(e))) {
|
|
4075
4075
|
let i = t.children.map((e) => D(e, n));
|
|
4076
|
-
v(new
|
|
4076
|
+
v(new R(Q([[e, -1], ...i.map((e) => [e, 1])], 0), ">=", 0, r), n);
|
|
4077
4077
|
return;
|
|
4078
4078
|
}
|
|
4079
4079
|
let a = [];
|
|
@@ -4087,25 +4087,25 @@ function st(t, n, r, o, s) {
|
|
|
4087
4087
|
lb: 0,
|
|
4088
4088
|
ub: 1
|
|
4089
4089
|
});
|
|
4090
|
-
c.push(t), a.push(t),
|
|
4090
|
+
c.push(t), a.push(t), N(t, o, n, `${r}_or_${e}`);
|
|
4091
4091
|
}
|
|
4092
4092
|
}
|
|
4093
|
-
v(new
|
|
4093
|
+
v(new R(Q([[e, -1], ...a.map((e) => [e, 1])], 0), ">=", 0, r), n);
|
|
4094
4094
|
return;
|
|
4095
4095
|
}
|
|
4096
4096
|
if (t.op === "implies") {
|
|
4097
4097
|
let [a, o] = t.children, s;
|
|
4098
|
-
if (a instanceof
|
|
4098
|
+
if (a instanceof R) {
|
|
4099
4099
|
let e = E(a, n);
|
|
4100
4100
|
s = new K({
|
|
4101
4101
|
name: _("ante"),
|
|
4102
4102
|
type: "Binary",
|
|
4103
4103
|
lb: 0,
|
|
4104
4104
|
ub: 1
|
|
4105
|
-
}), c.push(s),
|
|
4105
|
+
}), c.push(s), V(s, e, 0, `${r}_ante_neg`, n);
|
|
4106
4106
|
} else s = D(a, n);
|
|
4107
4107
|
if (o instanceof i) {
|
|
4108
|
-
v(new
|
|
4108
|
+
v(new R(Q([
|
|
4109
4109
|
[D(o, n), 1],
|
|
4110
4110
|
[e, -1],
|
|
4111
4111
|
[s, -1]
|
|
@@ -4118,82 +4118,82 @@ function st(t, n, r, o, s) {
|
|
|
4118
4118
|
lb: 0,
|
|
4119
4119
|
ub: 1
|
|
4120
4120
|
});
|
|
4121
|
-
c.push(l), v(new
|
|
4121
|
+
c.push(l), v(new R(Q([
|
|
4122
4122
|
[l, 1],
|
|
4123
4123
|
[e, -1],
|
|
4124
4124
|
[s, -1]
|
|
4125
|
-
], 0), ">=", -1, `${r}_joint`), n),
|
|
4125
|
+
], 0), ">=", -1, `${r}_joint`), n), N(l, o, n, r);
|
|
4126
4126
|
return;
|
|
4127
4127
|
}
|
|
4128
|
-
v(new
|
|
4128
|
+
v(new R(Q([[D(t, n), 1], [e, -1]], 0), ">=", 0, r), n);
|
|
4129
4129
|
return;
|
|
4130
4130
|
}
|
|
4131
4131
|
throw Error(`Unsupported logical element in implication consequent "${n}": ${t}`);
|
|
4132
4132
|
}
|
|
4133
|
-
function
|
|
4134
|
-
if (e instanceof
|
|
4133
|
+
function P(e, t, n = t) {
|
|
4134
|
+
if (e instanceof R) {
|
|
4135
4135
|
T(e.lhs, e.sense, e.rhs, n, t);
|
|
4136
4136
|
return;
|
|
4137
4137
|
}
|
|
4138
4138
|
if (e instanceof d) {
|
|
4139
|
-
|
|
4139
|
+
ne(e, !0, t);
|
|
4140
4140
|
return;
|
|
4141
4141
|
}
|
|
4142
4142
|
if (e instanceof i) {
|
|
4143
|
-
v(new
|
|
4143
|
+
v(new R(Q([[D(e, t), 1]], 0), ">=", 1, n), t);
|
|
4144
4144
|
return;
|
|
4145
4145
|
}
|
|
4146
4146
|
if (e instanceof a) {
|
|
4147
4147
|
if (e.op === "not") {
|
|
4148
4148
|
let r = e.children[0];
|
|
4149
4149
|
if (r instanceof i) {
|
|
4150
|
-
v(new
|
|
4150
|
+
v(new R(Q([[D(r, t), 1]], 0), "<=", 0, n), t);
|
|
4151
4151
|
return;
|
|
4152
4152
|
}
|
|
4153
4153
|
if (r instanceof d) {
|
|
4154
|
-
|
|
4154
|
+
ne(r, !1, t);
|
|
4155
4155
|
return;
|
|
4156
4156
|
}
|
|
4157
|
-
if (r instanceof
|
|
4158
|
-
|
|
4157
|
+
if (r instanceof R) {
|
|
4158
|
+
B(E(r, t), t);
|
|
4159
4159
|
return;
|
|
4160
4160
|
}
|
|
4161
4161
|
if (r instanceof a) {
|
|
4162
4162
|
if (r.op === "not") {
|
|
4163
|
-
|
|
4163
|
+
P(r.children[0], t, n);
|
|
4164
4164
|
return;
|
|
4165
4165
|
}
|
|
4166
4166
|
if (r.op === "or") {
|
|
4167
|
-
for (let e = 0; e < r.children.length; e++)
|
|
4167
|
+
for (let e = 0; e < r.children.length; e++) P(new a("not", [r.children[e]]), t, `${n}_not_or_${e}`);
|
|
4168
4168
|
return;
|
|
4169
4169
|
}
|
|
4170
4170
|
if (r.op === "and") {
|
|
4171
|
-
|
|
4171
|
+
P(new a("or", r.children.map((e) => new a("not", [e]))), t, n);
|
|
4172
4172
|
return;
|
|
4173
4173
|
}
|
|
4174
4174
|
if (r.op === "implies") {
|
|
4175
|
-
|
|
4175
|
+
P(r.children[0], t, `${n}_not_imp_0`), P(new a("not", [r.children[1]]), t, `${n}_not_imp_1`);
|
|
4176
4176
|
return;
|
|
4177
4177
|
}
|
|
4178
4178
|
}
|
|
4179
|
-
v(new
|
|
4179
|
+
v(new R(Q([[D(r, t), 1]], 0), "<=", 0, n), t);
|
|
4180
4180
|
return;
|
|
4181
4181
|
}
|
|
4182
4182
|
if (e.op === "and") {
|
|
4183
|
-
for (let r = 0; r < e.children.length; r++)
|
|
4183
|
+
for (let r = 0; r < e.children.length; r++) P(e.children[r], t, `${n}_and_${r}`);
|
|
4184
4184
|
return;
|
|
4185
4185
|
}
|
|
4186
4186
|
if (e.op === "or") {
|
|
4187
4187
|
if (e.children.length === 0) {
|
|
4188
|
-
|
|
4188
|
+
L(t);
|
|
4189
4189
|
return;
|
|
4190
4190
|
}
|
|
4191
4191
|
if (e.children.length === 1) {
|
|
4192
|
-
|
|
4192
|
+
P(e.children[0], t, n);
|
|
4193
4193
|
return;
|
|
4194
4194
|
}
|
|
4195
|
-
if (!e.children.some((e) =>
|
|
4196
|
-
v(new
|
|
4195
|
+
if (!e.children.some((e) => j(e))) {
|
|
4196
|
+
v(new R(Q(e.children.map((e) => D(e, t)).map((e) => [e, 1]), 0), ">=", 1, n), t);
|
|
4197
4197
|
return;
|
|
4198
4198
|
}
|
|
4199
4199
|
let r = [];
|
|
@@ -4207,24 +4207,24 @@ function st(t, n, r, o, s) {
|
|
|
4207
4207
|
lb: 0,
|
|
4208
4208
|
ub: 1
|
|
4209
4209
|
});
|
|
4210
|
-
c.push(e), r.push(e),
|
|
4210
|
+
c.push(e), r.push(e), N(e, o, t, `${n}_or_${a}`);
|
|
4211
4211
|
}
|
|
4212
4212
|
}
|
|
4213
|
-
v(new
|
|
4213
|
+
v(new R(Q(r.map((e) => [e, 1]), 0), ">=", 1, n), t);
|
|
4214
4214
|
return;
|
|
4215
4215
|
}
|
|
4216
4216
|
if (e.op === "xor") {
|
|
4217
4217
|
if (e.children.length === 0) {
|
|
4218
|
-
|
|
4218
|
+
L(t);
|
|
4219
4219
|
return;
|
|
4220
4220
|
}
|
|
4221
4221
|
if (e.children.length === 1) {
|
|
4222
|
-
|
|
4222
|
+
P(e.children[0], t, n);
|
|
4223
4223
|
return;
|
|
4224
4224
|
}
|
|
4225
4225
|
let r = e.children.map((e) => D(e, t));
|
|
4226
4226
|
if (r.length === 2) {
|
|
4227
|
-
v(new
|
|
4227
|
+
v(new R(Q([[r[0], 1], [r[1], 1]], 0), "==", 1, n), t);
|
|
4228
4228
|
return;
|
|
4229
4229
|
}
|
|
4230
4230
|
let i = r[0];
|
|
@@ -4238,89 +4238,89 @@ function st(t, n, r, o, s) {
|
|
|
4238
4238
|
c.push(t), ee(t, i, r[e], `${n}_xor_fold_${e}`), i = t;
|
|
4239
4239
|
}
|
|
4240
4240
|
let a = r[r.length - 1];
|
|
4241
|
-
v(new
|
|
4241
|
+
v(new R(Q([[i, 1], [a, 1]], 0), "==", 1, n), t);
|
|
4242
4242
|
return;
|
|
4243
4243
|
}
|
|
4244
4244
|
if (e.op === "implies") {
|
|
4245
|
-
let [r, o] = e.children, s = r instanceof
|
|
4245
|
+
let [r, o] = e.children, s = r instanceof R ? ct(r) : null;
|
|
4246
4246
|
if (s !== null) {
|
|
4247
|
-
if (o instanceof
|
|
4247
|
+
if (o instanceof R) {
|
|
4248
4248
|
let e = E(o, t);
|
|
4249
4249
|
if ((e.lhs.terms.get(s.binVar) ?? 0) === 0) {
|
|
4250
|
-
|
|
4250
|
+
re(s.binVar, e, s.activeVal, n, t);
|
|
4251
4251
|
return;
|
|
4252
4252
|
}
|
|
4253
4253
|
}
|
|
4254
4254
|
if (o instanceof i) {
|
|
4255
4255
|
let e = D(o, t);
|
|
4256
|
-
v(s.activeVal === 1 ? new
|
|
4256
|
+
v(s.activeVal === 1 ? new R(Q([[e, 1], [s.binVar, -1]], 0), ">=", 0, n) : new R(Q([[e, 1], [s.binVar, 1]], 0), ">=", 1, n), t);
|
|
4257
4257
|
return;
|
|
4258
4258
|
}
|
|
4259
4259
|
if (o instanceof a && o.op === "not") {
|
|
4260
4260
|
let e = o.children[0];
|
|
4261
4261
|
if (e instanceof i) {
|
|
4262
4262
|
let r = D(e, t);
|
|
4263
|
-
v(s.activeVal === 1 ? new
|
|
4263
|
+
v(s.activeVal === 1 ? new R(Q([[r, 1], [s.binVar, 1]], 0), "<=", 1, n) : new R(Q([[r, 1], [s.binVar, -1]], 0), "<=", 0, n), t);
|
|
4264
4264
|
return;
|
|
4265
4265
|
}
|
|
4266
|
-
if (e instanceof
|
|
4266
|
+
if (e instanceof R) {
|
|
4267
4267
|
let r = E(e, t);
|
|
4268
4268
|
if ((r.lhs.terms.get(s.binVar) ?? 0) === 0) {
|
|
4269
|
-
|
|
4269
|
+
V(s.binVar, r, s.activeVal, n, t);
|
|
4270
4270
|
return;
|
|
4271
4271
|
}
|
|
4272
4272
|
}
|
|
4273
4273
|
}
|
|
4274
|
-
if (s.activeVal === 1 && !
|
|
4275
|
-
|
|
4274
|
+
if (s.activeVal === 1 && !M(o, s.binVar)) {
|
|
4275
|
+
N(s.binVar, o, t, n);
|
|
4276
4276
|
return;
|
|
4277
4277
|
}
|
|
4278
4278
|
}
|
|
4279
4279
|
let l;
|
|
4280
|
-
if (r instanceof
|
|
4280
|
+
if (r instanceof R) {
|
|
4281
4281
|
let e = E(r, t);
|
|
4282
4282
|
l = new K({
|
|
4283
4283
|
name: _("ante"),
|
|
4284
4284
|
type: "Binary",
|
|
4285
4285
|
lb: 0,
|
|
4286
4286
|
ub: 1
|
|
4287
|
-
}), c.push(l),
|
|
4287
|
+
}), c.push(l), V(l, e, 0, `${n}_ante_neg`, t);
|
|
4288
4288
|
} else l = D(r, t);
|
|
4289
|
-
|
|
4289
|
+
N(l, o, t, n);
|
|
4290
4290
|
return;
|
|
4291
4291
|
}
|
|
4292
4292
|
}
|
|
4293
4293
|
throw Error(`Unsupported top-level logical constraint "${t}": ${e}`);
|
|
4294
4294
|
}
|
|
4295
|
-
function
|
|
4295
|
+
function F(e, t, n, r, i, a, o) {
|
|
4296
4296
|
let s = rt(e, t, n, r, i, n === "<=" ? tt(t, r, a) : nt(t, r, a), a);
|
|
4297
|
-
s.lhs.terms.size > 0 && v(new
|
|
4297
|
+
s.lhs.terms.size > 0 && v(new R(s.lhs, n, s.rhs, a), o);
|
|
4298
4298
|
}
|
|
4299
|
-
function
|
|
4300
|
-
return new
|
|
4299
|
+
function I(e) {
|
|
4300
|
+
return new R(e.lhs, "==", e.rhs, e.name);
|
|
4301
4301
|
}
|
|
4302
|
-
function
|
|
4302
|
+
function re(e, t, n, r, i) {
|
|
4303
4303
|
let a = E(t, i);
|
|
4304
4304
|
if (a.sense === "!=") {
|
|
4305
|
-
|
|
4305
|
+
V(e, I(a), n, r, i);
|
|
4306
4306
|
return;
|
|
4307
4307
|
}
|
|
4308
4308
|
let { lhs: o, sense: s, rhs: c } = a;
|
|
4309
|
-
s === "==" ? (
|
|
4309
|
+
s === "==" ? (F(e, o, "<=", c, n, `${r}_le`, i), F(e, o, ">=", c, n, `${r}_ge`, i)) : F(e, o, s, c, n, r, i);
|
|
4310
4310
|
}
|
|
4311
|
-
function
|
|
4311
|
+
function L(e) {
|
|
4312
4312
|
let t = new K({
|
|
4313
4313
|
name: _("unsat"),
|
|
4314
4314
|
type: "Binary",
|
|
4315
4315
|
lb: 0,
|
|
4316
4316
|
ub: 1
|
|
4317
4317
|
});
|
|
4318
|
-
c.push(t), v(new
|
|
4318
|
+
c.push(t), v(new R(Q([[t, 1]], 0), ">=", 2, e), e);
|
|
4319
4319
|
}
|
|
4320
|
-
function
|
|
4320
|
+
function z(e, t) {
|
|
4321
4321
|
let n = E(e, t), { lhs: r, sense: i, rhs: a } = n;
|
|
4322
4322
|
if (i === "!=") {
|
|
4323
|
-
|
|
4323
|
+
B(I(n), t);
|
|
4324
4324
|
return;
|
|
4325
4325
|
}
|
|
4326
4326
|
let o = r.constant ?? 0, s = a - o;
|
|
@@ -4331,25 +4331,25 @@ function st(t, n, r, o, s) {
|
|
|
4331
4331
|
i !== 0 && c.push([n, i]);
|
|
4332
4332
|
}
|
|
4333
4333
|
if (c.length === 0) {
|
|
4334
|
-
(i === "<=" ? 0 <= s : i === ">=" ? 0 >= s : s === 0) ||
|
|
4334
|
+
(i === "<=" ? 0 <= s : i === ">=" ? 0 >= s : s === 0) || L(t);
|
|
4335
4335
|
return;
|
|
4336
4336
|
}
|
|
4337
|
-
v(new
|
|
4337
|
+
v(new R(Q(c, 0), i, s, e.name || t), t);
|
|
4338
4338
|
}
|
|
4339
|
-
function
|
|
4339
|
+
function B(e, t) {
|
|
4340
4340
|
let n = E(e, t);
|
|
4341
4341
|
if (n.sense === "!=") {
|
|
4342
|
-
|
|
4342
|
+
z(I(n), t);
|
|
4343
4343
|
return;
|
|
4344
4344
|
}
|
|
4345
4345
|
let r = lt(n, t);
|
|
4346
4346
|
if (r.kind === "always_true") return;
|
|
4347
4347
|
if (r.kind === "always_false") {
|
|
4348
|
-
|
|
4348
|
+
L(t);
|
|
4349
4349
|
return;
|
|
4350
4350
|
}
|
|
4351
4351
|
if (r.kind === "single") {
|
|
4352
|
-
v(new
|
|
4352
|
+
v(new R(r.lhs, r.sense, r.rhs, n.name || t), t);
|
|
4353
4353
|
return;
|
|
4354
4354
|
}
|
|
4355
4355
|
let i = new K({
|
|
@@ -4360,22 +4360,22 @@ function st(t, n, r, o, s) {
|
|
|
4360
4360
|
});
|
|
4361
4361
|
c.push(i);
|
|
4362
4362
|
let a = n.name || t;
|
|
4363
|
-
|
|
4363
|
+
F(i, r.lhs, "<=", r.ltRhs, 1, `${a}_lt`, t), F(i, r.lhs, ">=", r.gtRhs, 0, `${a}_gt`, t);
|
|
4364
4364
|
}
|
|
4365
|
-
function
|
|
4365
|
+
function V(e, t, n, r, i) {
|
|
4366
4366
|
let a = E(t, i);
|
|
4367
4367
|
if (a.sense === "!=") {
|
|
4368
|
-
|
|
4368
|
+
re(e, I(a), n, r, i);
|
|
4369
4369
|
return;
|
|
4370
4370
|
}
|
|
4371
4371
|
let o = lt(a, i);
|
|
4372
4372
|
if (o.kind === "always_true") return;
|
|
4373
4373
|
if (o.kind === "always_false") {
|
|
4374
|
-
v(new
|
|
4374
|
+
v(new R(Q([[e, 1]], 0), n === 0 ? ">=" : "<=", +(n === 0), r), i);
|
|
4375
4375
|
return;
|
|
4376
4376
|
}
|
|
4377
4377
|
if (o.kind === "single") {
|
|
4378
|
-
|
|
4378
|
+
F(e, o.lhs, o.sense, o.rhs, n, r, i);
|
|
4379
4379
|
return;
|
|
4380
4380
|
}
|
|
4381
4381
|
let s = new K({
|
|
@@ -4389,14 +4389,14 @@ function st(t, n, r, o, s) {
|
|
|
4389
4389
|
lb: 0,
|
|
4390
4390
|
ub: 1
|
|
4391
4391
|
});
|
|
4392
|
-
c.push(s, l),
|
|
4392
|
+
c.push(s, l), F(s, o.lhs, "<=", o.ltRhs, 1, `${r}_lt`, i), F(l, o.lhs, ">=", o.gtRhs, 1, `${r}_gt`, i), v(new R(Q([
|
|
4393
4393
|
[s, 1],
|
|
4394
4394
|
[l, 1],
|
|
4395
4395
|
[e, n === 0 ? 1 : -1]
|
|
4396
4396
|
], 0), ">=", +(n === 0), `${r}_disj`), i);
|
|
4397
4397
|
}
|
|
4398
4398
|
for (let e of m) T(e.lhs, e.sense, e.rhs, e.name, e.name);
|
|
4399
|
-
let
|
|
4399
|
+
let H;
|
|
4400
4400
|
if (s && s.expr.hasNonlinearTerms()) {
|
|
4401
4401
|
let t = e(s.sense) === "Minimize", n = s.expr, r = new Map(n instanceof b ? n.linearTerms : n.terms), i = n.constant;
|
|
4402
4402
|
for (let e of n.nonlinearTerms) {
|
|
@@ -4408,18 +4408,18 @@ function st(t, n, r, o, s) {
|
|
|
4408
4408
|
i === 0 ? r.delete(t) : r.set(t, i);
|
|
4409
4409
|
}
|
|
4410
4410
|
}
|
|
4411
|
-
|
|
4412
|
-
} else s && (
|
|
4411
|
+
H = n instanceof b ? new b(r, n.quadTerms, i, []) : new G(r, i, []);
|
|
4412
|
+
} else s && (H = s.expr);
|
|
4413
4413
|
for (let e of o) {
|
|
4414
4414
|
let t = e.name, n = e.expr;
|
|
4415
|
-
|
|
4415
|
+
P(n, t);
|
|
4416
4416
|
}
|
|
4417
4417
|
return {
|
|
4418
4418
|
variables: c,
|
|
4419
4419
|
constraints: l,
|
|
4420
4420
|
boolVarToBinary: u,
|
|
4421
4421
|
constraintToOriginalName: f,
|
|
4422
|
-
...
|
|
4422
|
+
...H === void 0 ? {} : { objective: H }
|
|
4423
4423
|
};
|
|
4424
4424
|
}
|
|
4425
4425
|
function ct(e) {
|
|
@@ -4566,7 +4566,7 @@ async function ut(e) {
|
|
|
4566
4566
|
//#region src/modeler/objective.ts
|
|
4567
4567
|
function dt(e, t) {
|
|
4568
4568
|
let n = e;
|
|
4569
|
-
if (n instanceof
|
|
4569
|
+
if (n instanceof R || typeof n == "object" && n && "sense" in n && "lhs" in n && "rhs" in n) throw Error(`Cannot use a Constraint as an objective in ${t}(). Use m.constraint(expr\`... <= ...\`) for constraints, or supply an unconstrained arithmetic expression to ${t}(), e.g. m.objective(${t}(expr\`30 * \${x}\`)).`);
|
|
4570
4570
|
if (typeof n == "string" && /(<=|>=|==|!=|=<|=>|<|>|=)/.test(n)) throw Error(`Cannot use a comparison constraint as an objective in ${t}(). Use m.constraint(expr\`... <= ...\`) for constraints, or supply an unconstrained arithmetic expression to ${t}(), e.g. m.objective(${t}(expr\`30 * \${x}\`)).`);
|
|
4571
4571
|
if (typeof n == "number") {
|
|
4572
4572
|
if (!Number.isFinite(n)) throw Error(`Invalid non-finite objective constant "${n}" passed to ${t}().`);
|
|
@@ -4607,7 +4607,7 @@ async function gt(e, t, n, r, i, a, o, s, c = 1) {
|
|
|
4607
4607
|
}
|
|
4608
4608
|
let m = u - p, h = new G();
|
|
4609
4609
|
for (let [e, t] of d) h.addTerm(e, t);
|
|
4610
|
-
let g = new
|
|
4610
|
+
let g = new R(h, s, m, `__benders_link_${c}_${r}`);
|
|
4611
4611
|
e.constraint(g), l.push({
|
|
4612
4612
|
origConstraint: a,
|
|
4613
4613
|
subConstr: g,
|
|
@@ -4627,7 +4627,7 @@ async function gt(e, t, n, r, i, a, o, s, c = 1) {
|
|
|
4627
4627
|
if (!(a ? f < d - p : f > d + p)) return null;
|
|
4628
4628
|
let m = 0, h = /* @__PURE__ */ new Map(), g = new Set(l.map((e) => e.subConstr.name));
|
|
4629
4629
|
for (let t of e.constraints.values()) {
|
|
4630
|
-
if (!(t instanceof
|
|
4630
|
+
if (!(t instanceof R) || g.has(t.name)) continue;
|
|
4631
4631
|
let n = e.solution?.duals[t.name] ?? t.dual ?? 0;
|
|
4632
4632
|
if (Math.abs(n) > 1e-12) {
|
|
4633
4633
|
let e = t.rhs - (t.lhs.constant || 0);
|
|
@@ -4647,7 +4647,7 @@ async function gt(e, t, n, r, i, a, o, s, c = 1) {
|
|
|
4647
4647
|
let _ = new G();
|
|
4648
4648
|
_.addTerm(r, 1);
|
|
4649
4649
|
for (let [e, t] of h.entries()) Math.abs(t) > 1e-12 && _.addTerm(e, t);
|
|
4650
|
-
let v = new
|
|
4650
|
+
let v = new R(_, a ? ">=" : "<=", m, `__benders_opt_cut_${c}`), y = (n.objectiveValue ?? 0) - f + d;
|
|
4651
4651
|
return {
|
|
4652
4652
|
kind: "optimality",
|
|
4653
4653
|
constraint: v,
|
|
@@ -4755,6 +4755,31 @@ function yt(e) {
|
|
|
4755
4755
|
return !1;
|
|
4756
4756
|
}
|
|
4757
4757
|
function bt(e) {
|
|
4758
|
+
return e.type === "Integer" || e.type === "Binary";
|
|
4759
|
+
}
|
|
4760
|
+
function xt(e) {
|
|
4761
|
+
switch (e.kind) {
|
|
4762
|
+
case "abs": return Ct(e.arg);
|
|
4763
|
+
case "max":
|
|
4764
|
+
case "min": return e.args.length > 0 && e.args.every(Ct);
|
|
4765
|
+
case "at": return e.array.length > 0 && e.array.every(Ct);
|
|
4766
|
+
}
|
|
4767
|
+
}
|
|
4768
|
+
function St(e) {
|
|
4769
|
+
for (let t of e) if (t.coeff !== 0 && (!Number.isInteger(t.coeff) || !xt(t.atom))) return !1;
|
|
4770
|
+
return !0;
|
|
4771
|
+
}
|
|
4772
|
+
function Ct(e) {
|
|
4773
|
+
if (!Number.isInteger(e.constant)) return !1;
|
|
4774
|
+
if (e instanceof b) {
|
|
4775
|
+
for (let [t, n] of e.linearTerms) if (n !== 0 && (!bt(t) || !Number.isInteger(n))) return !1;
|
|
4776
|
+
for (let t of e.quadTerms.values()) if (t.coeff !== 0 && (!bt(t.var1) || !bt(t.var2) || !Number.isInteger(t.coeff))) return !1;
|
|
4777
|
+
return St(e.nonlinearTerms);
|
|
4778
|
+
}
|
|
4779
|
+
for (let [t, n] of e.terms) if (n !== 0 && (!bt(t) || !Number.isInteger(n))) return !1;
|
|
4780
|
+
return St(e.nonlinearTerms);
|
|
4781
|
+
}
|
|
4782
|
+
function wt(e) {
|
|
4758
4783
|
let t = Object.freeze({
|
|
4759
4784
|
get size() {
|
|
4760
4785
|
return e.size;
|
|
@@ -4785,19 +4810,19 @@ function bt(e) {
|
|
|
4785
4810
|
});
|
|
4786
4811
|
return t;
|
|
4787
4812
|
}
|
|
4788
|
-
function
|
|
4813
|
+
function Tt(e) {
|
|
4789
4814
|
return Array.isArray(e) || typeof e == "object" && !!e && !(e instanceof String) && typeof e[Symbol.iterator] == "function";
|
|
4790
4815
|
}
|
|
4791
4816
|
function $(e) {
|
|
4792
4817
|
return typeof e == "object" && !!e && !Array.isArray(e) && !(e instanceof String) && typeof e[Symbol.iterator] != "function";
|
|
4793
4818
|
}
|
|
4794
|
-
function
|
|
4795
|
-
return e instanceof K || typeof e == "object" && !!e && !(e instanceof r) && !(e instanceof
|
|
4819
|
+
function Et(e) {
|
|
4820
|
+
return e instanceof K || typeof e == "object" && !!e && !(e instanceof r) && !(e instanceof R) && "id" in e && "name" in e && "lb" in e && "ub" in e && !("terms" in e) && !("quadTerms" in e) && !("sense" in e);
|
|
4796
4821
|
}
|
|
4797
|
-
function
|
|
4822
|
+
function Dt(e, t) {
|
|
4798
4823
|
if (!Number.isInteger(e) || e < 0) throw Error(`Invalid count (${e}) for ${t} variable creation: count must be a non-negative integer.`);
|
|
4799
4824
|
}
|
|
4800
|
-
var
|
|
4825
|
+
var Ot = class {
|
|
4801
4826
|
name;
|
|
4802
4827
|
_sense;
|
|
4803
4828
|
_objectiveExpr;
|
|
@@ -4844,7 +4869,7 @@ var wt = class {
|
|
|
4844
4869
|
r = typeof t == "string" ? {
|
|
4845
4870
|
...n,
|
|
4846
4871
|
name: t
|
|
4847
|
-
} : t, this.name = r.name || "OptimizationModel", this._sense = e(r.sense), this._objectiveExpr = new G(), this.variables =
|
|
4872
|
+
} : t, this.name = r.name || "OptimizationModel", this._sense = e(r.sense), this._objectiveExpr = new G(), this.variables = wt(this.allVarsMap), this.constraints = wt(this.allConstrsMap), this.values = wt(this._values), T(this, () => this.recordModelMutation()), r.solver && (this.solver = qe(r.solver));
|
|
4848
4873
|
}
|
|
4849
4874
|
get sense() {
|
|
4850
4875
|
return this._sense;
|
|
@@ -4910,9 +4935,9 @@ var wt = class {
|
|
|
4910
4935
|
}
|
|
4911
4936
|
}
|
|
4912
4937
|
createDomainVars(e, t, n, r) {
|
|
4913
|
-
let i = e.toLowerCase(), a = typeof t == "number", o = typeof n == "number", s =
|
|
4938
|
+
let i = e.toLowerCase(), a = typeof t == "number", o = typeof n == "number", s = Tt(t), c = Tt(n);
|
|
4914
4939
|
if (o || c) {
|
|
4915
|
-
if (a &&
|
|
4940
|
+
if (a && Dt(t, i), o && Dt(n, i), !a && !s || r !== void 0 && !$(r)) throw Error(`Invalid arguments provided for ${i} variable creation`);
|
|
4916
4941
|
let c = a ? Array.from({ length: t }, (e, t) => t) : Array.from(t), l = o ? Array.from({ length: n }, (e, t) => t) : n === t ? c : Array.from(n), u = r || {}, d = u.prefix || u.name || "x";
|
|
4917
4942
|
return this.runTransactionalBatch(() => {
|
|
4918
4943
|
let t = a ? [] : {};
|
|
@@ -4947,7 +4972,7 @@ var wt = class {
|
|
|
4947
4972
|
}
|
|
4948
4973
|
if (n !== void 0 && !$(n)) throw Error(`Invalid arguments provided for ${i} variable creation`);
|
|
4949
4974
|
let l = n || {}, u = l.prefix || l.name;
|
|
4950
|
-
if (typeof t == "number") return
|
|
4975
|
+
if (typeof t == "number") return Dt(t, i), this.runTransactionalBatch(() => {
|
|
4951
4976
|
let n = [], r = u || "x";
|
|
4952
4977
|
for (let i = 0; i < t; i++) n.push(this.addVar({
|
|
4953
4978
|
...l,
|
|
@@ -4957,7 +4982,7 @@ var wt = class {
|
|
|
4957
4982
|
}));
|
|
4958
4983
|
return n;
|
|
4959
4984
|
});
|
|
4960
|
-
if (
|
|
4985
|
+
if (Tt(t)) return this.runTransactionalBatch(() => {
|
|
4961
4986
|
let n = {};
|
|
4962
4987
|
for (let r of t) {
|
|
4963
4988
|
let t = u ? `${u}_${r}` : `${r}`;
|
|
@@ -5012,9 +5037,9 @@ var wt = class {
|
|
|
5012
5037
|
return n;
|
|
5013
5038
|
}
|
|
5014
5039
|
bool(e, t, n) {
|
|
5015
|
-
let r = typeof e == "number", i = typeof t == "number", a =
|
|
5040
|
+
let r = typeof e == "number", i = typeof t == "number", a = Tt(e), o = Tt(t);
|
|
5016
5041
|
if (i || o) {
|
|
5017
|
-
if (r &&
|
|
5042
|
+
if (r && Dt(e, "boolean"), i && Dt(t, "boolean"), !r && !a || n !== void 0 && !$(n)) throw Error("Invalid arguments provided for boolean variable creation");
|
|
5018
5043
|
let o = r ? Array.from({ length: e }, (e, t) => t) : Array.from(e), s = i ? Array.from({ length: t }, (e, t) => t) : t === e ? o : Array.from(t), c = n || {}, l = c.prefix || c.name || "p";
|
|
5019
5044
|
return this.runTransactionalBatch(() => {
|
|
5020
5045
|
let e = r ? [] : {};
|
|
@@ -5038,12 +5063,12 @@ var wt = class {
|
|
|
5038
5063
|
}
|
|
5039
5064
|
if (t !== void 0 && !$(t)) throw Error("Invalid arguments provided for boolean variable creation");
|
|
5040
5065
|
let s = t || {}, c = s.prefix || s.name;
|
|
5041
|
-
if (typeof e == "number") return
|
|
5066
|
+
if (typeof e == "number") return Dt(e, "boolean"), this.runTransactionalBatch(() => {
|
|
5042
5067
|
let t = [], n = c || "p";
|
|
5043
5068
|
for (let r = 0; r < e; r++) t.push(this.createBoolVar(void 0, n));
|
|
5044
5069
|
return t;
|
|
5045
5070
|
});
|
|
5046
|
-
if (
|
|
5071
|
+
if (Tt(e)) return this.runTransactionalBatch(() => {
|
|
5047
5072
|
let t = {};
|
|
5048
5073
|
for (let n of e) {
|
|
5049
5074
|
let e = c ? `${c}_${n}` : `${n}`;
|
|
@@ -5098,7 +5123,7 @@ var wt = class {
|
|
|
5098
5123
|
name: s,
|
|
5099
5124
|
prefix: a
|
|
5100
5125
|
});
|
|
5101
|
-
return e.hasExplicitName = r !== void 0,
|
|
5126
|
+
return e.hasExplicitName = r !== void 0, A(e), ee(e, this), e.ownerModel = this, this._variables.push(e), this.varMapByName.set(e.name, e), this.allVarsMap.set(e.name, e), this.recordModelMutation(), e;
|
|
5102
5127
|
} catch (e) {
|
|
5103
5128
|
throw r === void 0 && (o === void 0 ? this.varPrefixCounters.delete(a) : this.varPrefixCounters.set(a, o)), e;
|
|
5104
5129
|
}
|
|
@@ -5106,12 +5131,12 @@ var wt = class {
|
|
|
5106
5131
|
objective(e) {
|
|
5107
5132
|
if (arguments.length === 0) return this._objectiveExpr.clone();
|
|
5108
5133
|
let t = e;
|
|
5109
|
-
if (t instanceof
|
|
5134
|
+
if (t instanceof R || typeof t == "object" && t && "sense" in t && "lhs" in t && "rhs" in t || typeof t == "string" && /(<=|>=|==|!=|=<|=>|<|>|=)/.test(t)) throw Error("Cannot use a Constraint as an objective. Did you mean to use m.constraint(expr`... <= ...`)? To set an objective, wrap an unconstrained expression with maximize(...) or minimize(...), e.g. m.objective(maximize(expr`30 * ${x}`)).");
|
|
5110
5135
|
if (typeof t != "object" || !t || !("expr" in t) || !("sense" in t)) throw Error("m.objective(...) expects an ObjectiveSpec created with maximize(...) or minimize(...), e.g. m.objective(maximize(expr`30 * ${x}`)).");
|
|
5111
5136
|
return this.applyObjective(t.expr, t.sense), this;
|
|
5112
5137
|
}
|
|
5113
5138
|
applyObjective(t, n) {
|
|
5114
|
-
if (t instanceof
|
|
5139
|
+
if (t instanceof R || typeof t == "object" && t && "sense" in t && "lhs" in t && "rhs" in t || typeof t == "string" && /(<=|>=|==|!=|=<|=>|<|>|=)/.test(t)) throw Error(typeof t == "string" ? "Cannot use a comparison constraint as an objective. Did you mean to use m.constraint(expr`... <= ...`)? To set an objective, wrap an unconstrained expression with maximize(...) or minimize(...), e.g. m.objective(maximize(expr`30 * ${x}`))." : "Cannot use a Constraint as an objective. Did you mean to use m.constraint(expr`... <= ...`)? To set an objective, wrap an unconstrained expression with maximize(...) or minimize(...), e.g. m.objective(maximize(expr`30 * ${x}`)).");
|
|
5115
5140
|
let r = n === void 0 ? this.sense : e(n), i;
|
|
5116
5141
|
if (typeof t == "string") i = ke(t, (e) => this.varMapByName.get(e));
|
|
5117
5142
|
else if (typeof t == "number") i = new G(/* @__PURE__ */ new Map(), t);
|
|
@@ -5125,7 +5150,7 @@ var wt = class {
|
|
|
5125
5150
|
i = new G(e.terms, e.constant, e.nonlinearTerms);
|
|
5126
5151
|
} else if (t instanceof K || typeof t == "object" && t && "id" in t && "name" in t && "lb" in t && "ub" in t) i = new G(/* @__PURE__ */ new Map([[t, 1]]), 0);
|
|
5127
5152
|
else throw Error("Invalid objective expression: expected a finite number, Var, LinExpr, QuadExpr, or arithmetic expression string.");
|
|
5128
|
-
|
|
5153
|
+
P(i, this.name, (e) => this.varMapByName.get(e.name) === e), this._sense = r, this._objectiveExpr = i, this.recordModelMutation();
|
|
5129
5154
|
}
|
|
5130
5155
|
constraint(e, t) {
|
|
5131
5156
|
if (Array.isArray(e)) return this.runTransactionalBatch(() => {
|
|
@@ -5135,13 +5160,13 @@ var wt = class {
|
|
|
5135
5160
|
});
|
|
5136
5161
|
if (e instanceof b || typeof e == "object" && e && "quadTerms" in e) throw Error("Constraint must contain a comparison operator (<=, >=, ==): cannot add a quadratic expression as a constraint.");
|
|
5137
5162
|
if (e instanceof G || typeof e == "object" && e && "terms" in e) throw Error("Constraint must contain a comparison operator (<=, >=, ==): cannot add a linear expression without a comparison operator. Use expr`... <= ...` or .le(), .ge(), .eq().");
|
|
5138
|
-
if (
|
|
5163
|
+
if (Et(e)) throw Error(`Cannot add numeric variable "${e.name}" directly as a constraint without a comparison operator (<=, >=, ==). Numeric variables require a comparison such as expr\`\${x} <= 10\` or x.le(10), whereas propositional BoolVar variables must be created with m.bool().`);
|
|
5139
5164
|
return this.addConstraint(e, t);
|
|
5140
5165
|
}
|
|
5141
5166
|
addConstraint(e, t) {
|
|
5142
5167
|
if (e instanceof b || typeof e == "object" && e && "quadTerms" in e) throw Error("Constraint must contain a comparison operator (<=, >=, ==): cannot add a quadratic expression as a constraint.");
|
|
5143
5168
|
if (e instanceof G || typeof e == "object" && e && "terms" in e) throw Error("Constraint must contain a comparison operator (<=, >=, ==): cannot add a linear expression without a comparison operator. Use expr`... <= ...` or .le(), .ge(), .eq().");
|
|
5144
|
-
if (
|
|
5169
|
+
if (Et(e)) throw Error(`Cannot add numeric variable "${e.name}" directly as a constraint without a comparison operator (<=, >=, ==). Numeric variables require a comparison such as expr\`\${x} <= 10\` or x.le(10), whereas propositional BoolVar variables must be created with m.bool().`);
|
|
5145
5170
|
if (e instanceof r) {
|
|
5146
5171
|
let n = typeof t == "string" && t.trim().length > 0 ? t.trim() : void 0;
|
|
5147
5172
|
if (n !== void 0) {
|
|
@@ -5150,7 +5175,7 @@ var wt = class {
|
|
|
5150
5175
|
}
|
|
5151
5176
|
let r = this.logicalConstrCounter, i = n ?? this.getNextLogicalConstrName();
|
|
5152
5177
|
try {
|
|
5153
|
-
|
|
5178
|
+
I(e, i, this.name, (e) => this.varMapByName.get(e.name) === e, (e) => this.boolVarMapByName.get(e.name) === e, this);
|
|
5154
5179
|
} catch (e) {
|
|
5155
5180
|
throw n === void 0 && (this.logicalConstrCounter = r), e;
|
|
5156
5181
|
}
|
|
@@ -5166,7 +5191,7 @@ var wt = class {
|
|
|
5166
5191
|
}
|
|
5167
5192
|
let n = typeof e == "string" ? Me(e, (e) => this.varMapByName.get(e), t) : e;
|
|
5168
5193
|
if (typeof n != "object" || !n || !("sense" in n) || !("lhs" in n) || !("rhs" in n)) throw Error("Invalid constraint passed to m.constraint(...): expected a linear Constraint (e.g. expr`${x} <= 10` or x.le(10)), a propositional BoolVar/BoolExpr (created with m.bool()), or an array of constraints.");
|
|
5169
|
-
n.ownerModel && n.ownerModel !== this && (
|
|
5194
|
+
n.ownerModel && n.ownerModel !== this && (F(n, this.name, (e) => this.varMapByName.get(e.name) === e, n.name), O(n, this));
|
|
5170
5195
|
let i = typeof t == "string" && t.trim().length > 0 ? t.trim() : n.hasExplicitName ? n.name.trim() : void 0;
|
|
5171
5196
|
if (i !== void 0) {
|
|
5172
5197
|
if (this.hasConstraintName(i)) throw Error(`Constraint with name '${i}' already exists in model`);
|
|
@@ -5174,7 +5199,7 @@ var wt = class {
|
|
|
5174
5199
|
}
|
|
5175
5200
|
let a = this.constrPrefixCounters.get("c"), o = i ?? this.getNextConstrName("c"), s;
|
|
5176
5201
|
try {
|
|
5177
|
-
|
|
5202
|
+
F(n, this.name, (e) => this.varMapByName.get(e.name) === e, o), s = O(n, this);
|
|
5178
5203
|
} catch (e) {
|
|
5179
5204
|
throw i === void 0 && (a === void 0 ? this.constrPrefixCounters.delete("c") : this.constrPrefixCounters.set("c", a)), e;
|
|
5180
5205
|
}
|
|
@@ -5210,7 +5235,7 @@ var wt = class {
|
|
|
5210
5235
|
let t = (e) => this.varMapByName.get(e.name) === e;
|
|
5211
5236
|
for (let [e] of c.terms) if (!t(e)) throw Error(`Variable "${e.name}" in constraint "${d}" does not belong to model "${this.name}". All variables must belong to the model by object identity.`);
|
|
5212
5237
|
if (l === "<=" || l === "==") {
|
|
5213
|
-
let t = n.M === void 0 ? tt(c, u, f) : n.M, r = rt(e, c, "<=", u, a, t, f), i = new
|
|
5238
|
+
let t = n.M === void 0 ? tt(c, u, f) : n.M, r = rt(e, c, "<=", u, a, t, f), i = new R(r.lhs, "<=", r.rhs, f);
|
|
5214
5239
|
n.M === void 0 && i._setIndicatorOrigin({
|
|
5215
5240
|
binVar: e,
|
|
5216
5241
|
activeValue: a,
|
|
@@ -5221,7 +5246,7 @@ var wt = class {
|
|
|
5221
5246
|
}), m.push([i, f]);
|
|
5222
5247
|
}
|
|
5223
5248
|
if (l === ">=" || l === "==") {
|
|
5224
|
-
let t = n.M === void 0 ? nt(c, u, p) : n.M, r = rt(e, c, ">=", u, a, t, p), i = new
|
|
5249
|
+
let t = n.M === void 0 ? nt(c, u, p) : n.M, r = rt(e, c, ">=", u, a, t, p), i = new R(r.lhs, ">=", r.rhs, p);
|
|
5225
5250
|
n.M === void 0 && i._setIndicatorOrigin({
|
|
5226
5251
|
binVar: e,
|
|
5227
5252
|
activeValue: a,
|
|
@@ -5231,7 +5256,7 @@ var wt = class {
|
|
|
5231
5256
|
derivedM: t
|
|
5232
5257
|
}), m.push([i, p]);
|
|
5233
5258
|
}
|
|
5234
|
-
for (let [e, n] of m)
|
|
5259
|
+
for (let [e, n] of m) F(e, this.name, t, n);
|
|
5235
5260
|
} catch (e) {
|
|
5236
5261
|
throw s === void 0 ? this.constrPrefixCounters.delete("c") : this.constrPrefixCounters.set("c", s), e;
|
|
5237
5262
|
}
|
|
@@ -5261,7 +5286,7 @@ var wt = class {
|
|
|
5261
5286
|
return e;
|
|
5262
5287
|
}
|
|
5263
5288
|
validateIntegrityInternal() {
|
|
5264
|
-
|
|
5289
|
+
re({
|
|
5265
5290
|
model: this,
|
|
5266
5291
|
name: this.name,
|
|
5267
5292
|
variables: this._variables,
|
|
@@ -5279,14 +5304,27 @@ var wt = class {
|
|
|
5279
5304
|
if (this.modelRevision !== e) throw this.activeOperationId === t && this.clearSolutionFields(), Error(`Model "${this.name}" was modified while ${n}() was in progress; stale solver result was discarded.`);
|
|
5280
5305
|
if (this.activeOperationId !== t) throw Error(`Stale ${n}() result discarded because a newer solve or check operation was started on model "${this.name}".`);
|
|
5281
5306
|
}
|
|
5282
|
-
wrapSolveOptions(e, t, n) {
|
|
5283
|
-
let
|
|
5284
|
-
return
|
|
5285
|
-
...
|
|
5286
|
-
onProgress: (
|
|
5287
|
-
this.activeOperationId ===
|
|
5307
|
+
wrapSolveOptions(e, t, n, r, i) {
|
|
5308
|
+
let a = t.onProgress;
|
|
5309
|
+
return a ? {
|
|
5310
|
+
...t,
|
|
5311
|
+
onProgress: (o) => {
|
|
5312
|
+
if (this.activeOperationId === r && this.modelRevision === n) {
|
|
5313
|
+
if (i && typeof o.objectiveValue == "number" && Number.isFinite(o.objectiveValue)) {
|
|
5314
|
+
let n = this.normalizeObjectiveValue(o.objectiveValue, e, t);
|
|
5315
|
+
if (!Object.is(n, o.objectiveValue)) {
|
|
5316
|
+
let e = typeof o.objectiveBound == "number" && Number.isFinite(o.objectiveBound), t = e ? Math.abs(n - o.objectiveBound) + 0 : void 0, r = {
|
|
5317
|
+
...o,
|
|
5318
|
+
objectiveValue: n
|
|
5319
|
+
};
|
|
5320
|
+
e && "absoluteGap" in o && o.absoluteGap !== void 0 && (r.absoluteGap = t), e && "relativeGap" in o && o.relativeGap !== void 0 && (t === 0 ? r.relativeGap = 0 : Math.abs(n) > 0 && t !== void 0 ? r.relativeGap = t / Math.abs(n) : delete r.relativeGap), a(r);
|
|
5321
|
+
return;
|
|
5322
|
+
}
|
|
5323
|
+
}
|
|
5324
|
+
a(o);
|
|
5325
|
+
}
|
|
5288
5326
|
}
|
|
5289
|
-
} :
|
|
5327
|
+
} : t;
|
|
5290
5328
|
}
|
|
5291
5329
|
hasPrimalFromResult(e) {
|
|
5292
5330
|
if (typeof e.hasPrimalSolution == "boolean") return e.hasPrimalSolution;
|
|
@@ -5294,7 +5332,14 @@ var wt = class {
|
|
|
5294
5332
|
return t !== "Infeasible" && t !== "Unsat" && t !== "Unbounded" && t !== "Error" && t !== "NotSolved" && n !== "Infeasible" && n !== "Unsat" && n !== "Unbounded" && n !== "InfeasibleOrUnbounded" && n !== "Error" && n !== "NotSolved" && (t === "Optimal" || t === "Feasible" || t === "Sat" || n === "Optimal" || n === "Feasible" || n === "Sat" || typeof e.objectiveValue == "number" && Number.isFinite(e.objectiveValue) || Object.values(r).some((e) => typeof e == "number" && Number.isFinite(e) || typeof e == "boolean") || Object.values(i).some((e) => typeof e == "boolean"));
|
|
5295
5333
|
}
|
|
5296
5334
|
normalizePrimalValue(e, t, n, r) {
|
|
5297
|
-
return (r.relax ?? n.options?.relax) !== !0 && (e
|
|
5335
|
+
return (r.relax ?? n.options?.relax) !== !0 && bt(e) && Math.abs(t - Math.round(t)) <= 1e-5 ? Math.round(t) + 0 : t;
|
|
5336
|
+
}
|
|
5337
|
+
normalizeObjectiveValue(e, t, n) {
|
|
5338
|
+
if ((n.relax ?? t.options?.relax) !== !0 && Ct(this._objectiveExpr)) {
|
|
5339
|
+
let t = Math.round(e);
|
|
5340
|
+
if (Number.isSafeInteger(t) && Math.abs(e - t) <= 1e-5) return t + 0;
|
|
5341
|
+
}
|
|
5342
|
+
return e;
|
|
5298
5343
|
}
|
|
5299
5344
|
resolveSolverAndOptions(e, t) {
|
|
5300
5345
|
if (e && typeof e == "object" && "solve" in e && typeof e.solve == "function") {
|
|
@@ -5363,7 +5408,7 @@ var wt = class {
|
|
|
5363
5408
|
logicalConstraints: this._logicalConstraints,
|
|
5364
5409
|
boolVars: this._boolVars
|
|
5365
5410
|
}, this._variables.some((e) => e.initialValue !== void 0) && i.capabilities?.supportsWarmStart !== !0) throw Error(`Solver "${i.name}" does not support primal initial values (initialValue). Please use a solver with warm-start support such as HiGHS or Pumpkin.`);
|
|
5366
|
-
let c = this.wrapSolveOptions(a, r, n), l;
|
|
5411
|
+
let c = this.wrapSolveOptions(i, a, r, n, !0), l;
|
|
5367
5412
|
try {
|
|
5368
5413
|
l = await i.solve(o, c);
|
|
5369
5414
|
} catch (e) {
|
|
@@ -5371,28 +5416,32 @@ var wt = class {
|
|
|
5371
5416
|
}
|
|
5372
5417
|
this.ensureExecutionValid(r, n, "solve"), this.runTime = l.runTime ?? 0, this.status = l.status, this.terminationStatus = l.terminationStatus ?? l.status;
|
|
5373
5418
|
let u = this.hasPrimalFromResult(l);
|
|
5374
|
-
this.hasPrimalSolution = u
|
|
5375
|
-
let d = typeof l.
|
|
5376
|
-
this.
|
|
5377
|
-
let
|
|
5419
|
+
this.hasPrimalSolution = u;
|
|
5420
|
+
let d = (a.relax ?? i.options?.relax) !== !0 && Ct(this._objectiveExpr), f = u && typeof l.objectiveValue == "number" && Number.isFinite(l.objectiveValue) ? l.objectiveValue : null;
|
|
5421
|
+
this.objectiveValue = f === null ? null : this.normalizeObjectiveValue(f, i, a);
|
|
5422
|
+
let p = typeof l.objectiveBound == "number" && Number.isFinite(l.objectiveBound) ? l.objectiveBound : void 0;
|
|
5423
|
+
this.objectiveBound = d && this.status === "Optimal" && this.objectiveValue !== null && p !== void 0 && Math.abs(p - this.objectiveValue) <= 1e-5 ? this.objectiveValue : p;
|
|
5424
|
+
let m = typeof l.relativeGap == "number" && Number.isFinite(l.relativeGap) ? l.relativeGap : void 0, h = f !== null && this.objectiveValue !== null && !Object.is(f, this.objectiveValue), g = p !== void 0 && this.objectiveBound !== void 0 && !Object.is(p, this.objectiveBound);
|
|
5425
|
+
this.absoluteGap = (h || g) && this.objectiveValue !== null && this.objectiveBound !== void 0 ? Math.abs(this.objectiveValue - this.objectiveBound) + 0 : typeof l.absoluteGap == "number" && Number.isFinite(l.absoluteGap) ? l.absoluteGap : this.objectiveValue !== null && this.objectiveBound !== void 0 ? Math.abs(this.objectiveValue - this.objectiveBound) : void 0, this.relativeGap = (h || g) && m !== void 0 && this.objectiveValue !== null && this.absoluteGap !== void 0 ? this.absoluteGap === 0 ? 0 : Math.abs(this.objectiveValue) > 0 ? this.absoluteGap / Math.abs(this.objectiveValue) : void 0 : m;
|
|
5426
|
+
let _ = (e, t, n) => {
|
|
5378
5427
|
Object.defineProperty(e, t, {
|
|
5379
5428
|
value: n,
|
|
5380
5429
|
enumerable: !0,
|
|
5381
5430
|
writable: !0,
|
|
5382
5431
|
configurable: !0
|
|
5383
5432
|
});
|
|
5384
|
-
},
|
|
5433
|
+
}, v = {}, y = {}, x = {}, S = {};
|
|
5385
5434
|
if (this._values.clear(), u && l.values) {
|
|
5386
5435
|
for (let [e, t] of Object.entries(l.values)) if (typeof t == "number" && Number.isFinite(t)) {
|
|
5387
5436
|
let n = this.varMapByName.get(e), r = this.boolVarMapByName.get(e);
|
|
5388
5437
|
if (n) {
|
|
5389
5438
|
let e = this.normalizePrimalValue(n, t, i, a);
|
|
5390
|
-
n.value = e,
|
|
5439
|
+
n.value = e, _(v, n.name, e), this._values.set(n.name, e);
|
|
5391
5440
|
}
|
|
5392
5441
|
r && (r.value = !!t, this._values.set(r.name, t)), !n && !r && !s && this._values.set(e, t);
|
|
5393
5442
|
} else if (typeof t == "boolean") {
|
|
5394
5443
|
let n = t, r = this.boolVarMapByName.get(e);
|
|
5395
|
-
r ? (r.value = n,
|
|
5444
|
+
r ? (r.value = n, _(v, r.name, +!!n), this._values.set(r.name, n)) : this._values.set(e, n);
|
|
5396
5445
|
}
|
|
5397
5446
|
if (s) for (let e of this._boolVars) {
|
|
5398
5447
|
let t = s.boolVarToBinary.get(e);
|
|
@@ -5400,7 +5449,7 @@ var wt = class {
|
|
|
5400
5449
|
let n = l.values[t.name];
|
|
5401
5450
|
if (typeof n == "number" && Number.isFinite(n)) {
|
|
5402
5451
|
let t = Math.round(n) === 1;
|
|
5403
|
-
e.value = t,
|
|
5452
|
+
e.value = t, _(v, e.name, +!!t), this._values.set(e.name, t);
|
|
5404
5453
|
}
|
|
5405
5454
|
}
|
|
5406
5455
|
}
|
|
@@ -5413,17 +5462,17 @@ var wt = class {
|
|
|
5413
5462
|
if (u && l.reducedCosts) for (let [e, t] of Object.entries(l.reducedCosts)) {
|
|
5414
5463
|
if (typeof t != "number" || !Number.isFinite(t)) continue;
|
|
5415
5464
|
let n = this.varMapByName.get(e);
|
|
5416
|
-
n && (n.reducedCost = t,
|
|
5465
|
+
n && (n.reducedCost = t, _(x, n.name, t));
|
|
5417
5466
|
}
|
|
5418
5467
|
if (l.duals) for (let [e, t] of Object.entries(l.duals)) {
|
|
5419
5468
|
if (typeof t != "number" || !Number.isFinite(t)) continue;
|
|
5420
5469
|
let n = this.constrMapByName.get(e);
|
|
5421
|
-
n && (n.dual = t,
|
|
5470
|
+
n && (n.dual = t, _(y, n.name, t));
|
|
5422
5471
|
}
|
|
5423
5472
|
if (l.slacks) for (let [e, t] of Object.entries(l.slacks)) {
|
|
5424
5473
|
if (typeof t != "number" || !Number.isFinite(t)) continue;
|
|
5425
5474
|
let n = this.constrMapByName.get(e);
|
|
5426
|
-
n && (n.slack = t,
|
|
5475
|
+
n && (n.slack = t, _(S, n.name, t));
|
|
5427
5476
|
}
|
|
5428
5477
|
return this.solution = {
|
|
5429
5478
|
status: this.status,
|
|
@@ -5433,10 +5482,10 @@ var wt = class {
|
|
|
5433
5482
|
...this.objectiveBound === void 0 ? {} : { objectiveBound: this.objectiveBound },
|
|
5434
5483
|
...this.relativeGap === void 0 ? {} : { relativeGap: this.relativeGap },
|
|
5435
5484
|
...this.absoluteGap === void 0 ? {} : { absoluteGap: this.absoluteGap },
|
|
5436
|
-
values:
|
|
5437
|
-
duals:
|
|
5438
|
-
reducedCosts:
|
|
5439
|
-
slacks:
|
|
5485
|
+
values: v,
|
|
5486
|
+
duals: y,
|
|
5487
|
+
reducedCosts: x,
|
|
5488
|
+
slacks: S,
|
|
5440
5489
|
runTime: this.runTime,
|
|
5441
5490
|
raw: l.raw
|
|
5442
5491
|
}, this.hasSolutionState = !0, this.status;
|
|
@@ -5446,7 +5495,7 @@ var wt = class {
|
|
|
5446
5495
|
this.clearSolutionFields(), this.validateIntegrityInternal();
|
|
5447
5496
|
let { activeSolver: i, activeOptions: a } = this.resolveSolverAndOptions(e, t);
|
|
5448
5497
|
if (this._variables.some((e) => e.initialValue !== void 0) && i.capabilities?.supportsWarmStart !== !0) throw Error(`Solver "${i.name}" does not support primal initial values (initialValue). Please use a solver with warm-start support such as HiGHS or Pumpkin.`);
|
|
5449
|
-
let o = this.wrapSolveOptions(a, r, n), s = (e, t, n) => {
|
|
5498
|
+
let o = this.wrapSolveOptions(i, a, r, n, !1), s = (e, t, n) => {
|
|
5450
5499
|
Object.defineProperty(e, t, {
|
|
5451
5500
|
value: n,
|
|
5452
5501
|
enumerable: !0,
|
|
@@ -5508,7 +5557,7 @@ var wt = class {
|
|
|
5508
5557
|
});
|
|
5509
5558
|
d.push(r), f.push([r, 1]), p.set(r, t);
|
|
5510
5559
|
let a = n.clone().add(new G(/* @__PURE__ */ new Map([[r, -1]]), 0));
|
|
5511
|
-
u.push(new
|
|
5560
|
+
u.push(new R(a, "<=", i, `${e.name}_slack`));
|
|
5512
5561
|
} else if (r === ">=") {
|
|
5513
5562
|
let r = new K({
|
|
5514
5563
|
name: `__slack_${++m}`,
|
|
@@ -5518,7 +5567,7 @@ var wt = class {
|
|
|
5518
5567
|
});
|
|
5519
5568
|
d.push(r), f.push([r, 1]), p.set(r, t);
|
|
5520
5569
|
let a = n.clone().add(new G(/* @__PURE__ */ new Map([[r, 1]]), 0));
|
|
5521
|
-
u.push(new
|
|
5570
|
+
u.push(new R(a, ">=", i, `${e.name}_slack`));
|
|
5522
5571
|
} else {
|
|
5523
5572
|
let r = new K({
|
|
5524
5573
|
name: `__slack_${++m}_p`,
|
|
@@ -5533,7 +5582,7 @@ var wt = class {
|
|
|
5533
5582
|
});
|
|
5534
5583
|
d.push(r, a), f.push([r, 1], [a, 1]), p.set(r, t), p.set(a, t);
|
|
5535
5584
|
let o = n.clone().add(new G(/* @__PURE__ */ new Map([[r, -1], [a, 1]]), 0));
|
|
5536
|
-
u.push(new
|
|
5585
|
+
u.push(new R(o, "==", i, `${e.name}_slack`));
|
|
5537
5586
|
}
|
|
5538
5587
|
}
|
|
5539
5588
|
let h = {
|
|
@@ -5586,7 +5635,7 @@ var wt = class {
|
|
|
5586
5635
|
}
|
|
5587
5636
|
link(e) {
|
|
5588
5637
|
if (e instanceof b || typeof e == "object" && e && "quadTerms" in e) throw Error("Linking constraint cannot be a quadratic expression.");
|
|
5589
|
-
if (!(e instanceof
|
|
5638
|
+
if (!(e instanceof R) && (typeof e != "object" || !e || !("sense" in e) || !("lhs" in e) || !("rhs" in e))) throw Error("Linking constraint must contain a comparison operator (<=, >=, ==). Use expr`... <= ...` or .le(), .ge(), .eq().");
|
|
5590
5639
|
this._linkingConstraints ||= [];
|
|
5591
5640
|
let t = e;
|
|
5592
5641
|
return this._linkingConstraints.push(t), t;
|
|
@@ -5610,4 +5659,4 @@ var wt = class {
|
|
|
5610
5659
|
}
|
|
5611
5660
|
};
|
|
5612
5661
|
//#endregion
|
|
5613
|
-
export { r as BoolExpr, a as BoolOp, i as BoolVar,
|
|
5662
|
+
export { r as BoolExpr, a as BoolOp, i as BoolVar, R as Constraint, d as GlobalConstraint, G as LinExpr, Ye as MockSolver, Ot as Model, b as QuadExpr, K as Var, se as abs, v as allowed, o as and, fe as at, rt as buildIndicatorLinearization, ze as buildLpSymbolMaps, _ as cumulative, nt as deriveBigMForGe, tt as deriveBigMForLe, g as disjoint, m as distinct, oe as dot, Ie as expr, Be as generateLpString, qe as getSolver, l as implies, Le as isLpExportResult, st as linearizeModelForMip, Je as listAvailableSolvers, ue as max, ft as maximize, de as min, pt as minimize, e as normalizeSense, c as not, s as or, Me as parseConstraint, ke as parseExpr, Ge as registerSolver, Re as sanitizeIdentifier, Ke as setDefaultSolver, _t as solveBenders, ut as solveColumnGeneration, ae as sum, $e as validateUserBigM, u as xor };
|