@ohtaman/washi 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +55 -20
- package/README.md +55 -20
- package/README.zh-CN.md +55 -20
- package/THIRD_PARTY_LICENSES.md +3 -4
- package/dist/browser/_washi-node-only-BvRk9kiK.js +0 -0
- package/dist/browser/browser-runtime-TLCY0hkc.js +1793 -0
- package/dist/browser/highs-worker.js +1 -1
- package/dist/browser/highs.wasm +0 -0
- package/dist/browser/highs.wasm.LICENSE +1 -2
- package/dist/browser/loader-DewlSho8.js +643 -0
- package/dist/browser/solvers/glpk.js +1 -1
- package/dist/browser/solvers/glpk.min.js +1 -1
- package/dist/browser/solvers/z3.js +7 -1
- package/dist/browser/solvers/z3.min.js +1 -1
- package/dist/browser/washi.js +1096 -444
- package/dist/browser/washi.min.js +3 -4
- package/dist/lib/_washi-node-only-BvRk9kiK.js +0 -0
- package/dist/lib/highs-browser-runtime.js +2120 -4124
- package/dist/lib/highs-node-runtime.js +24 -1
- package/dist/lib/highs-runtime.js +2 -0
- package/dist/lib/highs-worker.js +1 -1
- package/dist/lib/highs.wasm +0 -0
- package/dist/lib/highs.wasm.LICENSE +1 -2
- package/dist/lib/loader-BZUQNvh4.js +649 -0
- package/dist/lib/{registry-BEfvpZW3.js → registry-C20sxTwm.js} +54 -41
- package/dist/lib/solvers/glpk.js +2 -2
- package/dist/lib/solvers/z3.js +1 -1
- package/dist/lib/washi.js +973 -305
- package/dist/types/decomposition/benders.d.ts +32 -0
- package/dist/types/decomposition/benders.d.ts.map +1 -0
- package/dist/types/decomposition/column-generation.d.ts +34 -0
- package/dist/types/decomposition/column-generation.d.ts.map +1 -0
- package/dist/types/decomposition/index.d.ts +4 -0
- package/dist/types/decomposition/index.d.ts.map +1 -0
- package/dist/types/decomposition/types.d.ts +230 -0
- package/dist/types/decomposition/types.d.ts.map +1 -0
- package/dist/types/index.d.ts +4 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/modeler/boolean-expr.d.ts.map +1 -1
- package/dist/types/modeler/constraint.d.ts +11 -0
- package/dist/types/modeler/constraint.d.ts.map +1 -1
- package/dist/types/modeler/expression.d.ts +10 -0
- package/dist/types/modeler/expression.d.ts.map +1 -1
- package/dist/types/modeler/index.d.ts +2 -1
- package/dist/types/modeler/index.d.ts.map +1 -1
- package/dist/types/modeler/linearizer.d.ts +15 -0
- package/dist/types/modeler/linearizer.d.ts.map +1 -0
- package/dist/types/modeler/lp-writer.d.ts +3 -1
- package/dist/types/modeler/lp-writer.d.ts.map +1 -1
- package/dist/types/modeler/model.d.ts +147 -2
- package/dist/types/modeler/model.d.ts.map +1 -1
- package/dist/types/modeler/solvers/highs/browser-runtime.d.ts +2 -1
- package/dist/types/modeler/solvers/highs/browser-runtime.d.ts.map +1 -1
- package/dist/types/modeler/solvers/highs/driver.d.ts +232 -0
- package/dist/types/modeler/solvers/highs/driver.d.ts.map +1 -0
- package/dist/types/modeler/solvers/highs/index.d.ts +1 -0
- package/dist/types/modeler/solvers/highs/index.d.ts.map +1 -1
- package/dist/types/modeler/solvers/highs/loader.d.ts +4 -4
- package/dist/types/modeler/solvers/highs/loader.d.ts.map +1 -1
- package/dist/types/modeler/solvers/highs/node-runtime.d.ts +2 -1
- package/dist/types/modeler/solvers/highs/node-runtime.d.ts.map +1 -1
- package/dist/types/modeler/solvers/highs/solver.d.ts +1 -1
- package/dist/types/modeler/solvers/highs/solver.d.ts.map +1 -1
- package/dist/types/modeler/solvers/types.d.ts +2 -0
- package/dist/types/modeler/solvers/types.d.ts.map +1 -1
- package/dist/types/modeler/types.d.ts +27 -0
- package/dist/types/modeler/types.d.ts.map +1 -1
- package/docs/examples/index.md +4 -0
- package/docs/examples/traveling-salesperson.md +173 -0
- package/docs/examples/vehicle-routing.md +206 -0
- package/docs/getting-started/ai-agents.md +8 -4
- package/docs/guide/constraints.md +1 -1
- package/docs/guide/decomposition.md +399 -0
- package/docs/guide/unsat-core.md +10 -3
- package/docs/ja/getting-started/ai-agents.md +8 -4
- package/docs/solvers/custom-solver.md +1 -1
- package/docs/solvers/highs.md +25 -3
- package/docs/solvers/index.md +3 -3
- package/docs/zh/getting-started/ai-agents.md +8 -4
- package/llms-full.txt +831 -15
- package/llms.txt +9 -5
- package/package.json +17 -14
- package/skills/washi/SKILL.md +8 -8
- package/dist/browser/browser-runtime-D13gHOT5.js +0 -4189
- package/dist/browser/loader-CtaDHef_.js +0 -273
- package/dist/lib/loader-DmNC_UNk.js +0 -279
package/dist/lib/washi.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { A as e, C as t, D as n, E as r, M as i, N as a, O as o, S as s, T as c, _ as l, a as u, b as d, c as f, d as p, f as m, g as h, h as g, i as _, j as v, k as y, l as b, m as x, n as S, o as C, p as w, r as T, s as E, t as D, u as O, v as k, w as A, x as j, y as ee } from "./registry-
|
|
2
|
-
import { a as M, c as N,
|
|
3
|
-
import { createHighsWorker as
|
|
1
|
+
import { A as e, C as t, D as n, E as r, M as i, N as a, O as o, S as s, T as c, _ as l, a as u, b as d, c as f, d as p, f as m, g as h, h as g, i as _, j as v, k as y, l as b, m as x, n as S, o as C, p as w, r as T, s as E, t as D, u as O, v as k, w as A, x as j, y as ee } from "./registry-C20sxTwm.js";
|
|
2
|
+
import { a as M, c as N, d as P, f as te, h as ne, i as re, l as ie, m as ae, n as oe, o as F, p as se, r as I, s as L, t as ce, u as le } from "./loader-BZUQNvh4.js";
|
|
3
|
+
import { createHighsWorker as ue } from "./highs-worker-factory.js";
|
|
4
4
|
//#region \0rolldown/runtime.js
|
|
5
|
-
var
|
|
5
|
+
var de = Object.defineProperty, fe = Object.getOwnPropertyDescriptor, pe = Object.getOwnPropertyNames, me = Object.prototype.hasOwnProperty, he = (e, t) => {
|
|
6
6
|
let n = {};
|
|
7
|
-
for (var r in e)
|
|
7
|
+
for (var r in e) de(n, r, {
|
|
8
8
|
get: e[r],
|
|
9
9
|
enumerable: !0
|
|
10
10
|
});
|
|
11
|
-
return t ||
|
|
12
|
-
},
|
|
13
|
-
if (t && typeof t == "object" || typeof t == "function") for (var i =
|
|
11
|
+
return t || de(n, Symbol.toStringTag, { value: "Module" }), n;
|
|
12
|
+
}, ge = (e, t, n, r) => {
|
|
13
|
+
if (t && typeof t == "object" || typeof t == "function") for (var i = pe(t), a = 0, o = i.length, s; a < o; a++) s = i[a], !me.call(e, s) && s !== n && de(e, s, {
|
|
14
14
|
get: ((e) => t[e]).bind(null, s),
|
|
15
|
-
enumerable: !(r =
|
|
15
|
+
enumerable: !(r = fe(t, s)) || r.enumerable
|
|
16
16
|
});
|
|
17
17
|
return e;
|
|
18
|
-
},
|
|
18
|
+
}, R = (e, t, n) => (ge(e, t, "default"), n && ge(n, t, "default"));
|
|
19
19
|
//#endregion
|
|
20
20
|
//#region src/modeler/types.ts
|
|
21
|
-
function
|
|
21
|
+
function _e(e) {
|
|
22
22
|
if (e === void 0) return "Minimize";
|
|
23
23
|
if (typeof e == "string") {
|
|
24
24
|
let t = e.toLowerCase();
|
|
@@ -29,8 +29,8 @@ function le(e) {
|
|
|
29
29
|
}
|
|
30
30
|
//#endregion
|
|
31
31
|
//#region src/modeler/parser.ts
|
|
32
|
-
var
|
|
33
|
-
function
|
|
32
|
+
var ve = /^(?:[0-9]+(?:\.[0-9]+)?|\.[0-9]+)(?:[eE][+-]?[0-9]+)?$/;
|
|
33
|
+
function ye(e, t) {
|
|
34
34
|
let n = [], r = 0, i = e.length;
|
|
35
35
|
for (; r < i;) {
|
|
36
36
|
let a = e[r];
|
|
@@ -86,7 +86,7 @@ function de(e, t) {
|
|
|
86
86
|
for (; r < i && (e[r] === "." || e[r] === "e" || e[r] === "E" || /[0-9]/.test(e[r]));) a += e[r++];
|
|
87
87
|
}
|
|
88
88
|
} else for (; r < i && (e[r] === "." || /[0-9]/.test(e[r]));) a += e[r++];
|
|
89
|
-
if (!
|
|
89
|
+
if (!ve.test(a)) throw Error(`Invalid numeric literal '${a}' at position ${t} in: "${e}"`);
|
|
90
90
|
let o = Number(a);
|
|
91
91
|
if (!Number.isFinite(o)) throw Error(`Numeric literal '${a}' overflows finite floating-point range in: "${e}"`);
|
|
92
92
|
if (o === 0 && !/^[0.]+(?:[eE][+-]?\d+)?$/.test(a)) throw Error(`Numeric literal '${a}' underflows to zero at position ${t} in: "${e}"`);
|
|
@@ -113,7 +113,7 @@ function de(e, t) {
|
|
|
113
113
|
}
|
|
114
114
|
return n;
|
|
115
115
|
}
|
|
116
|
-
var
|
|
116
|
+
var be = class {
|
|
117
117
|
tokens;
|
|
118
118
|
pos = 0;
|
|
119
119
|
resolver;
|
|
@@ -214,15 +214,15 @@ var fe = class {
|
|
|
214
214
|
return t;
|
|
215
215
|
}
|
|
216
216
|
};
|
|
217
|
-
function
|
|
218
|
-
let r = new
|
|
217
|
+
function xe(e, t, n) {
|
|
218
|
+
let r = new be(ye(e, n), t), i = r.parseExpression(), a = r.getRemainingToken();
|
|
219
219
|
if (a) throw Error(`Unexpected token '${a.value}' after expression in "${e}"`);
|
|
220
|
-
return
|
|
220
|
+
return Ee(i), i;
|
|
221
221
|
}
|
|
222
|
-
function
|
|
223
|
-
return
|
|
222
|
+
function Se(e, t) {
|
|
223
|
+
return xe(e, t);
|
|
224
224
|
}
|
|
225
|
-
function
|
|
225
|
+
function Ce(e, t, n, r) {
|
|
226
226
|
let i = e.match(/(<=|>=|==|=<|=>|=)/);
|
|
227
227
|
if (!i) throw Error(`Constraint must contain a comparison operator (<=, >=, ==, =): "${e}"`);
|
|
228
228
|
let a = i[0], o = i.index, s = e.substring(0, o).trim(), c = e.substring(o + a.length).trim(), l;
|
|
@@ -230,19 +230,19 @@ function me(e, t, n, r) {
|
|
|
230
230
|
else if (a === ">=" || a === "=>") l = ">=";
|
|
231
231
|
else if (a === "==" || a === "=") l = "==";
|
|
232
232
|
else throw Error(`Unsupported operator "${a}"`);
|
|
233
|
-
let u =
|
|
233
|
+
let u = xe(s, t, r), d = xe(c, t, r);
|
|
234
234
|
if (u instanceof A && u.quadTerms.size > 0 || d instanceof A && d.quadTerms.size > 0) throw Error("Quadratic constraints are not supported (only linear constraints are allowed in MILP/LP/QP)");
|
|
235
235
|
let f = u instanceof A ? new j(u.linearTerms, u.constant) : u, p = d instanceof A ? new j(d.linearTerms, d.constant) : d, m;
|
|
236
|
-
if (m = l === "<=" ? f.le(p, n) : l === ">=" ? f.ge(p, n) : f.eq(p, n),
|
|
236
|
+
if (m = l === "<=" ? f.le(p, n) : l === ">=" ? f.ge(p, n) : f.eq(p, n), Ee(m.lhs), !Number.isFinite(m.rhs)) throw Error(`Invalid non-finite right-hand side "${m.rhs}" in constraint.`);
|
|
237
237
|
return m;
|
|
238
238
|
}
|
|
239
|
-
function
|
|
240
|
-
return
|
|
239
|
+
function we(e, t, n) {
|
|
240
|
+
return Ce(e, t, n);
|
|
241
241
|
}
|
|
242
|
-
function
|
|
242
|
+
function Te(e) {
|
|
243
243
|
return e instanceof b || e instanceof j || e instanceof A ? !0 : typeof e != "object" || !e ? !1 : "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 && "type" in e && typeof e.mul == "function";
|
|
244
244
|
}
|
|
245
|
-
function
|
|
245
|
+
function Ee(e) {
|
|
246
246
|
if ("constant" in e && !Number.isFinite(e.constant)) throw Error(`Invalid non-finite constant "${e.constant}" in expression.`);
|
|
247
247
|
if ("terms" in e && e.terms instanceof Map) {
|
|
248
248
|
for (let [, t] of e.terms) if (!Number.isFinite(t)) throw Error(`Invalid non-finite coefficient "${t}" in expression.`);
|
|
@@ -254,10 +254,10 @@ function _e(e) {
|
|
|
254
254
|
for (let [, t] of e.quadTerms) if (!Number.isFinite(t.coeff)) throw Error(`Invalid non-finite quadratic coefficient "${t.coeff}" in expression.`);
|
|
255
255
|
}
|
|
256
256
|
}
|
|
257
|
-
function
|
|
257
|
+
function De(e) {
|
|
258
258
|
return e instanceof c || typeof e == "object" && !!e && "sense" in e && "lhs" in e && "rhs" in e;
|
|
259
259
|
}
|
|
260
|
-
function
|
|
260
|
+
function Oe(e, t) {
|
|
261
261
|
let n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), i = e.join(""), a = "__washi_";
|
|
262
262
|
for (; i.includes(a);) a += "_";
|
|
263
263
|
let o = "";
|
|
@@ -267,9 +267,9 @@ function ye(e, t) {
|
|
|
267
267
|
if (!Number.isFinite(e)) throw Error(`Invalid numeric value "${e}" in template expression: interpolated numbers must be finite.`);
|
|
268
268
|
let t = `${a}num_${i}__`;
|
|
269
269
|
r.set(t, e), o += `(${t})`;
|
|
270
|
-
} else if (
|
|
271
|
-
else if (
|
|
272
|
-
|
|
270
|
+
} else if (De(e)) throw Error("Cannot interpolate a constraint comparison (<=, >=, ==) inside a template expression: expected a finite number, Var, LinExpr, or QuadExpr.");
|
|
271
|
+
else if (Te(e)) {
|
|
272
|
+
Ee(e);
|
|
273
273
|
let t = `${a}ph_${i}__`;
|
|
274
274
|
n.set(t, e), o += ` ${t} `;
|
|
275
275
|
} else throw Error("Unsupported interpolation value in template expression: expected a finite number, Var, LinExpr, or QuadExpr.");
|
|
@@ -280,14 +280,14 @@ function ye(e, t) {
|
|
|
280
280
|
numberMap: r
|
|
281
281
|
};
|
|
282
282
|
}
|
|
283
|
-
function
|
|
284
|
-
let { fullText: n, resolver: r, numberMap: i } =
|
|
285
|
-
return /(<=|>=|==|=<|=>|=)/.test(n) ?
|
|
283
|
+
function ke(e, ...t) {
|
|
284
|
+
let { fullText: n, resolver: r, numberMap: i } = Oe(e, t);
|
|
285
|
+
return /(<=|>=|==|=<|=>|=)/.test(n) ? Ce(n, r, void 0, i) : xe(n, r, i);
|
|
286
286
|
}
|
|
287
287
|
//#endregion
|
|
288
288
|
//#region src/modeler/solvers/highs/worker-client.ts
|
|
289
|
-
var
|
|
290
|
-
function
|
|
289
|
+
var z = null, Ae = 0, B = /* @__PURE__ */ new Map();
|
|
290
|
+
function je(e, t) {
|
|
291
291
|
return e ? {
|
|
292
292
|
Status: "Interrupted",
|
|
293
293
|
StatusCode: 17,
|
|
@@ -311,8 +311,8 @@ function Se(e, t) {
|
|
|
311
311
|
Rows: []
|
|
312
312
|
};
|
|
313
313
|
}
|
|
314
|
-
function
|
|
315
|
-
let t =
|
|
314
|
+
function Me(e) {
|
|
315
|
+
let t = B.values().next().value;
|
|
316
316
|
if (t && !t.dispatched) {
|
|
317
317
|
t.dispatched = !0;
|
|
318
318
|
try {
|
|
@@ -324,30 +324,30 @@ function U(e) {
|
|
|
324
324
|
...t.reportProgress ? { reportProgress: !0 } : {}
|
|
325
325
|
});
|
|
326
326
|
} catch (n) {
|
|
327
|
-
|
|
327
|
+
B.delete(t.id), t.cleanupAbort?.(), t.reject(n), Me(e);
|
|
328
328
|
}
|
|
329
329
|
}
|
|
330
330
|
}
|
|
331
|
-
function
|
|
332
|
-
let e =
|
|
333
|
-
e && (
|
|
334
|
-
for (let e of
|
|
335
|
-
if (
|
|
336
|
-
let e =
|
|
337
|
-
if (e)
|
|
331
|
+
function Ne() {
|
|
332
|
+
let e = z;
|
|
333
|
+
e && (z = null, e.terminate());
|
|
334
|
+
for (let e of B.values()) e.dispatched = !1;
|
|
335
|
+
if (B.size > 0) {
|
|
336
|
+
let e = Pe();
|
|
337
|
+
if (e) Me(e);
|
|
338
338
|
else {
|
|
339
339
|
let e = /* @__PURE__ */ Error("[WaSHI] Failed to recreate HiGHS Worker after interruption.");
|
|
340
|
-
for (let t of Array.from(
|
|
340
|
+
for (let t of Array.from(B.values())) B.delete(t.id), t.cleanupAbort?.(), t.reject(e);
|
|
341
341
|
}
|
|
342
342
|
}
|
|
343
343
|
}
|
|
344
|
-
function
|
|
344
|
+
function Pe() {
|
|
345
345
|
if (typeof window > "u" || typeof Worker > "u") return null;
|
|
346
|
-
if (!
|
|
347
|
-
|
|
348
|
-
let e =
|
|
349
|
-
|
|
350
|
-
let { type: n, id: r, result: i, runTime: a, error: o, progress: s, incumbent: c } = t.data, l =
|
|
346
|
+
if (!z) try {
|
|
347
|
+
z = ue();
|
|
348
|
+
let e = z;
|
|
349
|
+
z.onmessage = (t) => {
|
|
350
|
+
let { type: n, id: r, result: i, runTime: a, error: o, progress: s, incumbent: c } = t.data, l = B.get(r);
|
|
351
351
|
if (l) {
|
|
352
352
|
if (n === "SOLVE_PROGRESS") {
|
|
353
353
|
if (s) {
|
|
@@ -355,10 +355,10 @@ function we() {
|
|
|
355
355
|
try {
|
|
356
356
|
l.onProgress?.(s);
|
|
357
357
|
} catch (e) {
|
|
358
|
-
let t =
|
|
358
|
+
let t = B.get(r);
|
|
359
359
|
if (t) {
|
|
360
|
-
let n =
|
|
361
|
-
|
|
360
|
+
let n = B.keys().next().value;
|
|
361
|
+
B.delete(r), t.cleanupAbort?.(), n === r && Ne(), t.reject(e);
|
|
362
362
|
}
|
|
363
363
|
}
|
|
364
364
|
}
|
|
@@ -368,41 +368,41 @@ function we() {
|
|
|
368
368
|
c && (l.lastIncumbent = c);
|
|
369
369
|
return;
|
|
370
370
|
}
|
|
371
|
-
|
|
371
|
+
B.delete(r), l.cleanupAbort?.(), n === "SOLVE_SUCCESS" ? l.resolve({
|
|
372
372
|
result: i,
|
|
373
373
|
runTime: a
|
|
374
|
-
}) : l.reject(Error(o || "Worker solve failed")),
|
|
374
|
+
}) : l.reject(Error(o || "Worker solve failed")), z === e && Me(e);
|
|
375
375
|
}
|
|
376
376
|
};
|
|
377
377
|
let t = (t) => {
|
|
378
|
-
if (
|
|
379
|
-
|
|
380
|
-
for (let e of
|
|
381
|
-
|
|
378
|
+
if (z === e) {
|
|
379
|
+
z = null, e.terminate();
|
|
380
|
+
for (let e of B.values()) e.cleanupAbort?.(), e.reject(t);
|
|
381
|
+
B.clear();
|
|
382
382
|
}
|
|
383
383
|
};
|
|
384
|
-
|
|
384
|
+
z.onerror = (e) => t(/* @__PURE__ */ Error(`[WaSHI] HiGHS Worker failed to load or execute. Check Worker assets, CORS and CSP. ${e?.message || ""}`)), z.onmessageerror = () => t(/* @__PURE__ */ Error("[WaSHI] Could not deserialize the HiGHS Worker response."));
|
|
385
385
|
} catch {
|
|
386
|
-
|
|
386
|
+
z = null;
|
|
387
387
|
}
|
|
388
|
-
return
|
|
388
|
+
return z;
|
|
389
389
|
}
|
|
390
|
-
async function
|
|
390
|
+
async function V(e, t = {}) {
|
|
391
391
|
if (t.signal?.aborted) return {
|
|
392
|
-
result:
|
|
392
|
+
result: je(),
|
|
393
393
|
runTime: 0
|
|
394
394
|
};
|
|
395
|
-
let n = await
|
|
395
|
+
let n = await F(t.wasmUrl);
|
|
396
396
|
if (t.signal?.aborted) return {
|
|
397
|
-
result:
|
|
397
|
+
result: je(),
|
|
398
398
|
runTime: 0
|
|
399
399
|
};
|
|
400
|
-
let r = t.useWorker ?? typeof window < "u" ?
|
|
400
|
+
let r = t.useWorker ?? typeof window < "u" ? Pe() : null;
|
|
401
401
|
if (!r) return N(e, t);
|
|
402
402
|
let { signal: i, onProgress: a, ...o } = t, s = {};
|
|
403
403
|
for (let [e, t] of Object.entries(o)) typeof t != "function" && (s[e] = t);
|
|
404
404
|
s.wasmUrl = n;
|
|
405
|
-
let c = !!(a || i), l = `req_${++
|
|
405
|
+
let c = !!(a || i), l = `req_${++Ae}`, u = performance.now();
|
|
406
406
|
return new Promise((t, n) => {
|
|
407
407
|
let o = {
|
|
408
408
|
id: l,
|
|
@@ -416,24 +416,24 @@ async function W(e, t = {}) {
|
|
|
416
416
|
};
|
|
417
417
|
if (i) {
|
|
418
418
|
let e = () => {
|
|
419
|
-
let e =
|
|
419
|
+
let e = B.get(l);
|
|
420
420
|
if (!e) return;
|
|
421
|
-
let t =
|
|
422
|
-
|
|
421
|
+
let t = B.keys().next().value;
|
|
422
|
+
B.delete(l), e.cleanupAbort?.(), t === l && Ne();
|
|
423
423
|
let n = (performance.now() - e.startTime) / 1e3;
|
|
424
424
|
e.resolve({
|
|
425
|
-
result:
|
|
425
|
+
result: je(e.lastIncumbent, e.lastProgress),
|
|
426
426
|
runTime: n
|
|
427
427
|
});
|
|
428
428
|
};
|
|
429
429
|
i.addEventListener("abort", e, { once: !0 }), o.cleanupAbort = () => i.removeEventListener("abort", e);
|
|
430
430
|
}
|
|
431
|
-
|
|
431
|
+
B.set(l, o), Me(r);
|
|
432
432
|
});
|
|
433
433
|
}
|
|
434
434
|
//#endregion
|
|
435
435
|
//#region src/modeler/solvers/highs/solver.ts
|
|
436
|
-
function
|
|
436
|
+
function H(e, t) {
|
|
437
437
|
if (typeof t == "number") switch (t) {
|
|
438
438
|
case 0: return "NotSolved";
|
|
439
439
|
case 1:
|
|
@@ -492,8 +492,8 @@ function G(e, t) {
|
|
|
492
492
|
let r = n.toLowerCase();
|
|
493
493
|
return r.includes("infeasible") && r.includes("unbounded") ? "InfeasibleOrUnbounded" : r.includes("infeasible") ? "Infeasible" : r.includes("unbounded") ? "Unbounded" : r.includes("time limit") || r.includes("timelimit") ? "TimeLimit" : r.includes("iteration limit") || r.includes("iterationlimit") ? "IterationLimit" : r.includes("solution limit") || r.includes("solutionlimit") ? "SolutionLimit" : r.includes("memory limit") || r.includes("memorylimit") ? "MemoryLimit" : r.includes("bound on objective") ? "ObjectiveBound" : r.includes("target for objective") ? "ObjectiveTarget" : r.includes("interrupt") ? "Interrupted" : r.includes("error") ? "Error" : r === "optimal" ? "Optimal" : "Unknown";
|
|
494
494
|
}
|
|
495
|
-
function
|
|
496
|
-
switch (
|
|
495
|
+
function U(e, t, n) {
|
|
496
|
+
switch (H(e, t)) {
|
|
497
497
|
case "Optimal": return "Optimal";
|
|
498
498
|
case "Infeasible": return "Infeasible";
|
|
499
499
|
case "Unbounded": return "Unbounded";
|
|
@@ -510,14 +510,14 @@ function K(e, t, n) {
|
|
|
510
510
|
default: return "Unknown";
|
|
511
511
|
}
|
|
512
512
|
}
|
|
513
|
-
var
|
|
513
|
+
var W = class e {
|
|
514
514
|
static capabilities = {
|
|
515
515
|
supportsMIP: !0,
|
|
516
516
|
supportsQP: !0,
|
|
517
517
|
supportsWarmStart: !0
|
|
518
518
|
};
|
|
519
519
|
name = "HiGHS";
|
|
520
|
-
version = "1.15.
|
|
520
|
+
version = "1.15.1";
|
|
521
521
|
capabilities = e.capabilities;
|
|
522
522
|
options;
|
|
523
523
|
constructor(e = {}) {
|
|
@@ -529,7 +529,7 @@ var q = class e {
|
|
|
529
529
|
...i
|
|
530
530
|
}, o = e.objective.constant || 0;
|
|
531
531
|
for (let t of e.variables) d(t);
|
|
532
|
-
let { lpString: s, nameToVar: c, nameToConstraint: l } = r ? t : C(e), u = Object.create(null), p = !1, m = /* @__PURE__ */ new Set();
|
|
532
|
+
let { lpString: s, nameToVar: c, nameToConstraint: l } = r ? t : C(e, { relax: a.relax }), u = Object.create(null), p = !1, m = /* @__PURE__ */ new Set();
|
|
533
533
|
for (let [e, t] of c.entries()) {
|
|
534
534
|
m.add(t);
|
|
535
535
|
let n = w(t);
|
|
@@ -551,13 +551,13 @@ var q = class e {
|
|
|
551
551
|
...o === 0 ? {} : { objectiveOffset: o },
|
|
552
552
|
initialValues: p ? u : void 0
|
|
553
553
|
});
|
|
554
|
-
let { result: g, runTime: _ } = await
|
|
554
|
+
let { result: g, runTime: _ } = await V(s, h), v = g?.ObjectiveOffsetApplied ? 0 : o, y = H(g?.Status, g?.StatusCode), b = a.relax ? !1 : typeof g?.IsMip == "boolean" ? g.IsMip : e.variables.some((e) => e.type === "Integer" || e.type === "Binary"), x;
|
|
555
555
|
if (typeof g?.HasPrimalSolution == "boolean") x = g.HasPrimalSolution;
|
|
556
556
|
else {
|
|
557
557
|
let e = g?.Columns ? Object.values(g.Columns) : [], t = e.length > 0 && e.some((e) => typeof e?.Primal == "number" && Number.isFinite(e.Primal)), n = typeof g?.ObjectiveValue == "number" && Number.isFinite(g.ObjectiveValue);
|
|
558
558
|
x = y === "Infeasible" || y === "Unbounded" || y === "InfeasibleOrUnbounded" || y === "Error" || y === "NotSolved" ? !1 : y === "Optimal" || y === "Feasible" ? n || t : n && (e.length === 0 || t);
|
|
559
559
|
}
|
|
560
|
-
let S =
|
|
560
|
+
let S = U(g?.Status, g?.StatusCode, x), T = null;
|
|
561
561
|
x && typeof g?.ObjectiveValue == "number" && Number.isFinite(g.ObjectiveValue) && (T = g.ObjectiveValue + v);
|
|
562
562
|
let D, O, k;
|
|
563
563
|
if (typeof g?.MipDualBound == "number" && Number.isFinite(g.MipDualBound) ? D = g.MipDualBound + v : !b && y === "Optimal" && T !== null && (D = T), T !== null && D !== void 0 && Number.isFinite(D) && (k = Math.abs(T - D)), v !== 0 && b && T !== null && D !== void 0 && k !== void 0) {
|
|
@@ -632,55 +632,69 @@ var q = class e {
|
|
|
632
632
|
raw: g
|
|
633
633
|
};
|
|
634
634
|
}
|
|
635
|
-
},
|
|
636
|
-
function
|
|
637
|
-
T("highs", (e) => new
|
|
635
|
+
}, G = W;
|
|
636
|
+
function K() {
|
|
637
|
+
T("highs", (e) => new W(e)), _((e) => new W(e));
|
|
638
638
|
}
|
|
639
|
-
|
|
639
|
+
K();
|
|
640
640
|
//#endregion
|
|
641
641
|
//#region src/modeler/solvers/highs/index.ts
|
|
642
|
-
var
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
642
|
+
var Fe = /* @__PURE__ */ he({
|
|
643
|
+
HIGHS_CONSTANTS: () => ie,
|
|
644
|
+
HIGHS_STATUS_NAMES: () => le,
|
|
645
|
+
HiGHS: () => G,
|
|
646
|
+
Highs: () => P,
|
|
647
|
+
HighsError: () => te,
|
|
648
|
+
HighsModel: () => se,
|
|
649
|
+
HighsSolver: () => W,
|
|
650
|
+
HighsUnsupportedOptionError: () => ae,
|
|
651
|
+
OFFICIAL_HIGHS_CDN_WASM_URL: () => ce,
|
|
652
|
+
bindHighsFunctions: () => ne,
|
|
653
|
+
getHighs: () => oe,
|
|
654
|
+
getHighsWasmUrl: () => I,
|
|
655
|
+
isValidWasmHeader: () => re,
|
|
656
|
+
mapHighsStatus: () => U,
|
|
657
|
+
mapHighsTerminationStatus: () => H,
|
|
651
658
|
probeWasmUrl: () => M,
|
|
652
|
-
registerHighsSolver: () =>
|
|
653
|
-
resolveBrowserWasmUrl: () =>
|
|
654
|
-
setHighsWasmUrl: () =>
|
|
655
|
-
solveLp: () =>
|
|
659
|
+
registerHighsSolver: () => K,
|
|
660
|
+
resolveBrowserWasmUrl: () => F,
|
|
661
|
+
setHighsWasmUrl: () => L,
|
|
662
|
+
solveLp: () => V,
|
|
656
663
|
solveLpWithHighs: () => N
|
|
657
664
|
});
|
|
658
|
-
import * as
|
|
659
|
-
|
|
660
|
-
import * as
|
|
661
|
-
|
|
665
|
+
import * as Ie from "./highs-worker-factory.js";
|
|
666
|
+
R(Fe, Ie);
|
|
667
|
+
import * as Le from "./highs-assets.js";
|
|
668
|
+
R(Fe, Le);
|
|
662
669
|
//#endregion
|
|
663
670
|
//#region src/modeler/solvers/highs.ts
|
|
664
|
-
var
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
671
|
+
var Re = /* @__PURE__ */ he({
|
|
672
|
+
HIGHS_CONSTANTS: () => ie,
|
|
673
|
+
HIGHS_STATUS_NAMES: () => le,
|
|
674
|
+
HiGHS: () => G,
|
|
675
|
+
Highs: () => P,
|
|
676
|
+
HighsError: () => te,
|
|
677
|
+
HighsModel: () => se,
|
|
678
|
+
HighsSolver: () => W,
|
|
679
|
+
HighsUnsupportedOptionError: () => ae,
|
|
680
|
+
OFFICIAL_HIGHS_CDN_WASM_URL: () => ce,
|
|
681
|
+
bindHighsFunctions: () => ne,
|
|
682
|
+
getHighs: () => oe,
|
|
683
|
+
getHighsWasmUrl: () => I,
|
|
684
|
+
isValidWasmHeader: () => re,
|
|
685
|
+
mapHighsStatus: () => U,
|
|
686
|
+
mapHighsTerminationStatus: () => H,
|
|
673
687
|
probeWasmUrl: () => M,
|
|
674
|
-
registerHighsSolver: () =>
|
|
675
|
-
resolveBrowserWasmUrl: () =>
|
|
676
|
-
setHighsWasmUrl: () =>
|
|
677
|
-
solveLp: () =>
|
|
688
|
+
registerHighsSolver: () => K,
|
|
689
|
+
resolveBrowserWasmUrl: () => F,
|
|
690
|
+
setHighsWasmUrl: () => L,
|
|
691
|
+
solveLp: () => V,
|
|
678
692
|
solveLpWithHighs: () => N
|
|
679
693
|
});
|
|
680
|
-
|
|
694
|
+
R(Re, Fe);
|
|
681
695
|
//#endregion
|
|
682
696
|
//#region src/modeler/solvers/mock.ts
|
|
683
|
-
var
|
|
697
|
+
var ze = class {
|
|
684
698
|
name;
|
|
685
699
|
capabilities;
|
|
686
700
|
options;
|
|
@@ -780,44 +794,51 @@ var ke = class {
|
|
|
780
794
|
};
|
|
781
795
|
}
|
|
782
796
|
};
|
|
783
|
-
function
|
|
784
|
-
T("mock", (e) => new
|
|
797
|
+
function Be() {
|
|
798
|
+
T("mock", (e) => new ze(e));
|
|
785
799
|
}
|
|
786
|
-
|
|
800
|
+
Be();
|
|
787
801
|
//#endregion
|
|
788
802
|
//#region src/modeler/solvers/index.ts
|
|
789
|
-
var
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
803
|
+
var Ve = /* @__PURE__ */ he({
|
|
804
|
+
HIGHS_CONSTANTS: () => ie,
|
|
805
|
+
HIGHS_STATUS_NAMES: () => le,
|
|
806
|
+
HiGHS: () => G,
|
|
807
|
+
Highs: () => P,
|
|
808
|
+
HighsError: () => te,
|
|
809
|
+
HighsModel: () => se,
|
|
810
|
+
HighsSolver: () => W,
|
|
811
|
+
HighsUnsupportedOptionError: () => ae,
|
|
812
|
+
MockSolver: () => ze,
|
|
813
|
+
OFFICIAL_HIGHS_CDN_WASM_URL: () => ce,
|
|
814
|
+
bindHighsFunctions: () => ne,
|
|
815
|
+
getHighs: () => oe,
|
|
816
|
+
getHighsWasmUrl: () => I,
|
|
796
817
|
getSolver: () => D,
|
|
797
|
-
isValidWasmHeader: () =>
|
|
818
|
+
isValidWasmHeader: () => re,
|
|
798
819
|
listAvailableSolvers: () => S,
|
|
799
|
-
mapHighsStatus: () =>
|
|
800
|
-
mapHighsTerminationStatus: () =>
|
|
820
|
+
mapHighsStatus: () => U,
|
|
821
|
+
mapHighsTerminationStatus: () => H,
|
|
801
822
|
probeWasmUrl: () => M,
|
|
802
|
-
registerHighsSolver: () =>
|
|
803
|
-
registerMockSolver: () =>
|
|
823
|
+
registerHighsSolver: () => K,
|
|
824
|
+
registerMockSolver: () => Be,
|
|
804
825
|
registerSolver: () => T,
|
|
805
|
-
resolveBrowserWasmUrl: () =>
|
|
826
|
+
resolveBrowserWasmUrl: () => F,
|
|
806
827
|
setDefaultSolver: () => _,
|
|
807
|
-
setHighsWasmUrl: () =>
|
|
808
|
-
solveLp: () =>
|
|
828
|
+
setHighsWasmUrl: () => L,
|
|
829
|
+
solveLp: () => V,
|
|
809
830
|
solveLpWithHighs: () => N
|
|
810
831
|
});
|
|
811
|
-
|
|
832
|
+
R(Ve, Re);
|
|
812
833
|
//#endregion
|
|
813
834
|
//#region src/modeler/solution-validator.ts
|
|
814
|
-
function
|
|
835
|
+
function He(e, t) {
|
|
815
836
|
if (e === void 0) return 1e-6;
|
|
816
837
|
if (typeof e != "number" || !Number.isFinite(e) || e < 0) throw Error(`Invalid ${t}: expected a finite non-negative number, received ${String(e)}.`);
|
|
817
838
|
return e;
|
|
818
839
|
}
|
|
819
|
-
function
|
|
820
|
-
let r =
|
|
840
|
+
function Ue(e, t = {}) {
|
|
841
|
+
let r = He(t.feasibilityTolerance, "feasibilityTolerance"), i = He(t.integralityTolerance, "integralityTolerance"), a = t.evaluateLogicalConstraints === void 0 || !!t.evaluateLogicalConstraints, s = t.values !== void 0 && t.values !== null;
|
|
821
842
|
if (t.values !== void 0 && (typeof t.values != "object" || t.values === null || Array.isArray(t.values))) throw Error("Invalid values option: expected a plain object mapping variable names to values.");
|
|
822
843
|
let l = t.values, u = [], d = Object.create(null), f = [], p = [], m = 0, h = (e) => {
|
|
823
844
|
typeof e == "number" && !Number.isNaN(e) && e > m && (m = e);
|
|
@@ -1191,10 +1212,10 @@ function Ne(e, t = {}) {
|
|
|
1191
1212
|
}
|
|
1192
1213
|
//#endregion
|
|
1193
1214
|
//#region src/modeler/big-m.ts
|
|
1194
|
-
function
|
|
1215
|
+
function We(e, t) {
|
|
1195
1216
|
if (typeof e != "number" || !Number.isFinite(e) || e <= 0) throw Error(`Invalid Big-M value for indicator constraint "${t}": expected a finite positive number, received ${e}.`);
|
|
1196
1217
|
}
|
|
1197
|
-
function
|
|
1218
|
+
function Ge(e, t, n) {
|
|
1198
1219
|
let r = e.constant === void 0 ? 0 : e.constant;
|
|
1199
1220
|
if (!Number.isFinite(t) || !Number.isFinite(r)) throw Error(`Cannot derive safe Big-M for indicator constraint "${n}": constraint contains non-finite constant (${r}) or right-hand side (${t}).`);
|
|
1200
1221
|
let i = t - r;
|
|
@@ -1205,8 +1226,8 @@ function Fe(e, t, n) {
|
|
|
1205
1226
|
}
|
|
1206
1227
|
return i;
|
|
1207
1228
|
}
|
|
1208
|
-
function
|
|
1209
|
-
let r =
|
|
1229
|
+
function q(e, t, n) {
|
|
1230
|
+
let r = Ge(e, t, n), i = 0;
|
|
1210
1231
|
for (let [t, r] of e.terms) {
|
|
1211
1232
|
if (r === 0) continue;
|
|
1212
1233
|
let e;
|
|
@@ -1226,8 +1247,8 @@ function Ie(e, t, n) {
|
|
|
1226
1247
|
if (!Number.isFinite(o) || !Number.isFinite(r + o)) throw Error(`Cannot derive safe Big-M for indicator constraint "${n}": derived Big-M (${o}) or shifted right-hand side overflows finite floating-point range. Please rescale coefficients/bounds or specify a finite { M } explicitly.`);
|
|
1227
1248
|
return o;
|
|
1228
1249
|
}
|
|
1229
|
-
function
|
|
1230
|
-
let r =
|
|
1250
|
+
function J(e, t, n) {
|
|
1251
|
+
let r = Ge(e, t, n), i = 0;
|
|
1231
1252
|
for (let [t, r] of e.terms) {
|
|
1232
1253
|
if (r === 0) continue;
|
|
1233
1254
|
let e;
|
|
@@ -1247,10 +1268,10 @@ function Le(e, t, n) {
|
|
|
1247
1268
|
if (!Number.isFinite(o) || !Number.isFinite(r - o)) throw Error(`Cannot derive safe Big-M for indicator constraint "${n}": derived Big-M (${o}) or shifted right-hand side overflows finite floating-point range. Please rescale coefficients/bounds or specify a finite { M } explicitly.`);
|
|
1248
1269
|
return o;
|
|
1249
1270
|
}
|
|
1250
|
-
function
|
|
1271
|
+
function Y(e, t, n, r, i, a, o) {
|
|
1251
1272
|
if (!(e instanceof b && (e.type === "Binary" || e.type === "Integer" && e.lb === 0 && e.ub === 1))) throw Error(`Indicator variable "${e?.name ?? String(e)}" must be a Binary variable (or Integer variable with bounds [0, 1]), received "${e?.type ?? typeof e}" with bounds [${e?.lb}, ${e?.ub}].`);
|
|
1252
1273
|
if (!Number.isFinite(e.lb) || !Number.isFinite(e.ub) || e.lb < 0 || e.ub > 1 || e.lb > e.ub) throw Error(`Binary indicator variable "${e.name}" has invalid bounds [${e.lb}, ${e.ub}]. Binary variables must stay within [0, 1] with lb <= ub.`);
|
|
1253
|
-
let s =
|
|
1274
|
+
let s = Ge(t, r, o);
|
|
1254
1275
|
if (i !== 0 && i !== 1) throw Error(`Invalid activeValue: ${i}. Indicator activation value must be 0 or 1.`);
|
|
1255
1276
|
if (n !== "<=" && n !== ">=") throw Error(`Invalid indicator sense for "${o}": expected "<=" or ">=", received "${String(n)}".`);
|
|
1256
1277
|
if (!Number.isFinite(a) || a < 0) throw Error(`Invalid Big-M value for indicator constraint "${o}": expected a finite non-negative number, received ${a}.`);
|
|
@@ -1266,6 +1287,527 @@ function X(e, t, n, r, i, a, o) {
|
|
|
1266
1287
|
};
|
|
1267
1288
|
}
|
|
1268
1289
|
//#endregion
|
|
1290
|
+
//#region src/modeler/linearizer.ts
|
|
1291
|
+
function X(e, t = 0) {
|
|
1292
|
+
return new j(new Map(e), t);
|
|
1293
|
+
}
|
|
1294
|
+
function Ke(e, t, r, i) {
|
|
1295
|
+
let a = [...e], s = [...r], l = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map();
|
|
1296
|
+
for (let e of r) u.set(e, e.name);
|
|
1297
|
+
let d = new Set(e.map((e) => e.name)), f = 0;
|
|
1298
|
+
function p(e) {
|
|
1299
|
+
let t;
|
|
1300
|
+
do
|
|
1301
|
+
t = `__washi_${e}_${++f}`;
|
|
1302
|
+
while (d.has(t));
|
|
1303
|
+
return d.add(t), t;
|
|
1304
|
+
}
|
|
1305
|
+
for (let e of t) {
|
|
1306
|
+
let t = e.name;
|
|
1307
|
+
d.has(t) ? t = p(`bool_${e.name}`) : d.add(t);
|
|
1308
|
+
let n = new b({
|
|
1309
|
+
name: t,
|
|
1310
|
+
type: "Binary",
|
|
1311
|
+
lb: 0,
|
|
1312
|
+
ub: 1
|
|
1313
|
+
});
|
|
1314
|
+
l.set(e, n), a.push(n);
|
|
1315
|
+
}
|
|
1316
|
+
function m(e, t) {
|
|
1317
|
+
if (e instanceof qe) return e.wrappedVar;
|
|
1318
|
+
if (e instanceof o) {
|
|
1319
|
+
let n = l.get(e);
|
|
1320
|
+
if (!n) throw Error(`Unregistered BoolVar "${e.name}" in logical constraint "${t}".`);
|
|
1321
|
+
return n;
|
|
1322
|
+
}
|
|
1323
|
+
let n = new b({
|
|
1324
|
+
name: p("expr"),
|
|
1325
|
+
type: "Binary",
|
|
1326
|
+
lb: 0,
|
|
1327
|
+
ub: 1
|
|
1328
|
+
});
|
|
1329
|
+
return a.push(n), g(n, e, t), n;
|
|
1330
|
+
}
|
|
1331
|
+
function h(e, t, n, r) {
|
|
1332
|
+
let i = new c(X([
|
|
1333
|
+
[e, 1],
|
|
1334
|
+
[t, -1],
|
|
1335
|
+
[n, -1]
|
|
1336
|
+
], 0), "<=", 0, `${r}_xor_1`), a = new c(X([
|
|
1337
|
+
[e, 1],
|
|
1338
|
+
[t, -1],
|
|
1339
|
+
[n, 1]
|
|
1340
|
+
], 0), ">=", 0, `${r}_xor_2`), o = new c(X([
|
|
1341
|
+
[e, 1],
|
|
1342
|
+
[n, -1],
|
|
1343
|
+
[t, 1]
|
|
1344
|
+
], 0), ">=", 0, `${r}_xor_3`), l = new c(X([
|
|
1345
|
+
[e, 1],
|
|
1346
|
+
[t, 1],
|
|
1347
|
+
[n, 1]
|
|
1348
|
+
], 0), "<=", 2, `${r}_xor_4`);
|
|
1349
|
+
s.push(i, a, o, l), u.set(i, r), u.set(a, r), u.set(o, r), u.set(l, r);
|
|
1350
|
+
}
|
|
1351
|
+
function g(e, t, r) {
|
|
1352
|
+
if (t instanceof o) {
|
|
1353
|
+
let n = l.get(t), i = new c(X([[e, 1], [n, -1]], 0), "==", 0, `${r}_equiv`);
|
|
1354
|
+
s.push(i), u.set(i, r);
|
|
1355
|
+
return;
|
|
1356
|
+
}
|
|
1357
|
+
if (t instanceof n) {
|
|
1358
|
+
if (t.op === "not") {
|
|
1359
|
+
let n = m(t.children[0], r), i = new c(X([[e, 1], [n, 1]], 0), "==", 1, `${r}_not`);
|
|
1360
|
+
s.push(i), u.set(i, r);
|
|
1361
|
+
return;
|
|
1362
|
+
}
|
|
1363
|
+
if (t.op === "and") {
|
|
1364
|
+
let n = t.children.map((e) => m(e, r));
|
|
1365
|
+
for (let t = 0; t < n.length; t++) {
|
|
1366
|
+
let i = new c(X([[e, 1], [n[t], -1]], 0), "<=", 0, `${r}_and_ub_${t}`);
|
|
1367
|
+
s.push(i), u.set(i, r);
|
|
1368
|
+
}
|
|
1369
|
+
let i = [[e, 1], ...n.map((e) => [e, -1])], a = new c(X(i, 0), ">=", 1 - n.length, `${r}_and_lb`);
|
|
1370
|
+
s.push(a), u.set(a, r);
|
|
1371
|
+
return;
|
|
1372
|
+
}
|
|
1373
|
+
if (t.op === "or") {
|
|
1374
|
+
let n = t.children.map((e) => m(e, r));
|
|
1375
|
+
for (let t = 0; t < n.length; t++) {
|
|
1376
|
+
let i = new c(X([[e, 1], [n[t], -1]], 0), ">=", 0, `${r}_or_lb_${t}`);
|
|
1377
|
+
s.push(i), u.set(i, r);
|
|
1378
|
+
}
|
|
1379
|
+
let i = [[e, 1], ...n.map((e) => [e, -1])], a = new c(X(i, 0), "<=", 0, `${r}_or_ub`);
|
|
1380
|
+
s.push(a), u.set(a, r);
|
|
1381
|
+
return;
|
|
1382
|
+
}
|
|
1383
|
+
if (t.op === "implies") {
|
|
1384
|
+
let n = m(t.children[0], r), i = m(t.children[1], r), a = new c(X([
|
|
1385
|
+
[e, 1],
|
|
1386
|
+
[i, -1],
|
|
1387
|
+
[n, 1]
|
|
1388
|
+
], 0), ">=", 0, `${r}_imp_1`), o = new c(X([
|
|
1389
|
+
[e, 1],
|
|
1390
|
+
[n, 1],
|
|
1391
|
+
[i, -1]
|
|
1392
|
+
], 0), "<=", 1, `${r}_imp_2`);
|
|
1393
|
+
s.push(a, o), u.set(a, r), u.set(o, r);
|
|
1394
|
+
return;
|
|
1395
|
+
}
|
|
1396
|
+
if (t.op === "xor") {
|
|
1397
|
+
if (t.children.length === 0) {
|
|
1398
|
+
let t = new c(X([[e, 1]], 0), "==", 0, `${r}_xor_empty`);
|
|
1399
|
+
s.push(t), u.set(t, r);
|
|
1400
|
+
return;
|
|
1401
|
+
}
|
|
1402
|
+
if (t.children.length === 1) {
|
|
1403
|
+
let n = m(t.children[0], r), i = new c(X([[e, 1], [n, -1]], 0), "==", 0, `${r}_xor_single`);
|
|
1404
|
+
s.push(i), u.set(i, r);
|
|
1405
|
+
return;
|
|
1406
|
+
}
|
|
1407
|
+
let n = t.children.map((e) => m(e, r)), i = n[0];
|
|
1408
|
+
for (let e = 1; e < n.length - 1; e++) {
|
|
1409
|
+
let t = new b({
|
|
1410
|
+
name: p(`xor_fold_${e}`),
|
|
1411
|
+
type: "Binary",
|
|
1412
|
+
lb: 0,
|
|
1413
|
+
ub: 1
|
|
1414
|
+
});
|
|
1415
|
+
a.push(t), h(t, i, n[e], `${r}_xor_fold_${e}`), i = t;
|
|
1416
|
+
}
|
|
1417
|
+
h(e, i, n[n.length - 1], r);
|
|
1418
|
+
return;
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
throw Error(`Unsupported logical element in equivalence linearization: ${t}`);
|
|
1422
|
+
}
|
|
1423
|
+
for (let e of i) {
|
|
1424
|
+
let t = e.name, n = e.expr;
|
|
1425
|
+
_(n, t);
|
|
1426
|
+
}
|
|
1427
|
+
function _(e, t) {
|
|
1428
|
+
if (e instanceof o) {
|
|
1429
|
+
let n = l.get(e), r = new c(X([[n, 1]], 0), ">=", 1, t);
|
|
1430
|
+
s.push(r), u.set(r, t);
|
|
1431
|
+
return;
|
|
1432
|
+
}
|
|
1433
|
+
if (e instanceof n) {
|
|
1434
|
+
if (e.op === "not") {
|
|
1435
|
+
let n = e.children[0];
|
|
1436
|
+
if (n instanceof o) {
|
|
1437
|
+
let e = l.get(n), r = new c(X([[e, 1]], 0), "<=", 0, t);
|
|
1438
|
+
s.push(r), u.set(r, t);
|
|
1439
|
+
return;
|
|
1440
|
+
}
|
|
1441
|
+
let r = m(n, t), i = new c(X([[r, 1]], 0), "<=", 0, t);
|
|
1442
|
+
s.push(i), u.set(i, t);
|
|
1443
|
+
return;
|
|
1444
|
+
}
|
|
1445
|
+
if (e.op === "and") {
|
|
1446
|
+
for (let n = 0; n < e.children.length; n++) _(e.children[n], `${t}_and_${n}`);
|
|
1447
|
+
return;
|
|
1448
|
+
}
|
|
1449
|
+
if (e.op === "or") {
|
|
1450
|
+
if (e.children.every((e) => e instanceof o || e instanceof n)) {
|
|
1451
|
+
let n = e.children.map((e) => m(e, t)).map((e) => [e, 1]), r = new c(X(n, 0), ">=", 1, t);
|
|
1452
|
+
s.push(r), u.set(r, t);
|
|
1453
|
+
return;
|
|
1454
|
+
}
|
|
1455
|
+
let r = [];
|
|
1456
|
+
for (let n = 0; n < e.children.length; n++) {
|
|
1457
|
+
let i = e.children[n], o = new b({
|
|
1458
|
+
name: p(`or_branch_${n}`),
|
|
1459
|
+
type: "Binary",
|
|
1460
|
+
lb: 0,
|
|
1461
|
+
ub: 1
|
|
1462
|
+
});
|
|
1463
|
+
if (a.push(o), r.push(o), i instanceof c) v(o, i, 1, `${t}_or_branch_${n}`, t);
|
|
1464
|
+
else {
|
|
1465
|
+
let e = m(i, t), r = new c(X([[o, 1], [e, -1]], 0), "<=", 0, `${t}_or_bool_${n}`);
|
|
1466
|
+
s.push(r), u.set(r, t);
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
let i = r.map((e) => [e, 1]), l = new c(X(i, 0), ">=", 1, t);
|
|
1470
|
+
s.push(l), u.set(l, t);
|
|
1471
|
+
return;
|
|
1472
|
+
}
|
|
1473
|
+
if (e.op === "xor") {
|
|
1474
|
+
if (e.children.length === 0) {
|
|
1475
|
+
let e = new b({
|
|
1476
|
+
name: p("unsat"),
|
|
1477
|
+
type: "Binary",
|
|
1478
|
+
lb: 0,
|
|
1479
|
+
ub: 0
|
|
1480
|
+
});
|
|
1481
|
+
a.push(e);
|
|
1482
|
+
let n = new c(X([[e, 1]], 0), ">=", 1, t);
|
|
1483
|
+
s.push(n), u.set(n, t);
|
|
1484
|
+
return;
|
|
1485
|
+
}
|
|
1486
|
+
if (e.children.length === 1) {
|
|
1487
|
+
_(e.children[0], t);
|
|
1488
|
+
return;
|
|
1489
|
+
}
|
|
1490
|
+
let n = e.children.map((e) => m(e, t));
|
|
1491
|
+
if (n.length === 2) {
|
|
1492
|
+
let e = new c(X([[n[0], 1], [n[1], 1]], 0), "==", 1, t);
|
|
1493
|
+
s.push(e), u.set(e, t);
|
|
1494
|
+
return;
|
|
1495
|
+
}
|
|
1496
|
+
let r = n[0];
|
|
1497
|
+
for (let e = 1; e < n.length - 1; e++) {
|
|
1498
|
+
let i = new b({
|
|
1499
|
+
name: p(`xor_fold_${e}`),
|
|
1500
|
+
type: "Binary",
|
|
1501
|
+
lb: 0,
|
|
1502
|
+
ub: 1
|
|
1503
|
+
});
|
|
1504
|
+
a.push(i), h(i, r, n[e], `${t}_xor_fold_${e}`), r = i;
|
|
1505
|
+
}
|
|
1506
|
+
let i = n[n.length - 1], o = new c(X([[r, 1], [i, 1]], 0), "==", 1, t);
|
|
1507
|
+
s.push(o), u.set(o, t);
|
|
1508
|
+
return;
|
|
1509
|
+
}
|
|
1510
|
+
if (e.op === "implies") {
|
|
1511
|
+
let [r, i] = e.children;
|
|
1512
|
+
if (r instanceof c && r.lhs.terms.size === 1 && r.lhs.constant === 0) {
|
|
1513
|
+
let [[e, n]] = Array.from(r.lhs.terms.entries());
|
|
1514
|
+
if ((e.type === "Binary" || e.type === "Integer" && e.lb === 0 && e.ub === 1) && n === 1) {
|
|
1515
|
+
let n = null;
|
|
1516
|
+
if (r.sense === "==" && r.rhs === 1 ? n = 1 : r.sense === "==" && r.rhs === 0 || r.sense === "<=" && r.rhs === 0 ? n = 0 : r.sense === ">=" && r.rhs === 1 && (n = 1), n !== null && i instanceof c) {
|
|
1517
|
+
v(e, i, n, t, t);
|
|
1518
|
+
return;
|
|
1519
|
+
}
|
|
1520
|
+
}
|
|
1521
|
+
}
|
|
1522
|
+
let d;
|
|
1523
|
+
if (r instanceof c ? (d = new b({
|
|
1524
|
+
name: p("ante"),
|
|
1525
|
+
type: "Binary",
|
|
1526
|
+
lb: 0,
|
|
1527
|
+
ub: 1
|
|
1528
|
+
}), a.push(d), v(d, r, 1, `${t}_ante_active`, t)) : d = m(r, t), i instanceof c) {
|
|
1529
|
+
v(d, i, 1, t, t);
|
|
1530
|
+
return;
|
|
1531
|
+
}
|
|
1532
|
+
if (i instanceof o) {
|
|
1533
|
+
let e = l.get(i), n = new c(X([[e, 1], [d, -1]], 0), ">=", 0, t);
|
|
1534
|
+
s.push(n), u.set(n, t);
|
|
1535
|
+
return;
|
|
1536
|
+
}
|
|
1537
|
+
if (i instanceof n) {
|
|
1538
|
+
if (i.op === "and") {
|
|
1539
|
+
for (let e = 0; e < i.children.length; e++) _(new n("implies", [d instanceof b ? new qe(d) : r, i.children[e]]), `${t}_and_${e}`);
|
|
1540
|
+
return;
|
|
1541
|
+
}
|
|
1542
|
+
if (i.op === "not") {
|
|
1543
|
+
let e = i.children[0], n = m(e, t), r = new c(X([[d, 1], [n, 1]], 0), "<=", 1, t);
|
|
1544
|
+
s.push(r), u.set(r, t);
|
|
1545
|
+
return;
|
|
1546
|
+
}
|
|
1547
|
+
let e = m(i, t), a = new c(X([[e, 1], [d, -1]], 0), ">=", 0, t);
|
|
1548
|
+
s.push(a), u.set(a, t);
|
|
1549
|
+
return;
|
|
1550
|
+
}
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
throw Error(`Unsupported top-level logical constraint "${t}": ${e}`);
|
|
1554
|
+
}
|
|
1555
|
+
function v(e, t, n, r, i) {
|
|
1556
|
+
let { lhs: a, sense: o, rhs: l } = t;
|
|
1557
|
+
if (o === "<=" || o === ">=") {
|
|
1558
|
+
let t = Y(e, a, o, l, n, o === "<=" ? q(a, l, r) : J(a, l, r), r), d = new c(t.lhs, o, t.rhs, r);
|
|
1559
|
+
s.push(d), u.set(d, i);
|
|
1560
|
+
} else {
|
|
1561
|
+
let t = q(a, l, `${r}_le`), o = J(a, l, `${r}_ge`), d = Y(e, a, "<=", l, n, t, `${r}_le`), f = Y(e, a, ">=", l, n, o, `${r}_ge`), p = new c(d.lhs, "<=", d.rhs, `${r}_le`), m = new c(f.lhs, ">=", f.rhs, `${r}_ge`);
|
|
1562
|
+
s.push(p, m), u.set(p, i), u.set(m, i);
|
|
1563
|
+
}
|
|
1564
|
+
}
|
|
1565
|
+
return {
|
|
1566
|
+
variables: a,
|
|
1567
|
+
constraints: s,
|
|
1568
|
+
boolVarToBinary: l,
|
|
1569
|
+
constraintToOriginalName: u
|
|
1570
|
+
};
|
|
1571
|
+
}
|
|
1572
|
+
var qe = class extends o {
|
|
1573
|
+
wrappedVar;
|
|
1574
|
+
constructor(e) {
|
|
1575
|
+
super(e.name), this.wrappedVar = e;
|
|
1576
|
+
}
|
|
1577
|
+
};
|
|
1578
|
+
//#endregion
|
|
1579
|
+
//#region src/decomposition/column-generation.ts
|
|
1580
|
+
async function Je(e) {
|
|
1581
|
+
let t = e.master;
|
|
1582
|
+
if (!t) throw Error("A master Model must be provided for solveColumnGeneration.");
|
|
1583
|
+
let { pricing: n, maxIterations: r = 100, reducedCostTolerance: i = 1e-6, finalizeAsMIP: a = !0, solver: o, solverOptions: s, onIteration: c } = e, l = t.sense.toLowerCase() === "maximize", u = n;
|
|
1584
|
+
if (!u) throw Error("The 'pricing' callback must be provided in ColumnGenerationOptions.");
|
|
1585
|
+
let d = [], f = null, p = 0, m = t.status;
|
|
1586
|
+
for (let e = 1; e <= r; e++) {
|
|
1587
|
+
p = e;
|
|
1588
|
+
let n = await t.relax(o, s);
|
|
1589
|
+
if (m = n, n !== "Optimal" && n !== "Feasible" || !t.solution) break;
|
|
1590
|
+
f = t.objectiveValue;
|
|
1591
|
+
let r = t.solution, a = r.duals || {}, h = (e) => typeof e == "string" ? a[e] ?? 0 : e.dual ?? (e.name ? a[e.name] ?? 0 : 0), g = await u({
|
|
1592
|
+
iteration: e,
|
|
1593
|
+
duals: a,
|
|
1594
|
+
getDual: h,
|
|
1595
|
+
masterSolution: r,
|
|
1596
|
+
reducedCostTolerance: i,
|
|
1597
|
+
master: t
|
|
1598
|
+
}), _ = [];
|
|
1599
|
+
g && (Array.isArray(g) ? _.push(...g) : _.push(g));
|
|
1600
|
+
let v = [];
|
|
1601
|
+
for (let e of _) {
|
|
1602
|
+
let t = e.reducedCost;
|
|
1603
|
+
if (typeof t != "number" || !Number.isFinite(t)) {
|
|
1604
|
+
let n = 0, r = e.coefficients;
|
|
1605
|
+
if (Array.isArray(r)) for (let e of r) Array.isArray(e) ? n += e[1] * h(e[0]) : e && typeof e == "object" && (n += e.coeff * h(e.constraint));
|
|
1606
|
+
else if (r instanceof Map) for (let [e, t] of r.entries()) n += t * h(e);
|
|
1607
|
+
else if (r && typeof r == "object") for (let [e, t] of Object.entries(r)) n += t * h(e);
|
|
1608
|
+
t = e.cost - n;
|
|
1609
|
+
}
|
|
1610
|
+
(l ? t > i : t < -i) && v.push(e);
|
|
1611
|
+
}
|
|
1612
|
+
if (c && c({
|
|
1613
|
+
iteration: e,
|
|
1614
|
+
relaxationObjective: f,
|
|
1615
|
+
columnsAdded: d.length + v.length,
|
|
1616
|
+
proposedColumns: v
|
|
1617
|
+
}), v.length === 0) break;
|
|
1618
|
+
for (let e of v) {
|
|
1619
|
+
let n = t.addColumn({
|
|
1620
|
+
name: e.name,
|
|
1621
|
+
type: e.type || "Continuous",
|
|
1622
|
+
lb: e.lb,
|
|
1623
|
+
ub: e.ub,
|
|
1624
|
+
cost: e.cost,
|
|
1625
|
+
coefficients: e.coefficients
|
|
1626
|
+
});
|
|
1627
|
+
d.push({
|
|
1628
|
+
variable: n,
|
|
1629
|
+
proposal: e
|
|
1630
|
+
});
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1633
|
+
let h = f;
|
|
1634
|
+
a && (m === "Optimal" || m === "Feasible") && (m = await t.solve(o, s), h = t.objectiveValue);
|
|
1635
|
+
let g = {};
|
|
1636
|
+
for (let e of t.variables) e.value !== null && (g[e.name] = e.value);
|
|
1637
|
+
let _ = {
|
|
1638
|
+
status: m,
|
|
1639
|
+
objectiveValue: h,
|
|
1640
|
+
relaxationObjectiveValue: f,
|
|
1641
|
+
iterations: p,
|
|
1642
|
+
columnsAdded: d.length,
|
|
1643
|
+
generatedColumns: d,
|
|
1644
|
+
master: t,
|
|
1645
|
+
values: g
|
|
1646
|
+
};
|
|
1647
|
+
return t.decomposition = _, _;
|
|
1648
|
+
}
|
|
1649
|
+
//#endregion
|
|
1650
|
+
//#region src/modeler/objective.ts
|
|
1651
|
+
function Ye(e, t) {
|
|
1652
|
+
let n = e;
|
|
1653
|
+
if (n instanceof c || 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}\`)).`);
|
|
1654
|
+
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}\`)).`);
|
|
1655
|
+
if (typeof n == "number") {
|
|
1656
|
+
if (!Number.isFinite(n)) throw Error(`Invalid non-finite objective constant "${n}" passed to ${t}().`);
|
|
1657
|
+
return n;
|
|
1658
|
+
}
|
|
1659
|
+
if (typeof n == "string" || n instanceof j || n instanceof A || n instanceof b || typeof n == "object" && n && ("terms" in n && n.terms instanceof Map && typeof n.constant == "number" || "quadTerms" in n && n.quadTerms instanceof Map && "linearTerms" in n && n.linearTerms instanceof Map && typeof n.constant == "number" || "id" in n && "name" in n && "lb" in n && "ub" in n)) return n;
|
|
1660
|
+
throw Error(`Invalid expression passed to ${t}(): expected a finite number, Var, LinExpr, QuadExpr, or arithmetic expression string.`);
|
|
1661
|
+
}
|
|
1662
|
+
function Xe(e) {
|
|
1663
|
+
return {
|
|
1664
|
+
expr: Ye(e, "maximize"),
|
|
1665
|
+
sense: "Maximize"
|
|
1666
|
+
};
|
|
1667
|
+
}
|
|
1668
|
+
function Ze(e) {
|
|
1669
|
+
return {
|
|
1670
|
+
expr: Ye(e, "minimize"),
|
|
1671
|
+
sense: "Minimize"
|
|
1672
|
+
};
|
|
1673
|
+
}
|
|
1674
|
+
//#endregion
|
|
1675
|
+
//#region src/decomposition/benders.ts
|
|
1676
|
+
function Qe(e) {
|
|
1677
|
+
return !!(e && typeof e == "object" && "constraints" in e && "variables" in e && typeof e.solve == "function");
|
|
1678
|
+
}
|
|
1679
|
+
async function $e(e, t, n, r, i, a, o, s, l = 1) {
|
|
1680
|
+
let u = [];
|
|
1681
|
+
for (let r = 0; r < t.length; r++) {
|
|
1682
|
+
let a = t[r], o = a.lhs, s = a.sense, d = a.rhs - (o.constant || 0), f = [], p = [], m = 0;
|
|
1683
|
+
for (let [e, t] of o.terms.entries()) if (e.ownerModel === n || n.getVarByName(e.name) !== void 0) {
|
|
1684
|
+
p.push([e, t]);
|
|
1685
|
+
let n = i[e.name] ?? 0;
|
|
1686
|
+
m += t * n;
|
|
1687
|
+
} else f.push([e, t]);
|
|
1688
|
+
let h = d - m, g = new j();
|
|
1689
|
+
for (let [e, t] of f) g.addTerm(e, t);
|
|
1690
|
+
let _ = `__benders_link_${l}_${r}`, v = new c(g, s, h, _);
|
|
1691
|
+
e.constraint(v), u.push({
|
|
1692
|
+
origConstraint: a,
|
|
1693
|
+
subConstr: v,
|
|
1694
|
+
masterTerms: p,
|
|
1695
|
+
baseRhs: d
|
|
1696
|
+
});
|
|
1697
|
+
}
|
|
1698
|
+
let d = await e.solve(o, {
|
|
1699
|
+
...s,
|
|
1700
|
+
relax: !0
|
|
1701
|
+
});
|
|
1702
|
+
if (d !== "Optimal" && d !== "Feasible") return null;
|
|
1703
|
+
let f = e.objectiveValue ?? 0, p = i[r.name] ?? 0, m = 1e-4;
|
|
1704
|
+
if (!(a ? p < f - m : p > f + m)) return null;
|
|
1705
|
+
let h = 0, g = /* @__PURE__ */ new Map(), _ = new Set(u.map((e) => e.subConstr.name));
|
|
1706
|
+
for (let t of e.constraints) {
|
|
1707
|
+
if (_.has(t.name)) continue;
|
|
1708
|
+
let n = e.solution?.duals[t.name] ?? t.dual ?? 0;
|
|
1709
|
+
if (Math.abs(n) > 1e-12) {
|
|
1710
|
+
let e = t.rhs - (t.lhs.constant || 0);
|
|
1711
|
+
h += n * e;
|
|
1712
|
+
}
|
|
1713
|
+
}
|
|
1714
|
+
for (let t of u) {
|
|
1715
|
+
let n = e.solution?.duals[t.subConstr.name] ?? t.subConstr.dual ?? 0;
|
|
1716
|
+
if (Math.abs(n) > 1e-12) {
|
|
1717
|
+
h += n * t.baseRhs;
|
|
1718
|
+
for (let [e, r] of t.masterTerms) {
|
|
1719
|
+
let t = g.get(e) ?? 0;
|
|
1720
|
+
g.set(e, t + n * r);
|
|
1721
|
+
}
|
|
1722
|
+
}
|
|
1723
|
+
}
|
|
1724
|
+
let v = new j();
|
|
1725
|
+
v.addTerm(r, 1);
|
|
1726
|
+
for (let [e, t] of g.entries()) Math.abs(t) > 1e-12 && v.addTerm(e, t);
|
|
1727
|
+
let y = new c(v, a ? ">=" : "<=", h, `__benders_opt_cut_${l}`), b = (n.objectiveValue ?? 0) - p + f;
|
|
1728
|
+
return {
|
|
1729
|
+
kind: "optimality",
|
|
1730
|
+
constraint: y,
|
|
1731
|
+
name: y.name,
|
|
1732
|
+
subproblemObjective: b
|
|
1733
|
+
};
|
|
1734
|
+
}
|
|
1735
|
+
async function et(e) {
|
|
1736
|
+
let t = e.master;
|
|
1737
|
+
if (!t) throw Error("A master Model must be provided for solveBenders.");
|
|
1738
|
+
let { subproblem: n, maxIterations: r = 100, gapTolerance: i = 1e-4, solver: a, solverOptions: o, onIteration: s } = e, c;
|
|
1739
|
+
e.theta && (c = typeof e.theta == "string" ? t.getVarByName(e.theta) : e.theta), c ||= t.variables.find((e) => e.name === "theta" || e.name === "__benders_theta");
|
|
1740
|
+
let l = 0, u = 0, d = t.status, f, p, m, h = {}, g = null;
|
|
1741
|
+
for (let e = 1; e <= r; e++) {
|
|
1742
|
+
u = e;
|
|
1743
|
+
let r = await t.solve(a, o);
|
|
1744
|
+
if (d = r, r !== "Optimal" && r !== "Feasible") break;
|
|
1745
|
+
let _ = t.objectiveValue, v = t.sense.toLowerCase() === "minimize";
|
|
1746
|
+
v ? f = _ === null ? f : _ : p = _ === null ? p : _;
|
|
1747
|
+
let y = {};
|
|
1748
|
+
for (let e of t.variables) e.value !== null && (y[e.name] = e.value);
|
|
1749
|
+
let b = await n({
|
|
1750
|
+
iteration: e,
|
|
1751
|
+
masterValues: y,
|
|
1752
|
+
getMasterValue: (e) => typeof e == "string" ? y[e] ?? 0 : e.value ?? (e.name ? y[e.name] ?? 0 : 0),
|
|
1753
|
+
masterObjective: _,
|
|
1754
|
+
lowerBound: f,
|
|
1755
|
+
upperBound: p,
|
|
1756
|
+
master: t
|
|
1757
|
+
}), x = [];
|
|
1758
|
+
if (b) {
|
|
1759
|
+
if (Qe(b)) {
|
|
1760
|
+
let n = b, r = n.linkingConstraints;
|
|
1761
|
+
c || (c = t.continuous("__benders_theta", { lb: 0 }), v ? t.objective(Ze(t.objectiveExpr.add(c))) : t.objective(Xe(t.objectiveExpr.sub(c))));
|
|
1762
|
+
let i = await $e(n, r, t, c, y, v, a, o, e);
|
|
1763
|
+
i && x.push(i);
|
|
1764
|
+
} else Array.isArray(b) ? x.push(...b) : x.push(b);
|
|
1765
|
+
}
|
|
1766
|
+
for (let e of x) if (typeof e.subproblemObjective == "number" && Number.isFinite(e.subproblemObjective)) {
|
|
1767
|
+
if (v) {
|
|
1768
|
+
let t = e.subproblemObjective;
|
|
1769
|
+
(p === void 0 || t < p) && (p = t, g = t, h = { ...y });
|
|
1770
|
+
} else {
|
|
1771
|
+
let t = e.subproblemObjective;
|
|
1772
|
+
(f === void 0 || t > f) && (f = t, g = t, h = { ...y });
|
|
1773
|
+
}
|
|
1774
|
+
}
|
|
1775
|
+
if (f !== void 0 && p !== void 0) {
|
|
1776
|
+
let e = Math.abs(p) + 1e-10;
|
|
1777
|
+
m = Math.abs(p - f) / e;
|
|
1778
|
+
}
|
|
1779
|
+
if (s && s({
|
|
1780
|
+
iteration: e,
|
|
1781
|
+
masterObjective: _,
|
|
1782
|
+
lowerBound: f,
|
|
1783
|
+
upperBound: p,
|
|
1784
|
+
cutsAdded: l + x.length,
|
|
1785
|
+
proposedCuts: x
|
|
1786
|
+
}), x.length === 0) {
|
|
1787
|
+
g = _, h = { ...y };
|
|
1788
|
+
break;
|
|
1789
|
+
}
|
|
1790
|
+
if (m !== void 0 && m <= i) break;
|
|
1791
|
+
for (let e of x) t.constraint(e.constraint, e.name), l++;
|
|
1792
|
+
}
|
|
1793
|
+
let _ = Object.keys(h).length > 0 ? h : (() => {
|
|
1794
|
+
let e = {};
|
|
1795
|
+
for (let n of t.variables) n.value !== null && (e[n.name] = n.value);
|
|
1796
|
+
return e;
|
|
1797
|
+
})(), v = g === null ? t.objectiveValue : g, y = {
|
|
1798
|
+
status: d,
|
|
1799
|
+
objectiveValue: v,
|
|
1800
|
+
lowerBound: f,
|
|
1801
|
+
upperBound: p,
|
|
1802
|
+
gap: m,
|
|
1803
|
+
iterations: u,
|
|
1804
|
+
cutsAdded: l,
|
|
1805
|
+
master: t,
|
|
1806
|
+
values: _
|
|
1807
|
+
};
|
|
1808
|
+
return t.decomposition = y, y;
|
|
1809
|
+
}
|
|
1810
|
+
//#endregion
|
|
1269
1811
|
//#region src/modeler/model.ts
|
|
1270
1812
|
function Z(e) {
|
|
1271
1813
|
return Array.isArray(e) || typeof e == "object" && !!e && !(e instanceof String) && typeof e[Symbol.iterator] == "function";
|
|
@@ -1273,10 +1815,13 @@ function Z(e) {
|
|
|
1273
1815
|
function Q(e) {
|
|
1274
1816
|
return typeof e == "object" && !!e && !Array.isArray(e) && !(e instanceof String) && typeof e[Symbol.iterator] != "function";
|
|
1275
1817
|
}
|
|
1818
|
+
function tt(e) {
|
|
1819
|
+
return e instanceof b || typeof e == "object" && !!e && !(e instanceof r) && !(e instanceof c) && "id" in e && "name" in e && "lb" in e && "ub" in e && !("terms" in e) && !("quadTerms" in e) && !("sense" in e);
|
|
1820
|
+
}
|
|
1276
1821
|
function $(e, t) {
|
|
1277
1822
|
if (!Number.isInteger(e) || e < 0) throw Error(`Invalid count (${e}) for ${t} variable creation: count must be a non-negative integer.`);
|
|
1278
1823
|
}
|
|
1279
|
-
var
|
|
1824
|
+
var nt = class {
|
|
1280
1825
|
name;
|
|
1281
1826
|
_sense;
|
|
1282
1827
|
_objectiveExpr;
|
|
@@ -1285,6 +1830,7 @@ var Re = class {
|
|
|
1285
1830
|
boolVars = [];
|
|
1286
1831
|
logicalConstraints = [];
|
|
1287
1832
|
unsatCore = void 0;
|
|
1833
|
+
_conflicts = void 0;
|
|
1288
1834
|
values = /* @__PURE__ */ new Map();
|
|
1289
1835
|
varMapByName = /* @__PURE__ */ new Map();
|
|
1290
1836
|
varPrefixCounters = /* @__PURE__ */ new Map();
|
|
@@ -1305,6 +1851,8 @@ var Re = class {
|
|
|
1305
1851
|
runTime = 0;
|
|
1306
1852
|
solution = null;
|
|
1307
1853
|
solver = null;
|
|
1854
|
+
decomposition;
|
|
1855
|
+
_linkingConstraints;
|
|
1308
1856
|
hasSolutionState = !1;
|
|
1309
1857
|
modelRevision = 0;
|
|
1310
1858
|
activeOperationId = 0;
|
|
@@ -1316,13 +1864,13 @@ var Re = class {
|
|
|
1316
1864
|
n = typeof e == "string" ? {
|
|
1317
1865
|
...t,
|
|
1318
1866
|
name: e
|
|
1319
|
-
} : e, this.name = n.name || "OptimizationModel", this._sense =
|
|
1867
|
+
} : e, this.name = n.name || "OptimizationModel", this._sense = _e(n.sense), this._objectiveExpr = new j(), n.solver && (this.solver = D(n.solver));
|
|
1320
1868
|
}
|
|
1321
1869
|
get sense() {
|
|
1322
1870
|
return this._sense;
|
|
1323
1871
|
}
|
|
1324
1872
|
set sense(e) {
|
|
1325
|
-
let t =
|
|
1873
|
+
let t = _e(e);
|
|
1326
1874
|
this._sense !== t && (this._sense = t, this.recordModelMutation());
|
|
1327
1875
|
}
|
|
1328
1876
|
get objectiveExpr() {
|
|
@@ -1332,7 +1880,10 @@ var Re = class {
|
|
|
1332
1880
|
this.applyObjective(e);
|
|
1333
1881
|
}
|
|
1334
1882
|
get conflicts() {
|
|
1335
|
-
return this.unsatCore;
|
|
1883
|
+
return this._conflicts ?? this.unsatCore;
|
|
1884
|
+
}
|
|
1885
|
+
set conflicts(e) {
|
|
1886
|
+
this._conflicts = e;
|
|
1336
1887
|
}
|
|
1337
1888
|
get numVars() {
|
|
1338
1889
|
return this.variables.length;
|
|
@@ -1342,7 +1893,7 @@ var Re = class {
|
|
|
1342
1893
|
}
|
|
1343
1894
|
clearSolutionFields() {
|
|
1344
1895
|
if (this.hasSolutionState || this.status !== "NotSolved" || this.terminationStatus !== "NotSolved" || this.hasPrimalSolution || this.solution !== null || this.unsatCore !== void 0) {
|
|
1345
|
-
this.hasSolutionState = !1, this.status = "NotSolved", this.terminationStatus = "NotSolved", this.hasPrimalSolution = !1, this.objectiveValue = null, this.objectiveBound = void 0, this.relGap = void 0, this.mipGap = void 0, this.absGap = void 0, this.solution = null, this.runTime = 0, this.unsatCore = void 0, this.values.clear();
|
|
1896
|
+
this.hasSolutionState = !1, this.status = "NotSolved", this.terminationStatus = "NotSolved", this.hasPrimalSolution = !1, this.objectiveValue = null, this.objectiveBound = void 0, this.relGap = void 0, this.mipGap = void 0, this.absGap = void 0, this.solution = null, this.runTime = 0, this.unsatCore = void 0, this._conflicts = void 0, this.values.clear();
|
|
1346
1897
|
for (let e of this.variables) e.value = null, e.reducedCost = null;
|
|
1347
1898
|
for (let e of this.boolVars) e.value = null;
|
|
1348
1899
|
for (let e of this.constraints) e.dual = null, e.slack = null;
|
|
@@ -1467,6 +2018,37 @@ var Re = class {
|
|
|
1467
2018
|
continuous(e, t, n) {
|
|
1468
2019
|
return this.createDomainVars("Continuous", e, t, n);
|
|
1469
2020
|
}
|
|
2021
|
+
addColumn(e) {
|
|
2022
|
+
let t = e.type || "Continuous", n = this.addVar({
|
|
2023
|
+
name: e.name,
|
|
2024
|
+
type: t,
|
|
2025
|
+
lb: e.lb,
|
|
2026
|
+
ub: e.ub
|
|
2027
|
+
});
|
|
2028
|
+
if (typeof e.cost == "number" && e.cost !== 0 && (this._objectiveExpr = this._objectiveExpr.add(n.mul(e.cost)), this.recordModelMutation()), e.coefficients) {
|
|
2029
|
+
if (Array.isArray(e.coefficients)) {
|
|
2030
|
+
for (let t of e.coefficients) if (Array.isArray(t)) {
|
|
2031
|
+
let [e, r] = t, i = typeof e == "string" ? this.getConstraintByName(e) : e;
|
|
2032
|
+
if (!i) throw Error(`Constraint '${String(e)}' not found in model when adding column`);
|
|
2033
|
+
i.addTerm(n, r);
|
|
2034
|
+
} else if (typeof t == "object" && t) {
|
|
2035
|
+
let e = typeof t.constraint == "string" ? this.getConstraintByName(t.constraint) : t.constraint;
|
|
2036
|
+
if (!e) throw Error(`Constraint '${String(t.constraint)}' not found in model when adding column`);
|
|
2037
|
+
e.addTerm(n, t.coeff);
|
|
2038
|
+
}
|
|
2039
|
+
} else if (e.coefficients instanceof Map) for (let [t, r] of e.coefficients.entries()) {
|
|
2040
|
+
let e = typeof t == "string" ? this.getConstraintByName(t) : t;
|
|
2041
|
+
if (!e) throw Error(`Constraint '${String(t)}' not found in model when adding column`);
|
|
2042
|
+
e.addTerm(n, r);
|
|
2043
|
+
}
|
|
2044
|
+
else if (typeof e.coefficients == "object") for (let [t, r] of Object.entries(e.coefficients)) {
|
|
2045
|
+
let e = this.getConstraintByName(t);
|
|
2046
|
+
if (!e) throw Error(`Constraint '${t}' not found in model when adding column`);
|
|
2047
|
+
e.addTerm(n, r);
|
|
2048
|
+
}
|
|
2049
|
+
}
|
|
2050
|
+
return n;
|
|
2051
|
+
}
|
|
1470
2052
|
bool(e, t, n) {
|
|
1471
2053
|
let r = typeof e == "number", i = typeof t == "number", a = Z(e), o = Z(t);
|
|
1472
2054
|
if (i || o) {
|
|
@@ -1572,12 +2154,16 @@ var Re = class {
|
|
|
1572
2154
|
return this.logicalConstrMapByName.get(e);
|
|
1573
2155
|
}
|
|
1574
2156
|
objective(e) {
|
|
1575
|
-
|
|
2157
|
+
if (arguments.length === 0) return this.objectiveExpr;
|
|
2158
|
+
let t = e;
|
|
2159
|
+
if (t instanceof c || 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}`)).");
|
|
2160
|
+
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}`)).");
|
|
2161
|
+
return this.applyObjective(t.expr, t.sense), this;
|
|
1576
2162
|
}
|
|
1577
2163
|
applyObjective(e, t) {
|
|
1578
|
-
if (e instanceof c || typeof e == "object" && e && "sense" in e && "lhs" in e && "rhs" in e || typeof e == "string" && /(<=|>=|==|=<|=>|=)/.test(e)) throw Error(typeof e == "string" ? "Cannot use a comparison constraint as an objective. Did you mean to use m.constraint(expr`... <= ...`)?" : "Cannot use a Constraint as an objective. Did you mean to use m.constraint(expr`... <= ...`)?
|
|
1579
|
-
let n = t === void 0 ? this.sense :
|
|
1580
|
-
if (typeof e == "string") r =
|
|
2164
|
+
if (e instanceof c || typeof e == "object" && e && "sense" in e && "lhs" in e && "rhs" in e || typeof e == "string" && /(<=|>=|==|=<|=>|=)/.test(e)) throw Error(typeof e == "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}`)).");
|
|
2165
|
+
let n = t === void 0 ? this.sense : _e(t), r;
|
|
2166
|
+
if (typeof e == "string") r = Se(e, (e) => this.getVarByName(e));
|
|
1581
2167
|
else if (typeof e == "number") r = new j(/* @__PURE__ */ new Map(), e);
|
|
1582
2168
|
else if (e instanceof A) r = e.clone();
|
|
1583
2169
|
else if (e instanceof j) r = e.clone();
|
|
@@ -1598,6 +2184,7 @@ var Re = class {
|
|
|
1598
2184
|
});
|
|
1599
2185
|
if (e instanceof A || typeof e == "object" && e && "quadTerms" in e) throw Error("Constraint must contain a comparison operator (<=, >=, ==): cannot add a quadratic expression as a constraint.");
|
|
1600
2186
|
if (e instanceof j || 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().");
|
|
2187
|
+
if (tt(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().`);
|
|
1601
2188
|
return this.addConstraint(e, t), this;
|
|
1602
2189
|
}
|
|
1603
2190
|
getValues(e) {
|
|
@@ -1614,6 +2201,7 @@ var Re = class {
|
|
|
1614
2201
|
addConstraint(e, t) {
|
|
1615
2202
|
if (e instanceof A || typeof e == "object" && e && "quadTerms" in e) throw Error("Constraint must contain a comparison operator (<=, >=, ==): cannot add a quadratic expression as a constraint.");
|
|
1616
2203
|
if (e instanceof j || 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().");
|
|
2204
|
+
if (tt(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().`);
|
|
1617
2205
|
if (e instanceof r) {
|
|
1618
2206
|
let n = typeof t == "string" && t.trim().length > 0 ? t.trim() : void 0;
|
|
1619
2207
|
if (n !== void 0) {
|
|
@@ -1633,7 +2221,8 @@ var Re = class {
|
|
|
1633
2221
|
};
|
|
1634
2222
|
return this.logicalConstraints.push(a), this.logicalConstrMapByName.set(i, a), this.recordModelMutation(), e;
|
|
1635
2223
|
}
|
|
1636
|
-
let n = typeof e == "string" ?
|
|
2224
|
+
let n = typeof e == "string" ? we(e, (e) => this.getVarByName(e), t) : e;
|
|
2225
|
+
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.");
|
|
1637
2226
|
n.ownerModel && n.ownerModel !== this && (h(n, this.name, (e) => this.varMapByName.get(e.name) === e, n.name), p(n, this));
|
|
1638
2227
|
let i = typeof t == "string" && t.trim().length > 0 ? t.trim() : n.hasExplicitName ? n.name.trim() : void 0;
|
|
1639
2228
|
if (i !== void 0) {
|
|
@@ -1652,40 +2241,41 @@ var Re = class {
|
|
|
1652
2241
|
}), this.batchDepth === 0 && (this.batchUndoActions = []), n._assignModelName(o, !0), n.ownerModel = this, this.constraints.push(n), this.constrMapByName.set(n.name, n), this.recordModelMutation(), n;
|
|
1653
2242
|
}
|
|
1654
2243
|
indicator(e, t, n = {}) {
|
|
1655
|
-
if (
|
|
1656
|
-
if (!(e
|
|
1657
|
-
if (
|
|
1658
|
-
if (
|
|
1659
|
-
|
|
1660
|
-
|
|
2244
|
+
if (e instanceof r) throw Error("Invalid binary variable passed to indicator(): received a propositional BoolVar/BoolExpr, but m.indicator() requires a 0-1 numeric binary Var created with m.binary(). For general boolean logic with m.bool(), use m.constraint(implies(flag, expr`${x} <= 10`)) with the Z3 solver.");
|
|
2245
|
+
if (!(e instanceof b)) throw Error("Invalid binary variable passed to indicator(). Expected a 0-1 binary Var instance created with m.binary() (or use implies(flag, ...) with m.bool() and the Z3 solver for general boolean logic).");
|
|
2246
|
+
if (!(e.type === "Binary" || e.type === "Integer" && e.lb === 0 && e.ub === 1)) throw Error(`Invalid variable "${e.name}" passed to indicator(): variable has type "${e.type}" with bounds [${e.lb}, ${e.ub}]. Indicator activation variable must be a Binary variable created with m.binary() (or Integer variable with bounds [0, 1]).`);
|
|
2247
|
+
if (t instanceof A || typeof t == "object" && t && "quadTerms" in t) throw Error("Quadratic expressions or constraints are not supported in indicator constraints (only linear Constraints with <=, >=, or == such as expr`${x} <= 10` are allowed).");
|
|
2248
|
+
if (typeof t != "object" || !t || !("sense" in t) || !("lhs" in t) || !("rhs" in t)) throw Error("Invalid constraint expression passed to indicator(). Expression must include a comparison operator (<=, >=, ==), e.g. m.indicator(b, expr`${x} <= 10`). For general boolean logic (such as BoolVar or implies/and/or/not), use m.constraint(implies(flag, ...)) with the Z3 solver.");
|
|
2249
|
+
let i = t, a = n.activeValue === void 0 ? 1 : n.activeValue;
|
|
2250
|
+
if (a !== 0 && a !== 1) throw Error(`Invalid activeValue: ${a}. Indicator activeValue must be 0 or 1.`);
|
|
1661
2251
|
if (this.varMapByName.get(e.name) !== e) throw Error(`Variable "${e.name}" passed to indicator() does not belong to model "${this.name}". All variables must belong to the model by object identity.`);
|
|
1662
|
-
let
|
|
1663
|
-
if (
|
|
1664
|
-
else if (
|
|
2252
|
+
let o = typeof n.name == "string" && n.name.trim().length > 0 ? n.name.trim() : void 0, s = this.constrPrefixCounters.get("c"), { lhs: l, sense: u, rhs: d } = i, f, p, m;
|
|
2253
|
+
if (o !== void 0) f = o, p = u === "==" ? `${f}_le` : f, m = u === "==" ? `${f}_ge` : f;
|
|
2254
|
+
else if (i.hasExplicitName) f = `ind_${e.name}_${i.name.trim()}`, p = u === "==" ? `${f}_le` : f, m = u === "==" ? `${f}_ge` : f;
|
|
1665
2255
|
else do {
|
|
1666
2256
|
let t = this.getNextConstrName("c");
|
|
1667
|
-
|
|
1668
|
-
} while ((
|
|
1669
|
-
let
|
|
2257
|
+
f = `ind_${e.name}_${t}`, p = u === "==" ? `${f}_le` : f, m = u === "==" ? `${f}_ge` : f;
|
|
2258
|
+
} while ((u === "<=" || u === "==") && (this.hasConstraintName(p) || this.hasBoolVarName(p)) || (u === ">=" || u === "==") && (this.hasConstraintName(m) || this.hasBoolVarName(m)));
|
|
2259
|
+
let g = [];
|
|
1670
2260
|
try {
|
|
1671
|
-
if ((
|
|
1672
|
-
if ((
|
|
1673
|
-
n.M !== void 0 &&
|
|
2261
|
+
if ((u === "<=" || u === "==") && (this.hasConstraintName(p) || this.hasBoolVarName(p))) throw Error(this.hasBoolVarName(p) ? `Constraint name '${p}' conflicts with an existing Boolean variable in model` : `Constraint with name '${p}' already exists in model`);
|
|
2262
|
+
if ((u === ">=" || u === "==") && (this.hasConstraintName(m) || this.hasBoolVarName(m))) throw Error(this.hasBoolVarName(m) ? `Constraint name '${m}' conflicts with an existing Boolean variable in model` : `Constraint with name '${m}' already exists in model`);
|
|
2263
|
+
n.M !== void 0 && We(n.M, f);
|
|
1674
2264
|
let t = (e) => this.varMapByName.get(e.name) === e;
|
|
1675
|
-
for (let [e] of
|
|
1676
|
-
if (
|
|
1677
|
-
let t =
|
|
1678
|
-
|
|
2265
|
+
for (let [e] of l.terms) if (!t(e)) throw Error(`Variable "${e.name}" in constraint "${f}" does not belong to model "${this.name}". All variables must belong to the model by object identity.`);
|
|
2266
|
+
if (u === "<=" || u === "==") {
|
|
2267
|
+
let t = Y(e, l, "<=", d, a, n.M === void 0 ? q(l, d, p) : n.M, p);
|
|
2268
|
+
g.push([new c(t.lhs, "<=", t.rhs, p), p]);
|
|
1679
2269
|
}
|
|
1680
|
-
if (
|
|
1681
|
-
let t =
|
|
1682
|
-
|
|
2270
|
+
if (u === ">=" || u === "==") {
|
|
2271
|
+
let t = Y(e, l, ">=", d, a, n.M === void 0 ? J(l, d, m) : n.M, m);
|
|
2272
|
+
g.push([new c(t.lhs, ">=", t.rhs, m), m]);
|
|
1683
2273
|
}
|
|
1684
|
-
for (let [e, n] of
|
|
2274
|
+
for (let [e, n] of g) h(e, this.name, t, n);
|
|
1685
2275
|
} catch (e) {
|
|
1686
|
-
throw
|
|
2276
|
+
throw s === void 0 ? this.constrPrefixCounters.delete("c") : this.constrPrefixCounters.set("c", s), e;
|
|
1687
2277
|
}
|
|
1688
|
-
return this.runTransactionalBatch(() =>
|
|
2278
|
+
return this.runTransactionalBatch(() => g.map(([e, t]) => this.addConstraint(e, t)));
|
|
1689
2279
|
}
|
|
1690
2280
|
toLpString() {
|
|
1691
2281
|
this.validateIntegrity();
|
|
@@ -1750,14 +2340,31 @@ var Re = class {
|
|
|
1750
2340
|
activeOptions: r
|
|
1751
2341
|
};
|
|
1752
2342
|
}
|
|
2343
|
+
async relax(e, t) {
|
|
2344
|
+
let n = typeof e == "object" && !!e && !("solve" in e), r = n ? {
|
|
2345
|
+
...e,
|
|
2346
|
+
relax: !0
|
|
2347
|
+
} : {
|
|
2348
|
+
...t || {},
|
|
2349
|
+
relax: !0
|
|
2350
|
+
}, i = n ? void 0 : e;
|
|
2351
|
+
return i ? this.solve(i, r) : this.solve(r);
|
|
2352
|
+
}
|
|
1753
2353
|
async solve(e, t) {
|
|
1754
2354
|
let n = ++this.activeOperationId, r = this.modelRevision;
|
|
1755
2355
|
this.clearSolutionFields(), this.validateIntegrity();
|
|
1756
2356
|
let { activeSolver: i, activeOptions: a } = this.resolveSolverAndOptions(e, t);
|
|
1757
2357
|
if (this._objectiveExpr instanceof A && this._objectiveExpr.quadTerms.size > 0 && i.capabilities?.supportsQP === !1) throw Error(`Solver "${i.name}" does not support quadratic objectives (QP). Please use a QP-capable solver such as HiGHS or Clarabel.`);
|
|
1758
|
-
|
|
1759
|
-
if (this.
|
|
1760
|
-
|
|
2358
|
+
let o, s = null;
|
|
2359
|
+
if (this.logicalConstraints.length > 0 && i.capabilities?.supportsSMT !== !0 ? (s = Ke(this.variables, this.boolVars, this.constraints, this.logicalConstraints), o = {
|
|
2360
|
+
name: this.name,
|
|
2361
|
+
sense: this.sense,
|
|
2362
|
+
objective: this._objectiveExpr,
|
|
2363
|
+
constraints: s.constraints,
|
|
2364
|
+
variables: s.variables,
|
|
2365
|
+
logicalConstraints: [],
|
|
2366
|
+
boolVars: []
|
|
2367
|
+
}) : o = {
|
|
1761
2368
|
name: this.name,
|
|
1762
2369
|
sense: this.sense,
|
|
1763
2370
|
objective: this._objectiveExpr,
|
|
@@ -1765,53 +2372,64 @@ var Re = class {
|
|
|
1765
2372
|
variables: this.variables,
|
|
1766
2373
|
logicalConstraints: this.logicalConstraints,
|
|
1767
2374
|
boolVars: this.boolVars
|
|
1768
|
-
},
|
|
2375
|
+
}, 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.`);
|
|
2376
|
+
let c = this.wrapSolveOptions(a, r, n), l;
|
|
1769
2377
|
try {
|
|
1770
|
-
|
|
2378
|
+
l = await i.solve(o, c);
|
|
1771
2379
|
} catch (e) {
|
|
1772
2380
|
throw this.activeOperationId === n && this.clearSolutionFields(), e;
|
|
1773
2381
|
}
|
|
1774
|
-
this.ensureExecutionValid(r, n, "solve"), this.runTime =
|
|
1775
|
-
let
|
|
1776
|
-
this.hasPrimalSolution =
|
|
1777
|
-
let
|
|
1778
|
-
this.relGap =
|
|
1779
|
-
let
|
|
2382
|
+
this.ensureExecutionValid(r, n, "solve"), this.runTime = l.runTime ?? 0, this.status = l.status, this.terminationStatus = l.terminationStatus ?? l.status;
|
|
2383
|
+
let u = this.hasPrimalFromResult(l);
|
|
2384
|
+
this.hasPrimalSolution = u, this.objectiveValue = u && typeof l.objectiveValue == "number" && Number.isFinite(l.objectiveValue) ? l.objectiveValue : null, this.objectiveBound = typeof l.objectiveBound == "number" && Number.isFinite(l.objectiveBound) ? l.objectiveBound : void 0;
|
|
2385
|
+
let d = typeof l.relGap == "number" && Number.isFinite(l.relGap) ? l.relGap : typeof l.mipGap == "number" && Number.isFinite(l.mipGap) ? l.mipGap : void 0;
|
|
2386
|
+
this.relGap = d, this.mipGap = d, this.absGap = typeof l.absGap == "number" && Number.isFinite(l.absGap) ? l.absGap : this.objectiveValue !== null && this.objectiveBound !== void 0 ? Math.abs(this.objectiveValue - this.objectiveBound) : void 0;
|
|
2387
|
+
let f = (e, t, n) => {
|
|
1780
2388
|
Object.defineProperty(e, t, {
|
|
1781
2389
|
value: n,
|
|
1782
2390
|
enumerable: !0,
|
|
1783
2391
|
writable: !0,
|
|
1784
2392
|
configurable: !0
|
|
1785
2393
|
});
|
|
1786
|
-
},
|
|
1787
|
-
if (this.values.clear(),
|
|
1788
|
-
for (let [e, t] of Object.entries(
|
|
2394
|
+
}, p = {}, m = {}, h = {}, g = {};
|
|
2395
|
+
if (this.values.clear(), u && l.values) {
|
|
2396
|
+
for (let [e, t] of Object.entries(l.values)) if (typeof t == "number" && Number.isFinite(t)) {
|
|
1789
2397
|
let n = this.getVarByName(e), r = this.getBoolVarByName(e);
|
|
1790
|
-
n && (n.value = t,
|
|
2398
|
+
n && (n.value = t, f(p, n.name, t), this.values.set(n.name, t)), r && (r.value = !!t, this.values.set(r.name, t)), !n && !r && this.values.set(e, t);
|
|
1791
2399
|
} else if (typeof t == "boolean") {
|
|
1792
2400
|
let n = t, r = this.getBoolVarByName(e);
|
|
1793
|
-
r ? (r.value = n,
|
|
2401
|
+
r ? (r.value = n, f(p, r.name, +!!n), this.values.set(r.name, n)) : this.values.set(e, n);
|
|
2402
|
+
}
|
|
2403
|
+
if (s) for (let e of this.boolVars) {
|
|
2404
|
+
let t = s.boolVarToBinary.get(e);
|
|
2405
|
+
if (t && l.values) {
|
|
2406
|
+
let n = l.values[t.name];
|
|
2407
|
+
if (typeof n == "number" && Number.isFinite(n)) {
|
|
2408
|
+
let t = Math.round(n) === 1;
|
|
2409
|
+
e.value = t, f(p, e.name, +!!t), this.values.set(e.name, t);
|
|
2410
|
+
}
|
|
2411
|
+
}
|
|
1794
2412
|
}
|
|
1795
2413
|
}
|
|
1796
|
-
if (
|
|
2414
|
+
if (u && l.boolValues) for (let [e, t] of Object.entries(l.boolValues)) {
|
|
1797
2415
|
if (typeof t != "boolean") continue;
|
|
1798
2416
|
let n = this.getBoolVarByName(e);
|
|
1799
2417
|
n ? (n.value = t, this.values.has(n.name) || this.values.set(n.name, t)) : this.values.has(e) || this.values.set(e, t);
|
|
1800
2418
|
}
|
|
1801
|
-
if (
|
|
2419
|
+
if (u && l.reducedCosts) for (let [e, t] of Object.entries(l.reducedCosts)) {
|
|
1802
2420
|
if (typeof t != "number" || !Number.isFinite(t)) continue;
|
|
1803
2421
|
let n = this.getVarByName(e);
|
|
1804
|
-
n && (n.reducedCost = t,
|
|
2422
|
+
n && (n.reducedCost = t, f(h, n.name, t));
|
|
1805
2423
|
}
|
|
1806
|
-
if (
|
|
2424
|
+
if (l.duals) for (let [e, t] of Object.entries(l.duals)) {
|
|
1807
2425
|
if (typeof t != "number" || !Number.isFinite(t)) continue;
|
|
1808
2426
|
let n = this.getConstraintByName(e);
|
|
1809
|
-
n && (n.dual = t,
|
|
2427
|
+
n && (n.dual = t, f(m, n.name, t));
|
|
1810
2428
|
}
|
|
1811
|
-
if (
|
|
2429
|
+
if (l.slacks) for (let [e, t] of Object.entries(l.slacks)) {
|
|
1812
2430
|
if (typeof t != "number" || !Number.isFinite(t)) continue;
|
|
1813
2431
|
let n = this.getConstraintByName(e);
|
|
1814
|
-
n && (n.slack = t,
|
|
2432
|
+
n && (n.slack = t, f(g, n.name, t));
|
|
1815
2433
|
}
|
|
1816
2434
|
return this.solution = {
|
|
1817
2435
|
status: this.status,
|
|
@@ -1824,19 +2442,18 @@ var Re = class {
|
|
|
1824
2442
|
mipGap: this.mipGap
|
|
1825
2443
|
},
|
|
1826
2444
|
...this.absGap === void 0 ? {} : { absGap: this.absGap },
|
|
1827
|
-
values:
|
|
1828
|
-
duals:
|
|
1829
|
-
reducedCosts:
|
|
1830
|
-
slacks:
|
|
2445
|
+
values: p,
|
|
2446
|
+
duals: m,
|
|
2447
|
+
reducedCosts: h,
|
|
2448
|
+
slacks: g,
|
|
1831
2449
|
runTime: this.runTime,
|
|
1832
|
-
raw:
|
|
2450
|
+
raw: l.raw
|
|
1833
2451
|
}, this.hasSolutionState = !0, this.status;
|
|
1834
2452
|
}
|
|
1835
2453
|
async check(e, t) {
|
|
1836
2454
|
let n = ++this.activeOperationId, r = this.modelRevision;
|
|
1837
2455
|
this.clearSolutionFields(), this.validateIntegrity();
|
|
1838
2456
|
let { activeSolver: i, activeOptions: a } = this.resolveSolverAndOptions(e, t);
|
|
1839
|
-
if (this.logicalConstraints.length > 0 && i.capabilities?.supportsSMT !== !0) throw Error(`Solver "${i.name}" does not support SMT / logical constraints (or, implies, not, xor). Please use an SMT-capable solver such as Z3.`);
|
|
1840
2457
|
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.`);
|
|
1841
2458
|
let o = this.wrapSolveOptions(a, r, n), s = (e, t, n) => {
|
|
1842
2459
|
Object.defineProperty(e, t, {
|
|
@@ -1845,7 +2462,7 @@ var Re = class {
|
|
|
1845
2462
|
writable: !0,
|
|
1846
2463
|
configurable: !0
|
|
1847
2464
|
});
|
|
1848
|
-
},
|
|
2465
|
+
}, l = {
|
|
1849
2466
|
name: this.name,
|
|
1850
2467
|
variables: this.variables,
|
|
1851
2468
|
boolVars: this.boolVars,
|
|
@@ -1855,11 +2472,11 @@ var Re = class {
|
|
|
1855
2472
|
if (typeof i.check == "function") {
|
|
1856
2473
|
let e;
|
|
1857
2474
|
try {
|
|
1858
|
-
e = await i.check(
|
|
2475
|
+
e = await i.check(l, o);
|
|
1859
2476
|
} catch (e) {
|
|
1860
2477
|
throw this.activeOperationId === n && this.clearSolutionFields(), e;
|
|
1861
2478
|
}
|
|
1862
|
-
this.ensureExecutionValid(r, n, "check"), this.status = e.status, this.terminationStatus = a.signal?.aborted ? "Interrupted" : e.status, this.hasPrimalSolution = e.status === "Sat", this.runTime = e.runTime ?? 0, this.unsatCore = e.unsatCore === void 0 ? void 0 : Object.freeze([...e.unsatCore]);
|
|
2479
|
+
this.ensureExecutionValid(r, n, "check"), this.status = e.status, this.terminationStatus = a.signal?.aborted ? "Interrupted" : e.status, this.hasPrimalSolution = e.status === "Sat", this.runTime = e.runTime ?? 0, this.unsatCore = e.unsatCore === void 0 ? void 0 : Object.freeze([...e.unsatCore]), this.conflicts = e.conflicts === void 0 ? this.unsatCore : Object.freeze([...e.conflicts]);
|
|
1863
2480
|
let t = {};
|
|
1864
2481
|
if (e.values && e.status === "Sat") {
|
|
1865
2482
|
for (let [n, r] of Object.entries(e.values)) if (typeof r == "number") {
|
|
@@ -1875,133 +2492,184 @@ var Re = class {
|
|
|
1875
2492
|
status: e.status,
|
|
1876
2493
|
values: t,
|
|
1877
2494
|
unsatCore: this.unsatCore,
|
|
1878
|
-
conflicts: this.
|
|
2495
|
+
conflicts: this.conflicts,
|
|
1879
2496
|
runTime: this.runTime
|
|
1880
2497
|
};
|
|
1881
2498
|
}
|
|
1882
|
-
let
|
|
1883
|
-
|
|
2499
|
+
let u = this.logicalConstraints.length > 0 || this.boolVars.length > 0 ? Ke(this.variables, this.boolVars, this.constraints, this.logicalConstraints) : {
|
|
2500
|
+
variables: [...this.variables],
|
|
2501
|
+
constraints: [...this.constraints],
|
|
2502
|
+
boolVarToBinary: /* @__PURE__ */ new Map(),
|
|
2503
|
+
constraintToOriginalName: new Map(this.constraints.map((e) => [e, e.name]))
|
|
2504
|
+
}, d = [], f = [], p = [], m = /* @__PURE__ */ new Map(), h = 0;
|
|
2505
|
+
for (let e of u.constraints) {
|
|
2506
|
+
let t = u.constraintToOriginalName.get(e) ?? e.name, { lhs: n, sense: r, rhs: i } = e;
|
|
2507
|
+
if (r === "<=") {
|
|
2508
|
+
let r = new b({
|
|
2509
|
+
name: `__slack_${++h}`,
|
|
2510
|
+
type: "Continuous",
|
|
2511
|
+
lb: 0,
|
|
2512
|
+
ub: Infinity
|
|
2513
|
+
});
|
|
2514
|
+
f.push(r), p.push([r, 1]), m.set(r, t);
|
|
2515
|
+
let a = n.clone().add(new j(/* @__PURE__ */ new Map([[r, -1]]), 0));
|
|
2516
|
+
d.push(new c(a, "<=", i, `${e.name}_slack`));
|
|
2517
|
+
} else if (r === ">=") {
|
|
2518
|
+
let r = new b({
|
|
2519
|
+
name: `__slack_${++h}`,
|
|
2520
|
+
type: "Continuous",
|
|
2521
|
+
lb: 0,
|
|
2522
|
+
ub: Infinity
|
|
2523
|
+
});
|
|
2524
|
+
f.push(r), p.push([r, 1]), m.set(r, t);
|
|
2525
|
+
let a = n.clone().add(new j(/* @__PURE__ */ new Map([[r, 1]]), 0));
|
|
2526
|
+
d.push(new c(a, ">=", i, `${e.name}_slack`));
|
|
2527
|
+
} else {
|
|
2528
|
+
let r = new b({
|
|
2529
|
+
name: `__slack_${++h}_p`,
|
|
2530
|
+
type: "Continuous",
|
|
2531
|
+
lb: 0,
|
|
2532
|
+
ub: Infinity
|
|
2533
|
+
}), a = new b({
|
|
2534
|
+
name: `__slack_${++h}_n`,
|
|
2535
|
+
type: "Continuous",
|
|
2536
|
+
lb: 0,
|
|
2537
|
+
ub: Infinity
|
|
2538
|
+
});
|
|
2539
|
+
f.push(r, a), p.push([r, 1], [a, 1]), m.set(r, t), m.set(a, t);
|
|
2540
|
+
let o = n.clone().add(new j(/* @__PURE__ */ new Map([[r, -1], [a, 1]]), 0));
|
|
2541
|
+
d.push(new c(o, "==", i, `${e.name}_slack`));
|
|
2542
|
+
}
|
|
2543
|
+
}
|
|
2544
|
+
let g = {
|
|
2545
|
+
name: `${this.name}_elastic_check`,
|
|
1884
2546
|
sense: "Minimize",
|
|
1885
|
-
objective: new j(),
|
|
1886
|
-
constraints:
|
|
1887
|
-
variables:
|
|
1888
|
-
|
|
1889
|
-
boolVars: this.boolVars
|
|
1890
|
-
}, u;
|
|
2547
|
+
objective: new j(new Map(p), 0),
|
|
2548
|
+
constraints: d,
|
|
2549
|
+
variables: [...u.variables, ...f]
|
|
2550
|
+
}, _;
|
|
1891
2551
|
try {
|
|
1892
|
-
|
|
2552
|
+
_ = await i.solve(g, o);
|
|
1893
2553
|
} catch (e) {
|
|
1894
2554
|
throw this.activeOperationId === n && this.clearSolutionFields(), e;
|
|
1895
2555
|
}
|
|
1896
|
-
this.ensureExecutionValid(r, n, "check"), this.runTime =
|
|
1897
|
-
let
|
|
1898
|
-
this.status =
|
|
1899
|
-
let
|
|
1900
|
-
if (
|
|
1901
|
-
for (let
|
|
1902
|
-
let
|
|
1903
|
-
|
|
1904
|
-
}
|
|
1905
|
-
|
|
1906
|
-
|
|
2556
|
+
this.ensureExecutionValid(r, n, "check"), this.runTime = _.runTime ?? 0;
|
|
2557
|
+
let v = _.status, y = _.terminationStatus ?? v, x = this.hasPrimalFromResult(_), S = typeof _.objectiveValue == "number" && Number.isFinite(_.objectiveValue) ? _.objectiveValue : Infinity, C = (v === "Optimal" || v === "Feasible" || x) && S <= 1e-5, w = typeof _.objectiveBound == "number" && Number.isFinite(_.objectiveBound) && _.objectiveBound > 1e-5, T = !C && (v === "Infeasible" || v === "Optimal" && S > 1e-5 || w), E = C ? "Sat" : T ? "Unsat" : "Unknown";
|
|
2558
|
+
this.status = E, this.terminationStatus = a.signal?.aborted || y === "Interrupted" ? "Interrupted" : y === "Optimal" || y === "Feasible" || y === "Infeasible" ? E : y, this.hasPrimalSolution = C, this.objectiveValue = null, this.objectiveBound = void 0, this.relGap = void 0, this.mipGap = void 0, this.absGap = void 0, this.solution = null, this.values.clear();
|
|
2559
|
+
let D = {};
|
|
2560
|
+
if (C && _.values) {
|
|
2561
|
+
for (let e of this.variables) {
|
|
2562
|
+
let t = _.values[e.name];
|
|
2563
|
+
typeof t == "number" && Number.isFinite(t) && (e.value = t, this.values.set(e.name, t), s(D, e.name, t));
|
|
2564
|
+
}
|
|
2565
|
+
for (let e of this.boolVars) {
|
|
2566
|
+
let t = u.boolVarToBinary.get(e), n = t ? _.values[t.name] : _.values[e.name];
|
|
2567
|
+
if (typeof n == "number" && Number.isFinite(n)) {
|
|
2568
|
+
let t = Math.round(n) === 1;
|
|
2569
|
+
e.value = t, this.values.set(e.name, t), s(D, e.name, t);
|
|
2570
|
+
}
|
|
1907
2571
|
}
|
|
1908
2572
|
}
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
let n =
|
|
1912
|
-
n
|
|
1913
|
-
}
|
|
1914
|
-
if (u.slacks) for (let [e, t] of Object.entries(u.slacks)) {
|
|
1915
|
-
if (typeof t != "number" || !Number.isFinite(t)) continue;
|
|
1916
|
-
let n = this.getConstraintByName(e);
|
|
1917
|
-
n && (n.slack = t);
|
|
2573
|
+
let O = /* @__PURE__ */ new Set();
|
|
2574
|
+
if (T && _.values) for (let [e, t] of m.entries()) {
|
|
2575
|
+
let n = _.values[e.name];
|
|
2576
|
+
typeof n == "number" && n > 1e-5 && O.add(t);
|
|
1918
2577
|
}
|
|
1919
|
-
return this.hasSolutionState = !0, {
|
|
1920
|
-
status:
|
|
1921
|
-
values:
|
|
2578
|
+
return this.conflicts = T ? Object.freeze(Array.from(O)) : void 0, this.unsatCore = void 0, this.hasSolutionState = !0, {
|
|
2579
|
+
status: E,
|
|
2580
|
+
values: D,
|
|
2581
|
+
conflicts: this.conflicts,
|
|
2582
|
+
unsatCore: this.unsatCore,
|
|
1922
2583
|
runTime: this.runTime
|
|
1923
2584
|
};
|
|
1924
2585
|
}
|
|
1925
2586
|
validateSolution(e = {}) {
|
|
1926
|
-
return
|
|
2587
|
+
return Ue(this, e);
|
|
2588
|
+
}
|
|
2589
|
+
link(e) {
|
|
2590
|
+
if (e instanceof A || typeof e == "object" && e && "quadTerms" in e) throw Error("Linking constraint cannot be a quadratic expression.");
|
|
2591
|
+
if (!(e instanceof c) && (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().");
|
|
2592
|
+
this._linkingConstraints ||= [];
|
|
2593
|
+
let t = e;
|
|
2594
|
+
return this._linkingConstraints.push(t), t;
|
|
2595
|
+
}
|
|
2596
|
+
get linkingConstraints() {
|
|
2597
|
+
return this._linkingConstraints ?? [];
|
|
2598
|
+
}
|
|
2599
|
+
async solveBenders(e) {
|
|
2600
|
+
let t = await et({
|
|
2601
|
+
master: this,
|
|
2602
|
+
...e
|
|
2603
|
+
});
|
|
2604
|
+
return this.decomposition = t, t;
|
|
1927
2605
|
}
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
if (typeof n == "string" && /(<=|>=|==|=<|=>|=)/.test(n)) throw Error(`Cannot use a comparison constraint as an objective in ${t}(). Use model.constraint(expr\`... <= ...\`) for constraints, or supply an unconstrained arithmetic expression to ${t}().`);
|
|
1935
|
-
if (typeof n == "number") {
|
|
1936
|
-
if (!Number.isFinite(n)) throw Error(`Invalid non-finite objective constant "${n}" passed to ${t}().`);
|
|
1937
|
-
return n;
|
|
2606
|
+
async solveColumnGeneration(e) {
|
|
2607
|
+
let t = await Je({
|
|
2608
|
+
master: this,
|
|
2609
|
+
...e
|
|
2610
|
+
});
|
|
2611
|
+
return this.decomposition = t, t;
|
|
1938
2612
|
}
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
}
|
|
1942
|
-
function Be(e) {
|
|
1943
|
-
return {
|
|
1944
|
-
expr: ze(e, "maximize"),
|
|
1945
|
-
sense: "Maximize"
|
|
1946
|
-
};
|
|
1947
|
-
}
|
|
1948
|
-
function Ve(e) {
|
|
1949
|
-
return {
|
|
1950
|
-
expr: ze(e, "minimize"),
|
|
1951
|
-
sense: "Minimize"
|
|
1952
|
-
};
|
|
1953
|
-
}
|
|
1954
|
-
z(/* @__PURE__ */ se({
|
|
2613
|
+
};
|
|
2614
|
+
R(/* @__PURE__ */ he({
|
|
1955
2615
|
BoolExpr: () => r,
|
|
1956
2616
|
BoolOp: () => n,
|
|
1957
2617
|
BoolVar: () => o,
|
|
1958
2618
|
Constraint: () => c,
|
|
1959
|
-
|
|
1960
|
-
|
|
2619
|
+
HIGHS_CONSTANTS: () => ie,
|
|
2620
|
+
HIGHS_STATUS_NAMES: () => le,
|
|
2621
|
+
HiGHS: () => G,
|
|
2622
|
+
Highs: () => P,
|
|
2623
|
+
HighsError: () => te,
|
|
2624
|
+
HighsModel: () => se,
|
|
2625
|
+
HighsSolver: () => W,
|
|
2626
|
+
HighsUnsupportedOptionError: () => ae,
|
|
1961
2627
|
LinExpr: () => j,
|
|
1962
|
-
MockSolver: () =>
|
|
1963
|
-
Model: () =>
|
|
1964
|
-
OFFICIAL_HIGHS_CDN_WASM_URL: () =>
|
|
2628
|
+
MockSolver: () => ze,
|
|
2629
|
+
Model: () => nt,
|
|
2630
|
+
OFFICIAL_HIGHS_CDN_WASM_URL: () => ce,
|
|
1965
2631
|
QuadExpr: () => A,
|
|
1966
2632
|
Var: () => b,
|
|
1967
2633
|
and: () => y,
|
|
1968
|
-
|
|
2634
|
+
bindHighsFunctions: () => ne,
|
|
2635
|
+
buildIndicatorLinearization: () => Y,
|
|
1969
2636
|
buildLpSymbolMaps: () => u,
|
|
1970
|
-
deriveBigMForGe: () =>
|
|
1971
|
-
deriveBigMForLe: () =>
|
|
2637
|
+
deriveBigMForGe: () => J,
|
|
2638
|
+
deriveBigMForLe: () => q,
|
|
1972
2639
|
dot: () => s,
|
|
1973
|
-
expr: () =>
|
|
2640
|
+
expr: () => ke,
|
|
1974
2641
|
generateLpString: () => C,
|
|
1975
|
-
getHighs: () =>
|
|
1976
|
-
getHighsWasmUrl: () =>
|
|
2642
|
+
getHighs: () => oe,
|
|
2643
|
+
getHighsWasmUrl: () => I,
|
|
1977
2644
|
getSolver: () => D,
|
|
1978
2645
|
implies: () => e,
|
|
1979
2646
|
isLpExportResult: () => E,
|
|
1980
|
-
isValidWasmHeader: () =>
|
|
2647
|
+
isValidWasmHeader: () => re,
|
|
2648
|
+
linearizeModelForMip: () => Ke,
|
|
1981
2649
|
listAvailableSolvers: () => S,
|
|
1982
|
-
mapHighsStatus: () =>
|
|
1983
|
-
mapHighsTerminationStatus: () =>
|
|
1984
|
-
maximize: () =>
|
|
1985
|
-
minimize: () =>
|
|
2650
|
+
mapHighsStatus: () => U,
|
|
2651
|
+
mapHighsTerminationStatus: () => H,
|
|
2652
|
+
maximize: () => Xe,
|
|
2653
|
+
minimize: () => Ze,
|
|
1986
2654
|
not: () => v,
|
|
1987
2655
|
or: () => i,
|
|
1988
|
-
parseConstraint: () =>
|
|
1989
|
-
parseExpr: () =>
|
|
2656
|
+
parseConstraint: () => we,
|
|
2657
|
+
parseExpr: () => Se,
|
|
1990
2658
|
probeWasmUrl: () => M,
|
|
1991
|
-
registerHighsSolver: () =>
|
|
1992
|
-
registerMockSolver: () =>
|
|
2659
|
+
registerHighsSolver: () => K,
|
|
2660
|
+
registerMockSolver: () => Be,
|
|
1993
2661
|
registerSolver: () => T,
|
|
1994
|
-
resolveBrowserWasmUrl: () =>
|
|
2662
|
+
resolveBrowserWasmUrl: () => F,
|
|
1995
2663
|
sanitizeIdentifier: () => f,
|
|
1996
2664
|
setDefaultSolver: () => _,
|
|
1997
|
-
setHighsWasmUrl: () =>
|
|
1998
|
-
solveLp: () =>
|
|
2665
|
+
setHighsWasmUrl: () => L,
|
|
2666
|
+
solveLp: () => V,
|
|
1999
2667
|
solveLpWithHighs: () => N,
|
|
2000
2668
|
sum: () => t,
|
|
2001
2669
|
validateModelIntegrity: () => k,
|
|
2002
|
-
validateModelSolution: () =>
|
|
2003
|
-
validateUserBigM: () =>
|
|
2670
|
+
validateModelSolution: () => Ue,
|
|
2671
|
+
validateUserBigM: () => We,
|
|
2004
2672
|
xor: () => a
|
|
2005
|
-
}),
|
|
2673
|
+
}), Ve);
|
|
2006
2674
|
//#endregion
|
|
2007
|
-
export { r as BoolExpr, n as BoolOp, o as BoolVar, c as Constraint,
|
|
2675
|
+
export { r as BoolExpr, n as BoolOp, o as BoolVar, c as Constraint, G as HiGHS, P as Highs, W as HighsSolver, j as LinExpr, ze as MockSolver, nt as Model, A as QuadExpr, b as Var, y as and, Y as buildIndicatorLinearization, u as buildLpSymbolMaps, J as deriveBigMForGe, q as deriveBigMForLe, s as dot, ke as expr, C as generateLpString, oe as getHighs, I as getHighsWasmUrl, D as getSolver, e as implies, E as isLpExportResult, Ke as linearizeModelForMip, S as listAvailableSolvers, Xe as maximize, Ze as minimize, _e as normalizeSense, v as not, i as or, we as parseConstraint, Se as parseExpr, T as registerSolver, f as sanitizeIdentifier, _ as setDefaultSolver, L as setHighsWasmUrl, et as solveBenders, Je as solveColumnGeneration, N as solveLpWithHighs, t as sum, k as validateModelIntegrity, Ue as validateModelSolution, We as validateUserBigM, a as xor };
|