@ohtaman/washi 0.9.0 → 0.10.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.
Files changed (117) hide show
  1. package/README.md +9 -10
  2. package/THIRD_PARTY_LICENSES.md +4 -4
  3. package/dist/{browser/washi.js → core-b430-tAc.js} +656 -661
  4. package/dist/solvers/browser-_washi-browser-node-runtime-BOEcR5J2.js +28 -0
  5. package/dist/solvers/browser-browser-worker-CT6498Is.js +13 -0
  6. package/dist/{lib/solvers/loader-b5PNpCmX.js → solvers/browser-loader-D21chr4P.js} +12 -23
  7. package/dist/{lib/solvers/loader-DCtyxsfF.js → solvers/browser-loader-DWFhT0yY.js} +13 -13
  8. package/dist/solvers/browser-lp-writer-DH_1sdsF.js +115 -0
  9. package/dist/solvers/glpk.js +310 -0
  10. package/dist/{lib/solvers/glpk.js → solvers/glpk.node.js} +5 -9
  11. package/dist/{lib/solvers/__vite-browser-external-oLchLuMx.js → solvers/highs-browser-__vite-browser-external-Cu-Zq4Hm.js} +1 -1
  12. package/dist/solvers/highs-browser-runtime.js +2410 -0
  13. package/dist/{lib/solvers → solvers}/highs-node-runtime.js +1 -1
  14. package/dist/{lib/solvers → solvers}/highs-worker.js +2 -2
  15. package/dist/{lib/solvers → solvers}/highs.js +64 -70
  16. package/dist/{browser/solvers/highs-loader-Csn3-0tq.js → solvers/highs.node.js} +520 -138
  17. package/dist/solvers/node-browser-worker-CN93BPoO.js +54 -0
  18. package/dist/{lib/solvers/lp-writer-CLScMFbS.js → solvers/node-lp-writer-CqMLgMIk.js} +1 -1
  19. package/dist/solvers/node-node-runtime-BUlNfXvx.js +10 -0
  20. package/dist/solvers/node-registry-CrYRRk9q.js +907 -0
  21. package/dist/solvers/node-types-BGqPkxwu.js +12 -0
  22. package/dist/{lib/solvers → solvers}/pumpkin-node-runtime.js +1 -1
  23. package/dist/{browser/solvers → solvers}/pumpkin-worker.js +2 -1
  24. package/dist/{lib/solvers → solvers}/pumpkin.js +174 -164
  25. package/dist/solvers/pumpkin.node.js +1228 -0
  26. package/dist/{lib/solvers → solvers}/z3.js +123 -120
  27. package/dist/types/core.d.ts +11 -0
  28. package/dist/types/core.d.ts.map +1 -0
  29. package/dist/types/index.d.ts +3 -4
  30. package/dist/types/index.d.ts.map +1 -1
  31. package/dist/types/modeler/core.d.ts +14 -0
  32. package/dist/types/modeler/core.d.ts.map +1 -0
  33. package/dist/types/modeler/index.d.ts +1 -13
  34. package/dist/types/modeler/index.d.ts.map +1 -1
  35. package/dist/types/modeler/model.d.ts +1 -1
  36. package/dist/types/modeler/model.d.ts.map +1 -1
  37. package/dist/types/modeler/solvers/browser-worker.d.ts +17 -0
  38. package/dist/types/modeler/solvers/browser-worker.d.ts.map +1 -0
  39. package/dist/types/modeler/solvers/glpk/loader.d.ts +2 -2
  40. package/dist/types/modeler/solvers/glpk/node-runtime.d.ts +5 -0
  41. package/dist/types/modeler/solvers/glpk/node-runtime.d.ts.map +1 -0
  42. package/dist/types/modeler/solvers/highs/worker-client.d.ts +5 -5
  43. package/dist/types/modeler/solvers/highs/worker-client.d.ts.map +1 -1
  44. package/dist/types/modeler/solvers/pumpkin/loader.d.ts +0 -4
  45. package/dist/types/modeler/solvers/pumpkin/loader.d.ts.map +1 -1
  46. package/dist/types/modeler/solvers/pumpkin/solver.d.ts.map +1 -1
  47. package/dist/types/modeler/solvers/pumpkin/worker-client.d.ts +4 -3
  48. package/dist/types/modeler/solvers/pumpkin/worker-client.d.ts.map +1 -1
  49. package/dist/types/modeler/solvers/types.d.ts +5 -1
  50. package/dist/types/modeler/solvers/types.d.ts.map +1 -1
  51. package/dist/types/modeler/solvers/z3/loader.d.ts +3 -8
  52. package/dist/types/modeler/solvers/z3/loader.d.ts.map +1 -1
  53. package/dist/types/modeler/solvers/z3/solver.d.ts +3 -2
  54. package/dist/types/modeler/solvers/z3/solver.d.ts.map +1 -1
  55. package/dist/types/modeler/types.d.ts +18 -3
  56. package/dist/types/modeler/types.d.ts.map +1 -1
  57. package/dist/washi.js +4 -0
  58. package/dist/washi.min.js +6 -0
  59. package/dist/washi.node.js +4 -0
  60. package/docs/getting-started/ai-agents.md +23 -22
  61. package/docs/getting-started/coding-agents.md +26 -17
  62. package/docs/getting-started/cross-origin.md +2 -1
  63. package/docs/getting-started/index.md +3 -1
  64. package/docs/getting-started/runtimes.md +53 -63
  65. package/docs/guide/objectives.md +3 -3
  66. package/docs/solvers/custom-solver.md +4 -9
  67. package/docs/solvers/glpk.md +2 -0
  68. package/docs/solvers/highs.md +8 -10
  69. package/docs/solvers/index.md +1 -1
  70. package/docs/solvers/pumpkin.md +7 -7
  71. package/docs/solvers/z3.md +18 -1
  72. package/llms-full.txt +124 -118
  73. package/llms.txt +23 -22
  74. package/package.json +31 -64
  75. package/skills/washi/SKILL.md +18 -18
  76. package/skills/washi/references/single-html.md +7 -12
  77. package/dist/browser/solvers/glpk.js +0 -1263
  78. package/dist/browser/solvers/glpk.min.js +0 -1
  79. package/dist/browser/solvers/highs-__vite-browser-external-xcxOpLMD.js +0 -7
  80. package/dist/browser/solvers/highs-browser-runtime-ccRmE4qj.js +0 -2021
  81. package/dist/browser/solvers/highs-worker.js +0 -55
  82. package/dist/browser/solvers/highs.js +0 -1454
  83. package/dist/browser/solvers/pumpkin-_washi-pumpkin-node-runtime-CEKUDK6d.js +0 -9
  84. package/dist/browser/solvers/pumpkin-loader-BI3n3dWO.js +0 -401
  85. package/dist/browser/solvers/pumpkin.js +0 -1796
  86. package/dist/browser/solvers/z3-built.js +0 -8245
  87. package/dist/browser/solvers/z3-built.wasm +0 -4
  88. package/dist/browser/solvers/z3.js +0 -7842
  89. package/dist/browser/solvers/z3.min.js +0 -5
  90. package/dist/browser/washi.min.js +0 -6
  91. package/dist/lib/solvers/highs-browser-runtime.js +0 -2413
  92. package/dist/lib/solvers/highs.wasm +0 -0
  93. package/dist/lib/solvers/highs.wasm.LICENSE +0 -21
  94. package/dist/lib/solvers/pumpkin-worker.js +0 -47
  95. package/dist/lib/solvers/pumpkin.wasm +0 -0
  96. package/dist/lib/solvers/pumpkin.wasm.LICENSE +0 -21
  97. package/dist/lib/solvers/z3-assets.js +0 -1
  98. package/dist/lib/solvers/z3-built.js +0 -8245
  99. package/dist/lib/solvers/z3-built.wasm +0 -4
  100. package/dist/lib/washi.js +0 -5662
  101. package/dist/types/modeler/solvers/z3/assets.d.ts +0 -11
  102. package/dist/types/modeler/solvers/z3/assets.d.ts.map +0 -1
  103. /package/dist/{lib/solvers/embedded-wasm-CSFlLV5N.js → solvers/browser-embedded-wasm-CSFlLV5N.js} +0 -0
  104. /package/dist/{lib/solvers/registry-CrYRRk9q.js → solvers/browser-registry-CrYRRk9q.js} +0 -0
  105. /package/dist/{lib/solvers/types-BGqPkxwu.js → solvers/browser-types-BGqPkxwu.js} +0 -0
  106. /package/dist/{lib/solvers → solvers}/highs-assets.js +0 -0
  107. /package/dist/{lib/solvers/rolldown-runtime-DtPi1Y-2.js → solvers/highs-browser-rolldown-runtime-DtPi1Y-2.js} +0 -0
  108. /package/dist/{browser/solvers → solvers}/highs-inline.js +0 -0
  109. /package/dist/{lib/solvers → solvers}/highs-runtime.js +0 -0
  110. /package/dist/{lib/solvers → solvers}/highs-worker-factory.js +0 -0
  111. /package/dist/{browser/solvers → solvers}/highs.wasm +0 -0
  112. /package/dist/{browser/solvers → solvers}/highs.wasm.LICENSE +0 -0
  113. /package/dist/{lib/solvers → solvers}/pumpkin-assets.js +0 -0
  114. /package/dist/{browser/solvers → solvers}/pumpkin-inline.js +0 -0
  115. /package/dist/{lib/solvers → solvers}/pumpkin-worker-factory.js +0 -0
  116. /package/dist/{browser/solvers → solvers}/pumpkin.wasm +0 -0
  117. /package/dist/{browser/solvers → solvers}/pumpkin.wasm.LICENSE +0 -0
@@ -1,5 +1,3 @@
1
- import "./solvers/highs.js";
2
- import "./solvers/pumpkin.js";
3
1
  //#region src/modeler/types.ts
4
2
  function e(e) {
5
3
  if (e === void 0) return "Minimize";
@@ -14,7 +12,7 @@ function e(e) {
14
12
  //#region src/modeler/boolean-expr.ts
15
13
  var t = 0;
16
14
  function n(e, t) {
17
- if (e instanceof r || e instanceof R) return e;
15
+ if (e instanceof r || e instanceof z) return e;
18
16
  throw typeof e == "object" && e && ("terms" in e || "quadTerms" in e) ? Error(`Cannot use an arithmetic expression without a comparison operator (<=, >=, ==) in logical operator "${t}". Use a comparison constraint such as expr\`\${x} <= 10\` or a BoolVar/BoolExpr.`) : typeof e == "object" && e && "id" in e && "name" in e && "lb" in e && "ub" in e && !("sense" in e) ? Error(`Invalid operand passed to logical operator "${t}": expected a BoolVar, BoolExpr, or Constraint, but received numeric variable "${e.name}". Use m.bool() for propositional variables, add a comparison such as expr\`\${x} == 1\`, or use m.indicator(binVar, constraint) for 0-1 Big-M indicator constraints.`) : Error(`Invalid operand passed to logical operator "${t}": expected a BoolVar, BoolExpr, or Constraint.`);
19
17
  }
20
18
  var r = class {
@@ -88,20 +86,20 @@ var d = class extends r {
88
86
  }
89
87
  };
90
88
  function f(e) {
91
- if (typeof e != "object" || !e || Array.isArray(e) || e instanceof R || e instanceof r || e instanceof G) return !1;
89
+ if (typeof e != "object" || !e || Array.isArray(e) || e instanceof z || e instanceof r || e instanceof K) return !1;
92
90
  let t = Object.getPrototypeOf(e);
93
91
  return t === Object.prototype || t === null;
94
92
  }
95
93
  function p(e) {
96
- return typeof e == "number" || e instanceof R || e instanceof G || typeof e == "object" && !!e && ("terms" in e && e.terms instanceof Map || "quadTerms" in e && e.quadTerms instanceof Map || "id" in e && "name" in e && "lb" in e && "ub" in e && !("sense" in e));
94
+ return typeof e == "number" || e instanceof z || e instanceof K || typeof e == "object" && !!e && ("terms" in e && e.terms instanceof Map || "quadTerms" in e && e.quadTerms instanceof Map || "id" in e && "name" in e && "lb" in e && "ub" in e && !("sense" in e));
97
95
  }
98
96
  function m(...e) {
99
97
  if (e.length === 0) throw Error("distinct() requires at least one expression or container.");
100
98
  let t = [], n = /* @__PURE__ */ new Set(), r = (e, i) => {
101
99
  if (e == null) throw Error("Unsupported nullish item in distinct(): expected an integer-valued expression.");
102
100
  if (p(e)) {
103
- let r = W(e, "distinct()");
104
- U(r, "distinct()", n), t.push(r);
101
+ let r = G(e, "distinct()");
102
+ W(r, "distinct()", n), t.push(r);
105
103
  return;
106
104
  }
107
105
  if (Array.isArray(e)) {
@@ -154,8 +152,8 @@ function g(e) {
154
152
  for (let e = 0; e < t.length; e++) {
155
153
  let i = t[e];
156
154
  if (typeof i != "object" || !i || !("start" in i) || !("duration" in i)) throw Error(`disjoint() task at index ${e} must be an object with { start, duration }.`);
157
- let a = i, o = W(a.start, `disjoint() task[${e}].start`);
158
- if (U(o, `disjoint() task[${e}].start`, n), typeof a.duration != "number" || !Number.isSafeInteger(a.duration) || a.duration < 0) throw Error(`disjoint() task[${e}].duration must be a finite non-negative integer, received ${String(a.duration)}.`);
155
+ let a = i, o = G(a.start, `disjoint() task[${e}].start`);
156
+ if (W(o, `disjoint() task[${e}].start`, n), typeof a.duration != "number" || !Number.isSafeInteger(a.duration) || a.duration < 0) throw Error(`disjoint() task[${e}].duration must be a finite non-negative integer, received ${String(a.duration)}.`);
159
157
  r.push({
160
158
  start: o,
161
159
  duration: Object.is(a.duration, -0) ? 0 : a.duration
@@ -172,8 +170,8 @@ function _(e, t) {
172
170
  for (let e = 0; e < n.length; e++) {
173
171
  let t = n[e];
174
172
  if (typeof t != "object" || !t || !("start" in t) || !("duration" in t) || !("demand" in t)) throw Error(`cumulative() task at index ${e} must be an object with { start, duration, demand }.`);
175
- let a = t, o = W(a.start, `cumulative() task[${e}].start`);
176
- if (U(o, `cumulative() task[${e}].start`, r), typeof a.duration != "number" || !Number.isSafeInteger(a.duration) || a.duration < 0) throw Error(`cumulative() task[${e}].duration must be a finite non-negative integer, received ${String(a.duration)}.`);
173
+ let a = t, o = G(a.start, `cumulative() task[${e}].start`);
174
+ if (W(o, `cumulative() task[${e}].start`, r), typeof a.duration != "number" || !Number.isSafeInteger(a.duration) || a.duration < 0) throw Error(`cumulative() task[${e}].duration must be a finite non-negative integer, received ${String(a.duration)}.`);
177
175
  if (typeof a.demand != "number" || !Number.isSafeInteger(a.demand) || a.demand < 0) throw Error(`cumulative() task[${e}].demand must be a finite non-negative integer, received ${String(a.demand)}.`);
178
176
  i.push({
179
177
  start: o,
@@ -192,8 +190,8 @@ function v(e, t) {
192
190
  let n = /* @__PURE__ */ new Set(), r = Array(e.length);
193
191
  for (let t = 0; t < e.length; t++) {
194
192
  if (!(t in e)) throw Error(`allowed() vars encountered sparse array hole at index ${t}.`);
195
- let i = W(e[t], `allowed() vars[${t}]`);
196
- U(i, `allowed() vars[${t}]`, n), r[t] = i;
193
+ let i = G(e[t], `allowed() vars[${t}]`);
194
+ W(i, `allowed() vars[${t}]`, n), r[t] = i;
197
195
  }
198
196
  if (typeof t != "object" || !t || t instanceof String || !(Symbol.iterator in t) || typeof t[Symbol.iterator] != "function") throw Error("allowed(vars, tuples) requires an Iterable of integer tuples as its second argument.");
199
197
  let i = [], a = 0;
@@ -230,7 +228,7 @@ var b = class e {
230
228
  this.linearTerms = new Map(e), this.quadTerms = /* @__PURE__ */ new Map();
231
229
  for (let [e, n] of t) this.quadTerms.set(e, { ...n });
232
230
  this.constant = n, this.nonlinearTerms = r.filter((e) => e.coeff !== 0).map((e) => ({
233
- atom: B(e.atom),
231
+ atom: V(e.atom),
234
232
  coeff: e.coeff
235
233
  }));
236
234
  }
@@ -245,7 +243,7 @@ var b = class e {
245
243
  return r ? r.coeff : 0;
246
244
  }
247
245
  add(t) {
248
- if (z(t)) throw Error("Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.");
246
+ if (B(t)) throw Error("Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.");
249
247
  let n = this.clone();
250
248
  if (typeof t == "number") return n.constant += t, n;
251
249
  if (t instanceof e) {
@@ -262,7 +260,7 @@ var b = class e {
262
260
  t === 0 ? n.linearTerms.delete(e) : n.linearTerms.set(e, t);
263
261
  }
264
262
  if (n.constant += t.constant, Array.isArray(t.nonlinearTerms)) for (let e of t.nonlinearTerms) e.coeff !== 0 && n.nonlinearTerms.push({
265
- atom: B(e.atom),
263
+ atom: V(e.atom),
266
264
  coeff: e.coeff
267
265
  });
268
266
  return n;
@@ -273,7 +271,7 @@ var b = class e {
273
271
  t === 0 ? n.linearTerms.delete(e) : n.linearTerms.set(e, t);
274
272
  }
275
273
  if (n.constant += t.constant, Array.isArray(t.nonlinearTerms)) for (let e of t.nonlinearTerms) e.coeff !== 0 && n.nonlinearTerms.push({
276
- atom: B(e.atom),
274
+ atom: V(e.atom),
277
275
  coeff: e.coeff
278
276
  });
279
277
  return n;
@@ -282,11 +280,11 @@ var b = class e {
282
280
  return i === 0 ? n.linearTerms.delete(r) : n.linearTerms.set(r, i), n;
283
281
  }
284
282
  sub(e) {
285
- if (z(e)) throw Error("Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.");
283
+ if (B(e)) throw Error("Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.");
286
284
  return typeof e == "number" ? this.add(-e) : this.add(e.mul(-1));
287
285
  }
288
286
  mul(t) {
289
- if (z(t)) throw Error("Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.");
287
+ if (B(t)) throw Error("Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.");
290
288
  if (typeof t == "number") {
291
289
  let n = this.linearTerms.size > 0 || this.quadTerms.size > 0 || this.nonlinearTerms.length > 0, r = this.constant === 0 && n ? 0 : this.constant * t;
292
290
  if (this.constant !== 0 && t !== 0 && r === 0) throw Error("Constant multiplication underflows to zero.");
@@ -309,7 +307,7 @@ var b = class e {
309
307
  let n = e.coeff * t;
310
308
  if (e.coeff !== 0 && n === 0) throw Error("Coefficient multiplication underflows to zero.");
311
309
  n !== 0 && i.nonlinearTerms.push({
312
- atom: B(e.atom),
310
+ atom: V(e.atom),
313
311
  coeff: n
314
312
  });
315
313
  }
@@ -353,7 +351,7 @@ var b = class e {
353
351
  e += t.coeff * t.var1.value * t.var2.value;
354
352
  }
355
353
  for (let t of this.nonlinearTerms) {
356
- let n = H(t.atom);
354
+ let n = U(t.atom);
357
355
  if (n === null) return null;
358
356
  e += t.coeff * n;
359
357
  }
@@ -379,12 +377,12 @@ var b = class e {
379
377
  }
380
378
  toDiscreteComparison(e, t, n) {
381
379
  if (this.quadTerms.size > 0) throw Error(`Quadratic expressions are not supported in discrete comparisons (${e}): quadratic terms are only allowed in objectives.`);
382
- let r = new G(this.linearTerms, this.constant, this.nonlinearTerms);
380
+ let r = new K(this.linearTerms, this.constant, this.nonlinearTerms);
383
381
  return e === "<" ? r.lt(t, n) : e === ">" ? r.gt(t, n) : r.ne(t, n);
384
382
  }
385
383
  toConstraint(e, t, n) {
386
384
  if (this.quadTerms.size > 0) throw Error(`Quadratic expressions are not supported in linear constraints (${e}): quadratic terms are only allowed in objectives.`);
387
- let r = new G(this.linearTerms, this.constant, this.nonlinearTerms);
385
+ let r = new K(this.linearTerms, this.constant, this.nonlinearTerms);
388
386
  return e === "<=" ? r.le(t, n) : e === ">=" ? r.ge(t, n) : r.eq(t, n);
389
387
  }
390
388
  and(e) {
@@ -413,7 +411,7 @@ var b = class e {
413
411
  e.push(`${i}${o}${n.name}`), t = !1;
414
412
  }
415
413
  if (this.nonlinearTerms.length > 0) {
416
- let n = new G(/* @__PURE__ */ new Map(), 0, this.nonlinearTerms).toString();
414
+ let n = new K(/* @__PURE__ */ new Map(), 0, this.nonlinearTerms).toString();
417
415
  n !== "0" && (e.push(t ? n : n.startsWith("-") ? `- ${n.slice(2)}` : `+ ${n}`), t = !1);
418
416
  }
419
417
  if (this.constant !== 0 || e.length === 0) {
@@ -455,7 +453,7 @@ var b = class e {
455
453
  return s;
456
454
  }
457
455
  static extractScalarDivisor(e, t) {
458
- if (z(e)) throw Error("Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.");
456
+ if (B(e)) throw Error("Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.");
459
457
  if (typeof e == "number") {
460
458
  if (e === 0) throw Error(`Division by zero in ${t}`);
461
459
  return e;
@@ -474,7 +472,7 @@ function E(e) {
474
472
  }
475
473
  function D(e, t, n) {
476
474
  if (e instanceof a) for (let r of e.children) D(r, t, n);
477
- else if (e instanceof R) {
475
+ else if (e instanceof z) {
478
476
  let r = e.ownerModel, i = S.get(e);
479
477
  (r !== t || i !== t) && (n && n.push(() => {
480
478
  e.ownerModel = r, i ? S.set(e, i) : S.delete(e);
@@ -499,8 +497,8 @@ function te(e, t) {
499
497
  function k(e, t, n) {
500
498
  C.get(e) === t && C.delete(e), S.get(e) === t && (n ? S.set(e, n) : S.delete(e));
501
499
  }
502
- var ne = 1e-6;
503
- function A(e) {
500
+ var A = 1e-6;
501
+ function j(e) {
504
502
  if (typeof e.lb != "number" || Number.isNaN(e.lb)) throw Error(`Variable "${e.name}" has invalid lower bound: ${e.lb} (NaN or non-numeric bound is not allowed).`);
505
503
  if (e.lb === Infinity) throw Error(`Variable "${e.name}" has invalid lower bound: +Infinity is not allowed as a lower bound.`);
506
504
  if (typeof e.ub != "number" || Number.isNaN(e.ub)) throw Error(`Variable "${e.name}" has invalid upper bound: ${e.ub} (NaN or non-numeric bound is not allowed).`);
@@ -509,31 +507,31 @@ function A(e) {
509
507
  if (e.initialValue !== void 0) {
510
508
  if (typeof e.initialValue != "number" || !Number.isFinite(e.initialValue)) throw Error(`Variable "${e.name}" has invalid initialValue: ${String(e.initialValue)} (initialValue must be a finite number).`);
511
509
  let t = e.type === "Binary" ? Math.max(0, e.lb) : e.lb, n = e.type === "Binary" ? Math.min(1, e.ub) : e.ub;
512
- if (e.initialValue < t - 1e-6 || e.initialValue > n + 1e-6) throw Error(`Variable "${e.name}" has initialValue (${e.initialValue}) outside its bounds [${t}, ${n}] (tolerance ${ne}).`);
510
+ 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 ${A}).`);
513
511
  if (e.type === "Integer" || e.type === "Binary") {
514
512
  let r = Math.round(e.initialValue);
515
- if (Math.abs(e.initialValue - r) > 1e-6 || r < t || r > n) throw Error(`Variable "${e.name}" of type "${e.type}" has non-integral or out-of-domain initialValue: ${e.initialValue} (must be within ${ne} of an integer in [${t}, ${n}]).`);
513
+ 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 ${A} of an integer in [${t}, ${n}]).`);
516
514
  }
517
515
  }
518
516
  }
519
- function j(e, t) {
517
+ function M(e, t) {
520
518
  if (e) {
521
519
  for (let n of e) if (n.type !== "Integer" && n.type !== "Binary") throw Error(`${t} requires Integer or Binary variables, but variable "${n.name}" has type "${n.type}".`);
522
520
  }
523
521
  }
524
- function M(e, t, n, r) {
522
+ function N(e, t, n, r) {
525
523
  if (e && e.length !== 0) for (let i of e) {
526
524
  if (!Number.isFinite(i.coeff)) throw Error(`Nonlinear expression in ${t} has invalid coefficient: ${i.coeff}. Coefficients must be finite numbers.`);
527
525
  let e = i.atom;
528
- if (e.kind === "abs") N(e.arg, t, n, r);
529
- else if (e.kind === "max" || e.kind === "min") for (let i of e.args) N(i, t, n, r);
526
+ if (e.kind === "abs") P(e.arg, t, n, r);
527
+ else if (e.kind === "max" || e.kind === "min") for (let i of e.args) P(i, t, n, r);
530
528
  else if (e.kind === "at") {
531
- j(e.discreteVars, `at() index in ${t}`), N(e.index, t, n, r);
532
- for (let i of e.array) N(i, t, n, r);
529
+ M(e.discreteVars, `at() index in ${t}`), P(e.index, t, n, r);
530
+ for (let i of e.array) P(i, t, n, r);
533
531
  }
534
532
  }
535
533
  }
536
- function N(e, t, n, r, i) {
534
+ function P(e, t, n, r, i) {
537
535
  if (e.constant !== void 0 && !Number.isFinite(e.constant)) {
538
536
  let n = i?.constantPrefix ?? t, r = i?.constantKind ?? "constant";
539
537
  throw Error(`${n} has invalid ${r}: ${e.constant}. Constant must be a finite number.`);
@@ -543,9 +541,9 @@ function N(e, t, n, r, i) {
543
541
  if (!r(i)) throw Error(`Variable "${i.name}" ${a} does not belong to model "${n}". All variables must belong to the model by object identity.`);
544
542
  if (!Number.isFinite(o)) throw Error(`Variable "${i.name}" in ${t} has invalid coefficient: ${o}. Coefficients must be finite numbers.`);
545
543
  }
546
- M(e.nonlinearTerms, t, n, r);
544
+ N(e.nonlinearTerms, t, n, r);
547
545
  }
548
- function P(e, t, n) {
546
+ function F(e, t, n) {
549
547
  if (e instanceof b) {
550
548
  if (!Number.isFinite(e.constant)) throw Error(`Objective function has invalid constant: ${e.constant}. Constant must be a finite number.`);
551
549
  for (let [r, i] of e.linearTerms) {
@@ -557,14 +555,14 @@ function P(e, t, n) {
557
555
  if (!n(r.var2)) throw Error(`Variable "${r.var2.name}" in quadratic objective function does not belong to model "${t}". All variables must belong to the model by object identity.`);
558
556
  if (!Number.isFinite(r.coeff) || !Number.isFinite(r.coeff * 2)) throw Error(`Quadratic term (${r.var1.name} * ${r.var2.name}) in objective function has invalid coefficient: ${r.coeff}.`);
559
557
  }
560
- M(e.nonlinearTerms, "objective function", t, n);
561
- } else "terms" in e && N(e, "objective function", t, n, { constantPrefix: "Objective function" });
558
+ N(e.nonlinearTerms, "objective function", t, n);
559
+ } else "terms" in e && P(e, "objective function", t, n, { constantPrefix: "Objective function" });
562
560
  }
563
- function F(e, t, n, r = e.name) {
561
+ function I(e, t, n, r = e.name) {
564
562
  if (!Number.isFinite(e.rhs)) throw Error(`Constraint "${r}" has invalid right-hand side (RHS): ${e.rhs}. RHS must be a finite number.`);
565
- if (j(e._requiredDiscreteVars, `Discrete constraint "${r}"`), N(e.lhs, `constraint "${r}"`, t, n), e.sense === "!=") {
563
+ if (M(e._requiredDiscreteVars, `Discrete constraint "${r}"`), P(e.lhs, `constraint "${r}"`, t, n), e.sense === "!=") {
566
564
  if (!Number.isSafeInteger(e.rhs)) throw Error(`Discrete "!=" in constraint "${r}" requires a safe integer RHS, received ${e.rhs}.`);
567
- U(e.lhs, `Discrete "!=" in constraint "${r}"`);
565
+ W(e.lhs, `Discrete "!=" in constraint "${r}"`);
568
566
  }
569
567
  if (e._indicatorMeta) {
570
568
  let i = e._indicatorMeta.binVar;
@@ -572,45 +570,45 @@ function F(e, t, n, r = e.name) {
572
570
  if (!(i.type === "Binary" || i.type === "Integer" && i.lb === 0 && i.ub === 1)) throw Error(`Indicator variable "${i.name}" in constraint "${r}" has invalid type "${i.type}" or bounds [${i.lb}, ${i.ub}]: expected Binary or Integer [0, 1].`);
573
571
  }
574
572
  }
575
- function I(e, t, n, r, o, s) {
573
+ function L(e, t, n, r, o, s) {
576
574
  if (e instanceof i) {
577
575
  if (!o(e)) throw Error(`Boolean variable "${e.name}" in logical constraint "${t}" does not belong to model "${n}".`);
578
- } else if (e instanceof a) for (let i of e.children) I(i, t, n, r, o, s);
576
+ } else if (e instanceof a) for (let i of e.children) L(i, t, n, r, o, s);
579
577
  else if (e instanceof d) {
580
- j(e.discreteVars, `Global constraint "${t}"`);
578
+ M(e.discreteVars, `Global constraint "${t}"`);
581
579
  let i = `logical constraint "${t}"`;
582
580
  switch (e.spec.kind) {
583
581
  case "distinct":
584
- for (let t of e.spec.args) N(t, i, n, r);
582
+ for (let t of e.spec.args) P(t, i, n, r);
585
583
  break;
586
584
  case "disjoint":
587
- for (let t of e.spec.tasks) N(t.start, i, n, r);
585
+ for (let t of e.spec.tasks) P(t.start, i, n, r);
588
586
  break;
589
587
  case "cumulative":
590
- for (let t of e.spec.tasks) N(t.start, i, n, r);
588
+ for (let t of e.spec.tasks) P(t.start, i, n, r);
591
589
  break;
592
- case "allowed": for (let t of e.spec.vars) N(t, i, n, r);
590
+ case "allowed": for (let t of e.spec.vars) P(t, i, n, r);
593
591
  }
594
- } else if (e instanceof R) {
592
+ } else if (e instanceof z) {
595
593
  if (s) {
596
594
  let r = S.get(e) ?? e.ownerModel ?? void 0;
597
595
  if (r && r !== s) throw Error(`Constraint "${e.name}" embedded in logical constraint "${t}" already belongs to model "${r.name ?? "another model"}" and cannot be added to model "${n}".`);
598
596
  }
599
597
  if (!Number.isFinite(e.rhs)) throw Error(`Constraint "${e.name}" embedded in logical constraint "${t}" has invalid RHS: ${e.rhs}.`);
600
- if (j(e._requiredDiscreteVars, `Discrete constraint "${e.name}" embedded in logical constraint "${t}"`), N(e.lhs, `constraint "${e.name}" embedded in logical constraint "${t}"`, n, r, {
598
+ if (M(e._requiredDiscreteVars, `Discrete constraint "${e.name}" embedded in logical constraint "${t}"`), P(e.lhs, `constraint "${e.name}" embedded in logical constraint "${t}"`, n, r, {
601
599
  constantPrefix: `Constraint "${e.name}" embedded in logical constraint "${t}"`,
602
600
  constantKind: "LHS constant",
603
601
  varLocationPhrase: `embedded in logical constraint "${t}"`
604
602
  }), e.sense === "!=") {
605
603
  if (!Number.isSafeInteger(e.rhs)) throw Error(`Discrete "!=" in constraint "${e.name}" embedded in logical constraint "${t}" requires a safe integer RHS, received ${e.rhs}.`);
606
- U(e.lhs, `Discrete "!=" in constraint "${e.name}" embedded in logical constraint "${t}"`);
604
+ W(e.lhs, `Discrete "!=" in constraint "${e.name}" embedded in logical constraint "${t}"`);
607
605
  }
608
606
  }
609
607
  }
610
- function re(e) {
608
+ function ne(e) {
611
609
  let { model: t } = e, n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set();
612
610
  for (let i of e.variables) {
613
- A(i);
611
+ j(i);
614
612
  let a = x.get(i);
615
613
  if (a && a !== t || n.has(i.name) || e.getVarByName(i.name) !== i) throw Error(`Variable "${i.name}" is duplicated or not canonically registered in model "${e.name}".`);
616
614
  n.add(i.name), r.add(i);
@@ -636,13 +634,13 @@ function re(e) {
636
634
  if (r && r !== t || e.getConstraintByName(n.name) !== n) throw Error(`Constraint "${n.name}" is duplicated or not canonically registered in model "${e.name}".`);
637
635
  }
638
636
  for (let t of e.logicalConstraints) if (e.getLogicalConstraintByName(t.name) !== t) throw Error(`Logical constraint "${t.name}" is duplicated or not canonically registered in model "${e.name}".`);
639
- e.objectiveExpr && P(e.objectiveExpr, e.name, (e) => r.has(e));
640
- for (let t of e.constraints) F(t, e.name, (e) => r.has(e));
641
- for (let n of e.logicalConstraints) I(n.expr, n.name, e.name, (e) => r.has(e), (e) => a.has(e), t);
637
+ e.objectiveExpr && F(e.objectiveExpr, e.name, (e) => r.has(e));
638
+ for (let t of e.constraints) I(t, e.name, (e) => r.has(e));
639
+ for (let n of e.logicalConstraints) L(n.expr, n.name, e.name, (e) => r.has(e), (e) => a.has(e), t);
642
640
  }
643
641
  //#endregion
644
642
  //#region src/modeler/constraint.ts
645
- var L = 0, R = class e {
643
+ var R = 0, z = class e {
646
644
  kind = "constraint";
647
645
  id;
648
646
  _lhs;
@@ -663,7 +661,7 @@ var L = 0, R = class e {
663
661
  return this._indicatorOrigin = void 0, this._indicatorSnapshot = void 0, this._lhs.setTerm(e, t), E(this.ownerModel), this;
664
662
  }
665
663
  constructor(e, t, n, r) {
666
- this.id = ++L, this._lhs = e, this._sense = t, this._rhs = n;
664
+ this.id = ++R, this._lhs = e, this._sense = t, this._rhs = n;
667
665
  let i = typeof r == "string" ? r.trim() : void 0;
668
666
  i && i.length > 0 ? (this._name = i, this.hasExplicitName = !0) : (this._name = `c_${this.id}`, this.hasExplicitName = !1);
669
667
  }
@@ -797,12 +795,12 @@ var L = 0, R = class e {
797
795
  return `${this.name}: ${this.lhs.toString()} ${e} ${this.rhs}`;
798
796
  }
799
797
  };
800
- function z(e) {
801
- return e instanceof R || typeof e == "object" && !!e && "sense" in e && "lhs" in e && "rhs" in e;
798
+ function B(e) {
799
+ return e instanceof z || typeof e == "object" && !!e && "sense" in e && "lhs" in e && "rhs" in e;
802
800
  }
803
801
  //#endregion
804
802
  //#region src/modeler/expression.ts
805
- function B(e) {
803
+ function V(e) {
806
804
  switch (e.kind) {
807
805
  case "abs": return {
808
806
  kind: "abs",
@@ -824,7 +822,7 @@ function B(e) {
824
822
  };
825
823
  }
826
824
  }
827
- function V(e) {
825
+ function H(e) {
828
826
  switch (e.kind) {
829
827
  case "abs": return `abs(${e.arg.toString()})`;
830
828
  case "max": return `max(${e.args.map((e) => e.toString()).join(", ")})`;
@@ -832,7 +830,7 @@ function V(e) {
832
830
  case "at": return `at([${e.array.map((e) => e.toString()).join(", ")}], ${e.index.toString()})`;
833
831
  }
834
832
  }
835
- function H(e) {
833
+ function U(e) {
836
834
  switch (e.kind) {
837
835
  case "abs": {
838
836
  let t = e.arg.value;
@@ -864,21 +862,21 @@ function H(e) {
864
862
  }
865
863
  }
866
864
  }
867
- function ie(e) {
868
- return e instanceof K || typeof e == "object" && !!e && !z(e) && typeof e.id == "number" && typeof e.name == "string" && typeof e.lb == "number" && typeof e.ub == "number" && typeof e.type == "string" && typeof e.mul == "function";
865
+ function re(e) {
866
+ return e instanceof q || typeof e == "object" && !!e && !B(e) && typeof e.id == "number" && typeof e.name == "string" && typeof e.lb == "number" && typeof e.ub == "number" && typeof e.type == "string" && typeof e.mul == "function";
869
867
  }
870
- function U(e, t, n = /* @__PURE__ */ new Set()) {
868
+ function W(e, t, n = /* @__PURE__ */ new Set()) {
871
869
  if (typeof e == "number") {
872
870
  if (!Number.isSafeInteger(e)) throw Error(`${t} requires Integer or Binary variables and integer constants/coefficients, but received constant ${e}.`);
873
871
  return n;
874
872
  }
875
- if (z(e)) throw Error(`${t} cannot accept a Constraint comparison.`);
873
+ if (B(e)) throw Error(`${t} cannot accept a Constraint comparison.`);
876
874
  if (e instanceof b || "quadTerms" in e && e.quadTerms instanceof Map && "linearTerms" in e && e.linearTerms instanceof Map && typeof e.constant == "number") {
877
875
  let r = e;
878
876
  if (r.quadTerms.size > 0) throw Error(`${t} does not support quadratic expressions.`);
879
- return U(new G(r.linearTerms, r.constant, r.nonlinearTerms ?? []), t, n);
877
+ return W(new K(r.linearTerms, r.constant, r.nonlinearTerms ?? []), t, n);
880
878
  }
881
- if (ie(e)) {
879
+ if (re(e)) {
882
880
  if (e.type !== "Integer" && e.type !== "Binary") throw Error(`${t} requires Integer or Binary variables, but involves Continuous variable "${e.name}".`);
883
881
  return n.add(e), n;
884
882
  }
@@ -894,47 +892,47 @@ function U(e, t, n = /* @__PURE__ */ new Set()) {
894
892
  if (e.coeff === 0) continue;
895
893
  if (!Number.isSafeInteger(e.coeff)) throw Error(`${t} requires integer coefficients on nonlinear expressions, received ${e.coeff}.`);
896
894
  let r = e.atom;
897
- if (r.kind === "abs") U(r.arg, t, n);
898
- else if (r.kind === "max" || r.kind === "min") for (let e of r.args) U(e, t, n);
895
+ if (r.kind === "abs") W(r.arg, t, n);
896
+ else if (r.kind === "max" || r.kind === "min") for (let e of r.args) W(e, t, n);
899
897
  else if (r.kind === "at") {
900
- U(r.index, t, n);
901
- for (let e of r.array) U(e, t, n);
898
+ W(r.index, t, n);
899
+ for (let e of r.array) W(e, t, n);
902
900
  }
903
901
  }
904
902
  return n;
905
903
  }
906
904
  throw Error(`${t} expected an integer-valued scalar expression.`);
907
905
  }
908
- function W(e, t) {
906
+ function G(e, t) {
909
907
  if (typeof e == "number") {
910
908
  if (!Number.isFinite(e)) throw Error(`Invalid non-finite number "${e}" in ${t}.`);
911
- return new G(/* @__PURE__ */ new Map(), Object.is(e, -0) ? 0 : e);
909
+ return new K(/* @__PURE__ */ new Map(), Object.is(e, -0) ? 0 : e);
912
910
  }
913
- if (z(e)) throw t.startsWith("sum") ? Error(`Cannot sum a constraint comparison (<=, >=, ==, !=, <, >): expected arithmetic expressions in ${t}.`) : Error(`Cannot use a constraint comparison (<=, >=, ==, !=, <, >) in ${t}: expected a finite number, Var, or LinExpr.`);
911
+ if (B(e)) throw t.startsWith("sum") ? Error(`Cannot sum a constraint comparison (<=, >=, ==, !=, <, >): expected arithmetic expressions in ${t}.`) : Error(`Cannot use a constraint comparison (<=, >=, ==, !=, <, >) in ${t}: expected a finite number, Var, or LinExpr.`);
914
912
  if (e instanceof b || typeof e == "object" && e && "quadTerms" in e && e.quadTerms instanceof Map && "linearTerms" in e && e.linearTerms instanceof Map) {
915
913
  let n = e;
916
914
  if (n.quadTerms.size > 0) throw Error(`Quadratic expressions are not supported in ${t}.`);
917
915
  if (!Number.isFinite(n.constant)) throw Error(`Invalid non-finite constant "${n.constant}" in ${t}.`);
918
916
  for (let [, e] of n.linearTerms) if (!Number.isFinite(e)) throw Error(`Invalid non-finite coefficient "${e}" in ${t}.`);
919
- return new G(n.linearTerms, n.constant, n.nonlinearTerms ?? []);
917
+ return new K(n.linearTerms, n.constant, n.nonlinearTerms ?? []);
920
918
  }
921
- if (e instanceof G || typeof e == "object" && e && "terms" in e && e.terms instanceof Map && typeof e.constant == "number") {
919
+ if (e instanceof K || typeof e == "object" && e && "terms" in e && e.terms instanceof Map && typeof e.constant == "number") {
922
920
  let n = e;
923
921
  if (!Number.isFinite(n.constant)) throw Error(`Invalid non-finite constant "${n.constant}" in ${t}.`);
924
922
  for (let [, e] of n.terms) if (!Number.isFinite(e)) throw Error(`Invalid non-finite coefficient "${e}" in ${t}.`);
925
923
  return n.clone();
926
924
  }
927
- if (ie(e)) return new G(/* @__PURE__ */ new Map([[e, 1]]), 0);
925
+ if (re(e)) return new K(/* @__PURE__ */ new Map([[e, 1]]), 0);
928
926
  throw Error(`Unsupported item in ${t}: expected a finite number, Var, or LinExpr.`);
929
927
  }
930
- var G = class e {
928
+ var K = class e {
931
929
  kind = "linear";
932
930
  terms;
933
931
  constant;
934
932
  nonlinearTerms;
935
933
  constructor(e = /* @__PURE__ */ new Map(), t = 0, n = []) {
936
934
  this.terms = new Map(e), this.constant = t, this.nonlinearTerms = n.filter((e) => e.coeff !== 0).map((e) => ({
937
- atom: B(e.atom),
935
+ atom: V(e.atom),
938
936
  coeff: e.coeff
939
937
  }));
940
938
  }
@@ -952,7 +950,7 @@ var G = class e {
952
950
  return new e(this.terms, this.constant, this.nonlinearTerms);
953
951
  }
954
952
  add(e) {
955
- if (z(e)) throw Error("Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.");
953
+ if (B(e)) throw Error("Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.");
956
954
  if (e instanceof b) return e.add(this);
957
955
  let t = this.clone();
958
956
  if (typeof e == "number") t.constant += e;
@@ -962,7 +960,7 @@ var G = class e {
962
960
  e === 0 ? t.terms.delete(n) : t.terms.set(n, e);
963
961
  }
964
962
  if (t.constant += e.constant, Array.isArray(e.nonlinearTerms)) for (let n of e.nonlinearTerms) n.coeff !== 0 && t.nonlinearTerms.push({
965
- atom: B(n.atom),
963
+ atom: V(n.atom),
966
964
  coeff: n.coeff
967
965
  });
968
966
  } else {
@@ -972,11 +970,11 @@ var G = class e {
972
970
  return t;
973
971
  }
974
972
  sub(e) {
975
- if (z(e)) throw Error("Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.");
973
+ if (B(e)) throw Error("Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.");
976
974
  return e instanceof b ? e.neg().add(this) : typeof e == "number" ? this.add(-e) : this.add(e.mul(-1));
977
975
  }
978
976
  mul(t) {
979
- if (z(t)) throw Error("Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.");
977
+ if (B(t)) throw Error("Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.");
980
978
  if (typeof t == "number") {
981
979
  let n = this.terms.size > 0 || this.nonlinearTerms.length > 0, r = this.constant === 0 && n ? 0 : this.constant * t;
982
980
  if (this.constant !== 0 && t !== 0 && r === 0) throw Error("Constant multiplication underflows to zero.");
@@ -990,13 +988,13 @@ var G = class e {
990
988
  let n = e.coeff * t;
991
989
  if (e.coeff !== 0 && n === 0) throw Error("Coefficient multiplication underflows to zero.");
992
990
  n !== 0 && i.nonlinearTerms.push({
993
- atom: B(e.atom),
991
+ atom: V(e.atom),
994
992
  coeff: n
995
993
  });
996
994
  }
997
995
  return i;
998
996
  }
999
- if (t instanceof K || typeof t == "object" && t && "id" in t && !("terms" in t) && !("quadTerms" in t)) {
997
+ if (t instanceof q || typeof t == "object" && t && "id" in t && !("terms" in t) && !("quadTerms" in t)) {
1000
998
  if (this.hasNonlinearTerms()) throw Error("Cannot multiply nonlinear expression (max, min, abs, or at) by a variable expression: only scalar multiplication is supported.");
1001
999
  return b.multiplyLinearTerms(this.constant, this.terms, 0, /* @__PURE__ */ new Map([[t, 1]]));
1002
1000
  }
@@ -1037,7 +1035,7 @@ var G = class e {
1037
1035
  e += n * t.value;
1038
1036
  }
1039
1037
  for (let t of this.nonlinearTerms) {
1040
- let n = H(t.atom);
1038
+ let n = U(t.atom);
1041
1039
  if (n === null) return null;
1042
1040
  e += t.coeff * n;
1043
1041
  }
@@ -1062,9 +1060,9 @@ var G = class e {
1062
1060
  return this.toDiscreteComparison("!=", e, t);
1063
1061
  }
1064
1062
  toDiscreteComparison(e, t, n) {
1065
- if (t instanceof R || typeof t == "object" && t && "sense" in t && "lhs" in t) throw Error(`Cannot compare against a Constraint in (${e}): expected a finite integer, discrete Var, or discrete LinExpr.`);
1063
+ if (t instanceof z || typeof t == "object" && t && "sense" in t && "lhs" in t) throw Error(`Cannot compare against a Constraint in (${e}): expected a finite integer, discrete Var, or discrete LinExpr.`);
1066
1064
  let r = `discrete ${e}`, i = /* @__PURE__ */ new Set();
1067
- U(this, r, i), U(t, r, i);
1065
+ W(this, r, i), W(t, r, i);
1068
1066
  let a = this.toConstraint(e === "<" ? "<=" : e === ">" ? ">=" : "!=", t, n);
1069
1067
  if (e === "<") {
1070
1068
  let e = a.rhs - 1;
@@ -1080,14 +1078,14 @@ var G = class e {
1080
1078
  toConstraint(t, n, r) {
1081
1079
  let i = this.clone(), a = 0;
1082
1080
  if (typeof n == "number") a = n;
1083
- else if (n instanceof R || typeof n == "object" && n && "sense" in n && "lhs" in n) throw Error(`Cannot compare against a Constraint in (${t}): expected a number, Var, or LinExpr.`);
1081
+ else if (n instanceof z || typeof n == "object" && n && "sense" in n && "lhs" in n) throw Error(`Cannot compare against a Constraint in (${t}): expected a number, Var, or LinExpr.`);
1084
1082
  else if (n instanceof b || typeof n == "object" && n && "quadTerms" in n) {
1085
1083
  let r = n;
1086
1084
  if (r.quadTerms.size > 0) throw Error(`Quadratic expressions are not supported in linear constraints (${t}): quadratic terms are only allowed in objectives.`);
1087
1085
  i = i.sub(new e(r.linearTerms, 0, r.nonlinearTerms ?? [])), a = r.constant;
1088
1086
  } else "terms" in n ? (i = i.sub(new e(n.terms, 0, n.nonlinearTerms ?? [])), a = n.constant) : i = i.sub(n);
1089
1087
  let o = a - i.constant;
1090
- return i.constant = 0, new R(i, t, o, r);
1088
+ return i.constant = 0, new z(i, t, o, r);
1091
1089
  }
1092
1090
  and(e) {
1093
1091
  throw Error("Cannot use an arithmetic expression without a comparison operator (<=, >=, ==, !=, <, >) in logical 'and': expected a BoolVar, Constraint, or BoolOp.");
@@ -1112,7 +1110,7 @@ var G = class e {
1112
1110
  }
1113
1111
  for (let n of this.nonlinearTerms) {
1114
1112
  let r = n.coeff, i = r >= 0 ? t ? "" : "+ " : "- ", a = Math.abs(r), o = a === 1 ? "" : `${a} `;
1115
- e.push(`${i}${o}${V(n.atom)}`), t = !1;
1113
+ e.push(`${i}${o}${H(n.atom)}`), t = !1;
1116
1114
  }
1117
1115
  if (this.constant !== 0 || e.length === 0) {
1118
1116
  let n = this.constant >= 0 ? t ? "" : "+ " : "- ";
@@ -1121,19 +1119,19 @@ var G = class e {
1121
1119
  return e.join(" ") || "0";
1122
1120
  }
1123
1121
  };
1124
- function ae(e, t) {
1122
+ function ie(e, t) {
1125
1123
  let n = /* @__PURE__ */ new Map(), r = [], i = 0;
1126
1124
  function a(e) {
1127
- return e instanceof R || e.kind === "constraint" || "sense" in e && (e.sense === "<=" || e.sense === ">=" || e.sense === "==" || e.sense === "!=") && "lhs" in e && "rhs" in e && typeof e.rhs == "number" && typeof e.lhs == "object" && e.lhs !== null && "terms" in e.lhs && e.lhs.terms instanceof Map;
1125
+ return e instanceof z || e.kind === "constraint" || "sense" in e && (e.sense === "<=" || e.sense === ">=" || e.sense === "==" || e.sense === "!=") && "lhs" in e && "rhs" in e && typeof e.rhs == "number" && typeof e.lhs == "object" && e.lhs !== null && "terms" in e.lhs && e.lhs.terms instanceof Map;
1128
1126
  }
1129
1127
  function o(e) {
1130
1128
  return e instanceof b || "quadTerms" in e && e.quadTerms instanceof Map && "linearTerms" in e && e.linearTerms instanceof Map && typeof e.constant == "number";
1131
1129
  }
1132
1130
  function s(e) {
1133
- return e instanceof G || "terms" in e && e.terms instanceof Map && typeof e.constant == "number";
1131
+ return e instanceof K || "terms" in e && e.terms instanceof Map && typeof e.constant == "number";
1134
1132
  }
1135
1133
  function c(e) {
1136
- return e instanceof K || !a(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";
1134
+ return e instanceof q || !a(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";
1137
1135
  }
1138
1136
  function l(e) {
1139
1137
  return a(e) || o(e) || s(e) || c(e);
@@ -1166,7 +1164,7 @@ function ae(e, t) {
1166
1164
  if (i = a, Array.isArray(t.nonlinearTerms)) for (let e of t.nonlinearTerms) {
1167
1165
  if (!Number.isFinite(e.coeff)) throw Error(`Invalid non-finite coefficient "${e.coeff}" in sum().`);
1168
1166
  e.coeff !== 0 && r.push({
1169
- atom: B(e.atom),
1167
+ atom: V(e.atom),
1170
1168
  coeff: e.coeff
1171
1169
  });
1172
1170
  }
@@ -1184,7 +1182,7 @@ function ae(e, t) {
1184
1182
  if (i = a, Array.isArray(t.nonlinearTerms)) for (let e of t.nonlinearTerms) {
1185
1183
  if (!Number.isFinite(e.coeff)) throw Error(`Invalid non-finite coefficient "${e.coeff}" in sum().`);
1186
1184
  e.coeff !== 0 && r.push({
1187
- atom: B(e.atom),
1185
+ atom: V(e.atom),
1188
1186
  coeff: e.coeff
1189
1187
  });
1190
1188
  }
@@ -1238,20 +1236,20 @@ function ae(e, t) {
1238
1236
  }
1239
1237
  } else throw Error("Unsupported item in sum(): expected an Iterable, Record, or (count, mapFn).");
1240
1238
  for (let [e, t] of n) t === 0 && n.delete(e);
1241
- return new G(n, i, r);
1239
+ return new K(n, i, r);
1242
1240
  }
1243
- function oe(e, t) {
1241
+ function ae(e, t) {
1244
1242
  let n = /* @__PURE__ */ new Map(), r = [], i = 0;
1245
1243
  function a(e) {
1246
- return typeof e == "object" && !!e && !(e instanceof R) && typeof e.id == "number" && typeof e.name == "string" && typeof e.lb == "number" && typeof e.ub == "number" && typeof e.type == "string" && typeof e.mul == "function" && typeof e.le == "function";
1244
+ return typeof e == "object" && !!e && !(e instanceof z) && typeof e.id == "number" && typeof e.name == "string" && typeof e.lb == "number" && typeof e.ub == "number" && typeof e.type == "string" && typeof e.mul == "function" && typeof e.le == "function";
1247
1245
  }
1248
1246
  function o(e) {
1249
- return a(e) || e instanceof G || e instanceof b;
1247
+ return a(e) || e instanceof K || e instanceof b;
1250
1248
  }
1251
1249
  function s(e, t, o) {
1252
1250
  if (!Number.isFinite(e)) throw Error(`Invalid non-finite coefficient "${e}" in dot() at '${o || "root"}'.`);
1253
1251
  if (t instanceof b) throw Error(`Quadratic expressions are not supported in dot() at '${o || "root"}': dot() produces a linear expression (LinExpr).`);
1254
- if (t instanceof G) {
1252
+ if (t instanceof K) {
1255
1253
  if (!Number.isFinite(t.constant)) throw Error(`Invalid non-finite constant "${t.constant}" in dot() at '${o || "root"}'.`);
1256
1254
  let a = e === 0 || t.constant === 0 ? 0 : e * t.constant;
1257
1255
  if (e !== 0 && t.constant !== 0 && a === 0) throw Error("Constant multiplication underflows to zero.");
@@ -1274,7 +1272,7 @@ function oe(e, t) {
1274
1272
  if (n.coeff !== 0 && t === 0) throw Error("Coefficient multiplication underflows to zero.");
1275
1273
  if (!Number.isFinite(t)) throw Error(`Coefficient multiplication overflows finite floating-point range in dot() at '${o || "root"}'.`);
1276
1274
  t !== 0 && r.push({
1277
- atom: B(n.atom),
1275
+ atom: V(n.atom),
1278
1276
  coeff: t
1279
1277
  });
1280
1278
  }
@@ -1285,7 +1283,7 @@ function oe(e, t) {
1285
1283
  } else throw Error(`Cannot multiply number by non-variable/expression operand in dot() at '${o || "root"}'.`);
1286
1284
  }
1287
1285
  function c(e) {
1288
- return typeof e == "object" && !!e && !Array.isArray(e) && !o(e) && !(e instanceof R) && e.kind !== "constraint";
1286
+ return typeof e == "object" && !!e && !Array.isArray(e) && !o(e) && !(e instanceof z) && e.kind !== "constraint";
1289
1287
  }
1290
1288
  function l(e, t, n = "") {
1291
1289
  if (e === void 0 || t === void 0 || e === null || t === null) throw Error(`Nullish or undefined operand encountered in dot() at '${n || "root"}'.`);
@@ -1333,11 +1331,11 @@ function oe(e, t) {
1333
1331
  }
1334
1332
  l(e, t);
1335
1333
  for (let [e, t] of n) t === 0 && n.delete(e);
1336
- return new G(n, i, r);
1334
+ return new K(n, i, r);
1337
1335
  }
1338
- function se(e) {
1339
- let t = W(e, "abs()");
1340
- return t.terms.size === 0 && t.nonlinearTerms.length === 0 ? new G(/* @__PURE__ */ new Map(), Math.abs(t.constant) + 0) : new G(/* @__PURE__ */ new Map(), 0, [{
1336
+ function oe(e) {
1337
+ let t = G(e, "abs()");
1338
+ return t.terms.size === 0 && t.nonlinearTerms.length === 0 ? new K(/* @__PURE__ */ new Map(), Math.abs(t.constant) + 0) : new K(/* @__PURE__ */ new Map(), 0, [{
1341
1339
  atom: {
1342
1340
  kind: "abs",
1343
1341
  arg: t
@@ -1345,14 +1343,14 @@ function se(e) {
1345
1343
  coeff: 1
1346
1344
  }]);
1347
1345
  }
1348
- function ce(e, t) {
1346
+ function se(e, t) {
1349
1347
  if (t.length === 0) throw Error(`${e}() requires at least one expression.`);
1350
- let n = [], r = (e) => typeof e == "number" || z(e) || ie(e) || e instanceof G || e instanceof b || typeof e == "object" && !!e && ("terms" in e && e.terms instanceof Map || "quadTerms" in e && e.quadTerms instanceof Map), i = (e) => {
1348
+ let n = [], r = (e) => typeof e == "number" || B(e) || re(e) || e instanceof K || e instanceof b || typeof e == "object" && !!e && ("terms" in e && e.terms instanceof Map || "quadTerms" in e && e.quadTerms instanceof Map), i = (e) => {
1351
1349
  if (typeof e != "object" || !e || Array.isArray(e) || r(e)) return !1;
1352
1350
  let t = Object.getPrototypeOf(e);
1353
1351
  return t === Object.prototype || t === null;
1354
1352
  }, a = (t) => {
1355
- n.push(W(t, `${e}()`));
1353
+ n.push(G(t, `${e}()`));
1356
1354
  }, o = (t, n) => {
1357
1355
  if (t == null) throw Error(`Unsupported nullish item in ${e}(): expected a finite number, Var, or LinExpr.`);
1358
1356
  if (typeof t == "number" || r(t)) {
@@ -1404,13 +1402,13 @@ function ce(e, t) {
1404
1402
  if (n.length === 0) throw Error(`${e}() requires at least one expression.`);
1405
1403
  return n;
1406
1404
  }
1407
- function le(e, t) {
1405
+ function ce(e, t) {
1408
1406
  if (t.length === 1) return t[0].clone();
1409
1407
  if (t.every((e) => e.terms.size === 0 && e.nonlinearTerms.length === 0)) {
1410
1408
  let n = t.map((e) => e.constant), r = e === "max" ? Math.max(...n) : Math.min(...n);
1411
- return new G(/* @__PURE__ */ new Map(), Object.is(r, -0) ? 0 : r);
1409
+ return new K(/* @__PURE__ */ new Map(), Object.is(r, -0) ? 0 : r);
1412
1410
  }
1413
- return new G(/* @__PURE__ */ new Map(), 0, [{
1411
+ return new K(/* @__PURE__ */ new Map(), 0, [{
1414
1412
  atom: {
1415
1413
  kind: e,
1416
1414
  args: t
@@ -1418,22 +1416,22 @@ function le(e, t) {
1418
1416
  coeff: 1
1419
1417
  }]);
1420
1418
  }
1421
- function ue(...e) {
1422
- return le("max", ce("max", e));
1419
+ function le(...e) {
1420
+ return ce("max", se("max", e));
1423
1421
  }
1424
- function de(...e) {
1425
- return le("min", ce("min", e));
1422
+ function ue(...e) {
1423
+ return ce("min", se("min", e));
1426
1424
  }
1427
- function fe(e, t) {
1425
+ function de(e, t) {
1428
1426
  if (!Array.isArray(e)) throw Error("at(array, index) requires an Array as its first argument.");
1429
1427
  if (e.length === 0) throw Error("at(array, index) requires an array with at least 1 element.");
1430
1428
  let n = Array(e.length);
1431
1429
  for (let t = 0; t < e.length; t++) {
1432
1430
  if (!(t in e)) throw Error(`at(array, index) encountered sparse array hole at index ${t}.`);
1433
- n[t] = W(e[t], `at() array[${t}]`);
1431
+ n[t] = G(e[t], `at() array[${t}]`);
1434
1432
  }
1435
- let r = W(t, "at() index"), i = U(r, "at() index");
1436
- return new G(/* @__PURE__ */ new Map(), 0, [{
1433
+ let r = G(t, "at() index"), i = W(r, "at() index");
1434
+ return new K(/* @__PURE__ */ new Map(), 0, [{
1437
1435
  atom: {
1438
1436
  kind: "at",
1439
1437
  array: n,
@@ -1445,8 +1443,8 @@ function fe(e, t) {
1445
1443
  }
1446
1444
  //#endregion
1447
1445
  //#region src/modeler/variable.ts
1448
- var pe = 0;
1449
- function me(e) {
1446
+ var fe = 0;
1447
+ function pe(e) {
1450
1448
  if (e === void 0) return "Continuous";
1451
1449
  if (typeof e == "string") {
1452
1450
  let t = e.toLowerCase();
@@ -1456,7 +1454,7 @@ function me(e) {
1456
1454
  }
1457
1455
  throw Error(`Invalid variable type "${String(e)}": expected "Continuous", "Integer", or "Binary".`);
1458
1456
  }
1459
- var K = class {
1457
+ var q = class {
1460
1458
  id;
1461
1459
  _name;
1462
1460
  prefix;
@@ -1469,9 +1467,9 @@ var K = class {
1469
1467
  value = null;
1470
1468
  reducedCost = null;
1471
1469
  constructor(e = {}) {
1472
- this.id = ++pe;
1470
+ this.id = ++fe;
1473
1471
  let t = typeof e.name == "string" ? e.name.trim() : "", n = typeof e.prefix == "string" ? e.prefix.trim() : "";
1474
- this.prefix = n.length > 0 ? n : "x", this.hasExplicitName = t.length > 0, this._name = this.hasExplicitName ? t : `${this.prefix}_${this.id}`, this._type = me(e.type), this._type === "Binary" ? (this._lb = 0, this._ub = 1) : (this._lb = e.lb === void 0 ? 0 : e.lb, this._ub = e.ub === void 0 ? Infinity : e.ub), this._initialValue = e.initialValue === void 0 ? void 0 : Object.is(e.initialValue, -0) ? 0 : e.initialValue, this._initialValue !== void 0 && A(this);
1472
+ this.prefix = n.length > 0 ? n : "x", this.hasExplicitName = t.length > 0, this._name = this.hasExplicitName ? t : `${this.prefix}_${this.id}`, this._type = pe(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 && j(this);
1475
1473
  }
1476
1474
  get name() {
1477
1475
  return this._name;
@@ -1480,7 +1478,7 @@ var K = class {
1480
1478
  return this._type;
1481
1479
  }
1482
1480
  set type(e) {
1483
- let t = me(e);
1481
+ let t = pe(e);
1484
1482
  this._type !== t && (this._type = t, E(this.ownerModel));
1485
1483
  }
1486
1484
  get lb() {
@@ -1506,34 +1504,34 @@ var K = class {
1506
1504
  this._name = e;
1507
1505
  }
1508
1506
  mul(e) {
1509
- return typeof e == "number" ? new G(/* @__PURE__ */ new Map([[this, 1]]), 0).mul(e) : new b(/* @__PURE__ */ new Map([[this, 1]]), /* @__PURE__ */ new Map(), 0).mul(e);
1507
+ return typeof e == "number" ? new K(/* @__PURE__ */ new Map([[this, 1]]), 0).mul(e) : new b(/* @__PURE__ */ new Map([[this, 1]]), /* @__PURE__ */ new Map(), 0).mul(e);
1510
1508
  }
1511
1509
  add(e) {
1512
- return e instanceof b ? e.add(this) : new G(/* @__PURE__ */ new Map([[this, 1]]), 0).add(e);
1510
+ return e instanceof b ? e.add(this) : new K(/* @__PURE__ */ new Map([[this, 1]]), 0).add(e);
1513
1511
  }
1514
1512
  sub(e) {
1515
- return e instanceof b ? e.neg().add(this) : new G(/* @__PURE__ */ new Map([[this, 1]]), 0).sub(e);
1513
+ return e instanceof b ? e.neg().add(this) : new K(/* @__PURE__ */ new Map([[this, 1]]), 0).sub(e);
1516
1514
  }
1517
1515
  neg() {
1518
1516
  return this.mul(-1);
1519
1517
  }
1520
1518
  le(e, t) {
1521
- return new G(/* @__PURE__ */ new Map([[this, 1]]), 0).le(e, t);
1519
+ return new K(/* @__PURE__ */ new Map([[this, 1]]), 0).le(e, t);
1522
1520
  }
1523
1521
  ge(e, t) {
1524
- return new G(/* @__PURE__ */ new Map([[this, 1]]), 0).ge(e, t);
1522
+ return new K(/* @__PURE__ */ new Map([[this, 1]]), 0).ge(e, t);
1525
1523
  }
1526
1524
  eq(e, t) {
1527
- return new G(/* @__PURE__ */ new Map([[this, 1]]), 0).eq(e, t);
1525
+ return new K(/* @__PURE__ */ new Map([[this, 1]]), 0).eq(e, t);
1528
1526
  }
1529
1527
  lt(e, t) {
1530
- return new G(/* @__PURE__ */ new Map([[this, 1]]), 0).lt(e, t);
1528
+ return new K(/* @__PURE__ */ new Map([[this, 1]]), 0).lt(e, t);
1531
1529
  }
1532
1530
  gt(e, t) {
1533
- return new G(/* @__PURE__ */ new Map([[this, 1]]), 0).gt(e, t);
1531
+ return new K(/* @__PURE__ */ new Map([[this, 1]]), 0).gt(e, t);
1534
1532
  }
1535
1533
  ne(e, t) {
1536
- return new G(/* @__PURE__ */ new Map([[this, 1]]), 0).ne(e, t);
1534
+ return new K(/* @__PURE__ */ new Map([[this, 1]]), 0).ne(e, t);
1537
1535
  }
1538
1536
  toString() {
1539
1537
  return this.name;
@@ -1541,11 +1539,11 @@ var K = class {
1541
1539
  };
1542
1540
  //#endregion
1543
1541
  //#region src/modeler/parser.ts
1544
- function q(e) {
1542
+ function J(e) {
1545
1543
  return typeof e == "object" && !!e && e.kind === "container";
1546
1544
  }
1547
- var he = /^(?:[0-9]+(?:\.[0-9]+)?|\.[0-9]+)(?:[eE][+-]?[0-9]+)?$/;
1548
- function ge(e, t) {
1545
+ var me = /^(?:[0-9]+(?:\.[0-9]+)?|\.[0-9]+)(?:[eE][+-]?[0-9]+)?$/;
1546
+ function he(e, t) {
1549
1547
  let n = [], r = 0, i = e.length;
1550
1548
  for (; r < i;) {
1551
1549
  let a = e[r];
@@ -1606,7 +1604,7 @@ function ge(e, t) {
1606
1604
  for (; r < i && (e[r] === "." || e[r] === "e" || e[r] === "E" || /[0-9]/.test(e[r]));) a += e[r++];
1607
1605
  }
1608
1606
  } else for (; r < i && (e[r] === "." || /[0-9]/.test(e[r]));) a += e[r++];
1609
- if (!he.test(a)) throw Error(`Invalid numeric literal '${a}' at position ${t} in: "${e}"`);
1607
+ if (!me.test(a)) throw Error(`Invalid numeric literal '${a}' at position ${t} in: "${e}"`);
1610
1608
  let o = Number(a);
1611
1609
  if (!Number.isFinite(o)) throw Error(`Numeric literal '${a}' overflows finite floating-point range in: "${e}"`);
1612
1610
  if (o === 0 && !/^[0.]+(?:[eE][+-]?\d+)?$/.test(a)) throw Error(`Numeric literal '${a}' underflows to zero at position ${t} in: "${e}"`);
@@ -1633,16 +1631,16 @@ function ge(e, t) {
1633
1631
  }
1634
1632
  return n;
1635
1633
  }
1634
+ function ge(e) {
1635
+ return e instanceof b && e.quadTerms.size === 0 ? new K(e.linearTerms, e.constant, e.nonlinearTerms) : e;
1636
+ }
1636
1637
  function _e(e) {
1637
- return e instanceof b && e.quadTerms.size === 0 ? new G(e.linearTerms, e.constant, e.nonlinearTerms) : e;
1638
+ return typeof e == "number" || e instanceof q || e instanceof K || e instanceof b || Ne(e);
1638
1639
  }
1639
1640
  function ve(e) {
1640
- return typeof e == "number" || e instanceof K || e instanceof G || e instanceof b || Ne(e);
1641
- }
1642
- function ye(e) {
1643
- return typeof e == "number" ? new G(/* @__PURE__ */ new Map(), e) : e instanceof K || "id" in e && !("terms" in e) && !("quadTerms" in e) ? new G(/* @__PURE__ */ new Map([[e, 1]]), 0) : e.clone();
1641
+ return typeof e == "number" ? new K(/* @__PURE__ */ new Map(), e) : e instanceof q || "id" in e && !("terms" in e) && !("quadTerms" in e) ? new K(/* @__PURE__ */ new Map([[e, 1]]), 0) : e.clone();
1644
1642
  }
1645
- function be(e, t, n) {
1643
+ function ye(e, t, n) {
1646
1644
  if (typeof e == "number" && typeof t == "number") {
1647
1645
  if (n === "+") {
1648
1646
  let n = e + t;
@@ -1666,36 +1664,36 @@ function be(e, t, n) {
1666
1664
  if (!Number.isFinite(r)) throw Error(`Invalid non-finite constant "${r}" in expression.`);
1667
1665
  return r;
1668
1666
  }
1669
- let r = ye(e), i = ye(t), a;
1667
+ let r = ve(e), i = ve(t), a;
1670
1668
  a = n === "+" ? r.add(i) : n === "-" ? r.sub(i) : n === "*" ? r.mul(i) : r.div(i);
1671
- let o = _e(a);
1669
+ let o = ge(a);
1672
1670
  return Z(o), o;
1673
1671
  }
1674
- function J(e, t) {
1672
+ function Y(e, t) {
1675
1673
  if (Array.isArray(e)) {
1676
1674
  let n = Array(e.length);
1677
1675
  for (let r = 0; r < e.length; r++) {
1678
1676
  let i = e[r];
1679
- n[r] = ve(i) ? t(i) : J(i, t);
1677
+ n[r] = _e(i) ? t(i) : Y(i, t);
1680
1678
  }
1681
1679
  return n;
1682
1680
  }
1683
1681
  let n = Object.create(null);
1684
1682
  for (let r of Object.keys(e)) {
1685
1683
  let i = e[r];
1686
- n[r] = ve(i) ? t(i) : J(i, t);
1684
+ n[r] = _e(i) ? t(i) : Y(i, t);
1687
1685
  }
1688
1686
  return n;
1689
1687
  }
1690
- function xe(e, t, n, r = "") {
1691
- let i = ve(e), a = ve(t);
1692
- if (i && a) return be(e, t, n);
1688
+ function be(e, t, n, r = "") {
1689
+ let i = _e(e), a = _e(t);
1690
+ if (i && a) return ye(e, t, n);
1693
1691
  if (i || a) throw Error(`Dimension mismatch in template expression at '${r || "root"}': cannot combine scalar element with sub-container.`);
1694
1692
  if (Array.isArray(e) || Array.isArray(t)) {
1695
1693
  if (Array.isArray(e) && Array.isArray(t)) {
1696
1694
  if (e.length !== t.length) throw Error(`Array length mismatch in template expression at '${r || "root"}': received lengths ${e.length} and ${t.length}.`);
1697
1695
  let i = Array(e.length);
1698
- for (let a = 0; a < e.length; a++) i[a] = xe(e[a], t[a], n, r ? `${r}[${a}]` : `[${a}]`);
1696
+ for (let a = 0; a < e.length; a++) i[a] = be(e[a], t[a], n, r ? `${r}[${a}]` : `[${a}]`);
1699
1697
  return i;
1700
1698
  }
1701
1699
  let i = Array.isArray(e) ? e : t, a = Array.isArray(e) ? t : e, o = Object.keys(a);
@@ -1706,7 +1704,7 @@ function xe(e, t, n, r = "") {
1706
1704
  let s = Array(i.length);
1707
1705
  for (let a = 0; a < i.length; a++) {
1708
1706
  let i = e[a], o = t[a];
1709
- s[a] = xe(i, o, n, r ? `${r}[${a}]` : `[${a}]`);
1707
+ s[a] = be(i, o, n, r ? `${r}[${a}]` : `[${a}]`);
1710
1708
  }
1711
1709
  return s;
1712
1710
  }
@@ -1718,64 +1716,64 @@ function xe(e, t, n, r = "") {
1718
1716
  throw u.length > 0 && e.push(`missing in second operand: [${u.join(", ")}]`), d.length > 0 && e.push(`missing in first operand: [${d.join(", ")}]`), Error(`Key mismatch in template expression at '${r || "root"}': ${e.join("; ")}.`);
1719
1717
  }
1720
1718
  let f = Object.create(null);
1721
- for (let e of c) f[e] = xe(o[e], s[e], n, r ? `${r}.${e}` : e);
1719
+ for (let e of c) f[e] = be(o[e], s[e], n, r ? `${r}.${e}` : e);
1722
1720
  return f;
1723
1721
  }
1724
- function Se(e, t, n) {
1725
- let r = q(e), i = q(t);
1726
- if (!r && !i) return be(e, t, n);
1722
+ function xe(e, t, n) {
1723
+ let r = J(e), i = J(t);
1724
+ if (!r && !i) return ye(e, t, n);
1727
1725
  if (r && !i) return {
1728
1726
  kind: "container",
1729
- data: J(e.data, (e) => be(e, t, n)),
1727
+ data: Y(e.data, (e) => ye(e, t, n)),
1730
1728
  fromNonArrayIterable: e.fromNonArrayIterable
1731
1729
  };
1732
1730
  if (!r && i) return {
1733
1731
  kind: "container",
1734
- data: J(t.data, (t) => be(e, t, n)),
1732
+ data: Y(t.data, (t) => ye(e, t, n)),
1735
1733
  fromNonArrayIterable: t.fromNonArrayIterable
1736
1734
  };
1737
1735
  let a = e, o = t;
1738
1736
  return {
1739
1737
  kind: "container",
1740
- data: xe(a.data, o.data, n),
1738
+ data: be(a.data, o.data, n),
1741
1739
  fromNonArrayIterable: a.fromNonArrayIterable || o.fromNonArrayIterable
1742
1740
  };
1743
1741
  }
1744
- function Ce(e) {
1745
- return typeof e == "number" ? -e : q(e) ? {
1742
+ function Se(e) {
1743
+ return typeof e == "number" ? -e : J(e) ? {
1746
1744
  kind: "container",
1747
- data: J(e.data, (e) => typeof e == "number" ? -e : ye(e).neg()),
1745
+ data: Y(e.data, (e) => typeof e == "number" ? -e : ve(e).neg()),
1748
1746
  fromNonArrayIterable: e.fromNonArrayIterable
1749
1747
  } : e.neg();
1750
1748
  }
1751
- function we(e, t) {
1749
+ function Ce(e, t) {
1752
1750
  let n = e instanceof b, r = n ? e.quadTerms.size : 0, i = n ? e.linearTerms.size : e.terms.size, a = Array.isArray(e.nonlinearTerms) ? e.nonlinearTerms.length : 0;
1753
1751
  if (r === 0 && i === 0 && a === 0) {
1754
1752
  let n = e.constant ** +t;
1755
1753
  if (e.constant !== 0 && t > 0 && n === 0) throw Error("Constant exponentiation underflows to zero.");
1756
- return new G(/* @__PURE__ */ new Map(), n);
1754
+ return new K(/* @__PURE__ */ new Map(), n);
1757
1755
  }
1758
- if (t === 0) return new G(/* @__PURE__ */ new Map(), 1);
1756
+ if (t === 0) return new K(/* @__PURE__ */ new Map(), 1);
1759
1757
  if (t === 1) return e;
1760
1758
  if (a > 0) throw Error("Cannot multiply nonlinear expression (max, min, abs, or at) by a variable expression: only scalar multiplication is supported.");
1761
1759
  if (t === 2) return e.mul(e);
1762
1760
  throw Error(`Exponent ${t} creates a non-linear term of degree > 2 (not allowed in MILP/LP/QP)`);
1763
1761
  }
1764
- function Y(e) {
1762
+ function X(e) {
1765
1763
  if (typeof e != "object" || !e || Array.isArray(e) || Ne(e) || Pe(e)) return !1;
1766
1764
  let t = Object.getPrototypeOf(e);
1767
1765
  return t === Object.prototype || t === null;
1768
1766
  }
1769
- function Te(e) {
1767
+ function we(e) {
1770
1768
  if (typeof e == "number") {
1771
1769
  if (!Number.isFinite(e)) throw Error(`Invalid numeric value "${e}" in template expression: interpolated numbers must be finite.`);
1772
1770
  return e;
1773
1771
  }
1774
1772
  if (Pe(e)) throw Error("Cannot interpolate a constraint comparison (<=, >=, ==) inside a template expression: expected a finite number, Var, LinExpr, or QuadExpr.");
1775
- if (Ne(e)) return Z(e), e instanceof K || "id" in e && !("terms" in e) && !("quadTerms" in e) ? e : e.clone();
1773
+ if (Ne(e)) return Z(e), e instanceof q || "id" in e && !("terms" in e) && !("quadTerms" in e) ? e : e.clone();
1776
1774
  throw Error("Unsupported interpolation value in template expression: expected a finite number, Var, LinExpr, or QuadExpr.");
1777
1775
  }
1778
- function X(e) {
1776
+ function Te(e) {
1779
1777
  return typeof e == "object" && !!e && !(e instanceof String) && !(e instanceof Map) && !Ne(e) && !Pe(e) && Symbol.iterator in e && typeof e[Symbol.iterator] == "function";
1780
1778
  }
1781
1779
  function Ee(e, t = 0) {
@@ -1784,11 +1782,11 @@ function Ee(e, t = 0) {
1784
1782
  for (let i = 0; i < e.length; i++) {
1785
1783
  if (!(i in e)) throw Error(`Unsupported interpolation value in template expression: sparse array hole at index ${i}.`);
1786
1784
  let a = e[i];
1787
- if (Array.isArray(a) || Y(a) || X(a)) {
1785
+ if (Array.isArray(a) || X(a) || Te(a)) {
1788
1786
  if (t >= 1) throw Error("Nested containers deeper than 2D are not supported in template expressions.");
1789
1787
  let e = Ee(a, t + 1);
1790
1788
  e.fromNonArrayIterable && (n = !0), r[i] = e.data;
1791
- } else r[i] = Te(a);
1789
+ } else r[i] = we(a);
1792
1790
  }
1793
1791
  return {
1794
1792
  kind: "container",
@@ -1796,27 +1794,27 @@ function Ee(e, t = 0) {
1796
1794
  fromNonArrayIterable: n
1797
1795
  };
1798
1796
  }
1799
- if (X(e)) return {
1797
+ if (Te(e)) return {
1800
1798
  kind: "container",
1801
1799
  data: Array.from(e).map((e) => {
1802
- if (Array.isArray(e) || Y(e) || X(e)) {
1800
+ if (Array.isArray(e) || X(e) || Te(e)) {
1803
1801
  if (t >= 1) throw Error("Nested containers deeper than 2D are not supported in template expressions.");
1804
1802
  return Ee(e, t + 1).data;
1805
1803
  }
1806
- return Te(e);
1804
+ return we(e);
1807
1805
  }),
1808
1806
  fromNonArrayIterable: !0
1809
1807
  };
1810
- if (Y(e)) {
1808
+ if (X(e)) {
1811
1809
  if (Object.getOwnPropertySymbols(e).length > 0) throw Error("Symbol keys are not supported in template expression at 'root'.");
1812
1810
  let n = !1, r = Object.create(null);
1813
1811
  for (let i of Object.keys(e)) {
1814
1812
  let a = e[i];
1815
- if (Array.isArray(a) || Y(a) || X(a)) {
1813
+ if (Array.isArray(a) || X(a) || Te(a)) {
1816
1814
  if (t >= 1) throw Error("Nested containers deeper than 2D are not supported in template expressions.");
1817
1815
  let e = Ee(a, t + 1);
1818
1816
  e.fromNonArrayIterable && (n = !0), r[i] = e.data;
1819
- } else r[i] = Te(a);
1817
+ } else r[i] = we(a);
1820
1818
  }
1821
1819
  return {
1822
1820
  kind: "container",
@@ -1845,27 +1843,27 @@ var De = class {
1845
1843
  }
1846
1844
  parseExpression() {
1847
1845
  let e = this.parseExpressionNode();
1848
- if (q(e)) throw Error("Container expression (Array or Record) cannot be used directly as a scalar expression or constraint; wrap it in sum(...) or use dot(a, b).");
1849
- return typeof e == "number" ? new G(/* @__PURE__ */ new Map(), e) : _e(e);
1846
+ if (J(e)) throw Error("Container expression (Array or Record) cannot be used directly as a scalar expression or constraint; wrap it in sum(...) or use dot(a, b).");
1847
+ return typeof e == "number" ? new K(/* @__PURE__ */ new Map(), e) : ge(e);
1850
1848
  }
1851
1849
  parseExpressionNode() {
1852
1850
  let e = this.parseTermNode();
1853
1851
  for (; this.pos < this.tokens.length;) {
1854
1852
  let t = this.peek();
1855
1853
  if (!t) break;
1856
- if (t.type === "PLUS") this.consume(), e = Se(e, this.parseTermNode(), "+");
1857
- else if (t.type === "MINUS") this.consume(), e = Se(e, this.parseTermNode(), "-");
1854
+ if (t.type === "PLUS") this.consume(), e = xe(e, this.parseTermNode(), "+");
1855
+ else if (t.type === "MINUS") this.consume(), e = xe(e, this.parseTermNode(), "-");
1858
1856
  else break;
1859
1857
  }
1860
- return q(e) || typeof e == "number" ? e : _e(e);
1858
+ return J(e) || typeof e == "number" ? e : ge(e);
1861
1859
  }
1862
1860
  parseTermNode() {
1863
1861
  let e = this.parseFactorNode();
1864
1862
  for (; this.pos < this.tokens.length;) {
1865
1863
  let t = this.peek();
1866
1864
  if (!t) break;
1867
- if (t.type === "STAR") this.consume(), e = Se(e, this.parseFactorNode(), "*");
1868
- else if (t.type === "SLASH") this.consume(), e = Se(e, this.parseFactorNode(), "/");
1865
+ if (t.type === "STAR") this.consume(), e = xe(e, this.parseFactorNode(), "*");
1866
+ else if (t.type === "SLASH") this.consume(), e = xe(e, this.parseFactorNode(), "/");
1869
1867
  else break;
1870
1868
  }
1871
1869
  return e;
@@ -1874,14 +1872,14 @@ var De = class {
1874
1872
  let e = this.peek();
1875
1873
  if (!e) throw Error("Unexpected end of expression");
1876
1874
  if (e.type === "PLUS") return this.consume(), this.parseFactorNode();
1877
- if (e.type === "MINUS") return this.consume(), Ce(this.parseFactorNode());
1875
+ if (e.type === "MINUS") return this.consume(), Se(this.parseFactorNode());
1878
1876
  let t;
1879
1877
  if (e.type === "NUMBER") {
1880
1878
  this.consume();
1881
1879
  let n = e.numericValue ?? Number(e.value);
1882
1880
  if (this.peek()?.type === "IDENT" || this.peek()?.type === "LPAREN") {
1883
1881
  let e = this.parsePrimaryNode();
1884
- return Se(this.applyPowerNode(e), n, "*");
1882
+ return xe(this.applyPowerNode(e), n, "*");
1885
1883
  }
1886
1884
  t = n;
1887
1885
  } else if (e.type === "IDENT" || e.type === "LPAREN") t = this.parsePrimaryNode();
@@ -1910,11 +1908,11 @@ var De = class {
1910
1908
  if (e === "abs") {
1911
1909
  let e = this.parseExpressionNode();
1912
1910
  if (this.peek()?.type === "COMMA") throw Error("abs() in template expression accepts exactly 1 argument.");
1913
- return this.consume("RPAREN"), q(e) ? {
1911
+ return this.consume("RPAREN"), J(e) ? {
1914
1912
  kind: "container",
1915
- data: J(e.data, (e) => se(e)),
1913
+ data: Y(e.data, (e) => oe(e)),
1916
1914
  fromNonArrayIterable: e.fromNonArrayIterable
1917
- } : se(e);
1915
+ } : oe(e);
1918
1916
  }
1919
1917
  if (e === "at") {
1920
1918
  let e = this.parseExpressionNode();
@@ -1922,9 +1920,9 @@ var De = class {
1922
1920
  this.consume("COMMA");
1923
1921
  let t = this.parseExpressionNode();
1924
1922
  if (this.peek()?.type === "COMMA") throw Error("at() in template expression requires exactly 2 arguments: at(array, index).");
1925
- if (this.consume("RPAREN"), !q(e) || e.fromNonArrayIterable || !Array.isArray(e.data)) throw Error("at(array, index) requires a 1D Array as its first argument.");
1926
- if (q(t)) throw Error("at(array, index) requires a discrete scalar expression as its index.");
1927
- let n = fe(e.data, t);
1923
+ if (this.consume("RPAREN"), !J(e) || e.fromNonArrayIterable || !Array.isArray(e.data)) throw Error("at(array, index) requires a 1D Array as its first argument.");
1924
+ if (J(t)) throw Error("at(array, index) requires a discrete scalar expression as its index.");
1925
+ let n = de(e.data, t);
1928
1926
  return Z(n), n;
1929
1927
  }
1930
1928
  if (e === "max" || e === "min") {
@@ -1945,7 +1943,7 @@ var De = class {
1945
1943
  if (this.tokens[this.pos]?.type === "IDENT" && this.templateCtx?.rawContainerMap.has(this.tokens[this.pos].value) && this.tokens[this.pos + 1]?.type === "RPAREN") {
1946
1944
  let t = this.consume();
1947
1945
  this.consume("RPAREN");
1948
- let n = this.templateCtx.rawContainerMap.get(t.value), r = e === "max" ? ue(n) : de(n);
1946
+ let n = this.templateCtx.rawContainerMap.get(t.value), r = e === "max" ? le(n) : ue(n);
1949
1947
  return Z(r), r;
1950
1948
  }
1951
1949
  let r = this.parseExpressionNode();
@@ -1958,22 +1956,22 @@ var De = class {
1958
1956
  this.consume("RPAREN");
1959
1957
  let n = this.templateCtx.functionMap.get(t.value);
1960
1958
  if (typeof r == "number") return this.evalExtremumWithMapper(e, r, n);
1961
- if (!q(r) && r instanceof G && r.terms.size === 0 && r.nonlinearTerms.length === 0) return this.evalExtremumWithMapper(e, r.constant, n);
1962
- if (q(r)) return this.evalExtremumWithMapper(e, r.data, n);
1959
+ if (!J(r) && r instanceof K && r.terms.size === 0 && r.nonlinearTerms.length === 0) return this.evalExtremumWithMapper(e, r.constant, n);
1960
+ if (J(r)) return this.evalExtremumWithMapper(e, r.data, n);
1963
1961
  throw Error(`Invalid first argument in ${e}(itemsOrCount, mapFn): expected an Iterable, Record, or non-negative integer count.`);
1964
1962
  }
1965
- let n = [q(r) ? r.data : r];
1963
+ let n = [J(r) ? r.data : r];
1966
1964
  for (; this.peek()?.type === "COMMA";) {
1967
1965
  this.consume("COMMA");
1968
1966
  let e = this.parseExpressionNode();
1969
- n.push(q(e) ? e.data : e);
1967
+ n.push(J(e) ? e.data : e);
1970
1968
  }
1971
1969
  this.consume("RPAREN");
1972
- let i = e === "max" ? ue(...n) : de(...n);
1970
+ let i = e === "max" ? le(...n) : ue(...n);
1973
1971
  return Z(i), i;
1974
1972
  }
1975
1973
  this.consume("RPAREN");
1976
- let i = q(r) ? r.data : r, a = e === "max" ? ue(i) : de(i);
1974
+ let i = J(r) ? r.data : r, a = e === "max" ? le(i) : ue(i);
1977
1975
  return Z(a), a;
1978
1976
  }
1979
1977
  if (e === "sum") {
@@ -2007,8 +2005,8 @@ var De = class {
2007
2005
  this.consume("RPAREN");
2008
2006
  let t = this.templateCtx.functionMap.get(e.value);
2009
2007
  if (typeof n == "number") return this.evalSumWithMapper(n, t);
2010
- if (!q(n) && n instanceof G && n.terms.size === 0) return this.evalSumWithMapper(n.constant, t);
2011
- if (q(n)) return this.evalSumWithMapper(n.data, t);
2008
+ if (!J(n) && n instanceof K && n.terms.size === 0) return this.evalSumWithMapper(n.constant, t);
2009
+ if (J(n)) return this.evalSumWithMapper(n.data, t);
2012
2010
  throw Error("Invalid first argument in sum(itemsOrCount, mapFn): expected an Iterable, Record, or non-negative integer count.");
2013
2011
  }
2014
2012
  return this.consume("RPAREN"), this.evalSumSingle(n);
@@ -2059,12 +2057,12 @@ var De = class {
2059
2057
  });
2060
2058
  }
2061
2059
  if (Array.isArray(a.nonlinearTerms)) for (let e of a.nonlinearTerms) e.coeff !== 0 && r.push({
2062
- atom: B(e.atom),
2060
+ atom: V(e.atom),
2063
2061
  coeff: e.coeff
2064
2062
  });
2065
2063
  return;
2066
2064
  }
2067
- if (e instanceof G || typeof e == "object" && e && "terms" in e && e.terms instanceof Map && typeof e.constant == "number") {
2065
+ if (e instanceof K || typeof e == "object" && e && "terms" in e && e.terms instanceof Map && typeof e.constant == "number") {
2068
2066
  let n = e;
2069
2067
  Z(n);
2070
2068
  let a = i + n.constant;
@@ -2076,7 +2074,7 @@ var De = class {
2076
2074
  t.set(e, n);
2077
2075
  }
2078
2076
  if (Array.isArray(n.nonlinearTerms)) for (let e of n.nonlinearTerms) e.coeff !== 0 && r.push({
2079
- atom: B(e.atom),
2077
+ atom: V(e.atom),
2080
2078
  coeff: e.coeff
2081
2079
  });
2082
2080
  return;
@@ -2095,12 +2093,12 @@ var De = class {
2095
2093
  }
2096
2094
  return;
2097
2095
  }
2098
- if (X(e)) {
2096
+ if (Te(e)) {
2099
2097
  if (o >= 2) throw Error("Nested containers deeper than 2D are not supported in sum().");
2100
2098
  for (let t of e) a(t, o + 1);
2101
2099
  return;
2102
2100
  }
2103
- if (Y(e)) {
2101
+ if (X(e)) {
2104
2102
  if (o >= 2) throw Error("Nested containers deeper than 2D are not supported in sum().");
2105
2103
  if (Object.getOwnPropertySymbols(e).length > 0) throw Error("Symbol keys are not supported in sum().");
2106
2104
  for (let t of Object.keys(e)) a(e[t], o + 1);
@@ -2112,14 +2110,14 @@ var De = class {
2112
2110
  e(a);
2113
2111
  for (let [e, n] of t) n === 0 && t.delete(e);
2114
2112
  for (let [e, t] of n) t.coeff === 0 && n.delete(e);
2115
- return n.size > 0 ? new b(t, n, i, r) : new G(t, i, r);
2113
+ return n.size > 0 ? new b(t, n, i, r) : new K(t, i, r);
2116
2114
  }
2117
2115
  evalExtremumWithMapper(e, t, n) {
2118
- let r = e === "max" ? ue(t, n) : de(t, n);
2116
+ let r = e === "max" ? le(t, n) : ue(t, n);
2119
2117
  return Z(r), r;
2120
2118
  }
2121
2119
  evalSumSingle(e) {
2122
- if (!q(e)) throw Error("sum() requires a container (Array, Iterable, or Record) or (itemsOrCount, mapFn).");
2120
+ if (!J(e)) throw Error("sum() requires a container (Array, Iterable, or Record) or (itemsOrCount, mapFn).");
2123
2121
  return this.accumulateSumItems((t) => {
2124
2122
  t(e.data, 0);
2125
2123
  });
@@ -2143,7 +2141,7 @@ var De = class {
2143
2141
  for (let i of e) n(t(i, r++));
2144
2142
  return;
2145
2143
  }
2146
- if (Y(e)) {
2144
+ if (X(e)) {
2147
2145
  if (Object.getOwnPropertySymbols(e).length > 0) throw Error("Symbol keys are not supported in sum().");
2148
2146
  let r = 0;
2149
2147
  for (let i of Object.keys(e)) n(t(e[i], r++));
@@ -2153,9 +2151,9 @@ var De = class {
2153
2151
  });
2154
2152
  }
2155
2153
  evalDot(e, t) {
2156
- if (!q(e) || !q(t)) throw Error("dot() in template expression requires 1D or 2D Array or Record containers as arguments.");
2154
+ if (!J(e) || !J(t)) throw Error("dot() in template expression requires 1D or 2D Array or Record containers as arguments.");
2157
2155
  if (e.fromNonArrayIterable || t.fromNonArrayIterable) throw Error("Unsupported operand types in dot() at 'root': dot() requires Array or Record containers (use sum() for general Iterables).");
2158
- let n = oe(e.data, t.data);
2156
+ let n = ae(e.data, t.data);
2159
2157
  return Z(n), n;
2160
2158
  }
2161
2159
  applyPowerNode(e) {
@@ -2181,20 +2179,20 @@ var De = class {
2181
2179
  if (!Number.isFinite(t)) throw Error(`Invalid non-finite constant "${t}" in expression.`);
2182
2180
  return t;
2183
2181
  }
2184
- return q(e) ? {
2182
+ return J(e) ? {
2185
2183
  kind: "container",
2186
- data: J(e.data, (e) => {
2184
+ data: Y(e.data, (e) => {
2187
2185
  if (typeof e == "number") {
2188
2186
  let t = e ** +n;
2189
2187
  if (e !== 0 && n > 0 && t === 0) throw Error("Constant exponentiation underflows to zero.");
2190
2188
  if (!Number.isFinite(t)) throw Error("Constant exponentiation overflows finite floating-point range.");
2191
2189
  return t;
2192
2190
  }
2193
- let t = _e(we(ye(e), n));
2191
+ let t = ge(Ce(ve(e), n));
2194
2192
  return Z(t), t;
2195
2193
  }),
2196
2194
  fromNonArrayIterable: e.fromNonArrayIterable
2197
- } : we(e, n);
2195
+ } : Ce(e, n);
2198
2196
  }
2199
2197
  getRemainingToken() {
2200
2198
  return this.peek();
@@ -2204,11 +2202,11 @@ var De = class {
2204
2202
  if (this.templateCtx?.rawContainerMap.has(e)) return Ee(this.templateCtx.rawContainerMap.get(e));
2205
2203
  let t = this.resolver(e);
2206
2204
  if (!t) throw Error(`Unknown variable '${e}' in expression`);
2207
- return t instanceof K || "id" in t && !("terms" in t) && !("quadTerms" in t) ? new G(/* @__PURE__ */ new Map([[t, 1]]), 0) : t.clone();
2205
+ return t instanceof q || "id" in t && !("terms" in t) && !("quadTerms" in t) ? new K(/* @__PURE__ */ new Map([[t, 1]]), 0) : t.clone();
2208
2206
  }
2209
2207
  };
2210
2208
  function Oe(e, t, n, r) {
2211
- let i = new De(ge(e, n), t, r), a = i.parseExpression(), o = i.getRemainingToken();
2209
+ let i = new De(he(e, n), t, r), a = i.parseExpression(), o = i.getRemainingToken();
2212
2210
  if (o) throw Error(`Unexpected token '${o.value}' after expression in "${e}"`);
2213
2211
  return Z(a), a;
2214
2212
  }
@@ -2248,7 +2246,7 @@ function je(e, t, n, r, i) {
2248
2246
  else throw Error(`Unsupported operator "${o}"`);
2249
2247
  let d = Oe(c, t, r, i), f = Oe(l, t, r, i);
2250
2248
  if (d instanceof b && d.quadTerms.size > 0 || f instanceof b && f.quadTerms.size > 0) throw Error("Quadratic constraints are not supported (only linear constraints are allowed in MILP/LP/QP)");
2251
- let p = d instanceof b ? new G(d.linearTerms, d.constant, d.nonlinearTerms) : d, m = f instanceof b ? new G(f.linearTerms, f.constant, f.nonlinearTerms) : f, h;
2249
+ let p = d instanceof b ? new K(d.linearTerms, d.constant, d.nonlinearTerms) : d, m = f instanceof b ? new K(f.linearTerms, f.constant, f.nonlinearTerms) : f, h;
2252
2250
  if (h = u === "<=" ? p.le(m, n) : u === ">=" ? p.ge(m, n) : u === "==" ? p.eq(m, n) : u === "!=" ? p.ne(m, n) : u === "<" ? p.lt(m, n) : p.gt(m, n), Z(h.lhs), !Number.isFinite(h.rhs)) throw Error(`Invalid non-finite right-hand side "${h.rhs}" in constraint.`);
2253
2251
  return h;
2254
2252
  }
@@ -2256,7 +2254,7 @@ function Me(e, t, n) {
2256
2254
  return je(e, t, n);
2257
2255
  }
2258
2256
  function Ne(e) {
2259
- return e instanceof K || e instanceof G || e instanceof b ? !0 : typeof e != "object" || !e || Pe(e) ? !1 : "terms" in e && e.terms instanceof Map && typeof e.constant == "number" || "quadTerms" in e && e.quadTerms instanceof Map && "linearTerms" in e && e.linearTerms instanceof Map && typeof e.constant == "number" || typeof e.id == "number" && typeof e.name == "string" && typeof e.lb == "number" && typeof e.ub == "number" && typeof e.type == "string" && typeof e.mul == "function";
2257
+ return e instanceof q || e instanceof K || e instanceof b ? !0 : typeof e != "object" || !e || Pe(e) ? !1 : "terms" in e && e.terms instanceof Map && typeof e.constant == "number" || "quadTerms" in e && e.quadTerms instanceof Map && "linearTerms" in e && e.linearTerms instanceof Map && typeof e.constant == "number" || typeof e.id == "number" && typeof e.name == "string" && typeof e.lb == "number" && typeof e.ub == "number" && typeof e.type == "string" && typeof e.mul == "function";
2260
2258
  }
2261
2259
  function Z(e) {
2262
2260
  if ("constant" in e && !Number.isFinite(e.constant)) throw Error(`Invalid non-finite constant "${e.constant}" in expression.`);
@@ -2280,7 +2278,7 @@ function Z(e) {
2280
2278
  }
2281
2279
  }
2282
2280
  function Pe(e) {
2283
- return e instanceof R ? !0 : typeof e != "object" || !e ? !1 : e.kind === "constraint" || "sense" in e && (e.sense === "<=" || e.sense === ">=" || e.sense === "==" || e.sense === "!=") && "lhs" in e && "rhs" in e && typeof e.rhs == "number" && typeof e.lhs == "object" && e.lhs !== null && "terms" in e.lhs && e.lhs.terms instanceof Map;
2281
+ return e instanceof z ? !0 : typeof e != "object" || !e ? !1 : e.kind === "constraint" || "sense" in e && (e.sense === "<=" || e.sense === ">=" || e.sense === "==" || e.sense === "!=") && "lhs" in e && "rhs" in e && typeof e.rhs == "number" && typeof e.lhs == "object" && e.lhs !== null && "terms" in e.lhs && e.lhs.terms instanceof Map;
2284
2282
  }
2285
2283
  function Fe(e, t) {
2286
2284
  let n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), o = e.join(""), s = "__washi_";
@@ -2300,7 +2298,7 @@ function Fe(e, t) {
2300
2298
  } else if (typeof e == "function") {
2301
2299
  let t = `${s}fn_${o}__`;
2302
2300
  a.set(t, e), c += ` ${t} `;
2303
- } else if (Array.isArray(e) || X(e) || e instanceof Map || Y(e)) {
2301
+ } else if (Array.isArray(e) || Te(e) || e instanceof Map || X(e)) {
2304
2302
  let t = `${s}ph_${o}__`;
2305
2303
  i.set(t, e), c += ` ${t} `;
2306
2304
  } else throw Error("Unsupported interpolation value in template expression: expected a finite number, Var, LinExpr, or QuadExpr.");
@@ -2464,102 +2462,14 @@ function Je() {
2464
2462
  return Array.from(We.keys());
2465
2463
  }
2466
2464
  //#endregion
2467
- //#region src/modeler/solvers/mock.ts
2468
- var Ye = class {
2469
- name;
2470
- capabilities;
2471
- options;
2472
- constructor(e = {}) {
2473
- this.name = e.name || "MockSolver", this.capabilities = e.capabilities || {
2474
- supportsMIP: !0,
2475
- supportsQP: !0,
2476
- supportsWarmStart: !0
2477
- }, this.options = e;
2478
- }
2479
- async solve(e, t = {}, n = {}) {
2480
- let r = Le(t) ? n : t, i = {
2481
- ...this.options,
2482
- ...r
2483
- }, a = !!(i.values && Object.keys(i.values).length > 0 || i.boolValues && Object.keys(i.boolValues).length > 0);
2484
- if (i.signal?.aborted) return {
2485
- status: "Unknown",
2486
- terminationStatus: "Interrupted",
2487
- hasPrimalSolution: !1,
2488
- objectiveValue: null,
2489
- values: {},
2490
- runTime: 0,
2491
- raw: { mock: !0 }
2492
- };
2493
- if (i.delayMs && i.delayMs > 0 && (await new Promise((e) => {
2494
- let t = setTimeout(() => {
2495
- i.signal?.removeEventListener("abort", n), e();
2496
- }, i.delayMs), n = () => {
2497
- clearTimeout(t), e();
2498
- };
2499
- i.signal?.addEventListener("abort", n, { once: !0 });
2500
- }), i.signal?.aborted)) {
2501
- let e = !!(i.hasPrimalSolution ?? a);
2502
- return {
2503
- status: e ? "Feasible" : "Unknown",
2504
- terminationStatus: "Interrupted",
2505
- hasPrimalSolution: e,
2506
- objectiveValue: e ? i.objectiveValue ?? 0 : null,
2507
- ...i.objectiveBound === void 0 ? {} : { objectiveBound: i.objectiveBound },
2508
- ...i.relativeGap === void 0 ? {} : { relativeGap: i.relativeGap },
2509
- ...i.absoluteGap === void 0 ? {} : { absoluteGap: i.absoluteGap },
2510
- values: e && i.values || {},
2511
- ...e && i.boolValues !== void 0 ? { boolValues: i.boolValues } : {},
2512
- runTime: .001,
2513
- raw: { mock: !0 }
2514
- };
2515
- }
2516
- if (i.onProgress && Array.isArray(i.progressEvents)) for (let e of i.progressEvents) {
2517
- if (i.signal?.aborted) break;
2518
- i.onProgress(e);
2519
- }
2520
- let o = i.status || "Optimal", s = i.terminationStatus ?? o, c = i.hasPrimalSolution === void 0 ? o === "Optimal" || o === "Feasible" || o === "Sat" || (o === "TimeLimit" || o === "IterationLimit" || s === "Interrupted") && a : i.hasPrimalSolution;
2521
- if (i.onProgress && !Array.isArray(i.progressEvents) && !i.signal?.aborted) {
2522
- let e = c ? i.objectiveValue ?? 0 : void 0;
2523
- i.onProgress({
2524
- elapsedTime: .001,
2525
- elapsedSeconds: .001,
2526
- ...typeof e == "number" && Number.isFinite(e) ? { objectiveValue: e } : {},
2527
- ...i.objectiveBound === void 0 ? {} : { objectiveBound: i.objectiveBound },
2528
- ...i.relativeGap === void 0 ? {} : { relativeGap: i.relativeGap },
2529
- ...i.absoluteGap === void 0 ? {} : { absoluteGap: i.absoluteGap }
2530
- });
2531
- }
2532
- return i.signal?.aborted && (s = "Interrupted", c = i.hasPrimalSolution === void 0 ? a : i.hasPrimalSolution, o = c ? "Feasible" : "Unknown"), {
2533
- status: o,
2534
- terminationStatus: s,
2535
- hasPrimalSolution: c,
2536
- objectiveValue: c ? i.objectiveValue ?? 0 : null,
2537
- ...i.objectiveBound === void 0 ? {} : { objectiveBound: i.objectiveBound },
2538
- ...i.relativeGap === void 0 ? {} : { relativeGap: i.relativeGap },
2539
- ...i.absoluteGap === void 0 ? {} : { absoluteGap: i.absoluteGap },
2540
- values: c && i.values || {},
2541
- ...c && i.boolValues !== void 0 ? { boolValues: i.boolValues } : {},
2542
- reducedCosts: i.reducedCosts,
2543
- duals: i.duals,
2544
- slacks: i.slacks,
2545
- runTime: .001,
2546
- raw: { mock: !0 }
2547
- };
2548
- }
2549
- };
2550
- function Xe() {
2551
- Ge("mock", (e) => new Ye(e));
2552
- }
2553
- Xe();
2554
- //#endregion
2555
2465
  //#region src/modeler/solution-validator.ts
2556
- function Ze(e, t) {
2466
+ function Ye(e, t) {
2557
2467
  if (e === void 0) return 1e-6;
2558
2468
  if (typeof e != "number" || !Number.isFinite(e) || e < 0) throw Error(`Invalid ${t}: expected a finite non-negative number, received ${String(e)}.`);
2559
2469
  return e;
2560
2470
  }
2561
- function Qe(e, t = {}) {
2562
- let n = Ze(t.feasibilityTolerance, "feasibilityTolerance"), r = Ze(t.integralityTolerance, "integralityTolerance"), o = t.evaluateLogicalConstraints === void 0 || !!t.evaluateLogicalConstraints, s = t.values !== void 0 && t.values !== null;
2471
+ function Xe(e, t = {}) {
2472
+ let n = Ye(t.feasibilityTolerance, "feasibilityTolerance"), r = Ye(t.integralityTolerance, "integralityTolerance"), o = t.evaluateLogicalConstraints === void 0 || !!t.evaluateLogicalConstraints, s = t.values !== void 0 && t.values !== null;
2563
2473
  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.");
2564
2474
  let c = t.values, l = [], u = Object.create(null), f = [], p = [], m = 0, h = (e) => {
2565
2475
  typeof e == "number" && !Number.isNaN(e) && e > m && (m = e);
@@ -2568,7 +2478,7 @@ function Qe(e, t = {}) {
2568
2478
  }, _ = [], v = [];
2569
2479
  for (let t of e.variables.values()) t.type === "Boolean" ? v.push(t) : _.push(t);
2570
2480
  let y = [], x = [];
2571
- for (let t of e.constraints.values()) t instanceof R ? y.push(t) : x.push(t);
2481
+ for (let t of e.constraints.values()) t instanceof z ? y.push(t) : x.push(t);
2572
2482
  let S = /* @__PURE__ */ new Map(), C = /* @__PURE__ */ new Map(), w = 0, T = 0, E = 0, D = 0;
2573
2483
  for (let e of _) {
2574
2484
  let t = s ? Object.prototype.hasOwnProperty.call(c, e.name) ? c[e.name] : void 0 : e.value;
@@ -2845,9 +2755,9 @@ function Qe(e, t = {}) {
2845
2755
  ok: !0,
2846
2756
  errors: t
2847
2757
  };
2848
- }, ne = (e) => {
2758
+ }, A = (e) => {
2849
2759
  if (e instanceof i) return { ok: !0 };
2850
- if (e instanceof R) {
2760
+ if (e instanceof z) {
2851
2761
  let t = k(e.lhs);
2852
2762
  return t.ok ? {
2853
2763
  ok: !0,
@@ -2869,7 +2779,7 @@ function Qe(e, t = {}) {
2869
2779
  if (e instanceof a) {
2870
2780
  let t;
2871
2781
  for (let n of e.children) {
2872
- let e = ne(n);
2782
+ let e = A(n);
2873
2783
  if (!e.ok) return e;
2874
2784
  !t && e.firstError && (t = e.firstError);
2875
2785
  }
@@ -2879,7 +2789,7 @@ function Qe(e, t = {}) {
2879
2789
  };
2880
2790
  }
2881
2791
  return { ok: !0 };
2882
- }, A = (e, t = n) => {
2792
+ }, j = (e, t = n) => {
2883
2793
  if (typeof e.rhs != "number" || !Number.isFinite(e.rhs)) return {
2884
2794
  status: "unchecked",
2885
2795
  reason: `non-finite right-hand side (${String(e.rhs)})`
@@ -2922,9 +2832,9 @@ function Qe(e, t = {}) {
2922
2832
  signed: o,
2923
2833
  violation: s
2924
2834
  };
2925
- }, j = e.objective();
2926
- if ((j instanceof b || j instanceof G) && j.nonlinearTerms.length > 0) {
2927
- let e = k(new G(/* @__PURE__ */ new Map(), 0, j.nonlinearTerms));
2835
+ }, M = e.objective();
2836
+ if ((M instanceof b || M instanceof K) && M.nonlinearTerms.length > 0) {
2837
+ let e = k(new K(/* @__PURE__ */ new Map(), 0, M.nonlinearTerms));
2928
2838
  if (e.ok) for (let t of e.errors) g({
2929
2839
  type: "linear_constraint",
2930
2840
  target: "constraint",
@@ -2934,7 +2844,7 @@ function Qe(e, t = {}) {
2934
2844
  });
2935
2845
  }
2936
2846
  for (let e of y) {
2937
- let t = A(e);
2847
+ let t = j(e);
2938
2848
  t.status === "unchecked" ? (f.push(e.name), g({
2939
2849
  type: "unchecked_constraint",
2940
2850
  target: "constraint",
@@ -2957,7 +2867,7 @@ function Qe(e, t = {}) {
2957
2867
  message: t.message
2958
2868
  })) : (E++, h(t.violation));
2959
2869
  }
2960
- let M = (e) => {
2870
+ let N = (e) => {
2961
2871
  if (e instanceof i) return C.has(e) ? {
2962
2872
  ok: !0,
2963
2873
  value: C.get(e),
@@ -2966,7 +2876,7 @@ function Qe(e, t = {}) {
2966
2876
  ok: !1,
2967
2877
  reason: `missing or invalid value for Boolean variable "${e.name}"`
2968
2878
  };
2969
- if (e instanceof R) {
2879
+ if (e instanceof z) {
2970
2880
  if (e.sense === "!=") {
2971
2881
  let t = O(e.lhs);
2972
2882
  if (!t.ok) return {
@@ -2991,7 +2901,7 @@ function Qe(e, t = {}) {
2991
2901
  reason: `discrete comparison "${e.name}" lies between 0 and 1 (${t.value} != ${e.rhs})`
2992
2902
  };
2993
2903
  }
2994
- let t = A(e, 0);
2904
+ let t = j(e, 0);
2995
2905
  if (t.status === "unchecked") return {
2996
2906
  ok: !1,
2997
2907
  reason: t.reason
@@ -3130,7 +3040,7 @@ function Qe(e, t = {}) {
3130
3040
  }
3131
3041
  if (e instanceof a) switch (e.op) {
3132
3042
  case "not": {
3133
- let t = M(e.children[0]);
3043
+ let t = N(e.children[0]);
3134
3044
  return t.ok ? {
3135
3045
  ok: !0,
3136
3046
  value: !t.value,
@@ -3140,7 +3050,7 @@ function Qe(e, t = {}) {
3140
3050
  case "and": {
3141
3051
  let t = 0;
3142
3052
  for (let n of e.children) {
3143
- let e = M(n);
3053
+ let e = N(n);
3144
3054
  if (!e.ok) return e;
3145
3055
  if (!e.value) return {
3146
3056
  ok: !0,
@@ -3158,7 +3068,7 @@ function Qe(e, t = {}) {
3158
3068
  case "or": {
3159
3069
  let t = !1, n = Infinity;
3160
3070
  for (let r of e.children) {
3161
- let e = M(r);
3071
+ let e = N(r);
3162
3072
  if (!e.ok) return e;
3163
3073
  e.value && (t = !0, e.violation < n && (n = e.violation));
3164
3074
  }
@@ -3169,14 +3079,14 @@ function Qe(e, t = {}) {
3169
3079
  };
3170
3080
  }
3171
3081
  case "implies": {
3172
- let t = M(e.children[0]);
3082
+ let t = N(e.children[0]);
3173
3083
  if (!t.ok) return t;
3174
3084
  if (!t.value) return {
3175
3085
  ok: !0,
3176
3086
  value: !0,
3177
3087
  violation: 0
3178
3088
  };
3179
- let n = M(e.children[1]);
3089
+ let n = N(e.children[1]);
3180
3090
  return n.ok ? {
3181
3091
  ok: !0,
3182
3092
  value: n.value,
@@ -3186,7 +3096,7 @@ function Qe(e, t = {}) {
3186
3096
  case "xor": {
3187
3097
  let t = !1, n = 0;
3188
3098
  for (let r of e.children) {
3189
- let e = M(r);
3099
+ let e = N(r);
3190
3100
  if (!e.ok) return e;
3191
3101
  e.value && (t = !t, e.violation > n && (n = e.violation));
3192
3102
  }
@@ -3218,7 +3128,7 @@ function Qe(e, t = {}) {
3218
3128
  });
3219
3129
  continue;
3220
3130
  }
3221
- let r = ne(t.expr);
3131
+ let r = A(t.expr);
3222
3132
  if (!r.ok) {
3223
3133
  f.push(n), g({
3224
3134
  type: "unchecked_constraint",
@@ -3242,7 +3152,7 @@ function Qe(e, t = {}) {
3242
3152
  });
3243
3153
  continue;
3244
3154
  }
3245
- let i = M(t.expr);
3155
+ let i = N(t.expr);
3246
3156
  if (!i.ok) {
3247
3157
  f.push(n), g({
3248
3158
  type: "unchecked_constraint",
@@ -3264,10 +3174,10 @@ function Qe(e, t = {}) {
3264
3174
  message: `Logical constraint "${n}" evaluated to false.`
3265
3175
  });
3266
3176
  }
3267
- let N = w === _.length && T === v.length && E === y.length && D === x.length && f.length === 0 && p.length === 0;
3177
+ let P = w === _.length && T === v.length && E === y.length && D === x.length && f.length === 0 && p.length === 0;
3268
3178
  return {
3269
- valid: N && l.length === 0,
3270
- complete: N,
3179
+ valid: P && l.length === 0,
3180
+ complete: P,
3271
3181
  violations: l,
3272
3182
  violationsByName: u,
3273
3183
  uncheckedConstraints: f,
@@ -3287,10 +3197,10 @@ function Qe(e, t = {}) {
3287
3197
  }
3288
3198
  //#endregion
3289
3199
  //#region src/modeler/big-m.ts
3290
- function $e(e, t) {
3200
+ function Ze(e, t) {
3291
3201
  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}.`);
3292
3202
  }
3293
- function et(e, t, n) {
3203
+ function Qe(e, t, n) {
3294
3204
  let r = e.constant === void 0 ? 0 : e.constant;
3295
3205
  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}).`);
3296
3206
  let i = t - r;
@@ -3301,8 +3211,8 @@ function et(e, t, n) {
3301
3211
  }
3302
3212
  return i;
3303
3213
  }
3304
- function tt(e, t, n) {
3305
- let r = et(e, t, n), i = 0;
3214
+ function $e(e, t, n) {
3215
+ let r = Qe(e, t, n), i = 0;
3306
3216
  for (let [t, r] of e.terms) {
3307
3217
  if (r === 0) continue;
3308
3218
  let e;
@@ -3322,8 +3232,8 @@ function tt(e, t, n) {
3322
3232
  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.`);
3323
3233
  return o;
3324
3234
  }
3325
- function nt(e, t, n) {
3326
- let r = et(e, t, n), i = 0;
3235
+ function et(e, t, n) {
3236
+ let r = Qe(e, t, n), i = 0;
3327
3237
  for (let [t, r] of e.terms) {
3328
3238
  if (r === 0) continue;
3329
3239
  let e;
@@ -3343,10 +3253,10 @@ function nt(e, t, n) {
3343
3253
  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.`);
3344
3254
  return o;
3345
3255
  }
3346
- function rt(e, t, n, r, i, a, o) {
3347
- if (!(e instanceof K && (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}].`);
3256
+ function tt(e, t, n, r, i, a, o) {
3257
+ if (!(e instanceof q && (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}].`);
3348
3258
  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.`);
3349
- let s = et(t, r, o);
3259
+ let s = Qe(t, r, o);
3350
3260
  if (i !== 0 && i !== 1) throw Error(`Invalid activeValue: ${i}. Indicator activation value must be 0 or 1.`);
3351
3261
  if (n !== "<=" && n !== ">=") throw Error(`Invalid indicator sense for "${o}": expected "<=" or ">=", received "${String(n)}".`);
3352
3262
  if (!Number.isFinite(a) || a < 0) throw Error(`Invalid Big-M value for indicator constraint "${o}": expected a finite non-negative number, received ${a}.`);
@@ -3357,7 +3267,7 @@ function rt(e, t, n, r, i, a, o) {
3357
3267
  let d = /* @__PURE__ */ new Map();
3358
3268
  for (let [e, n] of t.terms) n !== 0 && d.set(e, n);
3359
3269
  return l !== 0 && d.set(e, l), {
3360
- lhs: new G(d, 0),
3270
+ lhs: new K(d, 0),
3361
3271
  rhs: u
3362
3272
  };
3363
3273
  }
@@ -3370,16 +3280,16 @@ function Q(e, t = 0) {
3370
3280
  let e = (n.get(t) ?? 0) + r;
3371
3281
  e === 0 ? n.delete(t) : n.set(t, e);
3372
3282
  }
3373
- return new G(n, t);
3283
+ return new K(n, t);
3374
3284
  }
3375
- function it(e, t, n = 1) {
3285
+ function nt(e, t, n = 1) {
3376
3286
  if (n !== 0) {
3377
3287
  e.constant += t.constant * n;
3378
3288
  for (let [r, i] of t.terms.entries()) i !== 0 && e.addTerm(r, i * n);
3379
3289
  }
3380
3290
  }
3381
- var at = 5e3, ot = 25e3;
3382
- function st(t, n, r, o, s) {
3291
+ var rt = 5e3, it = 25e3;
3292
+ function at(t, n, r, o, s) {
3383
3293
  let c = [...t], l = [], u = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Set(), m = [];
3384
3294
  for (let e of r) if (e.sense === "!=" || e.lhs.hasNonlinearTerms()) m.push(e);
3385
3295
  else {
@@ -3387,7 +3297,7 @@ function st(t, n, r, o, s) {
3387
3297
  if (p.has(t.name)) {
3388
3298
  let n = 1;
3389
3299
  for (; p.has(`${e.name}_${n}`);) n++;
3390
- t = new R(e.lhs, e.sense, e.rhs, `${e.name}_${n}`);
3300
+ t = new z(e.lhs, e.sense, e.rhs, `${e.name}_${n}`);
3391
3301
  }
3392
3302
  p.add(t.name), l.push(t), f.set(t, e.name);
3393
3303
  }
@@ -3404,14 +3314,14 @@ function st(t, n, r, o, s) {
3404
3314
  if (p.has(r)) {
3405
3315
  let t = 1;
3406
3316
  for (; p.has(`${n}_${t}`);) t++;
3407
- r = `${n}_${t}`, e = new R(e.lhs, e.sense, e.rhs, r);
3317
+ r = `${n}_${t}`, e = new z(e.lhs, e.sense, e.rhs, r);
3408
3318
  }
3409
3319
  p.add(r), l.push(e), f.set(e, t);
3410
3320
  }
3411
3321
  for (let e of n) {
3412
3322
  let t = e.name;
3413
3323
  h.has(t) ? t = _(`bool_${e.name}`) : h.add(t);
3414
- let n = new K({
3324
+ let n = new q({
3415
3325
  name: t,
3416
3326
  type: "Binary",
3417
3327
  lb: 0,
@@ -3446,8 +3356,8 @@ function st(t, n, r, o, s) {
3446
3356
  }
3447
3357
  function x(e, t) {
3448
3358
  if (!e.hasNonlinearTerms()) return e.clone();
3449
- let n = new G(e.terms, e.constant);
3450
- for (let r of e.nonlinearTerms) r.coeff !== 0 && it(n, S(r.atom, t), r.coeff);
3359
+ let n = new K(e.terms, e.constant);
3360
+ for (let r of e.nonlinearTerms) r.coeff !== 0 && nt(n, S(r.atom, t), r.coeff);
3451
3361
  return n;
3452
3362
  }
3453
3363
  function S(e, t) {
@@ -3456,12 +3366,12 @@ function st(t, n, r, o, s) {
3456
3366
  let n = x(e.arg, t), { lb: r, ub: i, isDiscrete: a } = y(n, t);
3457
3367
  if (r >= 0) return n;
3458
3368
  if (i <= 0) return n.mul(-1);
3459
- let o = Math.max(-r, i), s = new K({
3369
+ let o = Math.max(-r, i), s = new q({
3460
3370
  name: _("abs_t"),
3461
3371
  type: a ? "Integer" : "Continuous",
3462
3372
  lb: 0,
3463
3373
  ub: o
3464
- }), l = new K({
3374
+ }), l = new q({
3465
3375
  name: _("abs_z"),
3466
3376
  type: "Binary",
3467
3377
  lb: 0,
@@ -3469,12 +3379,12 @@ function st(t, n, r, o, s) {
3469
3379
  });
3470
3380
  c.push(s, l);
3471
3381
  let u = Q([[s, 1]], 0);
3472
- return z(new R(n.sub(u), "<=", 0, `${t}_abs_pos`), t), z(new R(n.mul(-1).sub(u), "<=", 0, `${t}_abs_neg`), t), z(new R(u.sub(n).add(Q([[l, 2 * -r]], 0)), "<=", 2 * -r, `${t}_abs_hi_pos`), t), z(new R(u.add(n).sub(Q([[l, 2 * i]], 0)), "<=", 0, `${t}_abs_hi_neg`), t), u;
3382
+ return B(new z(n.sub(u), "<=", 0, `${t}_abs_pos`), t), B(new z(n.mul(-1).sub(u), "<=", 0, `${t}_abs_neg`), t), B(new z(u.sub(n).add(Q([[l, 2 * -r]], 0)), "<=", 2 * -r, `${t}_abs_hi_pos`), t), B(new z(u.add(n).sub(Q([[l, 2 * i]], 0)), "<=", 0, `${t}_abs_hi_neg`), t), u;
3473
3383
  }
3474
3384
  case "max": {
3475
3385
  let n = e.args.map((e) => x(e, t));
3476
3386
  if (n.length === 1) return n[0];
3477
- let r = n.map((e) => y(e, t)), i = Math.max(...r.map((e) => e.lb)), a = Math.max(...r.map((e) => e.ub)), o = r.every((e) => e.isDiscrete), s = new K({
3387
+ let r = n.map((e) => y(e, t)), i = Math.max(...r.map((e) => e.lb)), a = Math.max(...r.map((e) => e.ub)), o = r.every((e) => e.isDiscrete), s = new q({
3478
3388
  name: _("max_t"),
3479
3389
  type: o ? "Integer" : "Continuous",
3480
3390
  lb: i,
@@ -3483,22 +3393,22 @@ function st(t, n, r, o, s) {
3483
3393
  c.push(s);
3484
3394
  let l = Q([[s, 1]], 0), u = [];
3485
3395
  for (let e = 0; e < n.length; e++) {
3486
- let i = new K({
3396
+ let i = new q({
3487
3397
  name: _(`max_z_${e}`),
3488
3398
  type: "Binary",
3489
3399
  lb: 0,
3490
3400
  ub: 1
3491
3401
  });
3492
- c.push(i), u.push(i), z(new R(n[e].sub(l), "<=", 0, `${t}_max_lb_${e}`), t);
3402
+ c.push(i), u.push(i), B(new z(n[e].sub(l), "<=", 0, `${t}_max_lb_${e}`), t);
3493
3403
  let o = a - r[e].lb;
3494
- z(new R(l.sub(n[e]).add(Q([[i, o]], 0)), "<=", o, `${t}_max_ub_${e}`), t);
3404
+ B(new z(l.sub(n[e]).add(Q([[i, o]], 0)), "<=", o, `${t}_max_ub_${e}`), t);
3495
3405
  }
3496
- return v(new R(Q(u.map((e) => [e, 1]), 0), "==", 1, `${t}_max_sos`), t), l;
3406
+ return v(new z(Q(u.map((e) => [e, 1]), 0), "==", 1, `${t}_max_sos`), t), l;
3497
3407
  }
3498
3408
  case "min": {
3499
3409
  let n = e.args.map((e) => x(e, t));
3500
3410
  if (n.length === 1) return n[0];
3501
- let r = n.map((e) => y(e, t)), i = Math.min(...r.map((e) => e.lb)), a = Math.min(...r.map((e) => e.ub)), o = r.every((e) => e.isDiscrete), s = new K({
3411
+ let r = n.map((e) => y(e, t)), i = Math.min(...r.map((e) => e.lb)), a = Math.min(...r.map((e) => e.ub)), o = r.every((e) => e.isDiscrete), s = new q({
3502
3412
  name: _("min_t"),
3503
3413
  type: o ? "Integer" : "Continuous",
3504
3414
  lb: i,
@@ -3507,22 +3417,22 @@ function st(t, n, r, o, s) {
3507
3417
  c.push(s);
3508
3418
  let l = Q([[s, 1]], 0), u = [];
3509
3419
  for (let e = 0; e < n.length; e++) {
3510
- let a = new K({
3420
+ let a = new q({
3511
3421
  name: _(`min_z_${e}`),
3512
3422
  type: "Binary",
3513
3423
  lb: 0,
3514
3424
  ub: 1
3515
3425
  });
3516
- c.push(a), u.push(a), z(new R(n[e].sub(l), ">=", 0, `${t}_min_ub_${e}`), t);
3426
+ c.push(a), u.push(a), B(new z(n[e].sub(l), ">=", 0, `${t}_min_ub_${e}`), t);
3517
3427
  let o = r[e].ub - i;
3518
- z(new R(n[e].sub(l).add(Q([[a, o]], 0)), "<=", o, `${t}_min_lb_${e}`), t);
3428
+ B(new z(n[e].sub(l).add(Q([[a, o]], 0)), "<=", o, `${t}_min_lb_${e}`), t);
3519
3429
  }
3520
- return v(new R(Q(u.map((e) => [e, 1]), 0), "==", 1, `${t}_min_sos`), t), l;
3430
+ return v(new z(Q(u.map((e) => [e, 1]), 0), "==", 1, `${t}_min_sos`), t), l;
3521
3431
  }
3522
3432
  case "at": {
3523
3433
  let n = e.array.length, r = x(e.index, t), i = e.array.map((e) => x(e, t)), a = [];
3524
3434
  for (let e = 0; e < n; e++) {
3525
- let t = new K({
3435
+ let t = new q({
3526
3436
  name: _(`at_lam_${e}`),
3527
3437
  type: "Binary",
3528
3438
  lb: 0,
@@ -3530,16 +3440,16 @@ function st(t, n, r, o, s) {
3530
3440
  });
3531
3441
  c.push(t), a.push(t);
3532
3442
  }
3533
- v(new R(Q(a.map((e) => [e, 1]), 0), "==", 1, `${t}_at_sos`), t);
3443
+ v(new z(Q(a.map((e) => [e, 1]), 0), "==", 1, `${t}_at_sos`), t);
3534
3444
  let o = r.clone();
3535
3445
  for (let e = 1; e < n; e++) o.addTerm(a[e], -e);
3536
- z(new R(o, "==", 0, `${t}_at_idx`), t);
3537
- let s = new G(/* @__PURE__ */ new Map(), 0);
3446
+ B(new z(o, "==", 0, `${t}_at_idx`), t);
3447
+ let s = new K(/* @__PURE__ */ new Map(), 0);
3538
3448
  for (let e = 0; e < n; e++) {
3539
3449
  let n = i[e];
3540
3450
  if (n.terms.size === 0) n.constant !== 0 && s.addTerm(a[e], n.constant);
3541
3451
  else {
3542
- let { lb: r, ub: i, isDiscrete: o } = y(n, t), l = new K({
3452
+ let { lb: r, ub: i, isDiscrete: o } = y(n, t), l = new q({
3543
3453
  name: _(`at_w_${e}`),
3544
3454
  type: o ? "Integer" : "Continuous",
3545
3455
  lb: Math.min(0, r),
@@ -3547,7 +3457,7 @@ function st(t, n, r, o, s) {
3547
3457
  });
3548
3458
  c.push(l);
3549
3459
  let u = Q([[l, 1]], 0);
3550
- z(new R(Q([[l, 1], [a[e], -r]], 0), ">=", 0, `${t}_at_mc1_${e}`), t), z(new R(Q([[l, 1], [a[e], -i]], 0), "<=", 0, `${t}_at_mc2_${e}`), t), z(new R(u.sub(n).add(Q([[a[e], -i]], 0)), ">=", -i, `${t}_at_mc3_${e}`), t), z(new R(u.sub(n).add(Q([[a[e], -r]], 0)), "<=", -r, `${t}_at_mc4_${e}`), t), s.addTerm(l, 1);
3460
+ B(new z(Q([[l, 1], [a[e], -r]], 0), ">=", 0, `${t}_at_mc1_${e}`), t), B(new z(Q([[l, 1], [a[e], -i]], 0), "<=", 0, `${t}_at_mc2_${e}`), t), B(new z(u.sub(n).add(Q([[a[e], -i]], 0)), ">=", -i, `${t}_at_mc3_${e}`), t), B(new z(u.sub(n).add(Q([[a[e], -r]], 0)), "<=", -r, `${t}_at_mc4_${e}`), t), s.addTerm(l, 1);
3551
3461
  }
3552
3462
  }
3553
3463
  return s;
@@ -3556,7 +3466,7 @@ function st(t, n, r, o, s) {
3556
3466
  }
3557
3467
  function C(e, t, n) {
3558
3468
  if (t === "upper" && e.kind === "max") {
3559
- let t = new K({
3469
+ let t = new q({
3560
3470
  name: _("epi_max"),
3561
3471
  type: "Continuous",
3562
3472
  lb: -Infinity,
@@ -3568,7 +3478,7 @@ function st(t, n, r, o, s) {
3568
3478
  return r;
3569
3479
  }
3570
3480
  if (t === "upper" && e.kind === "abs") {
3571
- let t = e.arg.hasNonlinearTerms() ? x(e.arg, n) : e.arg, r = new K({
3481
+ let t = e.arg.hasNonlinearTerms() ? x(e.arg, n) : e.arg, r = new q({
3572
3482
  name: _("epi_abs"),
3573
3483
  type: "Continuous",
3574
3484
  lb: 0,
@@ -3576,10 +3486,10 @@ function st(t, n, r, o, s) {
3576
3486
  });
3577
3487
  c.push(r);
3578
3488
  let i = Q([[r, 1]], 0);
3579
- return z(new R(t.sub(i), "<=", 0, `${n}_epi_abs_pos`), n), z(new R(t.mul(-1).sub(i), "<=", 0, `${n}_epi_abs_neg`), n), i;
3489
+ return B(new z(t.sub(i), "<=", 0, `${n}_epi_abs_pos`), n), B(new z(t.mul(-1).sub(i), "<=", 0, `${n}_epi_abs_neg`), n), i;
3580
3490
  }
3581
3491
  if (t === "lower" && e.kind === "min") {
3582
- let t = new K({
3492
+ let t = new q({
3583
3493
  name: _("epi_min"),
3584
3494
  type: "Continuous",
3585
3495
  lb: -Infinity,
@@ -3595,24 +3505,24 @@ function st(t, n, r, o, s) {
3595
3505
  function w(e, t, n) {
3596
3506
  if (!e.hasNonlinearTerms()) return e;
3597
3507
  if (t === "==" || t === "!=") return x(e, n);
3598
- let r = new G(e.terms, e.constant);
3508
+ let r = new K(e.terms, e.constant);
3599
3509
  for (let i of e.nonlinearTerms) {
3600
3510
  if (i.coeff === 0) continue;
3601
3511
  let e = t === "<=" ? i.coeff > 0 ? "upper" : "lower" : i.coeff > 0 ? "lower" : "upper";
3602
- it(r, C(i.atom, e, n), i.coeff);
3512
+ nt(r, C(i.atom, e, n), i.coeff);
3603
3513
  }
3604
3514
  return r;
3605
3515
  }
3606
3516
  function T(e, t, n, r, i) {
3607
3517
  let a = w(e, t, i);
3608
3518
  if (t === "!=") {
3609
- B(new R(a, "==", n, r), i);
3519
+ V(new z(a, "==", n, r), i);
3610
3520
  return;
3611
3521
  }
3612
- z(new R(a, t, n, r), i);
3522
+ B(new z(a, t, n, r), i);
3613
3523
  }
3614
3524
  function E(e, t) {
3615
- return e.lhs.hasNonlinearTerms() ? new R(x(e.lhs, t), e.sense, e.rhs, e.name) : e;
3525
+ return e.lhs.hasNonlinearTerms() ? new z(x(e.lhs, t), e.sense, e.rhs, e.name) : e;
3616
3526
  }
3617
3527
  function D(e, t) {
3618
3528
  if (e instanceof i) {
@@ -3620,7 +3530,7 @@ function st(t, n, r, o, s) {
3620
3530
  if (!n) throw Error(`Unregistered BoolVar "${e.name}" in logical constraint "${t}".`);
3621
3531
  return n;
3622
3532
  }
3623
- let n = new K({
3533
+ let n = new q({
3624
3534
  name: _("expr"),
3625
3535
  type: "Binary",
3626
3536
  lb: 0,
@@ -3629,19 +3539,19 @@ function st(t, n, r, o, s) {
3629
3539
  return c.push(n), O(n, e, t), n;
3630
3540
  }
3631
3541
  function ee(e, t, n, r) {
3632
- v(new R(Q([
3542
+ v(new z(Q([
3633
3543
  [e, 1],
3634
3544
  [t, -1],
3635
3545
  [n, -1]
3636
- ], 0), "<=", 0, `${r}_xor_1`), r), v(new R(Q([
3546
+ ], 0), "<=", 0, `${r}_xor_1`), r), v(new z(Q([
3637
3547
  [e, 1],
3638
3548
  [t, -1],
3639
3549
  [n, 1]
3640
- ], 0), ">=", 0, `${r}_xor_2`), r), v(new R(Q([
3550
+ ], 0), ">=", 0, `${r}_xor_2`), r), v(new z(Q([
3641
3551
  [e, 1],
3642
3552
  [n, -1],
3643
3553
  [t, 1]
3644
- ], 0), ">=", 0, `${r}_xor_3`), r), v(new R(Q([
3554
+ ], 0), ">=", 0, `${r}_xor_3`), r), v(new z(Q([
3645
3555
  [e, 1],
3646
3556
  [t, 1],
3647
3557
  [n, 1]
@@ -3650,39 +3560,39 @@ function st(t, n, r, o, s) {
3650
3560
  function O(e, t, n) {
3651
3561
  if (t instanceof i) {
3652
3562
  let r = u.get(t);
3653
- v(new R(Q([[e, 1], [r, -1]], 0), "==", 0, `${n}_equiv`), n);
3563
+ v(new z(Q([[e, 1], [r, -1]], 0), "==", 0, `${n}_equiv`), n);
3654
3564
  return;
3655
3565
  }
3656
- if (t instanceof R) {
3566
+ if (t instanceof z) {
3657
3567
  let r = E(t, n);
3658
- V(e, r, 0, `${n}_c_neg`, n), re(e, r, 1, `${n}_c_pos`, n);
3568
+ H(e, r, 0, `${n}_c_neg`, n), ne(e, r, 1, `${n}_c_pos`, n);
3659
3569
  return;
3660
3570
  }
3661
3571
  if (t instanceof d) {
3662
- A(e, t, n);
3572
+ j(e, t, n);
3663
3573
  return;
3664
3574
  }
3665
3575
  if (t instanceof a) {
3666
3576
  if (t.op === "not") {
3667
3577
  let r = D(t.children[0], n);
3668
- v(new R(Q([[e, 1], [r, 1]], 0), "==", 1, `${n}_not`), n);
3578
+ v(new z(Q([[e, 1], [r, 1]], 0), "==", 1, `${n}_not`), n);
3669
3579
  return;
3670
3580
  }
3671
3581
  if (t.op === "and") {
3672
3582
  let r = t.children.map((e) => D(e, n));
3673
- for (let t = 0; t < r.length; t++) v(new R(Q([[e, 1], [r[t], -1]], 0), "<=", 0, `${n}_and_ub_${t}`), n);
3674
- v(new R(Q([[e, 1], ...r.map((e) => [e, -1])], 0), ">=", 1 - r.length, `${n}_and_lb`), n);
3583
+ for (let t = 0; t < r.length; t++) v(new z(Q([[e, 1], [r[t], -1]], 0), "<=", 0, `${n}_and_ub_${t}`), n);
3584
+ v(new z(Q([[e, 1], ...r.map((e) => [e, -1])], 0), ">=", 1 - r.length, `${n}_and_lb`), n);
3675
3585
  return;
3676
3586
  }
3677
3587
  if (t.op === "or") {
3678
3588
  let r = t.children.map((e) => D(e, n));
3679
- for (let t = 0; t < r.length; t++) v(new R(Q([[e, 1], [r[t], -1]], 0), ">=", 0, `${n}_or_lb_${t}`), n);
3680
- v(new R(Q([[e, 1], ...r.map((e) => [e, -1])], 0), "<=", 0, `${n}_or_ub`), n);
3589
+ for (let t = 0; t < r.length; t++) v(new z(Q([[e, 1], [r[t], -1]], 0), ">=", 0, `${n}_or_lb_${t}`), n);
3590
+ v(new z(Q([[e, 1], ...r.map((e) => [e, -1])], 0), "<=", 0, `${n}_or_ub`), n);
3681
3591
  return;
3682
3592
  }
3683
3593
  if (t.op === "implies") {
3684
3594
  let r = D(t.children[0], n), i = D(t.children[1], n);
3685
- v(new R(Q([[e, 1], [r, 1]], 0), ">=", 1, `${n}_imp_1`), n), v(new R(Q([[e, 1], [i, -1]], 0), ">=", 0, `${n}_imp_2`), n), v(new R(Q([
3595
+ v(new z(Q([[e, 1], [r, 1]], 0), ">=", 1, `${n}_imp_1`), n), v(new z(Q([[e, 1], [i, -1]], 0), ">=", 0, `${n}_imp_2`), n), v(new z(Q([
3686
3596
  [e, 1],
3687
3597
  [r, 1],
3688
3598
  [i, -1]
@@ -3691,17 +3601,17 @@ function st(t, n, r, o, s) {
3691
3601
  }
3692
3602
  if (t.op === "xor") {
3693
3603
  if (t.children.length === 0) {
3694
- v(new R(Q([[e, 1]], 0), "==", 0, `${n}_xor_empty`), n);
3604
+ v(new z(Q([[e, 1]], 0), "==", 0, `${n}_xor_empty`), n);
3695
3605
  return;
3696
3606
  }
3697
3607
  if (t.children.length === 1) {
3698
3608
  let r = D(t.children[0], n);
3699
- v(new R(Q([[e, 1], [r, -1]], 0), "==", 0, `${n}_xor_single`), n);
3609
+ v(new z(Q([[e, 1], [r, -1]], 0), "==", 0, `${n}_xor_single`), n);
3700
3610
  return;
3701
3611
  }
3702
3612
  let r = t.children.map((e) => D(e, n)), i = r[0];
3703
3613
  for (let e = 1; e < r.length - 1; e++) {
3704
- let t = new K({
3614
+ let t = new q({
3705
3615
  name: _(`xor_fold_${e}`),
3706
3616
  type: "Binary",
3707
3617
  lb: 0,
@@ -3768,49 +3678,49 @@ function st(t, n, r, o, s) {
3768
3678
  active: i
3769
3679
  };
3770
3680
  }
3771
- function ne(e, t, n) {
3681
+ function A(e, t, n) {
3772
3682
  let r = e.spec;
3773
3683
  switch (r.kind) {
3774
3684
  case "distinct": {
3775
3685
  let e = r.args.map((e) => x(e, n));
3776
3686
  if (e.length <= 1) {
3777
- t || L(n);
3687
+ t || R(n);
3778
3688
  return;
3779
3689
  }
3780
3690
  if (t) for (let t = 0; t < e.length; t++) for (let r = t + 1; r < e.length; r++) T(e[t].sub(e[r]), "!=", 0, `${n}_neq_${t}_${r}`, n);
3781
3691
  else {
3782
3692
  let t = [];
3783
- for (let r = 0; r < e.length; r++) for (let i = r + 1; i < e.length; i++) t.push(new R(e[r].sub(e[i]), "==", 0, `${n}_eq_${r}_${i}`));
3784
- P(new a("or", t), n);
3693
+ for (let r = 0; r < e.length; r++) for (let i = r + 1; i < e.length; i++) t.push(new z(e[r].sub(e[i]), "==", 0, `${n}_eq_${r}_${i}`));
3694
+ F(new a("or", t), n);
3785
3695
  }
3786
3696
  return;
3787
3697
  }
3788
3698
  case "disjoint": {
3789
3699
  let e = te(r.tasks, n);
3790
3700
  if (e.length === 0) {
3791
- t || L(n);
3701
+ t || R(n);
3792
3702
  return;
3793
3703
  }
3794
3704
  if (t) for (let { i: t, j: r, sI: i, dI: a, sJ: o, dJ: s } of e) {
3795
- let e = new K({
3705
+ let e = new q({
3796
3706
  name: _(`disj_${t}_${r}`),
3797
3707
  type: "Binary",
3798
3708
  lb: 0,
3799
3709
  ub: 1
3800
3710
  });
3801
- c.push(e), F(e, i.sub(o), "<=", -a, 1, `${n}_p_${t}_${r}`, n), F(e, o.sub(i), "<=", -s, 0, `${n}_q_${t}_${r}`, n);
3711
+ c.push(e), I(e, i.sub(o), "<=", -a, 1, `${n}_p_${t}_${r}`, n), I(e, o.sub(i), "<=", -s, 0, `${n}_q_${t}_${r}`, n);
3802
3712
  }
3803
- else P(new a("or", e.map(({ i: e, j: t, sI: r, dI: i, sJ: o, dJ: s }) => new a("and", [new R(r.sub(o), ">=", 1 - i, `${n}_ov1_${e}_${t}`), new R(o.sub(r), ">=", 1 - s, `${n}_ov2_${e}_${t}`)]))), n);
3713
+ else F(new a("or", e.map(({ i: e, j: t, sI: r, dI: i, sJ: o, dJ: s }) => new a("and", [new z(r.sub(o), ">=", 1 - i, `${n}_ov1_${e}_${t}`), new z(o.sub(r), ">=", 1 - s, `${n}_ov2_${e}_${t}`)]))), n);
3804
3714
  return;
3805
3715
  }
3806
3716
  case "cumulative": {
3807
3717
  let e = k(r.tasks, r.capacity, n);
3808
3718
  if (e.kind === "empty_domain") {
3809
- L(n);
3719
+ R(n);
3810
3720
  return;
3811
3721
  }
3812
3722
  if (e.kind === "constant") {
3813
- e.value !== t && L(n);
3723
+ e.value !== t && R(n);
3814
3724
  return;
3815
3725
  }
3816
3726
  let { active: i } = e;
@@ -3818,12 +3728,12 @@ function st(t, n, r, o, s) {
3818
3728
  let e = Infinity, t = -Infinity, a = 0;
3819
3729
  for (let n of i) n.est < e && (e = n.est), n.lst + n.duration > t && (t = n.lst + n.duration), a += Math.max(0, n.lst - n.est + 1);
3820
3730
  let o = t - e;
3821
- if (!Number.isSafeInteger(o) || o > at || a > ot) throw Error(`Cannot linearize cumulative() constraint "${n}" for MIP solver: time horizon [${e}, ${t}) (span ${o}, ${a} time-indexed variables) exceeds MIP limit. Tighten start bounds or use { solver: "pumpkin" }.`);
3731
+ if (!Number.isSafeInteger(o) || o > rt || a > it) throw Error(`Cannot linearize cumulative() constraint "${n}" for MIP solver: time horizon [${e}, ${t}) (span ${o}, ${a} time-indexed variables) exceeds MIP limit. Tighten start bounds or use { solver: "pumpkin" }.`);
3822
3732
  let s = [];
3823
3733
  for (let e = 0; e < i.length; e++) {
3824
3734
  let t = i[e], r = /* @__PURE__ */ new Map(), a = [], o = t.start.clone();
3825
3735
  for (let n = t.est; n <= t.lst; n++) {
3826
- let t = new K({
3736
+ let t = new q({
3827
3737
  name: _(`cum_u_${e}_${n}`),
3828
3738
  type: "Binary",
3829
3739
  lb: 0,
@@ -3832,10 +3742,10 @@ function st(t, n, r, o, s) {
3832
3742
  c.push(t), r.set(n, t), a.push([t, 1]), n !== 0 && o.addTerm(t, -n);
3833
3743
  }
3834
3744
  if (a.length === 0) {
3835
- L(n);
3745
+ R(n);
3836
3746
  return;
3837
3747
  }
3838
- v(new R(Q(a, 0), "==", 1, `${n}_cum_sos_${e}`), n), z(new R(o, "==", 0, `${n}_cum_start_${e}`), n), s.push(r);
3748
+ v(new z(Q(a, 0), "==", 1, `${n}_cum_sos_${e}`), n), B(new z(o, "==", 0, `${n}_cum_start_${e}`), n), s.push(r);
3839
3749
  }
3840
3750
  for (let a = e; a < t; a++) {
3841
3751
  let e = [], t = 0;
@@ -3850,7 +3760,7 @@ function st(t, n, r, o, s) {
3850
3760
  }
3851
3761
  }
3852
3762
  }
3853
- t > r.capacity && e.length > 0 && v(new R(Q(e, 0), "<=", r.capacity, `${n}_cum_t_${a}`), n);
3763
+ t > r.capacity && e.length > 0 && v(new z(Q(e, 0), "<=", r.capacity, `${n}_cum_t_${a}`), n);
3854
3764
  }
3855
3765
  return;
3856
3766
  }
@@ -3859,30 +3769,30 @@ function st(t, n, r, o, s) {
3859
3769
  let t = i[e], s = [];
3860
3770
  for (let r = 0; r < i.length; r++) {
3861
3771
  if (r === e) continue;
3862
- let o = i[r], l = new K({
3772
+ let o = i[r], l = new q({
3863
3773
  name: _(`cum_act_${r}_${e}`),
3864
3774
  type: "Binary",
3865
3775
  lb: 0,
3866
3776
  ub: 1
3867
3777
  });
3868
- c.push(l), O(l, new a("and", [new R(o.start.sub(t.start), "<=", 0, `${n}_act_le_${r}_${e}`), new R(t.start.sub(o.start), "<=", o.duration - 1, `${n}_act_ge_${r}_${e}`)]), n), s.push([l, o.demand]);
3778
+ c.push(l), O(l, new a("and", [new z(o.start.sub(t.start), "<=", 0, `${n}_act_le_${r}_${e}`), new z(t.start.sub(o.start), "<=", o.duration - 1, `${n}_act_ge_${r}_${e}`)]), n), s.push([l, o.demand]);
3869
3779
  }
3870
- let l = new R(Q(s, 0), ">=", r.capacity - t.demand + 1, `${n}_overload_${e}`);
3780
+ let l = new z(Q(s, 0), ">=", r.capacity - t.demand + 1, `${n}_overload_${e}`);
3871
3781
  o.push(new a("and", [l]));
3872
3782
  }
3873
- P(new a("or", o), n);
3783
+ F(new a("or", o), n);
3874
3784
  return;
3875
3785
  }
3876
3786
  case "allowed": {
3877
3787
  let e = r.vars.map((e) => x(e, n));
3878
3788
  if (r.tuples.length === 0) {
3879
- t && L(n);
3789
+ t && R(n);
3880
3790
  return;
3881
3791
  }
3882
3792
  if (t) {
3883
3793
  let t = [];
3884
3794
  for (let e = 0; e < r.tuples.length; e++) {
3885
- let n = new K({
3795
+ let n = new q({
3886
3796
  name: _(`tbl_r_${e}`),
3887
3797
  type: "Binary",
3888
3798
  lb: 0,
@@ -3890,14 +3800,14 @@ function st(t, n, r, o, s) {
3890
3800
  });
3891
3801
  c.push(n), t.push(n);
3892
3802
  }
3893
- v(new R(Q(t.map((e) => [e, 1]), 0), "==", 1, `${n}_tbl_sos`), n);
3803
+ v(new z(Q(t.map((e) => [e, 1]), 0), "==", 1, `${n}_tbl_sos`), n);
3894
3804
  for (let i = 0; i < e.length; i++) {
3895
3805
  let a = e[i].clone();
3896
3806
  for (let e = 0; e < r.tuples.length; e++) {
3897
3807
  let n = r.tuples[e][i];
3898
3808
  n !== 0 && a.addTerm(t[e], -n);
3899
3809
  }
3900
- z(new R(a, "==", 0, `${n}_tbl_col_${i}`), n);
3810
+ B(new z(a, "==", 0, `${n}_tbl_col_${i}`), n);
3901
3811
  }
3902
3812
  return;
3903
3813
  }
@@ -3930,50 +3840,50 @@ function st(t, n, r, o, s) {
3930
3840
  }
3931
3841
  if (!c) {
3932
3842
  if (s) {
3933
- let e = new G(/* @__PURE__ */ new Map(), 0);
3843
+ let e = new K(/* @__PURE__ */ new Map(), 0);
3934
3844
  for (let t = 0; t < o.length; t++) {
3935
3845
  let n = i[t];
3936
- o[t] === n.lo ? it(e, n.expr.sub(n.lo), 1) : it(e, Q([], n.hi).sub(n.expr), 1);
3846
+ o[t] === n.lo ? nt(e, n.expr.sub(n.lo), 1) : nt(e, Q([], n.hi).sub(n.expr), 1);
3937
3847
  }
3938
- z(new R(e, ">=", 1, `${n}_nogood_${t}`), n);
3939
- } else P(new a("or", o.map((r, i) => new R(e[i], "!=", r, `${n}_ntbl_${t}_${i}`))), n, `${n}_ntbl_${t}`);
3848
+ B(new z(e, ">=", 1, `${n}_nogood_${t}`), n);
3849
+ } else F(new a("or", o.map((r, i) => new z(e[i], "!=", r, `${n}_ntbl_${t}_${i}`))), n, `${n}_ntbl_${t}`);
3940
3850
  }
3941
3851
  }
3942
3852
  return;
3943
3853
  }
3944
3854
  }
3945
3855
  }
3946
- function A(e, t, n) {
3856
+ function j(e, t, n) {
3947
3857
  let r = t.spec;
3948
3858
  switch (r.kind) {
3949
3859
  case "distinct": {
3950
3860
  let t = r.args.map((e) => x(e, n));
3951
3861
  if (t.length <= 1) {
3952
- v(new R(Q([[e, 1]], 0), "==", 1, `${n}_distinct_triv`), n);
3862
+ v(new z(Q([[e, 1]], 0), "==", 1, `${n}_distinct_triv`), n);
3953
3863
  return;
3954
3864
  }
3955
3865
  let i = [];
3956
- for (let e = 0; e < t.length; e++) for (let r = e + 1; r < t.length; r++) i.push(new R(t[e].sub(t[r]), "!=", 0, `${n}_d_${e}_${r}`));
3866
+ for (let e = 0; e < t.length; e++) for (let r = e + 1; r < t.length; r++) i.push(new z(t[e].sub(t[r]), "!=", 0, `${n}_d_${e}_${r}`));
3957
3867
  O(e, new a("and", i), n);
3958
3868
  return;
3959
3869
  }
3960
3870
  case "disjoint": {
3961
3871
  let t = te(r.tasks, n);
3962
3872
  if (t.length === 0) {
3963
- v(new R(Q([[e, 1]], 0), "==", 1, `${n}_disjoint_triv`), n);
3873
+ v(new z(Q([[e, 1]], 0), "==", 1, `${n}_disjoint_triv`), n);
3964
3874
  return;
3965
3875
  }
3966
- O(e, new a("and", t.map(({ i: e, j: t, sI: r, dI: i, sJ: o, dJ: s }) => new a("or", [new R(r.sub(o), "<=", -i, `${n}_dj1_${e}_${t}`), new R(o.sub(r), "<=", -s, `${n}_dj2_${e}_${t}`)]))), n);
3876
+ O(e, new a("and", t.map(({ i: e, j: t, sI: r, dI: i, sJ: o, dJ: s }) => new a("or", [new z(r.sub(o), "<=", -i, `${n}_dj1_${e}_${t}`), new z(o.sub(r), "<=", -s, `${n}_dj2_${e}_${t}`)]))), n);
3967
3877
  return;
3968
3878
  }
3969
3879
  case "cumulative": {
3970
3880
  let t = k(r.tasks, r.capacity, n);
3971
3881
  if (t.kind === "empty_domain") {
3972
- L(n);
3882
+ R(n);
3973
3883
  return;
3974
3884
  }
3975
3885
  if (t.kind === "constant") {
3976
- v(new R(Q([[e, 1]], 0), "==", +!!t.value, `${n}_cum_triv`), n);
3886
+ v(new z(Q([[e, 1]], 0), "==", +!!t.value, `${n}_cum_triv`), n);
3977
3887
  return;
3978
3888
  }
3979
3889
  let { active: i } = t, o = [];
@@ -3981,15 +3891,15 @@ function st(t, n, r, o, s) {
3981
3891
  let t = i[e], s = [];
3982
3892
  for (let r = 0; r < i.length; r++) {
3983
3893
  if (r === e) continue;
3984
- let o = i[r], l = new K({
3894
+ let o = i[r], l = new q({
3985
3895
  name: _(`cum_eq_act_${r}_${e}`),
3986
3896
  type: "Binary",
3987
3897
  lb: 0,
3988
3898
  ub: 1
3989
3899
  });
3990
- c.push(l), O(l, new a("and", [new R(o.start.sub(t.start), "<=", 0, `${n}_eq_le_${r}_${e}`), new R(t.start.sub(o.start), "<=", o.duration - 1, `${n}_eq_ge_${r}_${e}`)]), n), s.push([l, o.demand]);
3900
+ c.push(l), O(l, new a("and", [new z(o.start.sub(t.start), "<=", 0, `${n}_eq_le_${r}_${e}`), new z(t.start.sub(o.start), "<=", o.duration - 1, `${n}_eq_ge_${r}_${e}`)]), n), s.push([l, o.demand]);
3991
3901
  }
3992
- o.push(new R(Q(s, 0), "<=", r.capacity - t.demand, `${n}_ev_${e}`));
3902
+ o.push(new z(Q(s, 0), "<=", r.capacity - t.demand, `${n}_ev_${e}`));
3993
3903
  }
3994
3904
  O(e, new a("and", o), n);
3995
3905
  return;
@@ -3997,19 +3907,19 @@ function st(t, n, r, o, s) {
3997
3907
  case "allowed": {
3998
3908
  let t = r.vars.map((e) => x(e, n));
3999
3909
  if (r.tuples.length === 0) {
4000
- v(new R(Q([[e, 1]], 0), "==", 0, `${n}_allowed_empty`), n);
3910
+ v(new z(Q([[e, 1]], 0), "==", 0, `${n}_allowed_empty`), n);
4001
3911
  return;
4002
3912
  }
4003
- O(e, new a("or", r.tuples.map((e, r) => new a("and", e.map((e, i) => new R(t[i], "==", e, `${n}_eq_tbl_${r}_${i}`))))), n);
3913
+ O(e, new a("or", r.tuples.map((e, r) => new a("and", e.map((e, i) => new z(t[i], "==", e, `${n}_eq_tbl_${r}_${i}`))))), n);
4004
3914
  return;
4005
3915
  }
4006
3916
  }
4007
3917
  }
4008
- function j(e) {
4009
- return e instanceof R || e instanceof a && e.children.some((e) => j(e));
3918
+ function M(e) {
3919
+ return e instanceof z || e instanceof a && e.children.some((e) => M(e));
4010
3920
  }
4011
- function M(e, t) {
4012
- if (e instanceof R) {
3921
+ function N(e, t) {
3922
+ if (e instanceof z) {
4013
3923
  if ((e.lhs.terms.get(t) ?? 0) !== 0) return !0;
4014
3924
  for (let n of e.lhs.nonlinearTerms) {
4015
3925
  if (n.coeff === 0) continue;
@@ -4018,62 +3928,62 @@ function st(t, n, r, o, s) {
4018
3928
  }
4019
3929
  return !1;
4020
3930
  }
4021
- return e instanceof a && e.children.some((e) => M(e, t));
3931
+ return e instanceof a && e.children.some((e) => N(e, t));
4022
3932
  }
4023
- function N(e, t, n, r) {
4024
- if (t instanceof R) {
4025
- re(e, E(t, n), 1, r, n);
3933
+ function P(e, t, n, r) {
3934
+ if (t instanceof z) {
3935
+ ne(e, E(t, n), 1, r, n);
4026
3936
  return;
4027
3937
  }
4028
3938
  if (t instanceof i || t instanceof d) {
4029
- v(new R(Q([[D(t, n), 1], [e, -1]], 0), ">=", 0, r), n);
3939
+ v(new z(Q([[D(t, n), 1], [e, -1]], 0), ">=", 0, r), n);
4030
3940
  return;
4031
3941
  }
4032
3942
  if (t instanceof a) {
4033
3943
  if (t.op === "and") {
4034
- for (let i = 0; i < t.children.length; i++) N(e, t.children[i], n, `${r}_and_${i}`);
3944
+ for (let i = 0; i < t.children.length; i++) P(e, t.children[i], n, `${r}_and_${i}`);
4035
3945
  return;
4036
3946
  }
4037
3947
  if (t.op === "not") {
4038
3948
  let i = t.children[0];
4039
- if (i instanceof R) {
4040
- V(e, E(i, n), 1, r, n);
3949
+ if (i instanceof z) {
3950
+ H(e, E(i, n), 1, r, n);
4041
3951
  return;
4042
3952
  }
4043
3953
  if (i instanceof a) {
4044
3954
  if (i.op === "not") {
4045
- N(e, i.children[0], n, r);
3955
+ P(e, i.children[0], n, r);
4046
3956
  return;
4047
3957
  }
4048
3958
  if (i.op === "or") {
4049
- for (let t = 0; t < i.children.length; t++) N(e, new a("not", [i.children[t]]), n, `${r}_not_or_${t}`);
3959
+ for (let t = 0; t < i.children.length; t++) P(e, new a("not", [i.children[t]]), n, `${r}_not_or_${t}`);
4050
3960
  return;
4051
3961
  }
4052
3962
  if (i.op === "and") {
4053
- N(e, new a("or", i.children.map((e) => new a("not", [e]))), n, r);
3963
+ P(e, new a("or", i.children.map((e) => new a("not", [e]))), n, r);
4054
3964
  return;
4055
3965
  }
4056
3966
  if (i.op === "implies") {
4057
- N(e, i.children[0], n, `${r}_not_imp_0`), N(e, new a("not", [i.children[1]]), n, `${r}_not_imp_1`);
3967
+ P(e, i.children[0], n, `${r}_not_imp_0`), P(e, new a("not", [i.children[1]]), n, `${r}_not_imp_1`);
4058
3968
  return;
4059
3969
  }
4060
3970
  }
4061
3971
  let o = D(i, n);
4062
- v(new R(Q([[e, 1], [o, 1]], 0), "<=", 1, r), n);
3972
+ v(new z(Q([[e, 1], [o, 1]], 0), "<=", 1, r), n);
4063
3973
  return;
4064
3974
  }
4065
3975
  if (t.op === "or") {
4066
3976
  if (t.children.length === 0) {
4067
- v(new R(Q([[e, 1]], 0), "<=", 0, r), n);
3977
+ v(new z(Q([[e, 1]], 0), "<=", 0, r), n);
4068
3978
  return;
4069
3979
  }
4070
3980
  if (t.children.length === 1) {
4071
- N(e, t.children[0], n, r);
3981
+ P(e, t.children[0], n, r);
4072
3982
  return;
4073
3983
  }
4074
- if (!t.children.some((e) => j(e))) {
3984
+ if (!t.children.some((e) => M(e))) {
4075
3985
  let i = t.children.map((e) => D(e, n));
4076
- v(new R(Q([[e, -1], ...i.map((e) => [e, 1])], 0), ">=", 0, r), n);
3986
+ v(new z(Q([[e, -1], ...i.map((e) => [e, 1])], 0), ">=", 0, r), n);
4077
3987
  return;
4078
3988
  }
4079
3989
  let a = [];
@@ -4081,119 +3991,119 @@ function st(t, n, r, o, s) {
4081
3991
  let o = t.children[e];
4082
3992
  if (o instanceof i) a.push(D(o, n));
4083
3993
  else {
4084
- let t = new K({
3994
+ let t = new q({
4085
3995
  name: _(`imp_or_${e}`),
4086
3996
  type: "Binary",
4087
3997
  lb: 0,
4088
3998
  ub: 1
4089
3999
  });
4090
- c.push(t), a.push(t), N(t, o, n, `${r}_or_${e}`);
4000
+ c.push(t), a.push(t), P(t, o, n, `${r}_or_${e}`);
4091
4001
  }
4092
4002
  }
4093
- v(new R(Q([[e, -1], ...a.map((e) => [e, 1])], 0), ">=", 0, r), n);
4003
+ v(new z(Q([[e, -1], ...a.map((e) => [e, 1])], 0), ">=", 0, r), n);
4094
4004
  return;
4095
4005
  }
4096
4006
  if (t.op === "implies") {
4097
4007
  let [a, o] = t.children, s;
4098
- if (a instanceof R) {
4008
+ if (a instanceof z) {
4099
4009
  let e = E(a, n);
4100
- s = new K({
4010
+ s = new q({
4101
4011
  name: _("ante"),
4102
4012
  type: "Binary",
4103
4013
  lb: 0,
4104
4014
  ub: 1
4105
- }), c.push(s), V(s, e, 0, `${r}_ante_neg`, n);
4015
+ }), c.push(s), H(s, e, 0, `${r}_ante_neg`, n);
4106
4016
  } else s = D(a, n);
4107
4017
  if (o instanceof i) {
4108
- v(new R(Q([
4018
+ v(new z(Q([
4109
4019
  [D(o, n), 1],
4110
4020
  [e, -1],
4111
4021
  [s, -1]
4112
4022
  ], 0), ">=", -1, r), n);
4113
4023
  return;
4114
4024
  }
4115
- let l = new K({
4025
+ let l = new q({
4116
4026
  name: _("imp_joint"),
4117
4027
  type: "Binary",
4118
4028
  lb: 0,
4119
4029
  ub: 1
4120
4030
  });
4121
- c.push(l), v(new R(Q([
4031
+ c.push(l), v(new z(Q([
4122
4032
  [l, 1],
4123
4033
  [e, -1],
4124
4034
  [s, -1]
4125
- ], 0), ">=", -1, `${r}_joint`), n), N(l, o, n, r);
4035
+ ], 0), ">=", -1, `${r}_joint`), n), P(l, o, n, r);
4126
4036
  return;
4127
4037
  }
4128
- v(new R(Q([[D(t, n), 1], [e, -1]], 0), ">=", 0, r), n);
4038
+ v(new z(Q([[D(t, n), 1], [e, -1]], 0), ">=", 0, r), n);
4129
4039
  return;
4130
4040
  }
4131
4041
  throw Error(`Unsupported logical element in implication consequent "${n}": ${t}`);
4132
4042
  }
4133
- function P(e, t, n = t) {
4134
- if (e instanceof R) {
4043
+ function F(e, t, n = t) {
4044
+ if (e instanceof z) {
4135
4045
  T(e.lhs, e.sense, e.rhs, n, t);
4136
4046
  return;
4137
4047
  }
4138
4048
  if (e instanceof d) {
4139
- ne(e, !0, t);
4049
+ A(e, !0, t);
4140
4050
  return;
4141
4051
  }
4142
4052
  if (e instanceof i) {
4143
- v(new R(Q([[D(e, t), 1]], 0), ">=", 1, n), t);
4053
+ v(new z(Q([[D(e, t), 1]], 0), ">=", 1, n), t);
4144
4054
  return;
4145
4055
  }
4146
4056
  if (e instanceof a) {
4147
4057
  if (e.op === "not") {
4148
4058
  let r = e.children[0];
4149
4059
  if (r instanceof i) {
4150
- v(new R(Q([[D(r, t), 1]], 0), "<=", 0, n), t);
4060
+ v(new z(Q([[D(r, t), 1]], 0), "<=", 0, n), t);
4151
4061
  return;
4152
4062
  }
4153
4063
  if (r instanceof d) {
4154
- ne(r, !1, t);
4064
+ A(r, !1, t);
4155
4065
  return;
4156
4066
  }
4157
- if (r instanceof R) {
4158
- B(E(r, t), t);
4067
+ if (r instanceof z) {
4068
+ V(E(r, t), t);
4159
4069
  return;
4160
4070
  }
4161
4071
  if (r instanceof a) {
4162
4072
  if (r.op === "not") {
4163
- P(r.children[0], t, n);
4073
+ F(r.children[0], t, n);
4164
4074
  return;
4165
4075
  }
4166
4076
  if (r.op === "or") {
4167
- for (let e = 0; e < r.children.length; e++) P(new a("not", [r.children[e]]), t, `${n}_not_or_${e}`);
4077
+ for (let e = 0; e < r.children.length; e++) F(new a("not", [r.children[e]]), t, `${n}_not_or_${e}`);
4168
4078
  return;
4169
4079
  }
4170
4080
  if (r.op === "and") {
4171
- P(new a("or", r.children.map((e) => new a("not", [e]))), t, n);
4081
+ F(new a("or", r.children.map((e) => new a("not", [e]))), t, n);
4172
4082
  return;
4173
4083
  }
4174
4084
  if (r.op === "implies") {
4175
- P(r.children[0], t, `${n}_not_imp_0`), P(new a("not", [r.children[1]]), t, `${n}_not_imp_1`);
4085
+ F(r.children[0], t, `${n}_not_imp_0`), F(new a("not", [r.children[1]]), t, `${n}_not_imp_1`);
4176
4086
  return;
4177
4087
  }
4178
4088
  }
4179
- v(new R(Q([[D(r, t), 1]], 0), "<=", 0, n), t);
4089
+ v(new z(Q([[D(r, t), 1]], 0), "<=", 0, n), t);
4180
4090
  return;
4181
4091
  }
4182
4092
  if (e.op === "and") {
4183
- for (let r = 0; r < e.children.length; r++) P(e.children[r], t, `${n}_and_${r}`);
4093
+ for (let r = 0; r < e.children.length; r++) F(e.children[r], t, `${n}_and_${r}`);
4184
4094
  return;
4185
4095
  }
4186
4096
  if (e.op === "or") {
4187
4097
  if (e.children.length === 0) {
4188
- L(t);
4098
+ R(t);
4189
4099
  return;
4190
4100
  }
4191
4101
  if (e.children.length === 1) {
4192
- P(e.children[0], t, n);
4102
+ F(e.children[0], t, n);
4193
4103
  return;
4194
4104
  }
4195
- if (!e.children.some((e) => j(e))) {
4196
- v(new R(Q(e.children.map((e) => D(e, t)).map((e) => [e, 1]), 0), ">=", 1, n), t);
4105
+ if (!e.children.some((e) => M(e))) {
4106
+ v(new z(Q(e.children.map((e) => D(e, t)).map((e) => [e, 1]), 0), ">=", 1, n), t);
4197
4107
  return;
4198
4108
  }
4199
4109
  let r = [];
@@ -4201,35 +4111,35 @@ function st(t, n, r, o, s) {
4201
4111
  let o = e.children[a];
4202
4112
  if (o instanceof i) r.push(D(o, t));
4203
4113
  else {
4204
- let e = new K({
4114
+ let e = new q({
4205
4115
  name: _(`or_branch_${a}`),
4206
4116
  type: "Binary",
4207
4117
  lb: 0,
4208
4118
  ub: 1
4209
4119
  });
4210
- c.push(e), r.push(e), N(e, o, t, `${n}_or_${a}`);
4120
+ c.push(e), r.push(e), P(e, o, t, `${n}_or_${a}`);
4211
4121
  }
4212
4122
  }
4213
- v(new R(Q(r.map((e) => [e, 1]), 0), ">=", 1, n), t);
4123
+ v(new z(Q(r.map((e) => [e, 1]), 0), ">=", 1, n), t);
4214
4124
  return;
4215
4125
  }
4216
4126
  if (e.op === "xor") {
4217
4127
  if (e.children.length === 0) {
4218
- L(t);
4128
+ R(t);
4219
4129
  return;
4220
4130
  }
4221
4131
  if (e.children.length === 1) {
4222
- P(e.children[0], t, n);
4132
+ F(e.children[0], t, n);
4223
4133
  return;
4224
4134
  }
4225
4135
  let r = e.children.map((e) => D(e, t));
4226
4136
  if (r.length === 2) {
4227
- v(new R(Q([[r[0], 1], [r[1], 1]], 0), "==", 1, n), t);
4137
+ v(new z(Q([[r[0], 1], [r[1], 1]], 0), "==", 1, n), t);
4228
4138
  return;
4229
4139
  }
4230
4140
  let i = r[0];
4231
4141
  for (let e = 1; e < r.length - 1; e++) {
4232
- let t = new K({
4142
+ let t = new q({
4233
4143
  name: _(`xor_fold_${e}`),
4234
4144
  type: "Binary",
4235
4145
  lb: 0,
@@ -4238,89 +4148,89 @@ function st(t, n, r, o, s) {
4238
4148
  c.push(t), ee(t, i, r[e], `${n}_xor_fold_${e}`), i = t;
4239
4149
  }
4240
4150
  let a = r[r.length - 1];
4241
- v(new R(Q([[i, 1], [a, 1]], 0), "==", 1, n), t);
4151
+ v(new z(Q([[i, 1], [a, 1]], 0), "==", 1, n), t);
4242
4152
  return;
4243
4153
  }
4244
4154
  if (e.op === "implies") {
4245
- let [r, o] = e.children, s = r instanceof R ? ct(r) : null;
4155
+ let [r, o] = e.children, s = r instanceof z ? ot(r) : null;
4246
4156
  if (s !== null) {
4247
- if (o instanceof R) {
4157
+ if (o instanceof z) {
4248
4158
  let e = E(o, t);
4249
4159
  if ((e.lhs.terms.get(s.binVar) ?? 0) === 0) {
4250
- re(s.binVar, e, s.activeVal, n, t);
4160
+ ne(s.binVar, e, s.activeVal, n, t);
4251
4161
  return;
4252
4162
  }
4253
4163
  }
4254
4164
  if (o instanceof i) {
4255
4165
  let e = D(o, t);
4256
- v(s.activeVal === 1 ? new R(Q([[e, 1], [s.binVar, -1]], 0), ">=", 0, n) : new R(Q([[e, 1], [s.binVar, 1]], 0), ">=", 1, n), t);
4166
+ v(s.activeVal === 1 ? new z(Q([[e, 1], [s.binVar, -1]], 0), ">=", 0, n) : new z(Q([[e, 1], [s.binVar, 1]], 0), ">=", 1, n), t);
4257
4167
  return;
4258
4168
  }
4259
4169
  if (o instanceof a && o.op === "not") {
4260
4170
  let e = o.children[0];
4261
4171
  if (e instanceof i) {
4262
4172
  let r = D(e, t);
4263
- v(s.activeVal === 1 ? new R(Q([[r, 1], [s.binVar, 1]], 0), "<=", 1, n) : new R(Q([[r, 1], [s.binVar, -1]], 0), "<=", 0, n), t);
4173
+ v(s.activeVal === 1 ? new z(Q([[r, 1], [s.binVar, 1]], 0), "<=", 1, n) : new z(Q([[r, 1], [s.binVar, -1]], 0), "<=", 0, n), t);
4264
4174
  return;
4265
4175
  }
4266
- if (e instanceof R) {
4176
+ if (e instanceof z) {
4267
4177
  let r = E(e, t);
4268
4178
  if ((r.lhs.terms.get(s.binVar) ?? 0) === 0) {
4269
- V(s.binVar, r, s.activeVal, n, t);
4179
+ H(s.binVar, r, s.activeVal, n, t);
4270
4180
  return;
4271
4181
  }
4272
4182
  }
4273
4183
  }
4274
- if (s.activeVal === 1 && !M(o, s.binVar)) {
4275
- N(s.binVar, o, t, n);
4184
+ if (s.activeVal === 1 && !N(o, s.binVar)) {
4185
+ P(s.binVar, o, t, n);
4276
4186
  return;
4277
4187
  }
4278
4188
  }
4279
4189
  let l;
4280
- if (r instanceof R) {
4190
+ if (r instanceof z) {
4281
4191
  let e = E(r, t);
4282
- l = new K({
4192
+ l = new q({
4283
4193
  name: _("ante"),
4284
4194
  type: "Binary",
4285
4195
  lb: 0,
4286
4196
  ub: 1
4287
- }), c.push(l), V(l, e, 0, `${n}_ante_neg`, t);
4197
+ }), c.push(l), H(l, e, 0, `${n}_ante_neg`, t);
4288
4198
  } else l = D(r, t);
4289
- N(l, o, t, n);
4199
+ P(l, o, t, n);
4290
4200
  return;
4291
4201
  }
4292
4202
  }
4293
4203
  throw Error(`Unsupported top-level logical constraint "${t}": ${e}`);
4294
4204
  }
4295
- function F(e, t, n, r, i, a, o) {
4296
- let s = rt(e, t, n, r, i, n === "<=" ? tt(t, r, a) : nt(t, r, a), a);
4297
- s.lhs.terms.size > 0 && v(new R(s.lhs, n, s.rhs, a), o);
4205
+ function I(e, t, n, r, i, a, o) {
4206
+ let s = tt(e, t, n, r, i, n === "<=" ? $e(t, r, a) : et(t, r, a), a);
4207
+ s.lhs.terms.size > 0 && v(new z(s.lhs, n, s.rhs, a), o);
4298
4208
  }
4299
- function I(e) {
4300
- return new R(e.lhs, "==", e.rhs, e.name);
4209
+ function L(e) {
4210
+ return new z(e.lhs, "==", e.rhs, e.name);
4301
4211
  }
4302
- function re(e, t, n, r, i) {
4212
+ function ne(e, t, n, r, i) {
4303
4213
  let a = E(t, i);
4304
4214
  if (a.sense === "!=") {
4305
- V(e, I(a), n, r, i);
4215
+ H(e, L(a), n, r, i);
4306
4216
  return;
4307
4217
  }
4308
4218
  let { lhs: o, sense: s, rhs: c } = a;
4309
- s === "==" ? (F(e, o, "<=", c, n, `${r}_le`, i), F(e, o, ">=", c, n, `${r}_ge`, i)) : F(e, o, s, c, n, r, i);
4219
+ s === "==" ? (I(e, o, "<=", c, n, `${r}_le`, i), I(e, o, ">=", c, n, `${r}_ge`, i)) : I(e, o, s, c, n, r, i);
4310
4220
  }
4311
- function L(e) {
4312
- let t = new K({
4221
+ function R(e) {
4222
+ let t = new q({
4313
4223
  name: _("unsat"),
4314
4224
  type: "Binary",
4315
4225
  lb: 0,
4316
4226
  ub: 1
4317
4227
  });
4318
- c.push(t), v(new R(Q([[t, 1]], 0), ">=", 2, e), e);
4228
+ c.push(t), v(new z(Q([[t, 1]], 0), ">=", 2, e), e);
4319
4229
  }
4320
- function z(e, t) {
4230
+ function B(e, t) {
4321
4231
  let n = E(e, t), { lhs: r, sense: i, rhs: a } = n;
4322
4232
  if (i === "!=") {
4323
- B(I(n), t);
4233
+ V(L(n), t);
4324
4234
  return;
4325
4235
  }
4326
4236
  let o = r.constant ?? 0, s = a - o;
@@ -4331,28 +4241,28 @@ function st(t, n, r, o, s) {
4331
4241
  i !== 0 && c.push([n, i]);
4332
4242
  }
4333
4243
  if (c.length === 0) {
4334
- (i === "<=" ? 0 <= s : i === ">=" ? 0 >= s : s === 0) || L(t);
4244
+ (i === "<=" ? 0 <= s : i === ">=" ? 0 >= s : s === 0) || R(t);
4335
4245
  return;
4336
4246
  }
4337
- v(new R(Q(c, 0), i, s, e.name || t), t);
4247
+ v(new z(Q(c, 0), i, s, e.name || t), t);
4338
4248
  }
4339
- function B(e, t) {
4249
+ function V(e, t) {
4340
4250
  let n = E(e, t);
4341
4251
  if (n.sense === "!=") {
4342
- z(I(n), t);
4252
+ B(L(n), t);
4343
4253
  return;
4344
4254
  }
4345
- let r = lt(n, t);
4255
+ let r = st(n, t);
4346
4256
  if (r.kind === "always_true") return;
4347
4257
  if (r.kind === "always_false") {
4348
- L(t);
4258
+ R(t);
4349
4259
  return;
4350
4260
  }
4351
4261
  if (r.kind === "single") {
4352
- v(new R(r.lhs, r.sense, r.rhs, n.name || t), t);
4262
+ v(new z(r.lhs, r.sense, r.rhs, n.name || t), t);
4353
4263
  return;
4354
4264
  }
4355
- let i = new K({
4265
+ let i = new q({
4356
4266
  name: _("neq_dir"),
4357
4267
  type: "Binary",
4358
4268
  lb: 0,
@@ -4360,43 +4270,43 @@ function st(t, n, r, o, s) {
4360
4270
  });
4361
4271
  c.push(i);
4362
4272
  let a = n.name || t;
4363
- F(i, r.lhs, "<=", r.ltRhs, 1, `${a}_lt`, t), F(i, r.lhs, ">=", r.gtRhs, 0, `${a}_gt`, t);
4273
+ I(i, r.lhs, "<=", r.ltRhs, 1, `${a}_lt`, t), I(i, r.lhs, ">=", r.gtRhs, 0, `${a}_gt`, t);
4364
4274
  }
4365
- function V(e, t, n, r, i) {
4275
+ function H(e, t, n, r, i) {
4366
4276
  let a = E(t, i);
4367
4277
  if (a.sense === "!=") {
4368
- re(e, I(a), n, r, i);
4278
+ ne(e, L(a), n, r, i);
4369
4279
  return;
4370
4280
  }
4371
- let o = lt(a, i);
4281
+ let o = st(a, i);
4372
4282
  if (o.kind === "always_true") return;
4373
4283
  if (o.kind === "always_false") {
4374
- v(new R(Q([[e, 1]], 0), n === 0 ? ">=" : "<=", +(n === 0), r), i);
4284
+ v(new z(Q([[e, 1]], 0), n === 0 ? ">=" : "<=", +(n === 0), r), i);
4375
4285
  return;
4376
4286
  }
4377
4287
  if (o.kind === "single") {
4378
- F(e, o.lhs, o.sense, o.rhs, n, r, i);
4288
+ I(e, o.lhs, o.sense, o.rhs, n, r, i);
4379
4289
  return;
4380
4290
  }
4381
- let s = new K({
4291
+ let s = new q({
4382
4292
  name: _("neq_lt"),
4383
4293
  type: "Binary",
4384
4294
  lb: 0,
4385
4295
  ub: 1
4386
- }), l = new K({
4296
+ }), l = new q({
4387
4297
  name: _("neq_gt"),
4388
4298
  type: "Binary",
4389
4299
  lb: 0,
4390
4300
  ub: 1
4391
4301
  });
4392
- c.push(s, l), F(s, o.lhs, "<=", o.ltRhs, 1, `${r}_lt`, i), F(l, o.lhs, ">=", o.gtRhs, 1, `${r}_gt`, i), v(new R(Q([
4302
+ c.push(s, l), I(s, o.lhs, "<=", o.ltRhs, 1, `${r}_lt`, i), I(l, o.lhs, ">=", o.gtRhs, 1, `${r}_gt`, i), v(new z(Q([
4393
4303
  [s, 1],
4394
4304
  [l, 1],
4395
4305
  [e, n === 0 ? 1 : -1]
4396
4306
  ], 0), ">=", +(n === 0), `${r}_disj`), i);
4397
4307
  }
4398
4308
  for (let e of m) T(e.lhs, e.sense, e.rhs, e.name, e.name);
4399
- let H;
4309
+ let U;
4400
4310
  if (s && s.expr.hasNonlinearTerms()) {
4401
4311
  let t = e(s.sense) === "Minimize", n = s.expr, r = new Map(n instanceof b ? n.linearTerms : n.terms), i = n.constant;
4402
4312
  for (let e of n.nonlinearTerms) {
@@ -4408,21 +4318,21 @@ function st(t, n, r, o, s) {
4408
4318
  i === 0 ? r.delete(t) : r.set(t, i);
4409
4319
  }
4410
4320
  }
4411
- H = n instanceof b ? new b(r, n.quadTerms, i, []) : new G(r, i, []);
4412
- } else s && (H = s.expr);
4321
+ U = n instanceof b ? new b(r, n.quadTerms, i, []) : new K(r, i, []);
4322
+ } else s && (U = s.expr);
4413
4323
  for (let e of o) {
4414
4324
  let t = e.name, n = e.expr;
4415
- P(n, t);
4325
+ F(n, t);
4416
4326
  }
4417
4327
  return {
4418
4328
  variables: c,
4419
4329
  constraints: l,
4420
4330
  boolVarToBinary: u,
4421
4331
  constraintToOriginalName: f,
4422
- ...H === void 0 ? {} : { objective: H }
4332
+ ...U === void 0 ? {} : { objective: U }
4423
4333
  };
4424
4334
  }
4425
- function ct(e) {
4335
+ function ot(e) {
4426
4336
  if (e.lhs.hasNonlinearTerms() || e.lhs.terms.size !== 1 || (e.lhs.constant ?? 0) !== 0) return null;
4427
4337
  let [[t, n]] = Array.from(e.lhs.terms.entries());
4428
4338
  return t.type !== "Binary" && t.type !== "Integer" || t.lb !== 0 || t.ub !== 1 || n !== 1 ? null : e.sense === "==" && e.rhs === 1 || e.sense === ">=" && e.rhs === 1 || e.sense === "!=" && e.rhs === 0 ? {
@@ -4433,7 +4343,7 @@ function ct(e) {
4433
4343
  activeVal: 0
4434
4344
  } : null;
4435
4345
  }
4436
- function lt(e, t) {
4346
+ function st(e, t) {
4437
4347
  let { lhs: n, sense: r, rhs: i } = e;
4438
4348
  if (n.hasNonlinearTerms()) throw Error(`Cannot negate unlowered nonlinear constraint "${e.name}" in "${t}".`);
4439
4349
  let a = n.constant ?? 0, o = i - a;
@@ -4493,7 +4403,7 @@ function lt(e, t) {
4493
4403
  }
4494
4404
  //#endregion
4495
4405
  //#region src/decomposition/column-generation.ts
4496
- async function ut(e) {
4406
+ async function ct(e) {
4497
4407
  let t = e.master;
4498
4408
  if (!t) throw Error("A master Model must be provided for solveColumnGeneration.");
4499
4409
  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;
@@ -4549,7 +4459,7 @@ async function ut(e) {
4549
4459
  let h = f;
4550
4460
  a && (m === "Optimal" || m === "Feasible") && (m = await t.solve(o, s), h = t.objectiveValue);
4551
4461
  let g = {};
4552
- for (let e of t.variables.values()) e instanceof K && e.value !== null && (g[e.name] = e.value);
4462
+ for (let e of t.variables.values()) e instanceof q && e.value !== null && (g[e.name] = e.value);
4553
4463
  let _ = {
4554
4464
  status: m,
4555
4465
  objectiveValue: h,
@@ -4564,50 +4474,50 @@ async function ut(e) {
4564
4474
  }
4565
4475
  //#endregion
4566
4476
  //#region src/modeler/objective.ts
4567
- function dt(e, t) {
4477
+ function lt(e, t) {
4568
4478
  let n = e;
4569
- if (n instanceof R || typeof n == "object" && n && "sense" in n && "lhs" in n && "rhs" in n) throw Error(`Cannot use a Constraint as an objective in ${t}(). Use m.constraint(expr\`... <= ...\`) for constraints, or supply an unconstrained arithmetic expression to ${t}(), e.g. m.objective(${t}(expr\`30 * \${x}\`)).`);
4479
+ if (n instanceof z || typeof n == "object" && n && "sense" in n && "lhs" in n && "rhs" in n) throw Error(`Cannot use a Constraint as an objective in ${t}(). Use m.constraint(expr\`... <= ...\`) for constraints, or supply an unconstrained arithmetic expression to ${t}(), e.g. m.objective(${t}(expr\`30 * \${x}\`)).`);
4570
4480
  if (typeof n == "string" && /(<=|>=|==|!=|=<|=>|<|>|=)/.test(n)) throw Error(`Cannot use a comparison constraint as an objective in ${t}(). Use m.constraint(expr\`... <= ...\`) for constraints, or supply an unconstrained arithmetic expression to ${t}(), e.g. m.objective(${t}(expr\`30 * \${x}\`)).`);
4571
4481
  if (typeof n == "number") {
4572
4482
  if (!Number.isFinite(n)) throw Error(`Invalid non-finite objective constant "${n}" passed to ${t}().`);
4573
4483
  return n;
4574
4484
  }
4575
- if (typeof n == "string" || n instanceof G || n instanceof b || n instanceof K || 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;
4485
+ if (typeof n == "string" || n instanceof K || n instanceof b || n instanceof q || 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;
4576
4486
  throw Error(`Invalid expression passed to ${t}(): expected a finite number, Var, LinExpr, QuadExpr, or arithmetic expression string.`);
4577
4487
  }
4578
- function ft(e) {
4488
+ function ut(e) {
4579
4489
  return {
4580
- expr: dt(e, "maximize"),
4490
+ expr: lt(e, "maximize"),
4581
4491
  sense: "Maximize"
4582
4492
  };
4583
4493
  }
4584
- function pt(e) {
4494
+ function dt(e) {
4585
4495
  return {
4586
- expr: dt(e, "minimize"),
4496
+ expr: lt(e, "minimize"),
4587
4497
  sense: "Minimize"
4588
4498
  };
4589
4499
  }
4590
4500
  //#endregion
4591
4501
  //#region src/decomposition/benders.ts
4592
- var mt = /* @__PURE__ */ new WeakSet();
4593
- function ht(e) {
4502
+ var ft = /* @__PURE__ */ new WeakSet();
4503
+ function pt(e) {
4594
4504
  return !!(e && typeof e == "object" && "constraints" in e && "variables" in e && typeof e.solve == "function");
4595
4505
  }
4596
- async function gt(e, t, n, r, i, a, o, s, c = 1) {
4506
+ async function mt(e, t, n, r, i, a, o, s, c = 1) {
4597
4507
  let l = [];
4598
4508
  for (let r = 0; r < t.length; r++) {
4599
4509
  let a = t[r], o = a.lhs, s = a.sense, u = a.rhs - (o.constant || 0), d = [], f = [], p = 0;
4600
4510
  for (let [e, t] of o.terms.entries()) {
4601
4511
  let r = n.variables.get(e.name);
4602
- if (e.ownerModel === n || r instanceof K) {
4512
+ if (e.ownerModel === n || r instanceof q) {
4603
4513
  f.push([e, t]);
4604
4514
  let n = i[e.name] ?? 0;
4605
4515
  p += t * n;
4606
4516
  } else d.push([e, t]);
4607
4517
  }
4608
- let m = u - p, h = new G();
4518
+ let m = u - p, h = new K();
4609
4519
  for (let [e, t] of d) h.addTerm(e, t);
4610
- let g = new R(h, s, m, `__benders_link_${c}_${r}`);
4520
+ let g = new z(h, s, m, `__benders_link_${c}_${r}`);
4611
4521
  e.constraint(g), l.push({
4612
4522
  origConstraint: a,
4613
4523
  subConstr: g,
@@ -4622,12 +4532,12 @@ async function gt(e, t, n, r, i, a, o, s, c = 1) {
4622
4532
  if (u !== "Optimal" && u !== "Feasible") throw Error(`Benders subproblem failed at iteration ${c} with status "${u}". Auto-cut generation requires an Optimal or Feasible subproblem (expected Optimal or Feasible).`);
4623
4533
  let d = e.objectiveValue;
4624
4534
  if (typeof d != "number" || !Number.isFinite(d)) throw Error(`Benders subproblem returned invalid objectiveValue (${String(d)}) at iteration ${c}.`);
4625
- if (mt.has(r) && d < r.lb - 1e-6) throw Error(`Benders auto-created "__benders_theta" (lb: ${r.lb}) cannot represent negative subproblem cost (${d}) at iteration ${c}. Define an explicit theta variable with a negative lower bound and pass options.theta.`);
4535
+ if (ft.has(r) && d < r.lb - 1e-6) throw Error(`Benders auto-created "__benders_theta" (lb: ${r.lb}) cannot represent negative subproblem cost (${d}) at iteration ${c}. Define an explicit theta variable with a negative lower bound and pass options.theta.`);
4626
4536
  let f = i[r.name] ?? 0, p = 1e-4;
4627
4537
  if (!(a ? f < d - p : f > d + p)) return null;
4628
4538
  let m = 0, h = /* @__PURE__ */ new Map(), g = new Set(l.map((e) => e.subConstr.name));
4629
4539
  for (let t of e.constraints.values()) {
4630
- if (!(t instanceof R) || g.has(t.name)) continue;
4540
+ if (!(t instanceof z) || g.has(t.name)) continue;
4631
4541
  let n = e.solution?.duals[t.name] ?? t.dual ?? 0;
4632
4542
  if (Math.abs(n) > 1e-12) {
4633
4543
  let e = t.rhs - (t.lhs.constant || 0);
@@ -4644,10 +4554,10 @@ async function gt(e, t, n, r, i, a, o, s, c = 1) {
4644
4554
  }
4645
4555
  }
4646
4556
  }
4647
- let _ = new G();
4557
+ let _ = new K();
4648
4558
  _.addTerm(r, 1);
4649
4559
  for (let [e, t] of h.entries()) Math.abs(t) > 1e-12 && _.addTerm(e, t);
4650
- let v = new R(_, a ? ">=" : "<=", m, `__benders_opt_cut_${c}`), y = (n.objectiveValue ?? 0) - f + d;
4560
+ let v = new z(_, a ? ">=" : "<=", m, `__benders_opt_cut_${c}`), y = (n.objectiveValue ?? 0) - f + d;
4651
4561
  return {
4652
4562
  kind: "optimality",
4653
4563
  constraint: v,
@@ -4655,19 +4565,19 @@ async function gt(e, t, n, r, i, a, o, s, c = 1) {
4655
4565
  subproblemObjective: y
4656
4566
  };
4657
4567
  }
4658
- async function _t(e) {
4568
+ async function ht(e) {
4659
4569
  let t = e.master;
4660
4570
  if (!t) throw Error("A master Model must be provided for solveBenders.");
4661
4571
  let { subproblem: n, maxIterations: r = 100, gapTolerance: i = 1e-4, solver: a, solverOptions: o, onIteration: s } = e, c;
4662
4572
  if (e.theta !== void 0) {
4663
4573
  if (typeof e.theta == "string") {
4664
4574
  let n = t.variables.get(e.theta);
4665
- if (!(n instanceof K)) throw Error(`Benders option "theta" references variable "${e.theta}", which was not found on the master model.`);
4575
+ if (!(n instanceof q)) throw Error(`Benders option "theta" references variable "${e.theta}", which was not found on the master model.`);
4666
4576
  c = n;
4667
4577
  } else c = e.theta;
4668
4578
  }
4669
4579
  if (!c) {
4670
- for (let e of t.variables.values()) if (e instanceof K && (e.name === "theta" || e.name === "__benders_theta")) {
4580
+ for (let e of t.variables.values()) if (e instanceof q && (e.name === "theta" || e.name === "__benders_theta")) {
4671
4581
  c = e;
4672
4582
  break;
4673
4583
  }
@@ -4680,7 +4590,7 @@ async function _t(e) {
4680
4590
  let _ = t.objectiveValue, v = t.sense.toLowerCase() === "minimize";
4681
4591
  v ? f = _ === null ? f : _ : p = _ === null ? p : _;
4682
4592
  let y = {};
4683
- for (let e of t.variables.values()) e instanceof K && e.value !== null && (y[e.name] = e.value);
4593
+ for (let e of t.variables.values()) e instanceof q && e.value !== null && (y[e.name] = e.value);
4684
4594
  let b = await n({
4685
4595
  iteration: e,
4686
4596
  masterValues: y,
@@ -4691,13 +4601,13 @@ async function _t(e) {
4691
4601
  master: t
4692
4602
  }), x = [];
4693
4603
  if (b) {
4694
- if (ht(b)) {
4604
+ if (pt(b)) {
4695
4605
  let n = b, r = n.linkingConstraints;
4696
4606
  if (!c) {
4697
4607
  if (!v) throw Error("Benders auto-cut generation requires an explicit options.theta variable for Maximize master models.");
4698
- c = t.continuous("__benders_theta", { lb: 0 }), t.objective(pt(t.objective().add(c))), mt.add(c);
4608
+ c = t.continuous("__benders_theta", { lb: 0 }), t.objective(dt(t.objective().add(c))), ft.add(c);
4699
4609
  }
4700
- let i = await gt(n, r, t, c, y, v, a, o, e);
4610
+ let i = await mt(n, r, t, c, y, v, a, o, e);
4701
4611
  i && x.push(i);
4702
4612
  } else Array.isArray(b) ? x.push(...b) : x.push(b);
4703
4613
  }
@@ -4730,7 +4640,7 @@ async function _t(e) {
4730
4640
  }
4731
4641
  let _ = d === "Optimal" || d === "Feasible", v = Object.keys(h).length > 0 ? h : _ ? (() => {
4732
4642
  let e = {};
4733
- for (let n of t.variables.values()) n instanceof K && n.value !== null && (e[n.name] = n.value);
4643
+ for (let n of t.variables.values()) n instanceof q && n.value !== null && (e[n.name] = n.value);
4734
4644
  return e;
4735
4645
  })() : {}, y = g === null ? _ ? t.objectiveValue : null : g, b = {
4736
4646
  status: d,
@@ -4747,39 +4657,39 @@ async function _t(e) {
4747
4657
  }
4748
4658
  //#endregion
4749
4659
  //#region src/modeler/model.ts
4750
- function vt(e, t) {
4751
- return e.hasNonlinearTerms() ? !0 : yt(t);
4660
+ function gt(e, t) {
4661
+ return e.hasNonlinearTerms() ? !0 : _t(t);
4752
4662
  }
4753
- function yt(e) {
4663
+ function _t(e) {
4754
4664
  for (let t of e) if (t.sense === "!=" || t.lhs.hasNonlinearTerms()) return !0;
4755
4665
  return !1;
4756
4666
  }
4757
- function bt(e) {
4667
+ function vt(e) {
4758
4668
  return e.type === "Integer" || e.type === "Binary";
4759
4669
  }
4760
- function xt(e) {
4670
+ function yt(e) {
4761
4671
  switch (e.kind) {
4762
- case "abs": return Ct(e.arg);
4672
+ case "abs": return xt(e.arg);
4763
4673
  case "max":
4764
- case "min": return e.args.length > 0 && e.args.every(Ct);
4765
- case "at": return e.array.length > 0 && e.array.every(Ct);
4674
+ case "min": return e.args.length > 0 && e.args.every(xt);
4675
+ case "at": return e.array.length > 0 && e.array.every(xt);
4766
4676
  }
4767
4677
  }
4768
- function St(e) {
4769
- for (let t of e) if (t.coeff !== 0 && (!Number.isInteger(t.coeff) || !xt(t.atom))) return !1;
4678
+ function bt(e) {
4679
+ for (let t of e) if (t.coeff !== 0 && (!Number.isInteger(t.coeff) || !yt(t.atom))) return !1;
4770
4680
  return !0;
4771
4681
  }
4772
- function Ct(e) {
4682
+ function xt(e) {
4773
4683
  if (!Number.isInteger(e.constant)) return !1;
4774
4684
  if (e instanceof b) {
4775
- for (let [t, n] of e.linearTerms) if (n !== 0 && (!bt(t) || !Number.isInteger(n))) return !1;
4776
- for (let t of e.quadTerms.values()) if (t.coeff !== 0 && (!bt(t.var1) || !bt(t.var2) || !Number.isInteger(t.coeff))) return !1;
4777
- return St(e.nonlinearTerms);
4685
+ for (let [t, n] of e.linearTerms) if (n !== 0 && (!vt(t) || !Number.isInteger(n))) return !1;
4686
+ for (let t of e.quadTerms.values()) if (t.coeff !== 0 && (!vt(t.var1) || !vt(t.var2) || !Number.isInteger(t.coeff))) return !1;
4687
+ return bt(e.nonlinearTerms);
4778
4688
  }
4779
- for (let [t, n] of e.terms) if (n !== 0 && (!bt(t) || !Number.isInteger(n))) return !1;
4780
- return St(e.nonlinearTerms);
4689
+ for (let [t, n] of e.terms) if (n !== 0 && (!vt(t) || !Number.isInteger(n))) return !1;
4690
+ return bt(e.nonlinearTerms);
4781
4691
  }
4782
- function wt(e) {
4692
+ function St(e) {
4783
4693
  let t = Object.freeze({
4784
4694
  get size() {
4785
4695
  return e.size;
@@ -4810,19 +4720,19 @@ function wt(e) {
4810
4720
  });
4811
4721
  return t;
4812
4722
  }
4813
- function Tt(e) {
4723
+ function Ct(e) {
4814
4724
  return Array.isArray(e) || typeof e == "object" && !!e && !(e instanceof String) && typeof e[Symbol.iterator] == "function";
4815
4725
  }
4816
4726
  function $(e) {
4817
4727
  return typeof e == "object" && !!e && !Array.isArray(e) && !(e instanceof String) && typeof e[Symbol.iterator] != "function";
4818
4728
  }
4819
- function Et(e) {
4820
- return e instanceof K || typeof e == "object" && !!e && !(e instanceof r) && !(e instanceof R) && "id" in e && "name" in e && "lb" in e && "ub" in e && !("terms" in e) && !("quadTerms" in e) && !("sense" in e);
4729
+ function wt(e) {
4730
+ return e instanceof q || typeof e == "object" && !!e && !(e instanceof r) && !(e instanceof z) && "id" in e && "name" in e && "lb" in e && "ub" in e && !("terms" in e) && !("quadTerms" in e) && !("sense" in e);
4821
4731
  }
4822
- function Dt(e, t) {
4732
+ function Tt(e, t) {
4823
4733
  if (!Number.isInteger(e) || e < 0) throw Error(`Invalid count (${e}) for ${t} variable creation: count must be a non-negative integer.`);
4824
4734
  }
4825
- var Ot = class {
4735
+ var Et = class {
4826
4736
  name;
4827
4737
  _sense;
4828
4738
  _objectiveExpr;
@@ -4869,7 +4779,7 @@ var Ot = class {
4869
4779
  r = typeof t == "string" ? {
4870
4780
  ...n,
4871
4781
  name: t
4872
- } : t, this.name = r.name || "OptimizationModel", this._sense = e(r.sense), this._objectiveExpr = new G(), this.variables = wt(this.allVarsMap), this.constraints = wt(this.allConstrsMap), this.values = wt(this._values), T(this, () => this.recordModelMutation()), r.solver && (this.solver = qe(r.solver));
4782
+ } : t, this.name = r.name || "OptimizationModel", this._sense = e(r.sense), this._objectiveExpr = new K(), this.variables = St(this.allVarsMap), this.constraints = St(this.allConstrsMap), this.values = St(this._values), T(this, () => this.recordModelMutation()), r.solver && (this.solver = qe(r.solver));
4873
4783
  }
4874
4784
  get sense() {
4875
4785
  return this._sense;
@@ -4935,9 +4845,9 @@ var Ot = class {
4935
4845
  }
4936
4846
  }
4937
4847
  createDomainVars(e, t, n, r) {
4938
- let i = e.toLowerCase(), a = typeof t == "number", o = typeof n == "number", s = Tt(t), c = Tt(n);
4848
+ let i = e.toLowerCase(), a = typeof t == "number", o = typeof n == "number", s = Ct(t), c = Ct(n);
4939
4849
  if (o || c) {
4940
- if (a && Dt(t, i), o && Dt(n, i), !a && !s || r !== void 0 && !$(r)) throw Error(`Invalid arguments provided for ${i} variable creation`);
4850
+ if (a && Tt(t, i), o && Tt(n, i), !a && !s || r !== void 0 && !$(r)) throw Error(`Invalid arguments provided for ${i} variable creation`);
4941
4851
  let c = a ? Array.from({ length: t }, (e, t) => t) : Array.from(t), l = o ? Array.from({ length: n }, (e, t) => t) : n === t ? c : Array.from(n), u = r || {}, d = u.prefix || u.name || "x";
4942
4852
  return this.runTransactionalBatch(() => {
4943
4853
  let t = a ? [] : {};
@@ -4972,7 +4882,7 @@ var Ot = class {
4972
4882
  }
4973
4883
  if (n !== void 0 && !$(n)) throw Error(`Invalid arguments provided for ${i} variable creation`);
4974
4884
  let l = n || {}, u = l.prefix || l.name;
4975
- if (typeof t == "number") return Dt(t, i), this.runTransactionalBatch(() => {
4885
+ if (typeof t == "number") return Tt(t, i), this.runTransactionalBatch(() => {
4976
4886
  let n = [], r = u || "x";
4977
4887
  for (let i = 0; i < t; i++) n.push(this.addVar({
4978
4888
  ...l,
@@ -4982,7 +4892,7 @@ var Ot = class {
4982
4892
  }));
4983
4893
  return n;
4984
4894
  });
4985
- if (Tt(t)) return this.runTransactionalBatch(() => {
4895
+ if (Ct(t)) return this.runTransactionalBatch(() => {
4986
4896
  let n = {};
4987
4897
  for (let r of t) {
4988
4898
  let t = u ? `${u}_${r}` : `${r}`;
@@ -5037,9 +4947,9 @@ var Ot = class {
5037
4947
  return n;
5038
4948
  }
5039
4949
  bool(e, t, n) {
5040
- let r = typeof e == "number", i = typeof t == "number", a = Tt(e), o = Tt(t);
4950
+ let r = typeof e == "number", i = typeof t == "number", a = Ct(e), o = Ct(t);
5041
4951
  if (i || o) {
5042
- if (r && Dt(e, "boolean"), i && Dt(t, "boolean"), !r && !a || n !== void 0 && !$(n)) throw Error("Invalid arguments provided for boolean variable creation");
4952
+ if (r && Tt(e, "boolean"), i && Tt(t, "boolean"), !r && !a || n !== void 0 && !$(n)) throw Error("Invalid arguments provided for boolean variable creation");
5043
4953
  let o = r ? Array.from({ length: e }, (e, t) => t) : Array.from(e), s = i ? Array.from({ length: t }, (e, t) => t) : t === e ? o : Array.from(t), c = n || {}, l = c.prefix || c.name || "p";
5044
4954
  return this.runTransactionalBatch(() => {
5045
4955
  let e = r ? [] : {};
@@ -5063,12 +4973,12 @@ var Ot = class {
5063
4973
  }
5064
4974
  if (t !== void 0 && !$(t)) throw Error("Invalid arguments provided for boolean variable creation");
5065
4975
  let s = t || {}, c = s.prefix || s.name;
5066
- if (typeof e == "number") return Dt(e, "boolean"), this.runTransactionalBatch(() => {
4976
+ if (typeof e == "number") return Tt(e, "boolean"), this.runTransactionalBatch(() => {
5067
4977
  let t = [], n = c || "p";
5068
4978
  for (let r = 0; r < e; r++) t.push(this.createBoolVar(void 0, n));
5069
4979
  return t;
5070
4980
  });
5071
- if (Tt(e)) return this.runTransactionalBatch(() => {
4981
+ if (Ct(e)) return this.runTransactionalBatch(() => {
5072
4982
  let t = {};
5073
4983
  for (let n of e) {
5074
4984
  let e = c ? `${c}_${n}` : `${n}`;
@@ -5118,12 +5028,12 @@ var Ot = class {
5118
5028
  let t = e || {}, n = typeof t.name == "string" ? t.name.trim() : void 0, r = n && n.length > 0 ? n : void 0, i = typeof t.prefix == "string" ? t.prefix.trim() : "", a = i.length > 0 ? i : "x", o = this.varPrefixCounters.get(a), s = r ?? this.getNextVarName(a);
5119
5029
  try {
5120
5030
  if (this.hasVarName(s)) throw Error(`Variable with name '${s}' already exists in model`);
5121
- let e = new K({
5031
+ let e = new q({
5122
5032
  ...t,
5123
5033
  name: s,
5124
5034
  prefix: a
5125
5035
  });
5126
- return e.hasExplicitName = r !== void 0, A(e), ee(e, this), e.ownerModel = this, this._variables.push(e), this.varMapByName.set(e.name, e), this.allVarsMap.set(e.name, e), this.recordModelMutation(), e;
5036
+ return e.hasExplicitName = r !== void 0, j(e), ee(e, this), e.ownerModel = this, this._variables.push(e), this.varMapByName.set(e.name, e), this.allVarsMap.set(e.name, e), this.recordModelMutation(), e;
5127
5037
  } catch (e) {
5128
5038
  throw r === void 0 && (o === void 0 ? this.varPrefixCounters.delete(a) : this.varPrefixCounters.set(a, o)), e;
5129
5039
  }
@@ -5131,26 +5041,26 @@ var Ot = class {
5131
5041
  objective(e) {
5132
5042
  if (arguments.length === 0) return this._objectiveExpr.clone();
5133
5043
  let t = e;
5134
- if (t instanceof R || typeof t == "object" && t && "sense" in t && "lhs" in t && "rhs" in t || typeof t == "string" && /(<=|>=|==|!=|=<|=>|<|>|=)/.test(t)) throw Error("Cannot use a Constraint as an objective. Did you mean to use m.constraint(expr`... <= ...`)? To set an objective, wrap an unconstrained expression with maximize(...) or minimize(...), e.g. m.objective(maximize(expr`30 * ${x}`)).");
5044
+ if (t instanceof z || 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}`)).");
5135
5045
  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}`)).");
5136
5046
  return this.applyObjective(t.expr, t.sense), this;
5137
5047
  }
5138
5048
  applyObjective(t, n) {
5139
- if (t instanceof R || typeof t == "object" && t && "sense" in t && "lhs" in t && "rhs" in t || typeof t == "string" && /(<=|>=|==|!=|=<|=>|<|>|=)/.test(t)) throw Error(typeof t == "string" ? "Cannot use a comparison constraint as an objective. Did you mean to use m.constraint(expr`... <= ...`)? To set an objective, wrap an unconstrained expression with maximize(...) or minimize(...), e.g. m.objective(maximize(expr`30 * ${x}`))." : "Cannot use a Constraint as an objective. Did you mean to use m.constraint(expr`... <= ...`)? To set an objective, wrap an unconstrained expression with maximize(...) or minimize(...), e.g. m.objective(maximize(expr`30 * ${x}`)).");
5049
+ if (t instanceof z || typeof t == "object" && t && "sense" in t && "lhs" in t && "rhs" in t || typeof t == "string" && /(<=|>=|==|!=|=<|=>|<|>|=)/.test(t)) throw Error(typeof t == "string" ? "Cannot use a comparison constraint as an objective. Did you mean to use m.constraint(expr`... <= ...`)? To set an objective, wrap an unconstrained expression with maximize(...) or minimize(...), e.g. m.objective(maximize(expr`30 * ${x}`))." : "Cannot use a Constraint as an objective. Did you mean to use m.constraint(expr`... <= ...`)? To set an objective, wrap an unconstrained expression with maximize(...) or minimize(...), e.g. m.objective(maximize(expr`30 * ${x}`)).");
5140
5050
  let r = n === void 0 ? this.sense : e(n), i;
5141
5051
  if (typeof t == "string") i = ke(t, (e) => this.varMapByName.get(e));
5142
- else if (typeof t == "number") i = new G(/* @__PURE__ */ new Map(), t);
5052
+ else if (typeof t == "number") i = new K(/* @__PURE__ */ new Map(), t);
5143
5053
  else if (t instanceof b) i = t.clone();
5144
- else if (t instanceof G) i = t.clone();
5054
+ else if (t instanceof K) i = t.clone();
5145
5055
  else if (typeof t == "object" && t && "quadTerms" in t && t.quadTerms instanceof Map && "linearTerms" in t && t.linearTerms instanceof Map && typeof t.constant == "number") {
5146
5056
  let e = t;
5147
5057
  i = new b(e.linearTerms, e.quadTerms, e.constant, e.nonlinearTerms);
5148
5058
  } else if (typeof t == "object" && t && "terms" in t && t.terms instanceof Map && typeof t.constant == "number") {
5149
5059
  let e = t;
5150
- i = new G(e.terms, e.constant, e.nonlinearTerms);
5151
- } else if (t instanceof K || typeof t == "object" && t && "id" in t && "name" in t && "lb" in t && "ub" in t) i = new G(/* @__PURE__ */ new Map([[t, 1]]), 0);
5060
+ i = new K(e.terms, e.constant, e.nonlinearTerms);
5061
+ } else if (t instanceof q || typeof t == "object" && t && "id" in t && "name" in t && "lb" in t && "ub" in t) i = new K(/* @__PURE__ */ new Map([[t, 1]]), 0);
5152
5062
  else throw Error("Invalid objective expression: expected a finite number, Var, LinExpr, QuadExpr, or arithmetic expression string.");
5153
- P(i, this.name, (e) => this.varMapByName.get(e.name) === e), this._sense = r, this._objectiveExpr = i, this.recordModelMutation();
5063
+ F(i, this.name, (e) => this.varMapByName.get(e.name) === e), this._sense = r, this._objectiveExpr = i, this.recordModelMutation();
5154
5064
  }
5155
5065
  constraint(e, t) {
5156
5066
  if (Array.isArray(e)) return this.runTransactionalBatch(() => {
@@ -5159,14 +5069,14 @@ var Ot = class {
5159
5069
  return t;
5160
5070
  });
5161
5071
  if (e instanceof b || typeof e == "object" && e && "quadTerms" in e) throw Error("Constraint must contain a comparison operator (<=, >=, ==): cannot add a quadratic expression as a constraint.");
5162
- if (e instanceof G || typeof e == "object" && e && "terms" in e) throw Error("Constraint must contain a comparison operator (<=, >=, ==): cannot add a linear expression without a comparison operator. Use expr`... <= ...` or .le(), .ge(), .eq().");
5163
- if (Et(e)) throw Error(`Cannot add numeric variable "${e.name}" directly as a constraint without a comparison operator (<=, >=, ==). Numeric variables require a comparison such as expr\`\${x} <= 10\` or x.le(10), whereas propositional BoolVar variables must be created with m.bool().`);
5072
+ if (e instanceof K || 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().");
5073
+ if (wt(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().`);
5164
5074
  return this.addConstraint(e, t);
5165
5075
  }
5166
5076
  addConstraint(e, t) {
5167
5077
  if (e instanceof b || typeof e == "object" && e && "quadTerms" in e) throw Error("Constraint must contain a comparison operator (<=, >=, ==): cannot add a quadratic expression as a constraint.");
5168
- if (e instanceof G || typeof e == "object" && e && "terms" in e) throw Error("Constraint must contain a comparison operator (<=, >=, ==): cannot add a linear expression without a comparison operator. Use expr`... <= ...` or .le(), .ge(), .eq().");
5169
- if (Et(e)) throw Error(`Cannot add numeric variable "${e.name}" directly as a constraint without a comparison operator (<=, >=, ==). Numeric variables require a comparison such as expr\`\${x} <= 10\` or x.le(10), whereas propositional BoolVar variables must be created with m.bool().`);
5078
+ if (e instanceof K || 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().");
5079
+ if (wt(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().`);
5170
5080
  if (e instanceof r) {
5171
5081
  let n = typeof t == "string" && t.trim().length > 0 ? t.trim() : void 0;
5172
5082
  if (n !== void 0) {
@@ -5175,7 +5085,7 @@ var Ot = class {
5175
5085
  }
5176
5086
  let r = this.logicalConstrCounter, i = n ?? this.getNextLogicalConstrName();
5177
5087
  try {
5178
- I(e, i, this.name, (e) => this.varMapByName.get(e.name) === e, (e) => this.boolVarMapByName.get(e.name) === e, this);
5088
+ L(e, i, this.name, (e) => this.varMapByName.get(e.name) === e, (e) => this.boolVarMapByName.get(e.name) === e, this);
5179
5089
  } catch (e) {
5180
5090
  throw n === void 0 && (this.logicalConstrCounter = r), e;
5181
5091
  }
@@ -5191,7 +5101,7 @@ var Ot = class {
5191
5101
  }
5192
5102
  let n = typeof e == "string" ? Me(e, (e) => this.varMapByName.get(e), t) : e;
5193
5103
  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.");
5194
- n.ownerModel && n.ownerModel !== this && (F(n, this.name, (e) => this.varMapByName.get(e.name) === e, n.name), O(n, this));
5104
+ n.ownerModel && n.ownerModel !== this && (I(n, this.name, (e) => this.varMapByName.get(e.name) === e, n.name), O(n, this));
5195
5105
  let i = typeof t == "string" && t.trim().length > 0 ? t.trim() : n.hasExplicitName ? n.name.trim() : void 0;
5196
5106
  if (i !== void 0) {
5197
5107
  if (this.hasConstraintName(i)) throw Error(`Constraint with name '${i}' already exists in model`);
@@ -5199,7 +5109,7 @@ var Ot = class {
5199
5109
  }
5200
5110
  let a = this.constrPrefixCounters.get("c"), o = i ?? this.getNextConstrName("c"), s;
5201
5111
  try {
5202
- F(n, this.name, (e) => this.varMapByName.get(e.name) === e, o), s = O(n, this);
5112
+ I(n, this.name, (e) => this.varMapByName.get(e.name) === e, o), s = O(n, this);
5203
5113
  } catch (e) {
5204
5114
  throw i === void 0 && (a === void 0 ? this.constrPrefixCounters.delete("c") : this.constrPrefixCounters.set("c", a)), e;
5205
5115
  }
@@ -5210,7 +5120,7 @@ var Ot = class {
5210
5120
  }
5211
5121
  indicator(e, t, n = {}) {
5212
5122
  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.");
5213
- if (!(e instanceof K)) 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).");
5123
+ if (!(e instanceof q)) 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).");
5214
5124
  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]).`);
5215
5125
  if (t instanceof b || 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).");
5216
5126
  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.");
@@ -5231,11 +5141,11 @@ var Ot = class {
5231
5141
  try {
5232
5142
  if ((l === "<=" || l === "==") && (this.hasConstraintName(f) || this.hasBoolVarName(f))) throw Error(this.hasBoolVarName(f) ? `Constraint name '${f}' conflicts with an existing Boolean variable in model` : `Constraint with name '${f}' already exists in model`);
5233
5143
  if ((l === ">=" || l === "==") && (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`);
5234
- n.M !== void 0 && $e(n.M, d);
5144
+ n.M !== void 0 && Ze(n.M, d);
5235
5145
  let t = (e) => this.varMapByName.get(e.name) === e;
5236
5146
  for (let [e] of c.terms) if (!t(e)) throw Error(`Variable "${e.name}" in constraint "${d}" does not belong to model "${this.name}". All variables must belong to the model by object identity.`);
5237
5147
  if (l === "<=" || l === "==") {
5238
- let t = n.M === void 0 ? tt(c, u, f) : n.M, r = rt(e, c, "<=", u, a, t, f), i = new R(r.lhs, "<=", r.rhs, f);
5148
+ let t = n.M === void 0 ? $e(c, u, f) : n.M, r = tt(e, c, "<=", u, a, t, f), i = new z(r.lhs, "<=", r.rhs, f);
5239
5149
  n.M === void 0 && i._setIndicatorOrigin({
5240
5150
  binVar: e,
5241
5151
  activeValue: a,
@@ -5246,7 +5156,7 @@ var Ot = class {
5246
5156
  }), m.push([i, f]);
5247
5157
  }
5248
5158
  if (l === ">=" || l === "==") {
5249
- let t = n.M === void 0 ? nt(c, u, p) : n.M, r = rt(e, c, ">=", u, a, t, p), i = new R(r.lhs, ">=", r.rhs, p);
5159
+ let t = n.M === void 0 ? et(c, u, p) : n.M, r = tt(e, c, ">=", u, a, t, p), i = new z(r.lhs, ">=", r.rhs, p);
5250
5160
  n.M === void 0 && i._setIndicatorOrigin({
5251
5161
  binVar: e,
5252
5162
  activeValue: a,
@@ -5256,15 +5166,15 @@ var Ot = class {
5256
5166
  derivedM: t
5257
5167
  }), m.push([i, p]);
5258
5168
  }
5259
- for (let [e, n] of m) F(e, this.name, t, n);
5169
+ for (let [e, n] of m) I(e, this.name, t, n);
5260
5170
  } catch (e) {
5261
5171
  throw s === void 0 ? this.constrPrefixCounters.delete("c") : this.constrPrefixCounters.set("c", s), e;
5262
5172
  }
5263
5173
  return this.runTransactionalBatch(() => m.map(([e, t]) => this.addConstraint(e, t)));
5264
5174
  }
5265
5175
  toLpString() {
5266
- if (this.validateIntegrityInternal(), vt(this._objectiveExpr, this._constraints)) {
5267
- let e = st(this._variables, [], this._constraints, [], {
5176
+ if (this.validateIntegrityInternal(), gt(this._objectiveExpr, this._constraints)) {
5177
+ let e = at(this._variables, [], this._constraints, [], {
5268
5178
  expr: this._objectiveExpr,
5269
5179
  sense: this.sense
5270
5180
  }), { lpString: t } = Be({
@@ -5286,7 +5196,7 @@ var Ot = class {
5286
5196
  return e;
5287
5197
  }
5288
5198
  validateIntegrityInternal() {
5289
- re({
5199
+ ne({
5290
5200
  model: this,
5291
5201
  name: this.name,
5292
5202
  variables: this._variables,
@@ -5332,10 +5242,10 @@ var Ot = class {
5332
5242
  return t !== "Infeasible" && t !== "Unsat" && t !== "Unbounded" && t !== "Error" && t !== "NotSolved" && n !== "Infeasible" && n !== "Unsat" && n !== "Unbounded" && n !== "InfeasibleOrUnbounded" && n !== "Error" && n !== "NotSolved" && (t === "Optimal" || t === "Feasible" || t === "Sat" || n === "Optimal" || n === "Feasible" || n === "Sat" || typeof e.objectiveValue == "number" && Number.isFinite(e.objectiveValue) || Object.values(r).some((e) => typeof e == "number" && Number.isFinite(e) || typeof e == "boolean") || Object.values(i).some((e) => typeof e == "boolean"));
5333
5243
  }
5334
5244
  normalizePrimalValue(e, t, n, r) {
5335
- return (r.relax ?? n.options?.relax) !== !0 && bt(e) && Math.abs(t - Math.round(t)) <= 1e-5 ? Math.round(t) + 0 : t;
5245
+ return (r.relax ?? n.options?.relax) !== !0 && vt(e) && Math.abs(t - Math.round(t)) <= 1e-5 ? Math.round(t) + 0 : t;
5336
5246
  }
5337
5247
  normalizeObjectiveValue(e, t, n) {
5338
- if ((n.relax ?? t.options?.relax) !== !0 && Ct(this._objectiveExpr)) {
5248
+ if ((n.relax ?? t.options?.relax) !== !0 && xt(this._objectiveExpr)) {
5339
5249
  let t = Math.round(e);
5340
5250
  if (Number.isSafeInteger(t) && Math.abs(e - t) <= 1e-5) return t + 0;
5341
5251
  }
@@ -5388,7 +5298,7 @@ var Ot = class {
5388
5298
  let { activeSolver: i, activeOptions: a } = this.resolveSolverAndOptions(e, t);
5389
5299
  if (this._objectiveExpr instanceof b && 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.`);
5390
5300
  let o, s = null;
5391
- if (i.capabilities?.supportsLogicalConstraints !== !0 && i.capabilities?.supportsSMT !== !0 && (this._logicalConstraints.length > 0 || this._boolVars.length > 0 || vt(this._objectiveExpr, this._constraints)) ? (s = st(this._variables, this._boolVars, this._constraints, this._logicalConstraints, {
5301
+ if (i.capabilities?.supportsLogicalConstraints !== !0 && i.capabilities?.supportsSMT !== !0 && (this._logicalConstraints.length > 0 || this._boolVars.length > 0 || gt(this._objectiveExpr, this._constraints)) ? (s = at(this._variables, this._boolVars, this._constraints, this._logicalConstraints, {
5392
5302
  expr: this._objectiveExpr,
5393
5303
  sense: this.sense
5394
5304
  }), o = {
@@ -5417,7 +5327,7 @@ var Ot = class {
5417
5327
  this.ensureExecutionValid(r, n, "solve"), this.runTime = l.runTime ?? 0, this.status = l.status, this.terminationStatus = l.terminationStatus ?? l.status;
5418
5328
  let u = this.hasPrimalFromResult(l);
5419
5329
  this.hasPrimalSolution = u;
5420
- let d = (a.relax ?? i.options?.relax) !== !0 && Ct(this._objectiveExpr), f = u && typeof l.objectiveValue == "number" && Number.isFinite(l.objectiveValue) ? l.objectiveValue : null;
5330
+ let d = (a.relax ?? i.options?.relax) !== !0 && xt(this._objectiveExpr), f = u && typeof l.objectiveValue == "number" && Number.isFinite(l.objectiveValue) ? l.objectiveValue : null;
5421
5331
  this.objectiveValue = f === null ? null : this.normalizeObjectiveValue(f, i, a);
5422
5332
  let p = typeof l.objectiveBound == "number" && Number.isFinite(l.objectiveBound) ? l.objectiveBound : void 0;
5423
5333
  this.objectiveBound = d && this.status === "Optimal" && this.objectiveValue !== null && p !== void 0 && Math.abs(p - this.objectiveValue) <= 1e-5 ? this.objectiveValue : p;
@@ -5540,7 +5450,7 @@ var Ot = class {
5540
5450
  runTime: this.runTime
5541
5451
  };
5542
5452
  }
5543
- let l = this._logicalConstraints.length > 0 || this._boolVars.length > 0 || yt(this._constraints) ? st(this._variables, this._boolVars, this._constraints, this._logicalConstraints) : {
5453
+ let l = this._logicalConstraints.length > 0 || this._boolVars.length > 0 || _t(this._constraints) ? at(this._variables, this._boolVars, this._constraints, this._logicalConstraints) : {
5544
5454
  variables: [...this._variables],
5545
5455
  constraints: [...this._constraints],
5546
5456
  boolVarToBinary: /* @__PURE__ */ new Map(),
@@ -5549,46 +5459,46 @@ var Ot = class {
5549
5459
  for (let e of l.constraints) {
5550
5460
  let t = l.constraintToOriginalName.get(e) ?? e.name, { lhs: n, sense: r, rhs: i } = e;
5551
5461
  if (r === "<=") {
5552
- let r = new K({
5462
+ let r = new q({
5553
5463
  name: `__slack_${++m}`,
5554
5464
  type: "Continuous",
5555
5465
  lb: 0,
5556
5466
  ub: Infinity
5557
5467
  });
5558
5468
  d.push(r), f.push([r, 1]), p.set(r, t);
5559
- let a = n.clone().add(new G(/* @__PURE__ */ new Map([[r, -1]]), 0));
5560
- u.push(new R(a, "<=", i, `${e.name}_slack`));
5469
+ let a = n.clone().add(new K(/* @__PURE__ */ new Map([[r, -1]]), 0));
5470
+ u.push(new z(a, "<=", i, `${e.name}_slack`));
5561
5471
  } else if (r === ">=") {
5562
- let r = new K({
5472
+ let r = new q({
5563
5473
  name: `__slack_${++m}`,
5564
5474
  type: "Continuous",
5565
5475
  lb: 0,
5566
5476
  ub: Infinity
5567
5477
  });
5568
5478
  d.push(r), f.push([r, 1]), p.set(r, t);
5569
- let a = n.clone().add(new G(/* @__PURE__ */ new Map([[r, 1]]), 0));
5570
- u.push(new R(a, ">=", i, `${e.name}_slack`));
5479
+ let a = n.clone().add(new K(/* @__PURE__ */ new Map([[r, 1]]), 0));
5480
+ u.push(new z(a, ">=", i, `${e.name}_slack`));
5571
5481
  } else {
5572
- let r = new K({
5482
+ let r = new q({
5573
5483
  name: `__slack_${++m}_p`,
5574
5484
  type: "Continuous",
5575
5485
  lb: 0,
5576
5486
  ub: Infinity
5577
- }), a = new K({
5487
+ }), a = new q({
5578
5488
  name: `__slack_${++m}_n`,
5579
5489
  type: "Continuous",
5580
5490
  lb: 0,
5581
5491
  ub: Infinity
5582
5492
  });
5583
5493
  d.push(r, a), f.push([r, 1], [a, 1]), p.set(r, t), p.set(a, t);
5584
- let o = n.clone().add(new G(/* @__PURE__ */ new Map([[r, -1], [a, 1]]), 0));
5585
- u.push(new R(o, "==", i, `${e.name}_slack`));
5494
+ let o = n.clone().add(new K(/* @__PURE__ */ new Map([[r, -1], [a, 1]]), 0));
5495
+ u.push(new z(o, "==", i, `${e.name}_slack`));
5586
5496
  }
5587
5497
  }
5588
5498
  let h = {
5589
5499
  name: `${this.name}_elastic_check`,
5590
5500
  sense: "Minimize",
5591
- objective: new G(new Map(f), 0),
5501
+ objective: new K(new Map(f), 0),
5592
5502
  constraints: u,
5593
5503
  variables: [...l.variables, ...d]
5594
5504
  }, g;
@@ -5631,11 +5541,11 @@ var Ot = class {
5631
5541
  };
5632
5542
  }
5633
5543
  verify(e = {}) {
5634
- return Qe(this, e);
5544
+ return Xe(this, e);
5635
5545
  }
5636
5546
  link(e) {
5637
5547
  if (e instanceof b || typeof e == "object" && e && "quadTerms" in e) throw Error("Linking constraint cannot be a quadratic expression.");
5638
- if (!(e instanceof R) && (typeof e != "object" || !e || !("sense" in e) || !("lhs" in e) || !("rhs" in e))) throw Error("Linking constraint must contain a comparison operator (<=, >=, ==). Use expr`... <= ...` or .le(), .ge(), .eq().");
5548
+ if (!(e instanceof z) && (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().");
5639
5549
  this._linkingConstraints ||= [];
5640
5550
  let t = e;
5641
5551
  return this._linkingConstraints.push(t), t;
@@ -5644,19 +5554,104 @@ var Ot = class {
5644
5554
  return this._linkingConstraints ?? [];
5645
5555
  }
5646
5556
  async solveBenders(e) {
5647
- let t = await _t({
5557
+ let t = await ht({
5648
5558
  master: this,
5649
5559
  ...e
5650
5560
  });
5651
5561
  return this.decomposition = t, t;
5652
5562
  }
5653
5563
  async solveColumnGeneration(e) {
5654
- let t = await ut({
5564
+ let t = await ct({
5655
5565
  master: this,
5656
5566
  ...e
5657
5567
  });
5658
5568
  return this.decomposition = t, t;
5659
5569
  }
5570
+ }, Dt = class {
5571
+ name;
5572
+ capabilities;
5573
+ options;
5574
+ constructor(e = {}) {
5575
+ this.name = e.name || "MockSolver", this.capabilities = e.capabilities || {
5576
+ supportsMIP: !0,
5577
+ supportsQP: !0,
5578
+ supportsWarmStart: !0
5579
+ }, this.options = e;
5580
+ }
5581
+ async solve(e, t = {}, n = {}) {
5582
+ let r = Le(t) ? n : t, i = {
5583
+ ...this.options,
5584
+ ...r
5585
+ }, a = !!(i.values && Object.keys(i.values).length > 0 || i.boolValues && Object.keys(i.boolValues).length > 0);
5586
+ if (i.signal?.aborted) return {
5587
+ status: "Unknown",
5588
+ terminationStatus: "Interrupted",
5589
+ hasPrimalSolution: !1,
5590
+ objectiveValue: null,
5591
+ values: {},
5592
+ runTime: 0,
5593
+ raw: { mock: !0 }
5594
+ };
5595
+ if (i.delayMs && i.delayMs > 0 && (await new Promise((e) => {
5596
+ let t = setTimeout(() => {
5597
+ i.signal?.removeEventListener("abort", n), e();
5598
+ }, i.delayMs), n = () => {
5599
+ clearTimeout(t), e();
5600
+ };
5601
+ i.signal?.addEventListener("abort", n, { once: !0 });
5602
+ }), i.signal?.aborted)) {
5603
+ let e = !!(i.hasPrimalSolution ?? a);
5604
+ return {
5605
+ status: e ? "Feasible" : "Unknown",
5606
+ terminationStatus: "Interrupted",
5607
+ hasPrimalSolution: e,
5608
+ objectiveValue: e ? i.objectiveValue ?? 0 : null,
5609
+ ...i.objectiveBound === void 0 ? {} : { objectiveBound: i.objectiveBound },
5610
+ ...i.relativeGap === void 0 ? {} : { relativeGap: i.relativeGap },
5611
+ ...i.absoluteGap === void 0 ? {} : { absoluteGap: i.absoluteGap },
5612
+ values: e && i.values || {},
5613
+ ...e && i.boolValues !== void 0 ? { boolValues: i.boolValues } : {},
5614
+ runTime: .001,
5615
+ raw: { mock: !0 }
5616
+ };
5617
+ }
5618
+ if (i.onProgress && Array.isArray(i.progressEvents)) for (let e of i.progressEvents) {
5619
+ if (i.signal?.aborted) break;
5620
+ i.onProgress(e);
5621
+ }
5622
+ let o = i.status || "Optimal", s = i.terminationStatus ?? o, c = i.hasPrimalSolution === void 0 ? o === "Optimal" || o === "Feasible" || o === "Sat" || (o === "TimeLimit" || o === "IterationLimit" || s === "Interrupted") && a : i.hasPrimalSolution;
5623
+ if (i.onProgress && !Array.isArray(i.progressEvents) && !i.signal?.aborted) {
5624
+ let e = c ? i.objectiveValue ?? 0 : void 0;
5625
+ i.onProgress({
5626
+ elapsedTime: .001,
5627
+ elapsedSeconds: .001,
5628
+ ...typeof e == "number" && Number.isFinite(e) ? { objectiveValue: e } : {},
5629
+ ...i.objectiveBound === void 0 ? {} : { objectiveBound: i.objectiveBound },
5630
+ ...i.relativeGap === void 0 ? {} : { relativeGap: i.relativeGap },
5631
+ ...i.absoluteGap === void 0 ? {} : { absoluteGap: i.absoluteGap }
5632
+ });
5633
+ }
5634
+ return i.signal?.aborted && (s = "Interrupted", c = i.hasPrimalSolution === void 0 ? a : i.hasPrimalSolution, o = c ? "Feasible" : "Unknown"), {
5635
+ status: o,
5636
+ terminationStatus: s,
5637
+ hasPrimalSolution: c,
5638
+ objectiveValue: c ? i.objectiveValue ?? 0 : null,
5639
+ ...i.objectiveBound === void 0 ? {} : { objectiveBound: i.objectiveBound },
5640
+ ...i.relativeGap === void 0 ? {} : { relativeGap: i.relativeGap },
5641
+ ...i.absoluteGap === void 0 ? {} : { absoluteGap: i.absoluteGap },
5642
+ values: c && i.values || {},
5643
+ ...c && i.boolValues !== void 0 ? { boolValues: i.boolValues } : {},
5644
+ reducedCosts: i.reducedCosts,
5645
+ duals: i.duals,
5646
+ slacks: i.slacks,
5647
+ runTime: .001,
5648
+ raw: { mock: !0 }
5649
+ };
5650
+ }
5660
5651
  };
5652
+ function Ot() {
5653
+ Ge("mock", (e) => new Dt(e));
5654
+ }
5655
+ Ot();
5661
5656
  //#endregion
5662
- export { r as BoolExpr, a as BoolOp, i as BoolVar, R as Constraint, d as GlobalConstraint, G as LinExpr, Ye as MockSolver, Ot as Model, b as QuadExpr, K as Var, se as abs, v as allowed, o as and, fe as at, rt as buildIndicatorLinearization, ze as buildLpSymbolMaps, _ as cumulative, nt as deriveBigMForGe, tt as deriveBigMForLe, g as disjoint, m as distinct, oe as dot, Ie as expr, Be as generateLpString, qe as getSolver, l as implies, Le as isLpExportResult, st as linearizeModelForMip, Je as listAvailableSolvers, ue as max, ft as maximize, de as min, pt as minimize, e as normalizeSense, c as not, s as or, Me as parseConstraint, ke as parseExpr, Ge as registerSolver, Re as sanitizeIdentifier, Ke as setDefaultSolver, _t as solveBenders, ut as solveColumnGeneration, ae as sum, $e as validateUserBigM, u as xor };
5657
+ export { ie as A, g as B, q as C, ae as D, de as E, i as F, u as G, l as H, d as I, e as K, v as L, b as M, r as N, le as O, a as P, o as R, ke as S, oe as T, c as U, m as V, s as W, Be as _, dt as a, Ie as b, tt as c, Ze as d, qe as f, ze as g, Ke as h, ut as i, z as j, ue as k, et as l, Ge as m, Et as n, ct as o, Je as p, ht as r, at as s, Dt as t, $e as u, Le as v, K as w, Me as x, Re as y, _ as z };