@ohtaman/washi 0.6.0 → 0.8.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 (147) hide show
  1. package/README.ja.md +139 -418
  2. package/README.md +139 -418
  3. package/README.zh-CN.md +139 -418
  4. package/THIRD_PARTY_LICENSES.md +39 -4
  5. package/dist/browser/__vite-browser-external-rTVKos2U.js +7 -0
  6. package/dist/browser/browser-runtime-AG5QFtKf.js +2021 -0
  7. package/dist/browser/highs-worker.js +26 -11
  8. package/dist/browser/highs.wasm +0 -0
  9. package/dist/browser/{loader-DewlSho8.js → loader-i3FnqMes.js} +183 -149
  10. package/dist/browser/solvers/glpk.js +289 -238
  11. package/dist/browser/solvers/glpk.min.js +1 -1
  12. package/dist/browser/solvers/pumpkin-_washi-pumpkin-node-runtime-CEKUDK6d.js +9 -0
  13. package/dist/browser/solvers/pumpkin-loader-CvdaKxf4.js +320 -0
  14. package/dist/browser/solvers/pumpkin-worker.js +45 -0
  15. package/dist/browser/solvers/pumpkin.js +1777 -0
  16. package/dist/browser/solvers/pumpkin.min.js +1 -0
  17. package/dist/browser/solvers/pumpkin.wasm +0 -0
  18. package/dist/browser/solvers/pumpkin.wasm.LICENSE +21 -0
  19. package/dist/browser/solvers/z3.js +1600 -1335
  20. package/dist/browser/solvers/z3.min.js +2 -2
  21. package/dist/browser/washi.js +3828 -1315
  22. package/dist/browser/washi.min.js +5 -3
  23. package/dist/lib/__vite-browser-external-oLchLuMx.js +7 -0
  24. package/dist/lib/highs-browser-runtime.js +1846 -1618
  25. package/dist/lib/highs-runtime.js +16 -2
  26. package/dist/lib/highs-worker.js +26 -11
  27. package/dist/lib/highs.wasm +0 -0
  28. package/dist/lib/{loader-BZUQNvh4.js → loader-CDpPXN_F.js} +138 -116
  29. package/dist/lib/registry-dx7x4e5c.js +1694 -0
  30. package/dist/lib/rolldown-runtime-DtPi1Y-2.js +13 -0
  31. package/dist/lib/solvers/glpk.js +161 -121
  32. package/dist/lib/solvers/pumpkin-assets.js +1 -0
  33. package/dist/lib/solvers/pumpkin-loader-Ow74Fa1B.js +311 -0
  34. package/dist/lib/solvers/pumpkin-node-runtime.js +15 -0
  35. package/dist/lib/solvers/pumpkin-worker-factory.js +1 -0
  36. package/dist/lib/solvers/pumpkin-worker.js +45 -0
  37. package/dist/lib/solvers/pumpkin.js +1767 -0
  38. package/dist/lib/solvers/pumpkin.wasm +0 -0
  39. package/dist/lib/solvers/pumpkin.wasm.LICENSE +21 -0
  40. package/dist/lib/solvers/z3.js +486 -306
  41. package/dist/lib/washi.js +3054 -1202
  42. package/dist/types/decomposition/benders.d.ts.map +1 -1
  43. package/dist/types/index.d.ts +3 -3
  44. package/dist/types/index.d.ts.map +1 -1
  45. package/dist/types/modeler/boolean-expr.d.ts +137 -29
  46. package/dist/types/modeler/boolean-expr.d.ts.map +1 -1
  47. package/dist/types/modeler/constraint.d.ts +40 -4
  48. package/dist/types/modeler/constraint.d.ts.map +1 -1
  49. package/dist/types/modeler/expression.d.ts +176 -28
  50. package/dist/types/modeler/expression.d.ts.map +1 -1
  51. package/dist/types/modeler/index.d.ts +5 -6
  52. package/dist/types/modeler/index.d.ts.map +1 -1
  53. package/dist/types/modeler/linearizer.d.ts +11 -2
  54. package/dist/types/modeler/linearizer.d.ts.map +1 -1
  55. package/dist/types/modeler/lp-writer.d.ts.map +1 -1
  56. package/dist/types/modeler/model.d.ts +97 -130
  57. package/dist/types/modeler/model.d.ts.map +1 -1
  58. package/dist/types/modeler/parser.d.ts +25 -5
  59. package/dist/types/modeler/parser.d.ts.map +1 -1
  60. package/dist/types/modeler/quad-expr.d.ts +8 -2
  61. package/dist/types/modeler/quad-expr.d.ts.map +1 -1
  62. package/dist/types/modeler/solution-validator.d.ts +12 -12
  63. package/dist/types/modeler/solution-validator.d.ts.map +1 -1
  64. package/dist/types/modeler/solvers/glpk/loader.d.ts +4 -0
  65. package/dist/types/modeler/solvers/glpk/loader.d.ts.map +1 -1
  66. package/dist/types/modeler/solvers/glpk/solver.d.ts +2 -2
  67. package/dist/types/modeler/solvers/glpk/solver.d.ts.map +1 -1
  68. package/dist/types/modeler/solvers/highs/driver.d.ts.map +1 -1
  69. package/dist/types/modeler/solvers/highs/loader.d.ts +8 -6
  70. package/dist/types/modeler/solvers/highs/loader.d.ts.map +1 -1
  71. package/dist/types/modeler/solvers/highs/solver.d.ts.map +1 -1
  72. package/dist/types/modeler/solvers/highs/worker-client.d.ts +16 -0
  73. package/dist/types/modeler/solvers/highs/worker-client.d.ts.map +1 -1
  74. package/dist/types/modeler/solvers/mock.d.ts +2 -3
  75. package/dist/types/modeler/solvers/mock.d.ts.map +1 -1
  76. package/dist/types/modeler/solvers/pumpkin/assets.d.ts +2 -0
  77. package/dist/types/modeler/solvers/pumpkin/assets.d.ts.map +1 -0
  78. package/dist/types/modeler/solvers/pumpkin/index.d.ts +6 -0
  79. package/dist/types/modeler/solvers/pumpkin/index.d.ts.map +1 -0
  80. package/dist/types/modeler/solvers/pumpkin/loader.d.ts +40 -0
  81. package/dist/types/modeler/solvers/pumpkin/loader.d.ts.map +1 -0
  82. package/dist/types/modeler/solvers/pumpkin/node-runtime.d.ts +3 -0
  83. package/dist/types/modeler/solvers/pumpkin/node-runtime.d.ts.map +1 -0
  84. package/dist/types/modeler/solvers/pumpkin/solver.d.ts +23 -0
  85. package/dist/types/modeler/solvers/pumpkin/solver.d.ts.map +1 -0
  86. package/dist/types/modeler/solvers/pumpkin/worker-client.d.ts +74 -0
  87. package/dist/types/modeler/solvers/pumpkin/worker-client.d.ts.map +1 -0
  88. package/dist/types/modeler/solvers/pumpkin/worker-factory.d.ts +3 -0
  89. package/dist/types/modeler/solvers/pumpkin/worker-factory.d.ts.map +1 -0
  90. package/dist/types/modeler/solvers/pumpkin/worker.d.ts +7 -0
  91. package/dist/types/modeler/solvers/pumpkin/worker.d.ts.map +1 -0
  92. package/dist/types/modeler/solvers/pumpkin.d.ts +2 -0
  93. package/dist/types/modeler/solvers/pumpkin.d.ts.map +1 -0
  94. package/dist/types/modeler/solvers/registry.d.ts.map +1 -1
  95. package/dist/types/modeler/solvers/types.d.ts +9 -9
  96. package/dist/types/modeler/solvers/types.d.ts.map +1 -1
  97. package/dist/types/modeler/solvers/z3/loader.d.ts +4 -0
  98. package/dist/types/modeler/solvers/z3/loader.d.ts.map +1 -1
  99. package/dist/types/modeler/solvers/z3/solver.d.ts +2 -15
  100. package/dist/types/modeler/solvers/z3/solver.d.ts.map +1 -1
  101. package/dist/types/modeler/types.d.ts +12 -15
  102. package/dist/types/modeler/types.d.ts.map +1 -1
  103. package/dist/types/modeler/validation.d.ts +26 -2
  104. package/dist/types/modeler/validation.d.ts.map +1 -1
  105. package/dist/types/modeler/variable.d.ts +9 -5
  106. package/dist/types/modeler/variable.d.ts.map +1 -1
  107. package/docs/examples/diet-sensitivity.md +15 -14
  108. package/docs/examples/ecommerce-coupons.md +15 -22
  109. package/docs/examples/index.md +20 -13
  110. package/docs/examples/knapsack.md +8 -7
  111. package/docs/examples/portfolio-qp.md +11 -4
  112. package/docs/examples/production.md +4 -4
  113. package/docs/examples/project-scheduling.md +106 -0
  114. package/docs/examples/shift-scheduling.md +23 -7
  115. package/docs/examples/smt-security.md +17 -4
  116. package/docs/examples/transportation.md +46 -19
  117. package/docs/examples/traveling-salesperson.md +29 -45
  118. package/docs/examples/unsat-core.md +16 -5
  119. package/docs/examples/vehicle-routing.md +10 -8
  120. package/docs/getting-started/ai-agents.md +114 -34
  121. package/docs/getting-started/coding-agents.md +158 -0
  122. package/docs/getting-started/cross-origin.md +56 -28
  123. package/docs/getting-started/index.md +36 -66
  124. package/docs/getting-started/runtimes.md +98 -69
  125. package/docs/guide/constraint-programming.md +141 -0
  126. package/docs/guide/constraints.md +100 -44
  127. package/docs/guide/decomposition.md +141 -273
  128. package/docs/guide/expressions.md +125 -42
  129. package/docs/guide/formulation-tips.md +212 -0
  130. package/docs/guide/objectives.md +70 -64
  131. package/docs/guide/unsat-core.md +44 -23
  132. package/docs/guide/variables.md +56 -48
  133. package/docs/solvers/custom-solver.md +18 -13
  134. package/docs/solvers/highs.md +41 -25
  135. package/docs/solvers/index.md +13 -7
  136. package/docs/solvers/pumpkin.md +163 -0
  137. package/docs/solvers/z3.md +4 -1
  138. package/llms-full.txt +1732 -860
  139. package/llms.txt +59 -36
  140. package/package.json +40 -13
  141. package/skills/washi/SKILL.md +91 -35
  142. package/dist/browser/_washi-node-only-BvRk9kiK.js +0 -0
  143. package/dist/browser/browser-runtime-TLCY0hkc.js +0 -1793
  144. package/dist/lib/_washi-node-only-BvRk9kiK.js +0 -0
  145. package/dist/lib/registry-C20sxTwm.js +0 -964
  146. package/docs/ja/getting-started/ai-agents.md +0 -270
  147. package/docs/zh/getting-started/ai-agents.md +0 -270
@@ -1 +1 @@
1
- {"version":3,"file":"benders.d.ts","sourceRoot":"","sources":["../../../src/decomposition/benders.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,cAAc,EACd,aAAa,EAEd,MAAM,YAAY,CAAC;AAiJpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,YAAY,CAChC,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,aAAa,CAAC,CA8MxB"}
1
+ {"version":3,"file":"benders.d.ts","sourceRoot":"","sources":["../../../src/decomposition/benders.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,cAAc,EACd,aAAa,EAEd,MAAM,YAAY,CAAC;AAkKpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,YAAY,CAChC,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,aAAa,CAAC,CAuOxB"}
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * WaSHI: Modern Mathematical Optimization Modeler for TypeScript & JavaScript
3
3
  *
4
- * Domain-pure algebraic modeling with WebAssembly (HiGHS, Z3, GLPK) and pluggable solvers.
5
- * Supports LP (Linear Programming), MIP (Mixed-Integer Programming), QP (Quadratic Programming), and SMT.
4
+ * Domain-pure algebraic modeling with WebAssembly (HiGHS, Pumpkin, Z3, GLPK) and pluggable solvers.
5
+ * Supports LP (Linear Programming), MIP (Mixed-Integer Programming), QP (Quadratic Programming), CP (Constraint Programming), and SMT.
6
6
  */
7
- export { Model, type ModelOptions, type BoundsOptions, type BinaryOptions, type IndicatorOptions, type ConstraintItem, type KeyCollection, deriveBigMForLe, deriveBigMForGe, validateUserBigM, buildIndicatorLinearization, linearizeModelForMip, type LinearizationResult, validateModelIntegrity, maximize, minimize, type ObjectiveExpr, type ObjectiveSpec, Var, type VarOptions, LinExpr, QuadExpr, type Expr, type DotTerm, type DotVarContainer, type DotCoeffContainer, type QuadTerm, sum, dot, Constraint, BoolVar, BoolExpr, BoolOp, type LogicElement, type LogicInput, and, or, not, implies, xor, parseExpr, parseConstraint, expr, type ParsedExpr, type ExprResolver, generateLpString, buildLpSymbolMaps, isLpExportResult, sanitizeIdentifier, type LpModelData, type LpSymbolMaps, type LpExportResult, validateModelSolution, type SolutionValidationOptions, type ViolationType, type SolutionViolation, type SolutionValidationSummary, type SolutionValidationReport, } from "./modeler/index.js";
7
+ export { Model, type ModelOptions, type BoundsOptions, type BinaryOptions, type IndicatorOptions, type ConstraintItem, type KeyCollection, type LogicalConstraint, deriveBigMForLe, deriveBigMForGe, validateUserBigM, buildIndicatorLinearization, linearizeModelForMip, type LinearizationResult, maximize, minimize, type ObjectiveExpr, type ObjectiveSpec, Var, type VarOptions, LinExpr, QuadExpr, type Expr, type NonlinearAtom, type NonlinearTerm, type DotTerm, type DotVarContainer, type DotCoeffContainer, type SumTerm, type SumContainer, type ExtremumTerm, type ExtremumArg, type QuadTerm, sum, dot, abs, max, min, at, Constraint, BoolVar, BoolExpr, BoolOp, GlobalConstraint, type GlobalConstraintSpec, type DiscreteExprOperand, type DisjointTask, type CumulativeTask, type LogicElement, type LogicInput, and, or, not, implies, xor, distinct, disjoint, cumulative, allowed, parseExpr, parseConstraint, expr, type ParsedExpr, type ExprResolver, type ExprContainerLeaf, type ExprRecordContainer, type ExprMapperFn, type ExprInterpolation, generateLpString, buildLpSymbolMaps, isLpExportResult, sanitizeIdentifier, type LpModelData, type LpSymbolMaps, type LpExportResult, type VerifyOptions, type ViolationType, type VerificationViolation, type VerificationSummary, type VerificationReport, } from "./modeler/index.js";
8
8
  export { normalizeSense, type VarType, type OptimizationSense, type ComparisonSense, type SolverStatus, type TerminationStatus, type SolveProgressEvent, type SolveOptions, type SolverSolution, type CheckResult, type ColumnDefinition, } from "./modeler/types.js";
9
9
  export { solveColumnGeneration, solveBenders, type ColumnProposal, type PricingContext, type ColumnGenerationIterationInfo, type ColumnGenerationOptions, type ColumnGenerationResult, type BendersCut, type BendersSubproblemContext, type BendersSubproblemResult, type BendersIterationInfo, type BendersOptions, type BendersResult, } from "./decomposition/index.js";
10
10
  export { type Solver, type SolverOptions, type SolverResult, type SolverCheckResult, type SolverCapabilities, type SolveModelData, type CheckModelData, type LogicalConstraintItem, HighsSolver, HiGHS, MockSolver, type MockSolverOptions, registerSolver, getSolver, setDefaultSolver, listAvailableSolvers, } from "./modeler/solvers/index.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,KAAK,EACL,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,2BAA2B,EAC3B,oBAAoB,EACpB,KAAK,mBAAmB,EACxB,sBAAsB,EACtB,QAAQ,EACR,QAAQ,EACR,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,GAAG,EACH,KAAK,UAAU,EACf,OAAO,EACP,QAAQ,EACR,KAAK,IAAI,EACT,KAAK,OAAO,EACZ,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,QAAQ,E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SAAS,EACT,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EACL,QAAQ,EACR,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,KAAK,EACL,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,GACtB,MAAM,kCAAkC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,KAAK,EACL,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,2BAA2B,EAC3B,oBAAoB,EACpB,KAAK,mBAAmB,EACxB,QAAQ,EACR,QAAQ,EACR,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,GAAG,EACH,KAAK,UAAU,EACf,OAAO,EACP,QAAQ,EACR,KAAK,IAAI,EACT,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,OAAO,EACZ,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,OAAO,EACZ,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,QAAQ,EACb,GAAG,EACH,GAAG,EACH,GAAG,EACH,GAAG,EACH,GAAG,EACH,EAAE,EACF,UAAU,EACV,OAAO,EACP,QAAQ,EACR,MAAM,EACN,gBAAgB,EAChB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,GAAG,EACH,EAAE,EACF,GAAG,EACH,OAAO,EACP,GAAG,EACH,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,OAAO,EACP,SAAS,EACT,eAAe,EACf,IAAI,EACJ,KA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L,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,GACtB,MAAM,kCAAkC,CAAC"}
@@ -1,14 +1,19 @@
1
1
  import { Constraint } from "./constraint.js";
2
- import type { LinExpr } from "./expression.js";
2
+ import { LinExpr } from "./expression.js";
3
3
  import type { QuadExpr } from "./quad-expr.js";
4
+ import type { Var } from "./variable.js";
4
5
  export type LogicalOpType = "and" | "or" | "not" | "implies" | "xor" | "eq";
5
6
  export type LogicElement = BoolExpr | Constraint;
6
7
  export type LogicInput = LogicElement | LinExpr | QuadExpr;
7
8
  /**
8
9
  * Base abstract class for propositional / SMT Boolean expressions (`BoolVar` and `BoolOp`).
9
10
  *
10
- * **Solver capability note**: Registering `BoolExpr` constraints on a `Model` requires an
11
- * SMT-capable solver such as Z3 (`{ solver: "z3" }`); LP/MIP solvers (HiGHS, GLPK) throw an Error.
11
+ * **Solver capability note**: Logical constraints are solved natively by Pumpkin (`{ solver: "pumpkin" }`,
12
+ * bounded integer/boolean models) and Z3 (`{ solver: "z3" }`), and automatically linearized into 0-1 MIP
13
+ * constraints on HiGHS and GLPK. Comparison `Constraint`s in negated positions (`implies` antecedents,
14
+ * `not`, `xor`) require `Integer`/`Binary` variables with integer coefficients and RHS on MIP backends
15
+ * (and bounded `Integer`/`Binary` models on Pumpkin; for `Continuous` or non-integer negated constraints,
16
+ * use `{ solver: "z3" }`, or write `or(expr\`... >= ... + eps\`, ...)` / `m.bool()`).
12
17
  */
13
18
  export declare abstract class BoolExpr {
14
19
  /** Logical conjunction (`this AND other`). Requires a `BoolVar`, `BoolExpr`, or comparison `Constraint`. */
@@ -23,12 +28,14 @@ export declare abstract class BoolExpr {
23
28
  not(): BoolOp;
24
29
  }
25
30
  /**
26
- * Propositional Boolean variable (`true` / `false`) for SAT / SMT modeling.
27
- * Created via `m.bool(...)` and solved/checked with an SMT-capable solver (`{ solver: "z3" }`).
28
- * For 0-1 arithmetic variables in LP/MIP, use `m.binary(...)` instead.
31
+ * Propositional Boolean variable (`true` / `false`) for logical / SMT modeling.
32
+ * Created via `m.bool(...)`; solved natively on Pumpkin (`{ solver: "pumpkin" }`, bounded integer/boolean
33
+ * models) and Z3 (`{ solver: "z3" }`), and automatically linearized into a 0-1 MIP binary variable on HiGHS and GLPK.
34
+ * For 0-1 arithmetic variables in linear sums or objectives, use `m.binary(...)` instead.
29
35
  */
30
36
  export declare class BoolVar extends BoolExpr {
31
37
  readonly id: number;
38
+ readonly type: "Boolean";
32
39
  readonly name: string;
33
40
  value: boolean | null;
34
41
  constructor(name?: string);
@@ -46,14 +53,13 @@ export declare class BoolOp extends BoolExpr {
46
53
  /**
47
54
  * Logical conjunction (`e1 AND e2 AND ...`) over `BoolVar`, `BoolExpr`, or linear comparison `Constraint`s.
48
55
  *
49
- * **Solver capability note**: Logical constraints require an SMT-capable solver such as Z3
50
- * (`new Model("...", { solver: "z3" })` after `import "@ohtaman/washi/solvers/z3"`).
51
- * LP/MIP solvers (HiGHS, GLPK) throw an Error if logical constraints are present.
52
- * Passing an unconstrained arithmetic expression (`LinExpr` / `QuadExpr`) throws an Error.
56
+ * **Solver capability note**: Solved natively by Pumpkin (`{ solver: "pumpkin" }`, bounded integer/boolean
57
+ * models) and Z3 (`{ solver: "z3" }`), and automatically linearized into 0-1 MIP constraints on HiGHS and
58
+ * GLPK. Passing an unconstrained arithmetic expression (`LinExpr` / `QuadExpr`) throws an Error.
53
59
  *
54
60
  * @example
55
61
  * ```ts
56
- * const m = new Model("AndExample", { solver: "z3" });
62
+ * const m = new Model("AndExample");
57
63
  * const a = m.bool("a");
58
64
  * const x = m.integer("x", { lb: 0, ub: 20 });
59
65
  * m.constraint(and(a, expr`${x} >= 10`), "both_active");
@@ -63,14 +69,14 @@ export declare function and(...exprs: LogicInput[]): BoolOp;
63
69
  /**
64
70
  * Logical disjunction (`e1 OR e2 OR ...`) over `BoolVar`, `BoolExpr`, or linear comparison `Constraint`s.
65
71
  *
66
- * **Solver capability note**: Logical constraints require an SMT-capable solver such as Z3
67
- * (`new Model("...", { solver: "z3" })` after `import "@ohtaman/washi/solvers/z3"`).
68
- * LP/MIP solvers (HiGHS, GLPK) throw an Error if logical constraints are present.
69
- * Passing an unconstrained arithmetic expression (`LinExpr` / `QuadExpr`) throws an Error.
72
+ * **Solver capability note**: Solved natively by Pumpkin (`{ solver: "pumpkin" }`, bounded integer/boolean
73
+ * models) and Z3 (`{ solver: "z3" }`), and automatically linearized via 0-1 MIP Big-M indicators on HiGHS
74
+ * and GLPK (variables in comparison branches require finite bounds on MIP backends and Pumpkin). Passing
75
+ * an unconstrained arithmetic expression (`LinExpr` / `QuadExpr`) throws an Error.
70
76
  *
71
77
  * @example
72
78
  * ```ts
73
- * const m = new Model("OrExample", { solver: "z3" });
79
+ * const m = new Model("OrExample");
74
80
  * const x = m.integer("x", { lb: 0, ub: 20 });
75
81
  * m.constraint(or(expr`${x} <= 5`, expr`${x} >= 15`), "disjoint_range");
76
82
  * ```
@@ -79,13 +85,16 @@ export declare function or(...exprs: LogicInput[]): BoolOp;
79
85
  /**
80
86
  * Logical negation (`NOT e`) of a `BoolVar`, `BoolExpr`, or linear comparison `Constraint`.
81
87
  *
82
- * **Solver capability note**: Logical constraints require an SMT-capable solver such as Z3
83
- * (`new Model("...", { solver: "z3" })` after `import "@ohtaman/washi/solvers/z3"`).
84
- * LP/MIP solvers (HiGHS, GLPK) throw an Error if logical constraints are present.
88
+ * **Solver capability note**: Solved natively by Pumpkin (`{ solver: "pumpkin" }`, bounded integer/boolean
89
+ * models) and Z3 (`{ solver: "z3" }`), and automatically linearized on HiGHS and GLPK. Negating a
90
+ * comparison `Constraint` on MIP backends uses exact `+/- 1` integer shifts and requires `Integer`/`Binary`
91
+ * variables with integer coefficients and RHS (and bounded `Integer`/`Binary` models on Pumpkin); for
92
+ * `Continuous` or non-integer constraints, use `{ solver: "z3" }`, or write an explicit
93
+ * closed-tolerance disjunction `or(expr\`... >= ... + eps\`, ...)` / `m.bool()`.
85
94
  *
86
95
  * @example
87
96
  * ```ts
88
- * const m = new Model("NotExample", { solver: "z3" });
97
+ * const m = new Model("NotExample");
89
98
  * const blocked = m.bool("blocked");
90
99
  * m.constraint(not(blocked), "must_not_be_blocked");
91
100
  * ```
@@ -94,14 +103,17 @@ export declare function not(expr: LogicInput): BoolOp;
94
103
  /**
95
104
  * Logical implication (`antecedent => consequent`) over `BoolVar`, `BoolExpr`, or linear comparison `Constraint`s.
96
105
  *
97
- * **Solver capability note**: Logical constraints require an SMT-capable solver such as Z3
98
- * (`new Model("...", { solver: "z3" })` after `import "@ohtaman/washi/solvers/z3"`).
99
- * LP/MIP solvers (HiGHS, GLPK) throw an Error if logical constraints are present
100
- * (for LP/MIP 0-1 Big-M indicator constraints, use `m.indicator(binVar, constraint)` instead).
106
+ * **Solver capability note**: Solved natively by Pumpkin (`{ solver: "pumpkin" }`, bounded integer/boolean
107
+ * models) and Z3 (`{ solver: "z3" }`), and automatically linearized into 0-1 MIP constraints on HiGHS and
108
+ * GLPK. When `antecedent` contains a comparison `Constraint`, MIP backends negate it via exact `+/- 1`
109
+ * integer shifts (`Integer`/`Binary` variables with integer coefficients and RHS), and Pumpkin requires
110
+ * bounded `Integer`/`Binary` models; if `antecedent` involves `Continuous` variables or non-integer
111
+ * coefficients/thresholds, MIP solvers and Pumpkin throw an Error—use `{ solver: "z3" }`, or rewrite
112
+ * explicitly with `or(expr\`... >= ... + eps\`, ...)` / `m.bool()`.
101
113
  *
102
114
  * @example
103
115
  * ```ts
104
- * const m = new Model("ImpliesExample", { solver: "z3" });
116
+ * const m = new Model("ImpliesExample");
105
117
  * const vip = m.bool("vip");
106
118
  * const discount = m.integer("discount", { lb: 0, ub: 50 });
107
119
  * m.constraint(implies(vip, expr`${discount} >= 20`), "vip_min_discount");
@@ -111,17 +123,113 @@ export declare function implies(antecedent: LogicInput, consequent: LogicInput):
111
123
  /**
112
124
  * Logical exclusive-or (`e1 XOR e2 ...`) over `BoolVar`, `BoolExpr`, or linear comparison `Constraint`s.
113
125
  *
114
- * **Solver capability note**: Logical constraints require an SMT-capable solver such as Z3
115
- * (`new Model("...", { solver: "z3" })` after `import "@ohtaman/washi/solvers/z3"`).
116
- * LP/MIP solvers (HiGHS, GLPK) throw an Error if logical constraints are present.
126
+ * **Solver capability note**: Solved natively by Pumpkin (`{ solver: "pumpkin" }`, bounded integer/boolean
127
+ * models) and Z3 (`{ solver: "z3" }`), and automatically linearized into 0-1 MIP constraints on HiGHS and
128
+ * GLPK. Comparison `Constraint` operands require both positive and negated directions (`+/- 1` integer
129
+ * shifts over bounded `Integer`/`Binary` variables with integer coefficients and RHS); for `Continuous`
130
+ * or non-integer constraints, use `{ solver: "z3" }`, or model the propositions explicitly with
131
+ * `or(expr\`... >= ... + eps\`, ...)` / `m.bool()`.
117
132
  *
118
133
  * @example
119
134
  * ```ts
120
- * const m = new Model("XorExample", { solver: "z3" });
135
+ * const m = new Model("XorExample");
121
136
  * const shiftA = m.bool("shiftA");
122
137
  * const shiftB = m.bool("shiftB");
123
138
  * m.constraint(xor(shiftA, shiftB), "exactly_one_shift");
124
139
  * ```
125
140
  */
126
141
  export declare function xor(...exprs: LogicInput[]): BoolOp;
142
+ export type DiscreteExprOperand = Var | LinExpr | QuadExpr | Constraint | number;
143
+ export interface DisjointTask {
144
+ start: DiscreteExprOperand;
145
+ duration: number;
146
+ }
147
+ export interface CumulativeTask {
148
+ start: DiscreteExprOperand;
149
+ duration: number;
150
+ demand: number;
151
+ }
152
+ export type GlobalConstraintSpec = {
153
+ readonly kind: "distinct";
154
+ readonly args: ReadonlyArray<LinExpr>;
155
+ } | {
156
+ readonly kind: "disjoint";
157
+ readonly tasks: ReadonlyArray<{
158
+ readonly start: LinExpr;
159
+ readonly duration: number;
160
+ }>;
161
+ } | {
162
+ readonly kind: "cumulative";
163
+ readonly tasks: ReadonlyArray<{
164
+ readonly start: LinExpr;
165
+ readonly duration: number;
166
+ readonly demand: number;
167
+ }>;
168
+ readonly capacity: number;
169
+ } | {
170
+ readonly kind: "allowed";
171
+ readonly vars: ReadonlyArray<LinExpr>;
172
+ readonly tuples: ReadonlyArray<ReadonlyArray<number>>;
173
+ };
174
+ /**
175
+ * High-level structural Constraint Programming (CP) predicate returning a composable `BoolExpr`
176
+ * (`distinct`, `disjoint`, `cumulative`, `allowed`).
177
+ */
178
+ export declare class GlobalConstraint extends BoolExpr {
179
+ readonly spec: GlobalConstraintSpec;
180
+ readonly discreteVars: ReadonlySet<Var>;
181
+ constructor(spec: GlobalConstraintSpec, discreteVars: ReadonlySet<Var>);
182
+ toString(): string;
183
+ }
184
+ /**
185
+ * Enforce pairwise distinct values across all elements (`AllDifferent` global constraint).
186
+ * Accepts variadic scalar expressions or 1D/2D `Array` / `Iterable` / plain `Record` containers
187
+ * of `Integer` / `Binary` variables, discrete `LinExpr`s, or integer constants.
188
+ *
189
+ * @example
190
+ * ```ts
191
+ * const m = new Model("DistinctExample");
192
+ * const room = m.integer(3, { lb: 1, ub: 3, prefix: "room" });
193
+ * m.constraint(distinct(room), "unique_rooms");
194
+ * ```
195
+ */
196
+ export declare function distinct(...args: Array<DiscreteExprOperand | Iterable<DiscreteExprOperand | Iterable<DiscreteExprOperand> | Record<string, DiscreteExprOperand>> | Record<string, any>>): GlobalConstraint;
197
+ /**
198
+ * Enforce non-overlapping unary resource scheduling across tasks (`NoOverlap` / `Disjunctive` global constraint).
199
+ *
200
+ * @example
201
+ * ```ts
202
+ * const m = new Model("DisjointExample");
203
+ * const s1 = m.integer("s1", { lb: 0, ub: 10 });
204
+ * const s2 = m.integer("s2", { lb: 0, ub: 10 });
205
+ * m.constraint(disjoint([{ start: s1, duration: 5 }, { start: s2, duration: 3 }]), "machine_1");
206
+ * ```
207
+ */
208
+ export declare function disjoint(tasks: Iterable<DisjointTask> | Record<string, DisjointTask>): GlobalConstraint;
209
+ /**
210
+ * Enforce cumulative resource capacity over tasks with `{ start, duration, demand }`
211
+ * (`Cumulative` global constraint).
212
+ *
213
+ * @example
214
+ * ```ts
215
+ * const m = new Model("CumulativeExample");
216
+ * const s1 = m.integer("s1", { lb: 0, ub: 10 });
217
+ * const s2 = m.integer("s2", { lb: 0, ub: 10 });
218
+ * m.constraint(cumulative([{ start: s1, duration: 5, demand: 2 }, { start: s2, duration: 3, demand: 1 }], 2), "workers");
219
+ * ```
220
+ */
221
+ export declare function cumulative(tasks: Iterable<CumulativeTask> | Record<string, CumulativeTask>, capacity: number): GlobalConstraint;
222
+ /**
223
+ * Enforce extensional tuple membership `(vars[0], ..., vars[k-1]) in tuples`
224
+ * (`Table` / `AllowedAssignments` global constraint; wrap in `not(...)` for forbidden tuples).
225
+ *
226
+ * @example
227
+ * ```ts
228
+ * const m = new Model("AllowedExample");
229
+ * const a = m.integer("a", { lb: 1, ub: 2 });
230
+ * const b = m.integer("b", { lb: 1, ub: 2 });
231
+ * m.constraint(allowed([a, b], [[1, 2], [2, 1]]), "valid_pair");
232
+ * ```
233
+ */
234
+ export declare function allowed(vars: ReadonlyArray<DiscreteExprOperand>, tuples: Iterable<ReadonlyArray<number>>): GlobalConstraint;
127
235
  //# sourceMappingURL=boolean-expr.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"boolean-expr.d.ts","sourceRoot":"","sources":["../../../src/modeler/boolean-expr.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAI/C,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG,IAAI,CAAC;AAE5E,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,UAAU,CAAC;AAEjD,MAAM,MAAM,UAAU,GAAG,YAAY,GAAG,OAAO,GAAG,QAAQ,CAAC;AAmC3D;;;;;GAKG;AACH,8BAAsB,QAAQ;IAC5B,4GAA4G;I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;AA0CD;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CACtB,KAAK,EAAE,QAAQ,CAAC,YAAY,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAC3D,gBAAgB,CA0BlB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,QAAQ,CAAC,cAAc,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,EAChE,QAAQ,EAAE,MAAM,GACf,gBAAgB,CA2DlB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,OAAO,CACrB,IAAI,EAAE,aAAa,CAAC,mBAAmB,CAAC,EACxC,MAAM,EAAE,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,GACtC,gBAAgB,CAuDlB"}
@@ -3,7 +3,20 @@ import type { LinExpr } from "./expression.js";
3
3
  import type { Var } from "./variable.js";
4
4
  import { BoolOp, type LogicInput } from "./boolean-expr.js";
5
5
  /**
6
- * Represents a linear constraint: lhs (terms) <=, >=, or == rhs (constant)
6
+ * Internal metadata recording that an indicator constraint row was constructed
7
+ * via `Model.indicator(binVar, targetConstraint)` without an explicit `{ M }` override.
8
+ * Enables CP (Pumpkin) and SMT (Z3) backends to lower indicators natively instead of Big-M.
9
+ */
10
+ export interface IndicatorOrigin {
11
+ readonly binVar: Var;
12
+ readonly activeValue: 0 | 1;
13
+ readonly targetLhs: LinExpr;
14
+ readonly targetSense: "<=" | ">=";
15
+ readonly targetRhs: number;
16
+ readonly derivedM: number;
17
+ }
18
+ /**
19
+ * Represents a linear constraint: lhs (terms) <=, >=, ==, or != rhs (constant)
7
20
  */
8
21
  export declare class Constraint {
9
22
  readonly kind: "constraint";
@@ -13,9 +26,10 @@ export declare class Constraint {
13
26
  private _rhs;
14
27
  private _name;
15
28
  hasExplicitName: boolean;
16
- ownerModel: {
17
- notifyMutation?: () => void;
18
- } | null;
29
+ ownerModel: object | null;
30
+ private _indicatorOrigin?;
31
+ private _indicatorSnapshot?;
32
+ private _discreteVars?;
19
33
  /** Slack value after solve */
20
34
  slack: number | null;
21
35
  /** Dual value (shadow price) after solve */
@@ -39,12 +53,31 @@ export declare class Constraint {
39
53
  set rhs(value: number);
40
54
  get name(): string;
41
55
  set name(value: string);
56
+ /** @internal */
57
+ get _indicatorMeta(): IndicatorOrigin | undefined;
58
+ /** @internal */
59
+ _setIndicatorOrigin(origin: IndicatorOrigin | undefined): void;
60
+ /** @internal */
61
+ get _requiredDiscreteVars(): ReadonlySet<Var> | undefined;
62
+ /** @internal */
63
+ _setDiscreteVars(vars: ReadonlySet<Var> | undefined): void;
42
64
  /** @internal Assigns a model-scoped name and explicit flag without triggering setter mutation notifications */
43
65
  _assignModelName(name: string, hasExplicitName: boolean): void;
66
+ /** Logical conjunction (`this AND other`). */
44
67
  and(other: LogicInput): BoolOp;
68
+ /** Logical disjunction (`this OR other`). */
45
69
  or(other: LogicInput): BoolOp;
70
+ /**
71
+ * Logical implication (`this => consequent`).
72
+ * On MIP backends (HiGHS, GLPK), `this` is negated via exact `+/- 1` integer shifts
73
+ * (`Integer`/`Binary` variables with integer coefficients and RHS); `Continuous` or
74
+ * non-integer antecedents throw an Error (use `{ solver: "z3" }`, or write
75
+ * `or(expr\`... >= ... + eps\`, ...)` / `m.bool()`).
76
+ */
46
77
  implies(consequent: LogicInput): BoolOp;
78
+ /** Logical exclusive-or (`this XOR other`). Requires integer-valued `this` on MIP backends. */
47
79
  xor(other: LogicInput): BoolOp;
80
+ /** Logical negation (`NOT this`). Negated via exact `+/- 1` integer shifts on MIP backends. */
48
81
  not(): BoolOp;
49
82
  add(_other: unknown): never;
50
83
  sub(_other: unknown): never;
@@ -54,6 +87,9 @@ export declare class Constraint {
54
87
  le(_rhs: unknown, _name?: string): never;
55
88
  ge(_rhs: unknown, _name?: string): never;
56
89
  eq(_rhs: unknown, _name?: string): never;
90
+ lt(_rhs: unknown, _name?: string): never;
91
+ gt(_rhs: unknown, _name?: string): never;
92
+ ne(_rhs: unknown, _name?: string): never;
57
93
  get value(): never;
58
94
  get constant(): never;
59
95
  clone(): Constraint;
@@ -1 +1 @@
1
- {"version":3,"file":"constraint.d.ts","sourceRoot":"","sources":["../../../src/modeler/constraint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI5D;;GAEG;AACH,qBAAa,UAAU;IACrB,SAAgB,IAAI,EAAG,YAAY,CAAU;IAC7C,SAAgB,EAAE,EAAE,MAAM,CAAC;IAC3B,OAAO,CAAC,IAAI,CAAU;IACtB,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,KAAK,CAAS;IACf,eAAe,EAAE,OAAO,CAAC;IACzB,UAAU,EAAE;QAAE,cAAc,CAAC,EAAE,MAAM,IAAI,CAAA;KAAE,GAAG,IAAI,CAAQ;IACjE,8BAA8B;IACvB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAQ;IACnC,4CAA4C;IACrC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAQ;IAGlC;;;OAGG;IACH,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAKnC;IAED;;;OAGG;IACH,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAInC;IAED,YACE,GAAG,EAAE,OAAO,EACZ,KAAK,EAAE,eAAe,EACtB,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE,MAAM,EAcd;IAED,IAAI,GAAG,IAAI,OAAO,CAEjB;IAED,IAAI,GAAG,CAAC,KAAK,EAAE,OAAO,E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raint } from "./constraint.js";
3
3
  import { QuadExpr } from "./quad-expr.js";
4
4
  /**
5
- * Represents a linear expression: c0 + c1*x1 + c2*x2 + ...
5
+ * Nonlinear scalar atom representable inside a `LinExpr` (piecewise-linear `max`/`min`/`abs` or `at` element lookup).
6
+ */
7
+ export type NonlinearAtom = {
8
+ readonly kind: "max";
9
+ readonly args: ReadonlyArray<LinExpr>;
10
+ } | {
11
+ readonly kind: "min";
12
+ readonly args: ReadonlyArray<LinExpr>;
13
+ } | {
14
+ readonly kind: "abs";
15
+ readonly arg: LinExpr;
16
+ } | {
17
+ readonly kind: "at";
18
+ readonly array: ReadonlyArray<LinExpr>;
19
+ readonly index: LinExpr;
20
+ readonly discreteVars: ReadonlySet<Var>;
21
+ };
22
+ /**
23
+ * Weighted nonlinear scalar atom term (`coeff * atom`).
24
+ */
25
+ export interface NonlinearTerm {
26
+ readonly atom: NonlinearAtom;
27
+ readonly coeff: number;
28
+ }
29
+ export declare function cloneNonlinearAtom(atom: NonlinearAtom): NonlinearAtom;
30
+ export declare function evaluateNonlinearAtomValue(atom: NonlinearAtom): number | null;
31
+ /**
32
+ * Validates that an expression is purely integer-valued (only Integer/Binary variables,
33
+ * safe integer coefficients/constants, and discrete nested atoms) and collects all referenced `Var`s.
34
+ */
35
+ export declare function collectAndValidateDiscreteExpr(val: LinExpr | QuadExpr | Var | number, context: string, outVars?: Set<Var>): Set<Var>;
36
+ /**
37
+ * Converts a scalar `number | Var | LinExpr | degree-1 QuadExpr` to a cloned `LinExpr`,
38
+ * rejecting `Constraint`, non-finite numbers, and quadratic terms.
39
+ */
40
+ export declare function toScalarLinExpr(val: unknown, context: string): LinExpr;
41
+ /**
42
+ * Represents a linear (or piecewise-linear / element) expression: c0 + sum(c_i*x_i) + sum(w_k*atom_k)
6
43
  */
7
44
  export declare class LinExpr {
8
45
  readonly kind: "linear";
9
46
  terms: Map<Var, number>;
10
47
  constant: number;
11
- constructor(terms?: Map<Var, number>, constant?: number);
48
+ nonlinearTerms: NonlinearTerm[];
49
+ constructor(terms?: Map<Var, number>, constant?: number, nonlinearTerms?: ReadonlyArray<NonlinearTerm>);
50
+ /**
51
+ * Returns true if this expression includes nonlinear scalar atoms (`max`, `min`, `abs`, `at`).
52
+ */
53
+ hasNonlinearTerms(): boolean;
12
54
  /**
13
55
  * Set or overwrite the coefficient for a variable in this expression.
14
56
  * If `coeff === 0`, removes the variable from terms.
@@ -67,6 +109,22 @@ export declare class LinExpr {
67
109
  * Create constraint: this == rhs
68
110
  */
69
111
  eq(rhs: number | Var | LinExpr | QuadExpr | Constraint, name?: string): Constraint;
112
+ /**
113
+ * Create discrete strict less-than constraint (`this < rhs`, normalized to `this <= rhs - 1`).
114
+ * Requires integer-valued `Integer`/`Binary` expressions; throws on `Continuous` variables or fractional constants.
115
+ */
116
+ lt(rhs: number | Var | LinExpr | QuadExpr | Constraint, name?: string): Constraint;
117
+ /**
118
+ * Create discrete strict greater-than constraint (`this > rhs`, normalized to `this >= rhs + 1`).
119
+ * Requires integer-valued `Integer`/`Binary` expressions; throws on `Continuous` variables or fractional constants.
120
+ */
121
+ gt(rhs: number | Var | LinExpr | QuadExpr | Constraint, name?: string): Constraint;
122
+ /**
123
+ * Create discrete not-equal constraint (`this != rhs`).
124
+ * Requires integer-valued `Integer`/`Binary` expressions; throws on `Continuous` variables or fractional constants.
125
+ */
126
+ ne(rhs: number | Var | LinExpr | QuadExpr | Constraint, name?: string): Constraint;
127
+ private toDiscreteComparison;
70
128
  private toConstraint;
71
129
  and(_other: unknown): never;
72
130
  or(_other: unknown): never;
@@ -79,32 +137,6 @@ export declare class LinExpr {
79
137
  * Union expression type covering linear and quadratic expressions.
80
138
  */
81
139
  export type Expr = LinExpr | QuadExpr;
82
- /**
83
- * Sum an `Iterable` of `Var` / `LinExpr` / `number` items, an `Iterable` with a mapping function,
84
- * or a numeric count `n` with an index mapper `(0 .. n - 1)` into a single `LinExpr`.
85
- *
86
- * **Formulation notes**:
87
- * - Produces a linear expression (`LinExpr`).
88
- * - Passing comparison `Constraint`s (`<=`, `>=`, `==`) or non-linear `QuadExpr` terms throws an Error
89
- * (quadratic terms are supported in objectives only via `expr` or `.mul()`).
90
- *
91
- * @example
92
- * ```ts
93
- * const m = new Model("SumExample");
94
- * const x = m.continuous(3, { lb: 0, prefix: "x" });
95
- * const byItem = m.integer(["desk", "chair"] as const, { lb: 0 });
96
- *
97
- * // Sum an array or iterable directly
98
- * m.constraint(expr`${sum(x)} <= 100`, "total_x");
99
- * m.constraint(expr`${sum(Object.values(byItem))} <= 50`, "total_items");
100
- *
101
- * // Sum with a mapper or over a count range (0..2)
102
- * const weighted = sum(3, (i) => expr`${i + 1} * ${x[i]}`);
103
- * m.objective(maximize(weighted));
104
- * ```
105
- */
106
- export declare function sum(count: number, mapFn: (index: number) => LinExpr | QuadExpr | Constraint | Var | number): LinExpr;
107
- export declare function sum<T = any>(items: Iterable<T>, mapFn?: (item: T, index: number) => LinExpr | QuadExpr | Constraint | Var | number): LinExpr;
108
140
  export type DotTerm = Var | LinExpr;
109
141
  export type DotVarContainer<R extends string | number = string | number, C extends string | number = string | number> = ReadonlyArray<DotTerm> | {
110
142
  readonly [K in R]: DotTerm;
@@ -142,6 +174,53 @@ type DotRecordShape<T, Leaf, Inner = never> = object & {
142
174
  readonly [K in keyof T]: Leaf | ReadonlyArray<Leaf> | DotRecordLeafMap<T[K], Leaf> | DotRecordLeafMap<Inner, Leaf>;
143
175
  } & NoSymbolKeys<T>;
144
176
  type DotContainerArg<T, Leaf, Inner = never> = ReadonlyArray<Leaf> | ReadonlyArray<ReadonlyArray<Leaf>> | ReadonlyArray<DotRecordLeafMap<T[number & keyof T], Leaf>> | DotRecordShape<T, Leaf, Inner>;
177
+ export type SumTerm = Var | LinExpr | number;
178
+ export type SumContainer<R extends string | number = string | number, C extends string | number = string | number> = Iterable<SumTerm> | {
179
+ readonly [K in R]: SumTerm;
180
+ } | Iterable<Iterable<SumTerm>> | Iterable<{
181
+ readonly [K in C]: SumTerm;
182
+ }> | {
183
+ readonly [K in R]: Iterable<SumTerm>;
184
+ } | {
185
+ readonly [K in R]: {
186
+ readonly [L in C]: SumTerm;
187
+ };
188
+ };
189
+ type SumRecordLeaf = LinExpr | QuadExpr | Constraint | Var | number;
190
+ type SumRecordShape<T, Inner = never> = object & {
191
+ readonly [K in keyof T]: SumRecordLeaf | Iterable<SumRecordLeaf> | DotRecordLeafMap<T[K], SumRecordLeaf> | DotRecordLeafMap<Inner, SumRecordLeaf>;
192
+ } & NoSymbolKeys<T>;
193
+ /**
194
+ * Sum a 1D or 2D `Iterable` / `Array` / plain `Record` of `Var` / `LinExpr` / `number` items,
195
+ * an `Iterable` or `Record` with a mapping function, or a numeric count `n` with an index mapper `(0 .. n - 1)`
196
+ * into a single `LinExpr`.
197
+ *
198
+ * **Formulation notes**:
199
+ * - Produces a linear expression (`LinExpr`).
200
+ * - Accepts 1D/2D `Record` containers directly without `Object.values()`.
201
+ * - Passing comparison `Constraint`s (`<=`, `>=`, `==`) or non-linear `QuadExpr` terms throws an Error
202
+ * (quadratic terms are supported in objectives only via `expr` or `.mul()`).
203
+ *
204
+ * @example
205
+ * ```ts
206
+ * const m = new Model("SumExample");
207
+ * const x = m.continuous(3, { lb: 0, prefix: "x" });
208
+ * const byItem = m.integer(["desk", "chair"] as const, { lb: 0 });
209
+ *
210
+ * // Sum an array, iterable, or Record directly (or inside expr`sum(...)`)
211
+ * m.constraint(expr`sum(${x}) <= 100`, "total_x");
212
+ * m.constraint(expr`sum(${byItem}) <= 50`, "total_items");
213
+ *
214
+ * // Sum with a mapper or over a count range (0..2)
215
+ * const weighted = sum(3, (i) => expr`${i + 1} * ${x[i]}`);
216
+ * m.objective(maximize(weighted));
217
+ * ```
218
+ */
219
+ export declare function sum(count: number, mapFn: (index: number) => LinExpr | QuadExpr | Constraint | Var | number): LinExpr;
220
+ export declare function sum<T = any>(items: Iterable<T>, mapFn?: (item: T, index: number) => LinExpr | QuadExpr | Constraint | Var | number): LinExpr;
221
+ export declare function sum<T extends object>(record: T & NoSymbolKeys<T>, mapFn: (value: T[keyof T], index: number) => LinExpr | QuadExpr | Constraint | Var | number): LinExpr;
222
+ export declare function sum<T = SumContainer, TI = never>(container: T & (Record<any, TI> | unknown) & SumRecordShape<T, TI>): LinExpr;
223
+ export declare function sum(container: SumContainer<any, any>): LinExpr;
145
224
  /**
146
225
  * Compute the inner product (linear combination `LinExpr`) of numeric coefficients and
147
226
  * `Var` / `LinExpr` containers across 1D arrays, 2D matrices (`number[][]` / `Var[][]`),
@@ -181,5 +260,74 @@ export declare function dot<C = DotCoeffContainer, V = DotVarContainer, CI = nev
181
260
  export declare function dot<V = DotVarContainer, C = DotCoeffContainer, VI = never, CI = never>(vars: V & (Record<any, VI> | unknown) & DotContainerArg<V, DotTerm, VI>, coeffs: C & (Record<any, CI> | unknown) & DotContainerArg<C, number, CI>): LinExpr;
182
261
  export declare function dot(coeffs: DotCoeffContainer<any, any>, vars: DotVarContainer<any, any>): LinExpr;
183
262
  export declare function dot(vars: DotVarContainer<any, any>, coeffs: DotCoeffContainer<any, any>): LinExpr;
263
+ /**
264
+ * Compute the absolute value $|e|$ of a scalar expression (`number`, `Var`, or `LinExpr`).
265
+ *
266
+ * **Lowering behavior**:
267
+ * - **HiGHS / GLPK**: Pure LP epigraph (`t >= e, t >= -e`, zero binary variables) when used in a convex direction (`minimize(abs(e))`, `abs(e) <= rhs`); exact bounded MIP linearization using finite `[lb, ub]` bounds otherwise.
268
+ * - **Pumpkin**: Native `absolute` propagator on bounded integer expressions (`Continuous` rejected).
269
+ * - **Z3**: Exact `ITE` arithmetic AST on `Int` and `Real` sorts.
270
+ *
271
+ * @example
272
+ * ```ts
273
+ * const m = new Model("AbsExample");
274
+ * const a = m.continuous("a", { lb: 0, ub: 10 });
275
+ * const b = m.continuous("b", { lb: 0, ub: 10 });
276
+ * m.constraint(a.eq(7));
277
+ * m.constraint(abs(a.sub(b)).le(2), "balance");
278
+ * m.objective(minimize(b));
279
+ * ```
280
+ */
281
+ export declare function abs(value: number | Var | LinExpr | QuadExpr | Constraint): LinExpr;
282
+ export type ExtremumTerm = Var | LinExpr | QuadExpr | Constraint | number;
283
+ export type ExtremumArg<T = any> = SumContainer<any, any> | ExtremumTerm | Iterable<T> | {
284
+ readonly [key: string]: ExtremumTerm | Iterable<ExtremumTerm> | {
285
+ readonly [subKey: string]: ExtremumTerm;
286
+ };
287
+ };
288
+ /**
289
+ * Compute the maximum $\max(e_1, \dots, e_n)$ across variadic scalar expressions,
290
+ * 1D/2D `Array` / `Iterable` / `Record` containers, or a `(itemsOrCount, mapFn)` mapper.
291
+ *
292
+ * @example
293
+ * ```ts
294
+ * const m = new Model("MaxExample");
295
+ * const x = m.continuous("x", { lb: 2, ub: 10 });
296
+ * const y = m.continuous("y", { lb: 5, ub: 10 });
297
+ * m.objective(minimize(max(x, y)));
298
+ * ```
299
+ */
300
+ export declare function max(count: number, mapFn: (index: number) => LinExpr | QuadExpr | Constraint | Var | number): LinExpr;
301
+ export declare function max<T = any>(items: Iterable<T>, mapFn: (item: T, index: number) => LinExpr | QuadExpr | Constraint | Var | number): LinExpr;
302
+ export declare function max<T extends object>(record: T & NoSymbolKeys<T>, mapFn: (value: T[keyof T], index: number) => LinExpr | QuadExpr | Constraint | Var | number): LinExpr;
303
+ export declare function max(...args: ExtremumArg[]): LinExpr;
304
+ /**
305
+ * Compute the minimum $\min(e_1, \dots, e_n)$ across variadic scalar expressions,
306
+ * 1D/2D `Array` / `Iterable` / `Record` containers, or a `(itemsOrCount, mapFn)` mapper.
307
+ *
308
+ * @example
309
+ * ```ts
310
+ * const m = new Model("MinExample");
311
+ * const x = m.continuous("x", { lb: 0, ub: 8 });
312
+ * const y = m.continuous("y", { lb: 0, ub: 5 });
313
+ * m.objective(maximize(min(x, y)));
314
+ * ```
315
+ */
316
+ export declare function min(count: number, mapFn: (index: number) => LinExpr | QuadExpr | Constraint | Var | number): LinExpr;
317
+ export declare function min<T = any>(items: Iterable<T>, mapFn: (item: T, index: number) => LinExpr | QuadExpr | Constraint | Var | number): LinExpr;
318
+ export declare function min<T extends object>(record: T & NoSymbolKeys<T>, mapFn: (value: T[keyof T], index: number) => LinExpr | QuadExpr | Constraint | Var | number): LinExpr;
319
+ export declare function min(...args: ExtremumArg[]): LinExpr;
320
+ /**
321
+ * 0-based variable-indexed lookup `array[index]` (CP `Element` constraint).
322
+ * Automatically enforces $0 \le \text{index} < \text{array.length}$ and rejects `Continuous` or fractional indices.
323
+ *
324
+ * @example
325
+ * ```ts
326
+ * const m = new Model("AtExample");
327
+ * const route = m.integer("route", { lb: 0, ub: 2 });
328
+ * m.objective(minimize(at([30, 12, 25], route)));
329
+ * ```
330
+ */
331
+ export declare function at(array: ReadonlyArray<number | Var | LinExpr | QuadExpr | Constraint>, index: number | Var | LinExpr | QuadExpr | Constraint): LinExpr;
184
332
  export {};
185
333
  //# sourceMappingURL=expression.d.ts.map