@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
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { _ as e, a as t,
|
|
1
|
+
import { _ as e, a as t, b as n, c as r, d as i, f as a, g as o, h as s, i as c, l, m as u, n as d, o as f, p, r as m, s as h, t as g, u as _, y as v } from "./highs-loader-Csn3-0tq.js";
|
|
2
2
|
//#region src/modeler/constraint.ts
|
|
3
|
-
var
|
|
3
|
+
var y = 0, b = class e {
|
|
4
4
|
kind = "constraint";
|
|
5
5
|
id;
|
|
6
6
|
_lhs;
|
|
@@ -15,13 +15,13 @@ var _ = 0, v = class e {
|
|
|
15
15
|
slack = null;
|
|
16
16
|
dual = null;
|
|
17
17
|
addTerm(e, t) {
|
|
18
|
-
return t === 0 ? this : (this._indicatorOrigin = void 0, this._indicatorSnapshot = void 0, this._lhs.addTerm(e, t),
|
|
18
|
+
return t === 0 ? this : (this._indicatorOrigin = void 0, this._indicatorSnapshot = void 0, this._lhs.addTerm(e, t), E(this.ownerModel), this);
|
|
19
19
|
}
|
|
20
20
|
setTerm(e, t) {
|
|
21
|
-
return this._indicatorOrigin = void 0, this._indicatorSnapshot = void 0, this._lhs.setTerm(e, t),
|
|
21
|
+
return this._indicatorOrigin = void 0, this._indicatorSnapshot = void 0, this._lhs.setTerm(e, t), E(this.ownerModel), this;
|
|
22
22
|
}
|
|
23
23
|
constructor(e, t, n, r) {
|
|
24
|
-
this.id = ++
|
|
24
|
+
this.id = ++y, this._lhs = e, this._sense = t, this._rhs = n;
|
|
25
25
|
let i = typeof r == "string" ? r.trim() : void 0;
|
|
26
26
|
i && i.length > 0 ? (this._name = i, this.hasExplicitName = !0) : (this._name = `c_${this.id}`, this.hasExplicitName = !1);
|
|
27
27
|
}
|
|
@@ -29,27 +29,27 @@ var _ = 0, v = class e {
|
|
|
29
29
|
return this._lhs;
|
|
30
30
|
}
|
|
31
31
|
set lhs(e) {
|
|
32
|
-
this._lhs !== e && (this._indicatorOrigin = void 0, this._indicatorSnapshot = void 0, this._lhs = e,
|
|
32
|
+
this._lhs !== e && (this._indicatorOrigin = void 0, this._indicatorSnapshot = void 0, this._lhs = e, E(this.ownerModel));
|
|
33
33
|
}
|
|
34
34
|
get sense() {
|
|
35
35
|
return this._sense;
|
|
36
36
|
}
|
|
37
37
|
set sense(e) {
|
|
38
38
|
if (e === "!=" && !Number.isSafeInteger(this._rhs)) throw Error(`Discrete "!=" in constraint "${this._name}" requires a safe integer RHS, received ${this._rhs}.`);
|
|
39
|
-
this._sense !== e && (this._indicatorOrigin = void 0, this._indicatorSnapshot = void 0, this._sense = e,
|
|
39
|
+
this._sense !== e && (this._indicatorOrigin = void 0, this._indicatorSnapshot = void 0, this._sense = e, E(this.ownerModel));
|
|
40
40
|
}
|
|
41
41
|
get rhs() {
|
|
42
42
|
return this._rhs;
|
|
43
43
|
}
|
|
44
44
|
set rhs(e) {
|
|
45
45
|
if (this._sense === "!=" && !Number.isSafeInteger(e)) throw Error(`Discrete "!=" in constraint "${this._name}" requires a safe integer RHS, received ${e}.`);
|
|
46
|
-
Object.is(this._rhs, e) || (this._indicatorOrigin = void 0, this._indicatorSnapshot = void 0, this._rhs = e,
|
|
46
|
+
Object.is(this._rhs, e) || (this._indicatorOrigin = void 0, this._indicatorSnapshot = void 0, this._rhs = e, E(this.ownerModel));
|
|
47
47
|
}
|
|
48
48
|
get name() {
|
|
49
49
|
return this._name;
|
|
50
50
|
}
|
|
51
51
|
set name(e) {
|
|
52
|
-
this._name !== e && (this._name = e,
|
|
52
|
+
this._name !== e && (this._name = e, E(this.ownerModel)), this.hasExplicitName = !0;
|
|
53
53
|
}
|
|
54
54
|
get _indicatorMeta() {
|
|
55
55
|
let e = this._indicatorOrigin, t = this._indicatorSnapshot;
|
|
@@ -93,19 +93,19 @@ var _ = 0, v = class e {
|
|
|
93
93
|
this._name = e, this.hasExplicitName = t;
|
|
94
94
|
}
|
|
95
95
|
and(e) {
|
|
96
|
-
return new
|
|
96
|
+
return new w("and", [this, e]);
|
|
97
97
|
}
|
|
98
98
|
or(e) {
|
|
99
|
-
return new
|
|
99
|
+
return new w("or", [this, e]);
|
|
100
100
|
}
|
|
101
101
|
implies(e) {
|
|
102
|
-
return new
|
|
102
|
+
return new w("implies", [this, e]);
|
|
103
103
|
}
|
|
104
104
|
xor(e) {
|
|
105
|
-
return new
|
|
105
|
+
return new w("xor", [this, e]);
|
|
106
106
|
}
|
|
107
107
|
not() {
|
|
108
|
-
return new
|
|
108
|
+
return new w("not", [this]);
|
|
109
109
|
}
|
|
110
110
|
add(e) {
|
|
111
111
|
throw Error("Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.");
|
|
@@ -155,46 +155,46 @@ var _ = 0, v = class e {
|
|
|
155
155
|
return `${this.name}: ${this.lhs.toString()} ${e} ${this.rhs}`;
|
|
156
156
|
}
|
|
157
157
|
};
|
|
158
|
-
function
|
|
159
|
-
return e instanceof
|
|
158
|
+
function x(e) {
|
|
159
|
+
return e instanceof b || typeof e == "object" && !!e && "sense" in e && "lhs" in e && "rhs" in e;
|
|
160
160
|
}
|
|
161
161
|
//#endregion
|
|
162
162
|
//#region src/modeler/boolean-expr.ts
|
|
163
|
-
function
|
|
164
|
-
if (e instanceof
|
|
163
|
+
function S(e, t) {
|
|
164
|
+
if (e instanceof C || e instanceof b) return e;
|
|
165
165
|
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.`);
|
|
166
166
|
}
|
|
167
|
-
var
|
|
167
|
+
var C = class {
|
|
168
168
|
and(e) {
|
|
169
|
-
return new
|
|
169
|
+
return new w("and", [this, S(e, "and")]);
|
|
170
170
|
}
|
|
171
171
|
or(e) {
|
|
172
|
-
return new
|
|
172
|
+
return new w("or", [this, S(e, "or")]);
|
|
173
173
|
}
|
|
174
174
|
implies(e) {
|
|
175
|
-
return new
|
|
175
|
+
return new w("implies", [this, S(e, "implies")]);
|
|
176
176
|
}
|
|
177
177
|
xor(e) {
|
|
178
|
-
return new
|
|
178
|
+
return new w("xor", [this, S(e, "xor")]);
|
|
179
179
|
}
|
|
180
180
|
not() {
|
|
181
|
-
return new
|
|
181
|
+
return new w("not", [this]);
|
|
182
182
|
}
|
|
183
|
-
},
|
|
183
|
+
}, w = class extends C {
|
|
184
184
|
op;
|
|
185
185
|
children;
|
|
186
186
|
constructor(e, t) {
|
|
187
|
-
super(), this.op = e, this.children = t.map((t) =>
|
|
187
|
+
super(), this.op = e, this.children = t.map((t) => S(t, e));
|
|
188
188
|
}
|
|
189
189
|
toString() {
|
|
190
190
|
return this.op === "not" ? `not(${this.children[0].toString()})` : `(${this.children.map((e) => e.toString()).join(` ${this.op} `)})`;
|
|
191
191
|
}
|
|
192
|
-
},
|
|
193
|
-
function w(e) {
|
|
194
|
-
e && C.get(e)?.();
|
|
195
|
-
}
|
|
196
|
-
var T = 1e-6;
|
|
192
|
+
}, T = /* @__PURE__ */ new WeakMap();
|
|
197
193
|
function E(e) {
|
|
194
|
+
e && T.get(e)?.();
|
|
195
|
+
}
|
|
196
|
+
var D = 1e-6;
|
|
197
|
+
function O(e) {
|
|
198
198
|
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).`);
|
|
199
199
|
if (e.lb === Infinity) throw Error(`Variable "${e.name}" has invalid lower bound: +Infinity is not allowed as a lower bound.`);
|
|
200
200
|
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).`);
|
|
@@ -203,16 +203,16 @@ function E(e) {
|
|
|
203
203
|
if (e.initialValue !== void 0) {
|
|
204
204
|
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).`);
|
|
205
205
|
let t = e.type === "Binary" ? Math.max(0, e.lb) : e.lb, n = e.type === "Binary" ? Math.min(1, e.ub) : e.ub;
|
|
206
|
-
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 ${
|
|
206
|
+
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 ${D}).`);
|
|
207
207
|
if (e.type === "Integer" || e.type === "Binary") {
|
|
208
208
|
let r = Math.round(e.initialValue);
|
|
209
|
-
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 ${
|
|
209
|
+
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 ${D} of an integer in [${t}, ${n}]).`);
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
213
|
function ee(e) {
|
|
214
214
|
if (e.initialValue === void 0) return;
|
|
215
|
-
if (
|
|
215
|
+
if (O(e), e.type === "Integer" || e.type === "Binary") {
|
|
216
216
|
let t = Math.round(e.initialValue);
|
|
217
217
|
return Object.is(t, -0) ? 0 : t;
|
|
218
218
|
}
|
|
@@ -221,8 +221,8 @@ function ee(e) {
|
|
|
221
221
|
}
|
|
222
222
|
//#endregion
|
|
223
223
|
//#region src/modeler/variable.ts
|
|
224
|
-
var
|
|
225
|
-
function
|
|
224
|
+
var k = 0;
|
|
225
|
+
function A(e) {
|
|
226
226
|
if (e === void 0) return "Continuous";
|
|
227
227
|
if (typeof e == "string") {
|
|
228
228
|
let t = e.toLowerCase();
|
|
@@ -232,7 +232,7 @@ function O(e) {
|
|
|
232
232
|
}
|
|
233
233
|
throw Error(`Invalid variable type "${String(e)}": expected "Continuous", "Integer", or "Binary".`);
|
|
234
234
|
}
|
|
235
|
-
var
|
|
235
|
+
var j = class {
|
|
236
236
|
id;
|
|
237
237
|
_name;
|
|
238
238
|
prefix;
|
|
@@ -245,9 +245,9 @@ var k = class {
|
|
|
245
245
|
value = null;
|
|
246
246
|
reducedCost = null;
|
|
247
247
|
constructor(e = {}) {
|
|
248
|
-
this.id = ++
|
|
248
|
+
this.id = ++k;
|
|
249
249
|
let t = typeof e.name == "string" ? e.name.trim() : "", n = typeof e.prefix == "string" ? e.prefix.trim() : "";
|
|
250
|
-
this.prefix = n.length > 0 ? n : "x", this.hasExplicitName = t.length > 0, this._name = this.hasExplicitName ? t : `${this.prefix}_${this.id}`, this._type =
|
|
250
|
+
this.prefix = n.length > 0 ? n : "x", this.hasExplicitName = t.length > 0, this._name = this.hasExplicitName ? t : `${this.prefix}_${this.id}`, this._type = A(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 && O(this);
|
|
251
251
|
}
|
|
252
252
|
get name() {
|
|
253
253
|
return this._name;
|
|
@@ -256,60 +256,60 @@ var k = class {
|
|
|
256
256
|
return this._type;
|
|
257
257
|
}
|
|
258
258
|
set type(e) {
|
|
259
|
-
let t =
|
|
260
|
-
this._type !== t && (this._type = t,
|
|
259
|
+
let t = A(e);
|
|
260
|
+
this._type !== t && (this._type = t, E(this.ownerModel));
|
|
261
261
|
}
|
|
262
262
|
get lb() {
|
|
263
263
|
return this._lb;
|
|
264
264
|
}
|
|
265
265
|
set lb(e) {
|
|
266
|
-
Object.is(this._lb, e) || (this._lb = e,
|
|
266
|
+
Object.is(this._lb, e) || (this._lb = e, E(this.ownerModel));
|
|
267
267
|
}
|
|
268
268
|
get ub() {
|
|
269
269
|
return this._ub;
|
|
270
270
|
}
|
|
271
271
|
set ub(e) {
|
|
272
|
-
Object.is(this._ub, e) || (this._ub = e,
|
|
272
|
+
Object.is(this._ub, e) || (this._ub = e, E(this.ownerModel));
|
|
273
273
|
}
|
|
274
274
|
get initialValue() {
|
|
275
275
|
return this._initialValue;
|
|
276
276
|
}
|
|
277
277
|
set initialValue(e) {
|
|
278
278
|
let t = e !== void 0 && Object.is(e, -0) ? 0 : e;
|
|
279
|
-
Object.is(this._initialValue, t) || (this._initialValue = t,
|
|
279
|
+
Object.is(this._initialValue, t) || (this._initialValue = t, E(this.ownerModel));
|
|
280
280
|
}
|
|
281
281
|
_assignModelName(e) {
|
|
282
282
|
this._name = e;
|
|
283
283
|
}
|
|
284
284
|
mul(e) {
|
|
285
|
-
return typeof e == "number" ? new
|
|
285
|
+
return typeof e == "number" ? new F(/* @__PURE__ */ new Map([[this, 1]]), 0).mul(e) : new L(/* @__PURE__ */ new Map([[this, 1]]), /* @__PURE__ */ new Map(), 0).mul(e);
|
|
286
286
|
}
|
|
287
287
|
add(e) {
|
|
288
|
-
return e instanceof
|
|
288
|
+
return e instanceof L ? e.add(this) : new F(/* @__PURE__ */ new Map([[this, 1]]), 0).add(e);
|
|
289
289
|
}
|
|
290
290
|
sub(e) {
|
|
291
|
-
return e instanceof
|
|
291
|
+
return e instanceof L ? e.neg().add(this) : new F(/* @__PURE__ */ new Map([[this, 1]]), 0).sub(e);
|
|
292
292
|
}
|
|
293
293
|
neg() {
|
|
294
294
|
return this.mul(-1);
|
|
295
295
|
}
|
|
296
296
|
le(e, t) {
|
|
297
|
-
return new
|
|
297
|
+
return new F(/* @__PURE__ */ new Map([[this, 1]]), 0).le(e, t);
|
|
298
298
|
}
|
|
299
299
|
ge(e, t) {
|
|
300
|
-
return new
|
|
300
|
+
return new F(/* @__PURE__ */ new Map([[this, 1]]), 0).ge(e, t);
|
|
301
301
|
}
|
|
302
302
|
eq(e, t) {
|
|
303
|
-
return new
|
|
303
|
+
return new F(/* @__PURE__ */ new Map([[this, 1]]), 0).eq(e, t);
|
|
304
304
|
}
|
|
305
305
|
lt(e, t) {
|
|
306
|
-
return new
|
|
306
|
+
return new F(/* @__PURE__ */ new Map([[this, 1]]), 0).lt(e, t);
|
|
307
307
|
}
|
|
308
308
|
gt(e, t) {
|
|
309
|
-
return new
|
|
309
|
+
return new F(/* @__PURE__ */ new Map([[this, 1]]), 0).gt(e, t);
|
|
310
310
|
}
|
|
311
311
|
ne(e, t) {
|
|
312
|
-
return new
|
|
312
|
+
return new F(/* @__PURE__ */ new Map([[this, 1]]), 0).ne(e, t);
|
|
313
313
|
}
|
|
314
314
|
toString() {
|
|
315
315
|
return this.name;
|
|
@@ -317,7 +317,7 @@ var k = class {
|
|
|
317
317
|
};
|
|
318
318
|
//#endregion
|
|
319
319
|
//#region src/modeler/expression.ts
|
|
320
|
-
function
|
|
320
|
+
function M(e) {
|
|
321
321
|
switch (e.kind) {
|
|
322
322
|
case "abs": return {
|
|
323
323
|
kind: "abs",
|
|
@@ -339,7 +339,7 @@ function A(e) {
|
|
|
339
339
|
};
|
|
340
340
|
}
|
|
341
341
|
}
|
|
342
|
-
function
|
|
342
|
+
function te(e) {
|
|
343
343
|
switch (e.kind) {
|
|
344
344
|
case "abs": return `abs(${e.arg.toString()})`;
|
|
345
345
|
case "max": return `max(${e.args.map((e) => e.toString()).join(", ")})`;
|
|
@@ -347,7 +347,7 @@ function j(e) {
|
|
|
347
347
|
case "at": return `at([${e.array.map((e) => e.toString()).join(", ")}], ${e.index.toString()})`;
|
|
348
348
|
}
|
|
349
349
|
}
|
|
350
|
-
function
|
|
350
|
+
function N(e) {
|
|
351
351
|
switch (e.kind) {
|
|
352
352
|
case "abs": {
|
|
353
353
|
let t = e.arg.value;
|
|
@@ -379,21 +379,21 @@ function M(e) {
|
|
|
379
379
|
}
|
|
380
380
|
}
|
|
381
381
|
}
|
|
382
|
-
function
|
|
383
|
-
return e instanceof
|
|
382
|
+
function ne(e) {
|
|
383
|
+
return e instanceof j || typeof e == "object" && !!e && !x(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";
|
|
384
384
|
}
|
|
385
|
-
function
|
|
385
|
+
function P(e, t, n = /* @__PURE__ */ new Set()) {
|
|
386
386
|
if (typeof e == "number") {
|
|
387
387
|
if (!Number.isSafeInteger(e)) throw Error(`${t} requires Integer or Binary variables and integer constants/coefficients, but received constant ${e}.`);
|
|
388
388
|
return n;
|
|
389
389
|
}
|
|
390
|
-
if (
|
|
391
|
-
if (e instanceof
|
|
390
|
+
if (x(e)) throw Error(`${t} cannot accept a Constraint comparison.`);
|
|
391
|
+
if (e instanceof L || "quadTerms" in e && e.quadTerms instanceof Map && "linearTerms" in e && e.linearTerms instanceof Map && typeof e.constant == "number") {
|
|
392
392
|
let r = e;
|
|
393
393
|
if (r.quadTerms.size > 0) throw Error(`${t} does not support quadratic expressions.`);
|
|
394
|
-
return
|
|
394
|
+
return P(new F(r.linearTerms, r.constant, r.nonlinearTerms ?? []), t, n);
|
|
395
395
|
}
|
|
396
|
-
if (
|
|
396
|
+
if (ne(e)) {
|
|
397
397
|
if (e.type !== "Integer" && e.type !== "Binary") throw Error(`${t} requires Integer or Binary variables, but involves Continuous variable "${e.name}".`);
|
|
398
398
|
return n.add(e), n;
|
|
399
399
|
}
|
|
@@ -409,25 +409,25 @@ function N(e, t, n = /* @__PURE__ */ new Set()) {
|
|
|
409
409
|
if (e.coeff === 0) continue;
|
|
410
410
|
if (!Number.isSafeInteger(e.coeff)) throw Error(`${t} requires integer coefficients on nonlinear expressions, received ${e.coeff}.`);
|
|
411
411
|
let r = e.atom;
|
|
412
|
-
if (r.kind === "abs")
|
|
413
|
-
else if (r.kind === "max" || r.kind === "min") for (let e of r.args)
|
|
412
|
+
if (r.kind === "abs") P(r.arg, t, n);
|
|
413
|
+
else if (r.kind === "max" || r.kind === "min") for (let e of r.args) P(e, t, n);
|
|
414
414
|
else if (r.kind === "at") {
|
|
415
|
-
|
|
416
|
-
for (let e of r.array)
|
|
415
|
+
P(r.index, t, n);
|
|
416
|
+
for (let e of r.array) P(e, t, n);
|
|
417
417
|
}
|
|
418
418
|
}
|
|
419
419
|
return n;
|
|
420
420
|
}
|
|
421
421
|
throw Error(`${t} expected an integer-valued scalar expression.`);
|
|
422
422
|
}
|
|
423
|
-
var
|
|
423
|
+
var F = class e {
|
|
424
424
|
kind = "linear";
|
|
425
425
|
terms;
|
|
426
426
|
constant;
|
|
427
427
|
nonlinearTerms;
|
|
428
428
|
constructor(e = /* @__PURE__ */ new Map(), t = 0, n = []) {
|
|
429
429
|
this.terms = new Map(e), this.constant = t, this.nonlinearTerms = n.filter((e) => e.coeff !== 0).map((e) => ({
|
|
430
|
-
atom:
|
|
430
|
+
atom: M(e.atom),
|
|
431
431
|
coeff: e.coeff
|
|
432
432
|
}));
|
|
433
433
|
}
|
|
@@ -445,8 +445,8 @@ var P = class e {
|
|
|
445
445
|
return new e(this.terms, this.constant, this.nonlinearTerms);
|
|
446
446
|
}
|
|
447
447
|
add(e) {
|
|
448
|
-
if (
|
|
449
|
-
if (e instanceof
|
|
448
|
+
if (x(e)) throw Error("Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.");
|
|
449
|
+
if (e instanceof L) return e.add(this);
|
|
450
450
|
let t = this.clone();
|
|
451
451
|
if (typeof e == "number") t.constant += e;
|
|
452
452
|
else if ("terms" in e) {
|
|
@@ -455,7 +455,7 @@ var P = class e {
|
|
|
455
455
|
e === 0 ? t.terms.delete(n) : t.terms.set(n, e);
|
|
456
456
|
}
|
|
457
457
|
if (t.constant += e.constant, Array.isArray(e.nonlinearTerms)) for (let n of e.nonlinearTerms) n.coeff !== 0 && t.nonlinearTerms.push({
|
|
458
|
-
atom:
|
|
458
|
+
atom: M(n.atom),
|
|
459
459
|
coeff: n.coeff
|
|
460
460
|
});
|
|
461
461
|
} else {
|
|
@@ -465,11 +465,11 @@ var P = class e {
|
|
|
465
465
|
return t;
|
|
466
466
|
}
|
|
467
467
|
sub(e) {
|
|
468
|
-
if (
|
|
469
|
-
return e instanceof
|
|
468
|
+
if (x(e)) throw Error("Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.");
|
|
469
|
+
return e instanceof L ? e.neg().add(this) : typeof e == "number" ? this.add(-e) : this.add(e.mul(-1));
|
|
470
470
|
}
|
|
471
471
|
mul(t) {
|
|
472
|
-
if (
|
|
472
|
+
if (x(t)) throw Error("Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.");
|
|
473
473
|
if (typeof t == "number") {
|
|
474
474
|
let n = this.terms.size > 0 || this.nonlinearTerms.length > 0, r = this.constant === 0 && n ? 0 : this.constant * t;
|
|
475
475
|
if (this.constant !== 0 && t !== 0 && r === 0) throw Error("Constant multiplication underflows to zero.");
|
|
@@ -483,17 +483,17 @@ var P = class e {
|
|
|
483
483
|
let n = e.coeff * t;
|
|
484
484
|
if (e.coeff !== 0 && n === 0) throw Error("Coefficient multiplication underflows to zero.");
|
|
485
485
|
n !== 0 && i.nonlinearTerms.push({
|
|
486
|
-
atom:
|
|
486
|
+
atom: M(e.atom),
|
|
487
487
|
coeff: n
|
|
488
488
|
});
|
|
489
489
|
}
|
|
490
490
|
return i;
|
|
491
491
|
}
|
|
492
|
-
if (t instanceof
|
|
492
|
+
if (t instanceof j || typeof t == "object" && t && "id" in t && !("terms" in t) && !("quadTerms" in t)) {
|
|
493
493
|
if (this.hasNonlinearTerms()) throw Error("Cannot multiply nonlinear expression (max, min, abs, or at) by a variable expression: only scalar multiplication is supported.");
|
|
494
|
-
return
|
|
494
|
+
return L.multiplyLinearTerms(this.constant, this.terms, 0, /* @__PURE__ */ new Map([[t, 1]]));
|
|
495
495
|
}
|
|
496
|
-
if (t instanceof
|
|
496
|
+
if (t instanceof L) {
|
|
497
497
|
let e = t.linearTerms.size > 0 || t.quadTerms.size > 0 || t.hasNonlinearTerms();
|
|
498
498
|
if (this.hasNonlinearTerms()) {
|
|
499
499
|
if (!e) return this.mul(t.constant);
|
|
@@ -503,7 +503,7 @@ var P = class e {
|
|
|
503
503
|
if (this.terms.size === 0) return t.mul(this.constant);
|
|
504
504
|
throw Error("Cannot multiply nonlinear expression (max, min, abs, or at) by a variable expression: only scalar multiplication is supported.");
|
|
505
505
|
}
|
|
506
|
-
return this.terms.size === 0 ? t.mul(this.constant) : new
|
|
506
|
+
return this.terms.size === 0 ? t.mul(this.constant) : new L(this.terms, /* @__PURE__ */ new Map(), this.constant).mul(t);
|
|
507
507
|
}
|
|
508
508
|
let n = Array.isArray(t.nonlinearTerms) && t.nonlinearTerms.length > 0;
|
|
509
509
|
if (this.hasNonlinearTerms()) {
|
|
@@ -514,10 +514,10 @@ var P = class e {
|
|
|
514
514
|
if (this.terms.size === 0) return t.mul(this.constant);
|
|
515
515
|
throw Error("Cannot multiply nonlinear expression (max, min, abs, or at) by a variable expression: only scalar multiplication is supported.");
|
|
516
516
|
}
|
|
517
|
-
return this.terms.size === 0 ? t.mul(this.constant) : t.terms.size === 0 ? this.mul(t.constant) :
|
|
517
|
+
return this.terms.size === 0 ? t.mul(this.constant) : t.terms.size === 0 ? this.mul(t.constant) : L.multiplyLinearTerms(this.constant, this.terms, t.constant, t.terms);
|
|
518
518
|
}
|
|
519
519
|
div(e) {
|
|
520
|
-
let t =
|
|
520
|
+
let t = L.extractScalarDivisor(e, "LinExpr.div()");
|
|
521
521
|
return this.mul(1 / t);
|
|
522
522
|
}
|
|
523
523
|
neg() {
|
|
@@ -530,7 +530,7 @@ var P = class e {
|
|
|
530
530
|
e += n * t.value;
|
|
531
531
|
}
|
|
532
532
|
for (let t of this.nonlinearTerms) {
|
|
533
|
-
let n =
|
|
533
|
+
let n = N(t.atom);
|
|
534
534
|
if (n === null) return null;
|
|
535
535
|
e += t.coeff * n;
|
|
536
536
|
}
|
|
@@ -555,9 +555,9 @@ var P = class e {
|
|
|
555
555
|
return this.toDiscreteComparison("!=", e, t);
|
|
556
556
|
}
|
|
557
557
|
toDiscreteComparison(e, t, n) {
|
|
558
|
-
if (t instanceof
|
|
558
|
+
if (t instanceof b || 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.`);
|
|
559
559
|
let r = `discrete ${e}`, i = /* @__PURE__ */ new Set();
|
|
560
|
-
|
|
560
|
+
P(this, r, i), P(t, r, i);
|
|
561
561
|
let a = this.toConstraint(e === "<" ? "<=" : e === ">" ? ">=" : "!=", t, n);
|
|
562
562
|
if (e === "<") {
|
|
563
563
|
let e = a.rhs - 1;
|
|
@@ -573,14 +573,14 @@ var P = class e {
|
|
|
573
573
|
toConstraint(t, n, r) {
|
|
574
574
|
let i = this.clone(), a = 0;
|
|
575
575
|
if (typeof n == "number") a = n;
|
|
576
|
-
else if (n instanceof
|
|
577
|
-
else if (n instanceof
|
|
576
|
+
else if (n instanceof b || 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.`);
|
|
577
|
+
else if (n instanceof L || typeof n == "object" && n && "quadTerms" in n) {
|
|
578
578
|
let r = n;
|
|
579
579
|
if (r.quadTerms.size > 0) throw Error(`Quadratic expressions are not supported in linear constraints (${t}): quadratic terms are only allowed in objectives.`);
|
|
580
580
|
i = i.sub(new e(r.linearTerms, 0, r.nonlinearTerms ?? [])), a = r.constant;
|
|
581
581
|
} else "terms" in n ? (i = i.sub(new e(n.terms, 0, n.nonlinearTerms ?? [])), a = n.constant) : i = i.sub(n);
|
|
582
582
|
let o = a - i.constant;
|
|
583
|
-
return i.constant = 0, new
|
|
583
|
+
return i.constant = 0, new b(i, t, o, r);
|
|
584
584
|
}
|
|
585
585
|
and(e) {
|
|
586
586
|
throw Error("Cannot use an arithmetic expression without a comparison operator (<=, >=, ==, !=, <, >) in logical 'and': expected a BoolVar, Constraint, or BoolOp.");
|
|
@@ -605,7 +605,7 @@ var P = class e {
|
|
|
605
605
|
}
|
|
606
606
|
for (let n of this.nonlinearTerms) {
|
|
607
607
|
let r = n.coeff, i = r >= 0 ? t ? "" : "+ " : "- ", a = Math.abs(r), o = a === 1 ? "" : `${a} `;
|
|
608
|
-
e.push(`${i}${o}${
|
|
608
|
+
e.push(`${i}${o}${te(n.atom)}`), t = !1;
|
|
609
609
|
}
|
|
610
610
|
if (this.constant !== 0 || e.length === 0) {
|
|
611
611
|
let n = this.constant >= 0 ? t ? "" : "+ " : "- ";
|
|
@@ -616,11 +616,11 @@ var P = class e {
|
|
|
616
616
|
};
|
|
617
617
|
//#endregion
|
|
618
618
|
//#region src/modeler/quad-expr.ts
|
|
619
|
-
function
|
|
619
|
+
function I(e, t) {
|
|
620
620
|
let n = e.id, r = t.id;
|
|
621
621
|
return n <= r ? `${n}:${r}` : `${r}:${n}`;
|
|
622
622
|
}
|
|
623
|
-
var
|
|
623
|
+
var L = class e {
|
|
624
624
|
kind = "quadratic";
|
|
625
625
|
linearTerms;
|
|
626
626
|
quadTerms;
|
|
@@ -630,7 +630,7 @@ var I = class e {
|
|
|
630
630
|
this.linearTerms = new Map(e), this.quadTerms = /* @__PURE__ */ new Map();
|
|
631
631
|
for (let [e, n] of t) this.quadTerms.set(e, { ...n });
|
|
632
632
|
this.constant = n, this.nonlinearTerms = r.filter((e) => e.coeff !== 0).map((e) => ({
|
|
633
|
-
atom:
|
|
633
|
+
atom: M(e.atom),
|
|
634
634
|
coeff: e.coeff
|
|
635
635
|
}));
|
|
636
636
|
}
|
|
@@ -641,11 +641,11 @@ var I = class e {
|
|
|
641
641
|
return new e(this.linearTerms, this.quadTerms, this.constant, this.nonlinearTerms);
|
|
642
642
|
}
|
|
643
643
|
getQuadCoeff(e, t) {
|
|
644
|
-
let n =
|
|
644
|
+
let n = I(e, t), r = this.quadTerms.get(n);
|
|
645
645
|
return r ? r.coeff : 0;
|
|
646
646
|
}
|
|
647
647
|
add(t) {
|
|
648
|
-
if (
|
|
648
|
+
if (x(t)) throw Error("Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.");
|
|
649
649
|
let n = this.clone();
|
|
650
650
|
if (typeof t == "number") return n.constant += t, n;
|
|
651
651
|
if (t instanceof e) {
|
|
@@ -662,7 +662,7 @@ var I = class e {
|
|
|
662
662
|
t === 0 ? n.linearTerms.delete(e) : n.linearTerms.set(e, t);
|
|
663
663
|
}
|
|
664
664
|
if (n.constant += t.constant, Array.isArray(t.nonlinearTerms)) for (let e of t.nonlinearTerms) e.coeff !== 0 && n.nonlinearTerms.push({
|
|
665
|
-
atom:
|
|
665
|
+
atom: M(e.atom),
|
|
666
666
|
coeff: e.coeff
|
|
667
667
|
});
|
|
668
668
|
return n;
|
|
@@ -673,7 +673,7 @@ var I = class e {
|
|
|
673
673
|
t === 0 ? n.linearTerms.delete(e) : n.linearTerms.set(e, t);
|
|
674
674
|
}
|
|
675
675
|
if (n.constant += t.constant, Array.isArray(t.nonlinearTerms)) for (let e of t.nonlinearTerms) e.coeff !== 0 && n.nonlinearTerms.push({
|
|
676
|
-
atom:
|
|
676
|
+
atom: M(e.atom),
|
|
677
677
|
coeff: e.coeff
|
|
678
678
|
});
|
|
679
679
|
return n;
|
|
@@ -682,11 +682,11 @@ var I = class e {
|
|
|
682
682
|
return i === 0 ? n.linearTerms.delete(r) : n.linearTerms.set(r, i), n;
|
|
683
683
|
}
|
|
684
684
|
sub(e) {
|
|
685
|
-
if (
|
|
685
|
+
if (x(e)) throw Error("Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.");
|
|
686
686
|
return typeof e == "number" ? this.add(-e) : this.add(e.mul(-1));
|
|
687
687
|
}
|
|
688
688
|
mul(t) {
|
|
689
|
-
if (
|
|
689
|
+
if (x(t)) throw Error("Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.");
|
|
690
690
|
if (typeof t == "number") {
|
|
691
691
|
let n = this.linearTerms.size > 0 || this.quadTerms.size > 0 || this.nonlinearTerms.length > 0, r = this.constant === 0 && n ? 0 : this.constant * t;
|
|
692
692
|
if (this.constant !== 0 && t !== 0 && r === 0) throw Error("Constant multiplication underflows to zero.");
|
|
@@ -709,7 +709,7 @@ var I = class e {
|
|
|
709
709
|
let n = e.coeff * t;
|
|
710
710
|
if (e.coeff !== 0 && n === 0) throw Error("Coefficient multiplication underflows to zero.");
|
|
711
711
|
n !== 0 && i.nonlinearTerms.push({
|
|
712
|
-
atom:
|
|
712
|
+
atom: M(e.atom),
|
|
713
713
|
coeff: n
|
|
714
714
|
});
|
|
715
715
|
}
|
|
@@ -753,7 +753,7 @@ var I = class e {
|
|
|
753
753
|
e += t.coeff * t.var1.value * t.var2.value;
|
|
754
754
|
}
|
|
755
755
|
for (let t of this.nonlinearTerms) {
|
|
756
|
-
let n =
|
|
756
|
+
let n = N(t.atom);
|
|
757
757
|
if (n === null) return null;
|
|
758
758
|
e += t.coeff * n;
|
|
759
759
|
}
|
|
@@ -779,12 +779,12 @@ var I = class e {
|
|
|
779
779
|
}
|
|
780
780
|
toDiscreteComparison(e, t, n) {
|
|
781
781
|
if (this.quadTerms.size > 0) throw Error(`Quadratic expressions are not supported in discrete comparisons (${e}): quadratic terms are only allowed in objectives.`);
|
|
782
|
-
let r = new
|
|
782
|
+
let r = new F(this.linearTerms, this.constant, this.nonlinearTerms);
|
|
783
783
|
return e === "<" ? r.lt(t, n) : e === ">" ? r.gt(t, n) : r.ne(t, n);
|
|
784
784
|
}
|
|
785
785
|
toConstraint(e, t, n) {
|
|
786
786
|
if (this.quadTerms.size > 0) throw Error(`Quadratic expressions are not supported in linear constraints (${e}): quadratic terms are only allowed in objectives.`);
|
|
787
|
-
let r = new
|
|
787
|
+
let r = new F(this.linearTerms, this.constant, this.nonlinearTerms);
|
|
788
788
|
return e === "<=" ? r.le(t, n) : e === ">=" ? r.ge(t, n) : r.eq(t, n);
|
|
789
789
|
}
|
|
790
790
|
and(e) {
|
|
@@ -813,7 +813,7 @@ var I = class e {
|
|
|
813
813
|
e.push(`${i}${o}${n.name}`), t = !1;
|
|
814
814
|
}
|
|
815
815
|
if (this.nonlinearTerms.length > 0) {
|
|
816
|
-
let n = new
|
|
816
|
+
let n = new F(/* @__PURE__ */ new Map(), 0, this.nonlinearTerms).toString();
|
|
817
817
|
n !== "0" && (e.push(t ? n : n.startsWith("-") ? `- ${n.slice(2)}` : `+ ${n}`), t = !1);
|
|
818
818
|
}
|
|
819
819
|
if (this.constant !== 0 || e.length === 0) {
|
|
@@ -825,7 +825,7 @@ var I = class e {
|
|
|
825
825
|
static fromProduct(t, n, r = 1) {
|
|
826
826
|
let i = new e();
|
|
827
827
|
if (r === 0) return i;
|
|
828
|
-
let a =
|
|
828
|
+
let a = I(t, n);
|
|
829
829
|
return i.quadTerms.set(a, {
|
|
830
830
|
var1: t.id <= n.id ? t : n,
|
|
831
831
|
var2: t.id <= n.id ? n : t,
|
|
@@ -855,7 +855,7 @@ var I = class e {
|
|
|
855
855
|
return s;
|
|
856
856
|
}
|
|
857
857
|
static extractScalarDivisor(e, t) {
|
|
858
|
-
if (
|
|
858
|
+
if (x(e)) throw Error("Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.");
|
|
859
859
|
if (typeof e == "number") {
|
|
860
860
|
if (e === 0) throw Error(`Division by zero in ${t}`);
|
|
861
861
|
return e;
|
|
@@ -868,10 +868,10 @@ var I = class e {
|
|
|
868
868
|
};
|
|
869
869
|
//#endregion
|
|
870
870
|
//#region src/modeler/lp-writer.ts
|
|
871
|
-
function
|
|
871
|
+
function re(e) {
|
|
872
872
|
return typeof e == "object" && !!e && typeof e.lpString == "string" && e.nameToVar instanceof Map && e.nameToConstraint instanceof Map;
|
|
873
873
|
}
|
|
874
|
-
function
|
|
874
|
+
function R(e, t = "x", n = 0) {
|
|
875
875
|
let r = e.replace(/[^a-zA-Z0-9_]/g, "_");
|
|
876
876
|
return /^[0-9]/.test(r) && (r = `${t}_${r}`), (!r || r.length === 0) && (r = `${t}_${n}`), r;
|
|
877
877
|
}
|
|
@@ -880,13 +880,13 @@ function ie(e) {
|
|
|
880
880
|
for (let e = 0; e < t.length; e++) {
|
|
881
881
|
let n = t[e];
|
|
882
882
|
s.set(n, e);
|
|
883
|
-
let a =
|
|
883
|
+
let a = R(n.name, "x", e), o = a, l = 1;
|
|
884
884
|
for (; c.has(o);) o = `${a}_${l++}`;
|
|
885
885
|
c.add(o), i.set(n, o), r.set(o, n);
|
|
886
886
|
}
|
|
887
887
|
let l = /* @__PURE__ */ new Set();
|
|
888
888
|
for (let e = 0; e < n.length; e++) {
|
|
889
|
-
let t = n[e], r =
|
|
889
|
+
let t = n[e], r = R(t.name, "c", e + 1), i = r, s = 1;
|
|
890
890
|
for (; l.has(i);) i = `${r}_${s++}`;
|
|
891
891
|
l.add(i), o.set(t, i), a.set(i, t);
|
|
892
892
|
}
|
|
@@ -904,13 +904,13 @@ function ae(e, t) {
|
|
|
904
904
|
if (typeof r.hasNonlinearTerms == "function" && r.hasNonlinearTerms()) throw Error("generateLpString() received an unlowered nonlinear objective (max/min/abs/at). Lower via Model.toLpString() or linearizeModelForMip() first.");
|
|
905
905
|
let o = t?.relax === !0, { nameToVar: s, varToName: c, nameToConstraint: l, constrToName: u, varOrder: d } = ie(e), f = [];
|
|
906
906
|
f.push(n && n.toLowerCase() === "maximize" ? "Maximize" : "Minimize");
|
|
907
|
-
let p = [], m = !0, h = r instanceof
|
|
907
|
+
let p = [], m = !0, h = r instanceof L ? r.linearTerms : r.terms;
|
|
908
908
|
if (h) for (let [e, t] of h) {
|
|
909
909
|
if (t === 0) continue;
|
|
910
910
|
let n = c.get(e), r = t >= 0 ? m ? "" : "+ " : "- ", i = Math.abs(t), a = i === 1 ? "" : `${i} `;
|
|
911
911
|
p.push(`${r}${a}${n}`), m = !1;
|
|
912
912
|
}
|
|
913
|
-
if (r instanceof
|
|
913
|
+
if (r instanceof L && r.quadTerms.size > 0) {
|
|
914
914
|
let e = [], t = !0, n = Array.from(r.quadTerms.values()).filter((e) => e.coeff !== 0).map((e) => {
|
|
915
915
|
let t = d.get(e.var1) ?? e.var1.id, n = d.get(e.var2) ?? e.var2.id, [r, i, a, o] = t <= n ? [
|
|
916
916
|
e.var1,
|
|
@@ -981,8 +981,8 @@ function ae(e, t) {
|
|
|
981
981
|
}
|
|
982
982
|
//#endregion
|
|
983
983
|
//#region \0washi-browser-worker-factory
|
|
984
|
-
function
|
|
985
|
-
let e =
|
|
984
|
+
function z() {
|
|
985
|
+
let e = o("highs-worker.js"), t = typeof window.origin == "string" ? window.origin : window.location?.origin;
|
|
986
986
|
if (new URL(e).origin === t) return new Worker(e, { type: "module" });
|
|
987
987
|
let n = URL.createObjectURL(new Blob(["import " + JSON.stringify(e) + ";"], { type: "text/javascript" }));
|
|
988
988
|
try {
|
|
@@ -994,8 +994,8 @@ function L() {
|
|
|
994
994
|
}
|
|
995
995
|
//#endregion
|
|
996
996
|
//#region src/modeler/solvers/highs/worker-client.ts
|
|
997
|
-
var
|
|
998
|
-
function
|
|
997
|
+
var B = null, V = null, H = null, U = !1, W = 0, G = /* @__PURE__ */ new Map();
|
|
998
|
+
function K(e, t) {
|
|
999
999
|
return e ? {
|
|
1000
1000
|
Status: "Interrupted",
|
|
1001
1001
|
StatusCode: 17,
|
|
@@ -1019,52 +1019,55 @@ function U(e, t) {
|
|
|
1019
1019
|
Rows: []
|
|
1020
1020
|
};
|
|
1021
1021
|
}
|
|
1022
|
-
function
|
|
1023
|
-
let t =
|
|
1024
|
-
if (t
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1022
|
+
function q(e) {
|
|
1023
|
+
let t = G.values().next().value;
|
|
1024
|
+
if (!t || t.dispatched) return;
|
|
1025
|
+
t.dispatched = !0;
|
|
1026
|
+
let n = {}, r = !1;
|
|
1027
|
+
t.embeddedWasmBinary !== null && !U && (n.embeddedWasmBinary = t.embeddedWasmBinary, r = !0);
|
|
1028
|
+
try {
|
|
1029
|
+
t.kind === "WARMUP" ? e.postMessage({
|
|
1030
|
+
type: "WARMUP",
|
|
1031
|
+
id: t.id,
|
|
1032
|
+
options: t.workerOptions,
|
|
1033
|
+
...n
|
|
1034
|
+
}) : e.postMessage({
|
|
1035
|
+
type: "SOLVE",
|
|
1036
|
+
id: t.id,
|
|
1037
|
+
lpString: t.lpString,
|
|
1038
|
+
options: t.workerOptions,
|
|
1039
|
+
...n,
|
|
1040
|
+
...t.reportProgress ? { reportProgress: !0 } : {}
|
|
1041
|
+
}), r && (U = !0);
|
|
1042
|
+
} catch (n) {
|
|
1043
|
+
G.delete(t.id), t.cleanupAbort?.(), t.reject(n), q(e);
|
|
1041
1044
|
}
|
|
1042
1045
|
}
|
|
1043
|
-
function
|
|
1044
|
-
let e =
|
|
1045
|
-
e && (
|
|
1046
|
-
for (let e of
|
|
1047
|
-
if (
|
|
1048
|
-
let e =
|
|
1049
|
-
if (e)
|
|
1046
|
+
function oe() {
|
|
1047
|
+
let e = B;
|
|
1048
|
+
e && (B = null, V = null, H = null, U = !1, e.terminate());
|
|
1049
|
+
for (let e of G.values()) e.dispatched = !1;
|
|
1050
|
+
if (G.size > 0) try {
|
|
1051
|
+
let e = se();
|
|
1052
|
+
if (e) q(e);
|
|
1050
1053
|
else {
|
|
1051
1054
|
let e = /* @__PURE__ */ Error("[WaSHI] Failed to recreate HiGHS Worker after interruption.");
|
|
1052
|
-
for (let t of Array.from(
|
|
1055
|
+
for (let t of Array.from(G.values())) G.delete(t.id), t.cleanupAbort?.(), t.reject(e);
|
|
1053
1056
|
}
|
|
1054
1057
|
} catch (e) {
|
|
1055
|
-
for (let t of Array.from(
|
|
1058
|
+
for (let t of Array.from(G.values())) G.delete(t.id), t.cleanupAbort?.(), t.reject(e);
|
|
1056
1059
|
}
|
|
1057
1060
|
}
|
|
1058
|
-
function
|
|
1061
|
+
function J() {
|
|
1059
1062
|
return typeof window < "u" && typeof Worker < "u" && typeof Worker?.prototype?.unref != "function";
|
|
1060
1063
|
}
|
|
1061
|
-
function
|
|
1062
|
-
if (!
|
|
1063
|
-
if (!
|
|
1064
|
+
function se() {
|
|
1065
|
+
if (!J()) return null;
|
|
1066
|
+
if (!B) {
|
|
1064
1067
|
let e;
|
|
1065
1068
|
try {
|
|
1066
|
-
e =
|
|
1067
|
-
let { type: n, id: r, result: i, runTime: a, error: o, progress: s, incumbent: c } = t.data, l =
|
|
1069
|
+
e = z(), e.onmessage = (t) => {
|
|
1070
|
+
let { type: n, id: r, result: i, runTime: a, error: o, progress: s, incumbent: c } = t.data, l = G.get(r);
|
|
1068
1071
|
if (l) {
|
|
1069
1072
|
if (n === "SOLVE_PROGRESS") {
|
|
1070
1073
|
if (l.kind === "SOLVE" && s) {
|
|
@@ -1072,10 +1075,10 @@ function q() {
|
|
|
1072
1075
|
try {
|
|
1073
1076
|
l.onProgress?.(s);
|
|
1074
1077
|
} catch (e) {
|
|
1075
|
-
let t =
|
|
1078
|
+
let t = G.get(r);
|
|
1076
1079
|
if (t) {
|
|
1077
|
-
let n =
|
|
1078
|
-
|
|
1080
|
+
let n = G.keys().next().value;
|
|
1081
|
+
G.delete(r), t.cleanupAbort?.(), n === r && oe(), t.reject(e);
|
|
1079
1082
|
}
|
|
1080
1083
|
}
|
|
1081
1084
|
}
|
|
@@ -1085,142 +1088,179 @@ function q() {
|
|
|
1085
1088
|
l.kind === "SOLVE" && c && (l.lastIncumbent = c);
|
|
1086
1089
|
return;
|
|
1087
1090
|
}
|
|
1088
|
-
|
|
1091
|
+
G.delete(r), l.cleanupAbort?.(), l.kind === "WARMUP" ? n === "WARMUP_SUCCESS" ? (B === e && (V = e, H = l.targetKey), l.resolve()) : l.reject(Error(o || "Worker warmup failed")) : n === "SOLVE_SUCCESS" ? (B === e && (V = e, H = l.targetKey), l.resolve({
|
|
1089
1092
|
result: i,
|
|
1090
1093
|
runTime: a
|
|
1091
|
-
})) : l.reject(Error(o || "Worker solve failed")),
|
|
1094
|
+
})) : l.reject(Error(o || "Worker solve failed")), B === e && q(e);
|
|
1092
1095
|
}
|
|
1093
1096
|
};
|
|
1094
1097
|
let t = (t) => {
|
|
1095
|
-
if (
|
|
1096
|
-
|
|
1097
|
-
for (let e of
|
|
1098
|
-
|
|
1098
|
+
if (B === e) {
|
|
1099
|
+
B = null, V = null, H = null, U = !1, e.terminate();
|
|
1100
|
+
for (let e of G.values()) e.cleanupAbort?.(), e.reject(t);
|
|
1101
|
+
G.clear();
|
|
1099
1102
|
}
|
|
1100
1103
|
};
|
|
1101
|
-
e.onerror = (e) => t(/* @__PURE__ */ Error(`[WaSHI] HiGHS Worker failed to load or execute. Check Worker assets, CORS and CSP. ${e?.message || ""}`)), e.onmessageerror = () => t(/* @__PURE__ */ Error("[WaSHI] Could not deserialize the HiGHS Worker response.")),
|
|
1104
|
+
e.onerror = (e) => t(/* @__PURE__ */ Error(`[WaSHI] HiGHS Worker failed to load or execute. Check Worker assets, CORS and CSP. ${e?.message || ""}`)), e.onmessageerror = () => t(/* @__PURE__ */ Error("[WaSHI] Could not deserialize the HiGHS Worker response.")), B = e;
|
|
1102
1105
|
} catch (e) {
|
|
1103
|
-
throw
|
|
1106
|
+
throw B = null, e;
|
|
1104
1107
|
}
|
|
1105
1108
|
}
|
|
1106
|
-
return
|
|
1109
|
+
return B;
|
|
1107
1110
|
}
|
|
1108
|
-
function
|
|
1111
|
+
function ce(e) {
|
|
1109
1112
|
let t = typeof window < "u" ? typeof window.origin == "string" ? window.origin : window.location?.origin : void 0;
|
|
1110
1113
|
return e.useWorker ?? (typeof window < "u" && t !== "null" && !t?.startsWith("file:"));
|
|
1111
1114
|
}
|
|
1112
|
-
function
|
|
1113
|
-
if (e.useWorker === !0 && !
|
|
1114
|
-
return
|
|
1115
|
+
function le(e) {
|
|
1116
|
+
if (e.useWorker === !0 && !J()) throw Error("[WaSHI] Web Worker execution was requested (useWorker: true), but browser Web Workers are unavailable in this environment.");
|
|
1117
|
+
return ce(e) ? se() : null;
|
|
1118
|
+
}
|
|
1119
|
+
async function Y(e, r) {
|
|
1120
|
+
let i = r ? v("highs") : n("highs"), a = i?.kind === "embedded" ? i.bytes : null;
|
|
1121
|
+
if (e.wasmUrl) {
|
|
1122
|
+
let n = await t(e.wasmUrl);
|
|
1123
|
+
return {
|
|
1124
|
+
wasmUrl: n,
|
|
1125
|
+
embeddedWasmBinary: a,
|
|
1126
|
+
targetKey: `url:${n}`
|
|
1127
|
+
};
|
|
1128
|
+
}
|
|
1129
|
+
if (d()) {
|
|
1130
|
+
let e = await t();
|
|
1131
|
+
return {
|
|
1132
|
+
wasmUrl: e,
|
|
1133
|
+
embeddedWasmBinary: a,
|
|
1134
|
+
targetKey: `url:${e}`
|
|
1135
|
+
};
|
|
1136
|
+
}
|
|
1137
|
+
if (!i) return {
|
|
1138
|
+
wasmUrl: null,
|
|
1139
|
+
embeddedWasmBinary: null,
|
|
1140
|
+
targetKey: null
|
|
1141
|
+
};
|
|
1142
|
+
if (i.kind === "embedded") return {
|
|
1143
|
+
wasmUrl: null,
|
|
1144
|
+
embeddedWasmBinary: a,
|
|
1145
|
+
targetKey: "__embedded__"
|
|
1146
|
+
};
|
|
1147
|
+
let o = await t();
|
|
1148
|
+
return {
|
|
1149
|
+
wasmUrl: o,
|
|
1150
|
+
embeddedWasmBinary: null,
|
|
1151
|
+
targetKey: `url:${o}`
|
|
1152
|
+
};
|
|
1115
1153
|
}
|
|
1116
|
-
function
|
|
1154
|
+
function ue(e, t) {
|
|
1117
1155
|
let { signal: n, onProgress: r, onIncumbent: i, ...a } = e, o = {};
|
|
1118
1156
|
for (let [e, t] of Object.entries(a)) {
|
|
1119
1157
|
if (typeof t == "function") throw Error(`[WaSHI] HiGHS Worker option "${e}" cannot be a function (functions cannot be cloned across Web Worker boundaries).`);
|
|
1120
1158
|
o[e] = t;
|
|
1121
1159
|
}
|
|
1122
|
-
return o.wasmUrl = t, o;
|
|
1160
|
+
return t === null ? delete o.wasmUrl : o.wasmUrl = t, o;
|
|
1123
1161
|
}
|
|
1124
|
-
async function
|
|
1125
|
-
if (e.useWorker === !0 && !
|
|
1126
|
-
if (!
|
|
1127
|
-
if (!
|
|
1128
|
-
let
|
|
1129
|
-
return
|
|
1162
|
+
async function de(e = {}) {
|
|
1163
|
+
if (e.useWorker === !0 && !J()) return !1;
|
|
1164
|
+
if (!ce(e) || !J()) return m(e);
|
|
1165
|
+
if (!B || !V || V !== B) return !1;
|
|
1166
|
+
let { targetKey: t } = await Y(e, !1);
|
|
1167
|
+
return t !== null && H === t;
|
|
1130
1168
|
}
|
|
1131
|
-
function
|
|
1169
|
+
function fe(e, t, n) {
|
|
1132
1170
|
if (!e) return;
|
|
1133
1171
|
let r = () => {
|
|
1134
|
-
let e =
|
|
1172
|
+
let e = G.get(t.id);
|
|
1135
1173
|
if (!e) return;
|
|
1136
|
-
let r =
|
|
1137
|
-
|
|
1174
|
+
let r = G.keys().next().value;
|
|
1175
|
+
G.delete(t.id), e.cleanupAbort?.(), r === t.id && oe(), n();
|
|
1138
1176
|
};
|
|
1139
1177
|
e.addEventListener("abort", r, { once: !0 }), t.cleanupAbort = () => e.removeEventListener("abort", r);
|
|
1140
1178
|
}
|
|
1141
|
-
async function
|
|
1142
|
-
|
|
1143
|
-
let { signal:
|
|
1144
|
-
if (
|
|
1145
|
-
let
|
|
1146
|
-
if (
|
|
1147
|
-
let
|
|
1148
|
-
if (!
|
|
1149
|
-
let
|
|
1150
|
-
return
|
|
1179
|
+
async function pe(e = {}) {
|
|
1180
|
+
r(e);
|
|
1181
|
+
let { signal: t } = e;
|
|
1182
|
+
if (t?.aborted) return { cached: !1 };
|
|
1183
|
+
let n = await Y(e, !0);
|
|
1184
|
+
if (t?.aborted) return { cached: !1 };
|
|
1185
|
+
let i = le(e);
|
|
1186
|
+
if (!i) {
|
|
1187
|
+
let n = await m(e);
|
|
1188
|
+
return n || t?.aborted ? { cached: n } : t ? (await new Promise((n, r) => {
|
|
1151
1189
|
let i = !1, a = () => {
|
|
1152
|
-
i || (i = !0,
|
|
1190
|
+
i || (i = !0, n());
|
|
1153
1191
|
};
|
|
1154
|
-
|
|
1155
|
-
|
|
1192
|
+
t.addEventListener("abort", a, { once: !0 }), g(e).then(() => {
|
|
1193
|
+
t.removeEventListener("abort", a), i || (i = !0, n());
|
|
1156
1194
|
}, (e) => {
|
|
1157
|
-
|
|
1195
|
+
t.removeEventListener("abort", a), i || (i = !0, r(e));
|
|
1158
1196
|
});
|
|
1159
|
-
}), { cached:
|
|
1197
|
+
}), { cached: n }) : (await g(e), { cached: n });
|
|
1160
1198
|
}
|
|
1161
|
-
if (
|
|
1162
|
-
let
|
|
1163
|
-
return await new Promise((e,
|
|
1164
|
-
let
|
|
1199
|
+
if (V === i && H === n.targetKey) return { cached: !0 };
|
|
1200
|
+
let a = ue(e, n.wasmUrl), o = `req_${++W}`;
|
|
1201
|
+
return await new Promise((e, r) => {
|
|
1202
|
+
let s = {
|
|
1165
1203
|
kind: "WARMUP",
|
|
1166
|
-
id:
|
|
1167
|
-
workerOptions:
|
|
1168
|
-
|
|
1204
|
+
id: o,
|
|
1205
|
+
workerOptions: a,
|
|
1206
|
+
embeddedWasmBinary: n.embeddedWasmBinary,
|
|
1207
|
+
targetKey: n.targetKey,
|
|
1169
1208
|
resolve: e,
|
|
1170
|
-
reject:
|
|
1209
|
+
reject: r
|
|
1171
1210
|
};
|
|
1172
|
-
|
|
1211
|
+
fe(t, s, e), G.set(o, s), q(i);
|
|
1173
1212
|
}), { cached: !1 };
|
|
1174
1213
|
}
|
|
1175
|
-
async function
|
|
1176
|
-
if (
|
|
1177
|
-
result:
|
|
1214
|
+
async function me(e, t = {}) {
|
|
1215
|
+
if (r(t), t.signal?.aborted) return {
|
|
1216
|
+
result: K(),
|
|
1178
1217
|
runTime: 0
|
|
1179
1218
|
};
|
|
1180
|
-
let
|
|
1181
|
-
if (
|
|
1182
|
-
result:
|
|
1219
|
+
let n = await Y(t, !0);
|
|
1220
|
+
if (t.signal?.aborted) return {
|
|
1221
|
+
result: K(),
|
|
1183
1222
|
runTime: 0
|
|
1184
1223
|
};
|
|
1185
|
-
let
|
|
1186
|
-
if (!
|
|
1187
|
-
let { signal:
|
|
1188
|
-
return new Promise((t,
|
|
1189
|
-
let
|
|
1224
|
+
let i = le(t);
|
|
1225
|
+
if (!i) return h(e, t);
|
|
1226
|
+
let { signal: a, onProgress: o } = t, s = ue(t, n.wasmUrl), c = !!(o || a), l = `req_${++W}`, u = performance.now();
|
|
1227
|
+
return new Promise((t, r) => {
|
|
1228
|
+
let d = {
|
|
1190
1229
|
kind: "SOLVE",
|
|
1191
|
-
id:
|
|
1230
|
+
id: l,
|
|
1192
1231
|
lpString: e,
|
|
1193
|
-
workerOptions:
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1232
|
+
workerOptions: s,
|
|
1233
|
+
embeddedWasmBinary: n.embeddedWasmBinary,
|
|
1234
|
+
targetKey: n.targetKey,
|
|
1235
|
+
reportProgress: c,
|
|
1236
|
+
startTime: u,
|
|
1237
|
+
onProgress: o,
|
|
1198
1238
|
resolve: t,
|
|
1199
|
-
reject:
|
|
1239
|
+
reject: r
|
|
1200
1240
|
};
|
|
1201
|
-
|
|
1202
|
-
let e = (performance.now() -
|
|
1203
|
-
|
|
1204
|
-
result:
|
|
1241
|
+
fe(a, d, () => {
|
|
1242
|
+
let e = (performance.now() - d.startTime) / 1e3;
|
|
1243
|
+
d.resolve({
|
|
1244
|
+
result: K(d.lastIncumbent, d.lastProgress),
|
|
1205
1245
|
runTime: e
|
|
1206
1246
|
});
|
|
1207
|
-
}),
|
|
1247
|
+
}), G.set(l, d), q(i);
|
|
1208
1248
|
});
|
|
1209
1249
|
}
|
|
1210
1250
|
//#endregion
|
|
1211
1251
|
//#region src/modeler/solvers/registry.ts
|
|
1212
|
-
var X = Symbol.for("washi.solverRegistry"),
|
|
1252
|
+
var X = Symbol.for("washi.solverRegistry"), he = Symbol.for("washi.defaultSolverFactory"), Z = globalThis;
|
|
1213
1253
|
Z[X] || (Z[X] = /* @__PURE__ */ new Map());
|
|
1214
|
-
var
|
|
1215
|
-
function
|
|
1216
|
-
|
|
1254
|
+
var ge = Z[X];
|
|
1255
|
+
function _e(e, t) {
|
|
1256
|
+
ge.set(e.toLowerCase(), t);
|
|
1217
1257
|
}
|
|
1218
|
-
function
|
|
1258
|
+
function ve(e) {
|
|
1219
1259
|
if (typeof e == "string") {
|
|
1220
|
-
let t =
|
|
1260
|
+
let t = ge.get(e.toLowerCase());
|
|
1221
1261
|
if (!t) throw Error(`Solver '${e}' is not registered.`);
|
|
1222
|
-
Z[
|
|
1223
|
-
} else Z[
|
|
1262
|
+
Z[he] = t;
|
|
1263
|
+
} else Z[he] = typeof e == "function" ? e : () => e;
|
|
1224
1264
|
}
|
|
1225
1265
|
//#endregion
|
|
1226
1266
|
//#region src/modeler/solvers/highs/solver.ts
|
|
@@ -1282,7 +1322,7 @@ function Q(e, t) {
|
|
|
1282
1322
|
}
|
|
1283
1323
|
return "Unknown";
|
|
1284
1324
|
}
|
|
1285
|
-
function
|
|
1325
|
+
function ye(e, t, n) {
|
|
1286
1326
|
switch (Q(e, t)) {
|
|
1287
1327
|
case "Optimal": return "Optimal";
|
|
1288
1328
|
case "Infeasible": return "Infeasible";
|
|
@@ -1313,16 +1353,16 @@ var $ = class e {
|
|
|
1313
1353
|
constructor(e = {}) {
|
|
1314
1354
|
this.options = e;
|
|
1315
1355
|
}
|
|
1316
|
-
async solve(e, t = {},
|
|
1317
|
-
let i =
|
|
1356
|
+
async solve(e, t = {}, n = {}) {
|
|
1357
|
+
let i = re(t), a = i ? n : t, o = {
|
|
1318
1358
|
...this.options,
|
|
1319
1359
|
...a
|
|
1320
1360
|
};
|
|
1321
|
-
|
|
1361
|
+
r(o);
|
|
1322
1362
|
let s = e.objective?.constant ?? 0;
|
|
1323
1363
|
if (typeof s != "number" || !Number.isFinite(s)) throw Error(`Solver "${this.name}" encountered non-finite objective constant: ${String(s)}.`);
|
|
1324
1364
|
let c = s === 0 ? 0 : s;
|
|
1325
|
-
for (let t of e.variables)
|
|
1365
|
+
for (let t of e.variables) O(t);
|
|
1326
1366
|
let { lpString: l, nameToVar: u, nameToConstraint: d } = i ? t : ae(e, { relax: o.relax }), f = Object.create(null), p = !1, m = /* @__PURE__ */ new Set();
|
|
1327
1367
|
for (let [e, t] of u.entries()) {
|
|
1328
1368
|
m.add(t);
|
|
@@ -1336,16 +1376,16 @@ var $ = class e {
|
|
|
1336
1376
|
...c === 0 ? {} : { objectiveOffset: c },
|
|
1337
1377
|
...p ? { initialValues: f } : {}
|
|
1338
1378
|
});
|
|
1339
|
-
let { result: g, runTime: _ } = await
|
|
1379
|
+
let { result: g, runTime: _ } = await me(l, h), v = g?.ObjectiveOffsetApplied ? 0 : c, y = Q(g?.Status, g?.StatusCode), b = o.relax ? !1 : typeof g?.IsMip == "boolean" ? g.IsMip : e.variables.some((e) => e.type === "Integer" || e.type === "Binary"), x = g?.HasPrimalSolution === !0, S = ye(g?.Status, g?.StatusCode, x), C = null;
|
|
1340
1380
|
x && typeof g?.ObjectiveValue == "number" && Number.isFinite(g.ObjectiveValue) && (C = g.ObjectiveValue + v);
|
|
1341
|
-
let w, T,
|
|
1342
|
-
if (typeof g?.MipDualBound == "number" && Number.isFinite(g.MipDualBound) ? w = g.MipDualBound + v : !b && y === "Optimal" && C !== null && (w = C), C !== null && w !== void 0 && Number.isFinite(w) && (
|
|
1343
|
-
if (
|
|
1381
|
+
let w, T, E;
|
|
1382
|
+
if (typeof g?.MipDualBound == "number" && Number.isFinite(g.MipDualBound) ? w = g.MipDualBound + v : !b && y === "Optimal" && C !== null && (w = C), C !== null && w !== void 0 && Number.isFinite(w) && (E = Math.abs(C - w)), v !== 0 && b && C !== null && w !== void 0 && E !== void 0) {
|
|
1383
|
+
if (E === 0) T = 0;
|
|
1344
1384
|
else if (Math.abs(C) > 0) {
|
|
1345
|
-
let e =
|
|
1385
|
+
let e = E / Math.abs(C);
|
|
1346
1386
|
T = Number.isFinite(e) ? e : void 0;
|
|
1347
1387
|
} else T = void 0;
|
|
1348
|
-
} else typeof g?.MipGap == "number" && Number.isFinite(g.MipGap) ? T = g.MipGap : b && y === "Optimal" && x && (
|
|
1388
|
+
} else typeof g?.MipGap == "number" && Number.isFinite(g.MipGap) ? T = g.MipGap : b && y === "Optimal" && x && (E === void 0 || E === 0) && (T = 0);
|
|
1349
1389
|
if (!x) return {
|
|
1350
1390
|
status: S,
|
|
1351
1391
|
terminationStatus: y,
|
|
@@ -1353,7 +1393,7 @@ var $ = class e {
|
|
|
1353
1393
|
objectiveValue: null,
|
|
1354
1394
|
...w === void 0 ? {} : { objectiveBound: w },
|
|
1355
1395
|
...T === void 0 ? {} : { relativeGap: T },
|
|
1356
|
-
...
|
|
1396
|
+
...E === void 0 ? {} : { absoluteGap: E },
|
|
1357
1397
|
values: {},
|
|
1358
1398
|
reducedCosts: {},
|
|
1359
1399
|
duals: {},
|
|
@@ -1361,7 +1401,7 @@ var $ = class e {
|
|
|
1361
1401
|
runTime: _,
|
|
1362
1402
|
raw: g
|
|
1363
1403
|
};
|
|
1364
|
-
let
|
|
1404
|
+
let D = (e, t, n) => {
|
|
1365
1405
|
Object.defineProperty(e, t, {
|
|
1366
1406
|
value: n,
|
|
1367
1407
|
enumerable: !0,
|
|
@@ -1374,18 +1414,18 @@ var $ = class e {
|
|
|
1374
1414
|
if (n) {
|
|
1375
1415
|
if (typeof t.Primal == "number" && Number.isFinite(t.Primal)) {
|
|
1376
1416
|
let e = Math.abs(t.Primal) < 1e-9 ? 0 : t.Primal;
|
|
1377
|
-
!o.relax && (n.type === "Integer" || n.type === "Binary") && Math.abs(e - Math.round(e)) <= 1e-5 && (e = Math.round(e) + 0),
|
|
1417
|
+
!o.relax && (n.type === "Integer" || n.type === "Binary") && Math.abs(e - Math.round(e)) <= 1e-5 && (e = Math.round(e) + 0), D(k, n.name, e);
|
|
1378
1418
|
}
|
|
1379
|
-
typeof t.Dual == "number" && Number.isFinite(t.Dual) &&
|
|
1419
|
+
typeof t.Dual == "number" && Number.isFinite(t.Dual) && D(j, n.name, Math.abs(t.Dual) < 1e-9 ? 0 : t.Dual);
|
|
1380
1420
|
}
|
|
1381
1421
|
}
|
|
1382
1422
|
if (g.Rows) {
|
|
1383
1423
|
let e = Array.isArray(g.Rows) ? g.Rows : Object.values(g.Rows);
|
|
1384
1424
|
for (let t of e) {
|
|
1385
1425
|
let e = t.Name, n = e ? d.get(e) : void 0;
|
|
1386
|
-
if (n && (typeof t.Dual == "number" && Number.isFinite(t.Dual) &&
|
|
1426
|
+
if (n && (typeof t.Dual == "number" && Number.isFinite(t.Dual) && D(A, n.name, Math.abs(t.Dual) < 1e-9 ? 0 : t.Dual), typeof t.Primal == "number" && Number.isFinite(t.Primal))) {
|
|
1387
1427
|
let e = n.rhs - t.Primal;
|
|
1388
|
-
|
|
1428
|
+
D(M, n.name, Math.abs(e) < 1e-9 ? 0 : e);
|
|
1389
1429
|
}
|
|
1390
1430
|
}
|
|
1391
1431
|
}
|
|
@@ -1396,7 +1436,7 @@ var $ = class e {
|
|
|
1396
1436
|
objectiveValue: C,
|
|
1397
1437
|
...w === void 0 ? {} : { objectiveBound: w },
|
|
1398
1438
|
...T === void 0 ? {} : { relativeGap: T },
|
|
1399
|
-
...
|
|
1439
|
+
...E === void 0 ? {} : { absoluteGap: E },
|
|
1400
1440
|
values: k,
|
|
1401
1441
|
reducedCosts: j,
|
|
1402
1442
|
duals: A,
|
|
@@ -1405,10 +1445,10 @@ var $ = class e {
|
|
|
1405
1445
|
raw: g
|
|
1406
1446
|
};
|
|
1407
1447
|
}
|
|
1408
|
-
},
|
|
1409
|
-
function
|
|
1410
|
-
|
|
1448
|
+
}, be = $;
|
|
1449
|
+
function xe() {
|
|
1450
|
+
_e("highs", (e) => new $(e)), ve((e) => new $(e));
|
|
1411
1451
|
}
|
|
1412
|
-
|
|
1452
|
+
xe();
|
|
1413
1453
|
//#endregion
|
|
1414
|
-
export {
|
|
1454
|
+
export { l as HIGHS_CONSTANTS, _ as HIGHS_STATUS_NAMES, be as HiGHS, i as Highs, a as HighsError, p as HighsModel, $ as HighsSolver, u as HighsUnsupportedOptionError, s as bindHighsFunctions, z as createHighsWorker, o as getAssetUrl, e as getBundledWasmUrl, g as getHighs, d as getHighsWasmUrl, m as isHighsCached, de as isHighsWarmed, c as isValidWasmHeader, ye as mapHighsStatus, Q as mapHighsTerminationStatus, xe as registerHighsSolver, t as resolveBrowserWasmUrl, f as setHighsWasmUrl, me as solveLp, h as solveLpWithHighs, r as validateHighsOptions, pe as warmupHighs };
|