@ohtaman/washi 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/README.ja.md +149 -121
  2. package/README.md +149 -121
  3. package/README.zh-CN.md +150 -122
  4. package/THIRD_PARTY_LICENSES.md +3 -4
  5. package/dist/browser/_washi-node-only-BvRk9kiK.js +0 -0
  6. package/dist/browser/browser-runtime-TLCY0hkc.js +1793 -0
  7. package/dist/browser/highs-worker.js +21 -3
  8. package/dist/browser/highs.wasm +0 -0
  9. package/dist/browser/highs.wasm.LICENSE +1 -2
  10. package/dist/browser/loader-DewlSho8.js +643 -0
  11. package/dist/browser/solvers/glpk.js +433 -286
  12. package/dist/browser/solvers/glpk.min.js +1 -1
  13. package/dist/browser/solvers/z3.js +1008 -981
  14. package/dist/browser/solvers/z3.min.js +2 -2
  15. package/dist/browser/washi.js +2778 -673
  16. package/dist/browser/washi.min.js +3 -4
  17. package/dist/lib/_washi-node-only-BvRk9kiK.js +0 -0
  18. package/dist/lib/highs-browser-runtime.js +2120 -4124
  19. package/dist/lib/highs-node-runtime.js +24 -1
  20. package/dist/lib/highs-runtime.js +2 -0
  21. package/dist/lib/highs-worker.js +21 -3
  22. package/dist/lib/highs.wasm +0 -0
  23. package/dist/lib/highs.wasm.LICENSE +1 -2
  24. package/dist/lib/loader-BZUQNvh4.js +649 -0
  25. package/dist/lib/registry-C20sxTwm.js +964 -0
  26. package/dist/lib/solvers/glpk.js +201 -90
  27. package/dist/lib/solvers/z3.js +399 -259
  28. package/dist/lib/washi.js +2363 -1056
  29. package/dist/types/decomposition/benders.d.ts +32 -0
  30. package/dist/types/decomposition/benders.d.ts.map +1 -0
  31. package/dist/types/decomposition/column-generation.d.ts +34 -0
  32. package/dist/types/decomposition/column-generation.d.ts.map +1 -0
  33. package/dist/types/decomposition/index.d.ts +4 -0
  34. package/dist/types/decomposition/index.d.ts.map +1 -0
  35. package/dist/types/decomposition/types.d.ts +230 -0
  36. package/dist/types/decomposition/types.d.ts.map +1 -0
  37. package/dist/types/index.d.ts +5 -4
  38. package/dist/types/index.d.ts.map +1 -1
  39. package/dist/types/modeler/big-m.d.ts +75 -0
  40. package/dist/types/modeler/big-m.d.ts.map +1 -0
  41. package/dist/types/modeler/boolean-expr.d.ts +103 -14
  42. package/dist/types/modeler/boolean-expr.d.ts.map +1 -1
  43. package/dist/types/modeler/constraint.d.ts +47 -9
  44. package/dist/types/modeler/constraint.d.ts.map +1 -1
  45. package/dist/types/modeler/expression.d.ts +123 -28
  46. package/dist/types/modeler/expression.d.ts.map +1 -1
  47. package/dist/types/modeler/index.d.ts +11 -6
  48. package/dist/types/modeler/index.d.ts.map +1 -1
  49. package/dist/types/modeler/linearizer.d.ts +15 -0
  50. package/dist/types/modeler/linearizer.d.ts.map +1 -0
  51. package/dist/types/modeler/lp-writer.d.ts +30 -3
  52. package/dist/types/modeler/lp-writer.d.ts.map +1 -1
  53. package/dist/types/modeler/model.d.ts +623 -131
  54. package/dist/types/modeler/model.d.ts.map +1 -1
  55. package/dist/types/modeler/objective.d.ts +59 -0
  56. package/dist/types/modeler/objective.d.ts.map +1 -0
  57. package/dist/types/modeler/parser.d.ts +34 -10
  58. package/dist/types/modeler/parser.d.ts.map +1 -1
  59. package/dist/types/modeler/quad-expr.d.ts +26 -7
  60. package/dist/types/modeler/quad-expr.d.ts.map +1 -1
  61. package/dist/types/modeler/solution-validator.d.ts +93 -0
  62. package/dist/types/modeler/solution-validator.d.ts.map +1 -0
  63. package/dist/types/modeler/solvers/glpk/solver.d.ts +26 -2
  64. package/dist/types/modeler/solvers/glpk/solver.d.ts.map +1 -1
  65. package/dist/types/modeler/solvers/highs/browser-runtime.d.ts +2 -1
  66. package/dist/types/modeler/solvers/highs/browser-runtime.d.ts.map +1 -1
  67. package/dist/types/modeler/solvers/highs/driver.d.ts +232 -0
  68. package/dist/types/modeler/solvers/highs/driver.d.ts.map +1 -0
  69. package/dist/types/modeler/solvers/highs/index.d.ts +1 -0
  70. package/dist/types/modeler/solvers/highs/index.d.ts.map +1 -1
  71. package/dist/types/modeler/solvers/highs/loader.d.ts +38 -13
  72. package/dist/types/modeler/solvers/highs/loader.d.ts.map +1 -1
  73. package/dist/types/modeler/solvers/highs/node-runtime.d.ts +2 -1
  74. package/dist/types/modeler/solvers/highs/node-runtime.d.ts.map +1 -1
  75. package/dist/types/modeler/solvers/highs/solver.d.ts +12 -5
  76. package/dist/types/modeler/solvers/highs/solver.d.ts.map +1 -1
  77. package/dist/types/modeler/solvers/highs/worker-client.d.ts.map +1 -1
  78. package/dist/types/modeler/solvers/mock.d.ts +14 -5
  79. package/dist/types/modeler/solvers/mock.d.ts.map +1 -1
  80. package/dist/types/modeler/solvers/types.d.ts +73 -11
  81. package/dist/types/modeler/solvers/types.d.ts.map +1 -1
  82. package/dist/types/modeler/solvers/z3/loader.d.ts +2 -3
  83. package/dist/types/modeler/solvers/z3/loader.d.ts.map +1 -1
  84. package/dist/types/modeler/solvers/z3/solver.d.ts +15 -5
  85. package/dist/types/modeler/solvers/z3/solver.d.ts.map +1 -1
  86. package/dist/types/modeler/types.d.ts +86 -1
  87. package/dist/types/modeler/types.d.ts.map +1 -1
  88. package/dist/types/modeler/validation.d.ts +56 -0
  89. package/dist/types/modeler/validation.d.ts.map +1 -0
  90. package/dist/types/modeler/variable.d.ts +48 -14
  91. package/dist/types/modeler/variable.d.ts.map +1 -1
  92. package/docs/examples/diet-sensitivity.md +90 -0
  93. package/docs/examples/ecommerce-coupons.md +106 -0
  94. package/docs/examples/index.md +57 -0
  95. package/docs/examples/knapsack.md +60 -0
  96. package/docs/examples/portfolio-qp.md +83 -0
  97. package/docs/examples/production.md +51 -0
  98. package/docs/examples/shift-scheduling.md +175 -0
  99. package/docs/examples/smt-security.md +74 -0
  100. package/docs/examples/transportation.md +90 -0
  101. package/docs/examples/traveling-salesperson.md +173 -0
  102. package/docs/examples/unsat-core.md +64 -0
  103. package/docs/examples/vehicle-routing.md +206 -0
  104. package/docs/getting-started/ai-agents.md +271 -0
  105. package/docs/getting-started/cross-origin.md +87 -0
  106. package/docs/getting-started/index.md +116 -0
  107. package/docs/getting-started/runtimes.md +227 -0
  108. package/docs/guide/constraints.md +177 -0
  109. package/docs/guide/decomposition.md +399 -0
  110. package/docs/guide/expressions.md +204 -0
  111. package/docs/guide/objectives.md +170 -0
  112. package/docs/guide/unsat-core.md +154 -0
  113. package/docs/guide/variables.md +188 -0
  114. package/docs/ja/getting-started/ai-agents.md +270 -0
  115. package/docs/solvers/custom-solver.md +525 -0
  116. package/docs/solvers/glpk.md +66 -0
  117. package/docs/solvers/highs.md +115 -0
  118. package/docs/solvers/index.md +42 -0
  119. package/docs/solvers/z3.md +78 -0
  120. package/docs/zh/getting-started/ai-agents.md +270 -0
  121. package/llms-full.txt +4065 -0
  122. package/llms.txt +201 -0
  123. package/package.json +32 -16
  124. package/skills/washi/SKILL.md +197 -0
  125. package/dist/browser/browser-runtime-D13gHOT5.js +0 -4189
  126. package/dist/browser/loader-CVt4CloI.js +0 -58
  127. package/dist/lib/async-mutex-Duo4jwzn.js +0 -195
  128. package/dist/lib/constraint-BRuB3ooC.js +0 -90
  129. package/dist/lib/loader-Dti0v9yC.js +0 -50
  130. package/dist/lib/registry-DksqCSjI.js +0 -32
@@ -0,0 +1,32 @@
1
+ import type { BendersOptions, BendersResult } from "./types.js";
2
+ /**
3
+ * Solve a problem using Benders Decomposition.
4
+ *
5
+ * Benders Decomposition partitions a problem into a Master Problem (containing complicating variables,
6
+ * such as discrete binary/integer design decisions, and an auxiliary objective estimator variable)
7
+ * and a Subproblem (typically a continuous LP or independent operational model).
8
+ *
9
+ * The master problem is solved iteratively, passing its tentative decision values to the subproblem callback.
10
+ * The subproblem callback evaluates feasibility and optimality, returning Benders Optimality Cuts or
11
+ * Feasibility Cuts to be dynamically added to the master until bounds converge.
12
+ *
13
+ * @param options Benders options including master model and subproblem callback
14
+ * @returns Result object containing status, objective, bounds, gap, iterations, and variable values
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * const result = await master.solveBenders({
19
+ * subproblem: () => {
20
+ * const sub = new Model("OperationalSub");
21
+ * const x = sub.continuous("x", { lb: 0 });
22
+ * sub.objective(minimize(expr`2 * ${x}`));
23
+ * sub.constraint(expr`${x} >= 30`, "demand");
24
+ * sub.link(expr`${x} <= 50 * ${openVar}`);
25
+ * return sub;
26
+ * },
27
+ * gapTolerance: 1e-4,
28
+ * });
29
+ * ```
30
+ */
31
+ export declare function solveBenders(options: BendersOptions): Promise<BendersResult>;
32
+ //# sourceMappingURL=benders.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,34 @@
1
+ import type { ColumnGenerationOptions, ColumnGenerationResult } from "./types.js";
2
+ /**
3
+ * Solve a problem using Column Generation (Dantzig-Wolfe decomposition).
4
+ *
5
+ * Column Generation starts with a Restricted Master Problem (RMP) containing a small set of initial columns,
6
+ * repeatedly solves its continuous LP relaxation to obtain dual values (shadow prices), and calls a user-provided
7
+ * `pricing` subproblem callback to identify new columns with improving reduced costs.
8
+ * Once no improving columns exist, it optionally solves the master as a Mixed-Integer Program (MIP)
9
+ * to produce an integer solution.
10
+ *
11
+ * @param options Column generation options including master model and pricing callback
12
+ * @returns Result object containing status, objective, iterations, columns added, and final variable values
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * const result = await master.solveColumnGeneration({
17
+ * pricing: async () => {
18
+ * const sub = new Model("Pricing");
19
+ * const a = sub.integer("a", { lb: 0, ub: 2 });
20
+ * sub.objective(maximize(expr`${(demandA.dual ?? 0)} * ${a}`));
21
+ * sub.constraint(expr`45 * ${a} <= 100`);
22
+ * await sub.solve();
23
+ * return {
24
+ * cost: 1,
25
+ * type: "Integer",
26
+ * coefficients: { demand_A: a.value ?? 0 },
27
+ * };
28
+ * },
29
+ * finalizeAsMIP: true,
30
+ * });
31
+ * ```
32
+ */
33
+ export declare function solveColumnGeneration<TColumnMeta = unknown>(options: ColumnGenerationOptions<TColumnMeta>): Promise<ColumnGenerationResult<TColumnMeta>>;
34
+ //# sourceMappingURL=column-generation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"column-generation.d.ts","sourceRoot":"","sources":["../../../src/decomposition/column-generation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uBAAuB,EACvB,sBAAsB,EAGvB,MAAM,YAAY,CAAC;AAKpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAsB,qBAAqB,CAAC,WAAW,GAAG,OAAO,EAC/D,OAAO,EAAE,uBAAuB,CAAC,WAAW,CAAC,GAC5C,OAAO,CAAC,sBAAsB,CAAC,WAAW,CAAC,CAAC,CA4K9C"}
@@ -0,0 +1,4 @@
1
+ export * from "./types.js";
2
+ export * from "./column-generation.js";
3
+ export * from "./benders.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/decomposition/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC"}
@@ -0,0 +1,230 @@
1
+ import type { Model } from "../modeler/model.js";
2
+ import type { Var } from "../modeler/variable.js";
3
+ import type { Constraint } from "../modeler/constraint.js";
4
+ import type { ParsedExpr } from "../modeler/parser.js";
5
+ import type { SolverStatus, SolverSolution, SolverOptions, Solver, VarType } from "../modeler/index.js";
6
+ /**
7
+ * Definition of a newly proposed column generated by a pricing subproblem.
8
+ */
9
+ export interface ColumnProposal<TColumnMeta = unknown> {
10
+ /** Optional variable name for the column */
11
+ name?: string;
12
+ /** Variable domain type (defaults to "Continuous" during LP relaxation, cast to "Integer" during MIP finalization if requested) */
13
+ type?: VarType;
14
+ /** Variable lower bound (default: 0) */
15
+ lb?: number;
16
+ /** Variable upper bound (default: Infinity) */
17
+ ub?: number;
18
+ /** Objective cost coefficient */
19
+ cost: number;
20
+ /**
21
+ * Constraint coefficients for this column.
22
+ * Can be a record keyed by constraint name, Map of Constraint/name to coefficient,
23
+ * or an array of [constraint, coeff] tuples.
24
+ */
25
+ coefficients: Record<string, number> | Map<Constraint | string, number> | Array<[Constraint | string, number]> | Array<{
26
+ constraint: Constraint | string;
27
+ coeff: number;
28
+ }>;
29
+ /**
30
+ * Optional reduced cost computed by the subproblem.
31
+ * For minimization: negative values improve the master objective.
32
+ * For maximization: positive values improve the master objective.
33
+ */
34
+ reducedCost?: number;
35
+ /** Optional domain-specific metadata attached to this column (e.g. pattern vector) */
36
+ meta?: TColumnMeta;
37
+ }
38
+ /**
39
+ * Context provided to the pricing subproblem callback on each Column Generation iteration.
40
+ */
41
+ export interface PricingContext<TColumnMeta = unknown> {
42
+ /** 1-based iteration index */
43
+ iteration: number;
44
+ /** Constraint shadow prices (duals) from the master LP relaxation, keyed by canonical constraint name */
45
+ duals: Record<string, number>;
46
+ /** Helper to retrieve the dual value (shadow price) of a specific constraint */
47
+ getDual: (constraintOrName: Constraint | string) => number;
48
+ /** Full solution payload of the restricted master LP relaxation */
49
+ masterSolution: SolverSolution;
50
+ /** Numerical tolerance for reduced cost optimality check */
51
+ reducedCostTolerance: number;
52
+ /** Master model instance */
53
+ master: Model;
54
+ }
55
+ /**
56
+ * Progress event emitted on each Column Generation iteration.
57
+ */
58
+ export interface ColumnGenerationIterationInfo<TColumnMeta = unknown> {
59
+ iteration: number;
60
+ relaxationObjective: number | null;
61
+ columnsAdded: number;
62
+ proposedColumns: Array<ColumnProposal<TColumnMeta>>;
63
+ }
64
+ /**
65
+ * Options for `solveColumnGeneration`
66
+ */
67
+ export interface ColumnGenerationOptions<TColumnMeta = unknown> {
68
+ /** Restricted Master Problem (RMP) model containing initial columns and constraints (optional when called via `master.solveColumnGeneration(...)`) */
69
+ master?: Model;
70
+ /**
71
+ * Pricing subproblem generator callback.
72
+ * Receives constraint duals (shadow prices) and returns one or more new columns with improving reduced costs,
73
+ * or `null` / `[]` when no improving columns exist (LP relaxation is optimal).
74
+ */
75
+ pricing: (context: PricingContext<TColumnMeta>) => Promise<ColumnProposal<TColumnMeta> | ColumnProposal<TColumnMeta>[] | null | undefined> | ColumnProposal<TColumnMeta> | ColumnProposal<TColumnMeta>[] | null | undefined;
76
+ /** Maximum number of column generation iterations (default: 100) */
77
+ maxIterations?: number;
78
+ /**
79
+ * Numerical tolerance to test if reduced cost improves the objective (default: 1e-6).
80
+ * For minimization, column is accepted if `reducedCost < -reducedCostTolerance`.
81
+ * For maximization, column is accepted if `reducedCost > reducedCostTolerance`.
82
+ */
83
+ reducedCostTolerance?: number;
84
+ /**
85
+ * Whether to solve the final Restricted Master Problem as a Mixed-Integer Program (MIP)
86
+ * after column generation terminates (default: true).
87
+ * When true, integer/binary columns generate an exact integer solution.
88
+ */
89
+ finalizeAsMIP?: boolean;
90
+ /** Solver name or instance to use for master problem (defaults to HiGHS) */
91
+ solver?: Solver | string;
92
+ /** Solver options passed to master solves */
93
+ solverOptions?: SolverOptions;
94
+ /** Optional callback invoked on each iteration */
95
+ onIteration?: (info: ColumnGenerationIterationInfo<TColumnMeta>) => void;
96
+ }
97
+ /**
98
+ * Result returned by `solveColumnGeneration`
99
+ */
100
+ export interface ColumnGenerationResult<TColumnMeta = unknown> {
101
+ /** Final solver status ("Optimal", "Feasible", "Infeasible", etc.) */
102
+ status: SolverStatus;
103
+ /** Objective value of the final solution (MIP objective if finalized, otherwise LP relaxation objective) */
104
+ objectiveValue: number | null;
105
+ /** Optimal objective value of the continuous LP relaxation (theoretical dual bound) */
106
+ relaxationObjectiveValue: number | null;
107
+ /** Total number of column generation iterations performed */
108
+ iterations: number;
109
+ /** Total number of columns dynamically generated and injected into the master */
110
+ columnsAdded: number;
111
+ /** All dynamically generated columns and their associated `Var` handles */
112
+ generatedColumns: Array<{
113
+ variable: Var;
114
+ proposal: ColumnProposal<TColumnMeta>;
115
+ }>;
116
+ /** The master model containing all generated columns and the final solution state */
117
+ master: Model;
118
+ /** Primal variable values of the final solution */
119
+ values: Record<string, number>;
120
+ }
121
+ /**
122
+ * Definition of a Benders cut (optimality cut or feasibility cut) to be added to the master problem.
123
+ */
124
+ export interface BendersCut {
125
+ /**
126
+ * Cut classification:
127
+ * - "optimality": Benders optimality cut bounding the master auxiliary objective variable theta
128
+ * - "feasibility": Benders feasibility cut cutting off an infeasible subproblem candidate
129
+ */
130
+ kind: "optimality" | "feasibility";
131
+ /** The linear constraint expression representing the cut */
132
+ constraint: Constraint | ParsedExpr;
133
+ /** Optional cut constraint name */
134
+ name?: string;
135
+ /** Optional subproblem objective or diagnostic value */
136
+ subproblemObjective?: number;
137
+ /** Optional dual values used to generate the cut */
138
+ dualValues?: Record<string, number>;
139
+ }
140
+ /**
141
+ * Context provided to the Benders subproblem callback on each iteration.
142
+ */
143
+ export interface BendersSubproblemContext {
144
+ /** 1-based iteration index */
145
+ iteration: number;
146
+ /** Primal values of master decision variables from the current master solution */
147
+ masterValues: Record<string, number>;
148
+ /** Helper to look up the primal value of a master variable */
149
+ getMasterValue: (v: Var | string) => number;
150
+ /** Current master objective value */
151
+ masterObjective: number | null;
152
+ /** Current best lower bound */
153
+ lowerBound?: number;
154
+ /** Current best upper bound */
155
+ upperBound?: number;
156
+ /** Master model instance */
157
+ master: Model;
158
+ }
159
+ /**
160
+ * Progress event emitted on each Benders decomposition iteration.
161
+ */
162
+ export interface BendersIterationInfo {
163
+ iteration: number;
164
+ masterObjective: number | null;
165
+ lowerBound?: number;
166
+ upperBound?: number;
167
+ cutsAdded: number;
168
+ proposedCuts: BendersCut[];
169
+ }
170
+ /**
171
+ * Result returned by a Benders subproblem callback.
172
+ * Can be:
173
+ * - A subproblem `Model` (with linking constraints registered via `sub.link(...)`) for automatic Benders cut generation,
174
+ * - Or `BendersCut | BendersCut[] | null | undefined` for manual cut definition.
175
+ */
176
+ export type BendersSubproblemResult = Model | BendersCut | BendersCut[] | null | undefined;
177
+ /**
178
+ * Options for `solveBenders`
179
+ */
180
+ export interface BendersOptions {
181
+ /** Master problem model containing master variables (optional when called via `master.solveBenders(...)`) */
182
+ master?: Model;
183
+ /**
184
+ * Subproblem evaluation callback.
185
+ * Evaluates the subproblem given current master decisions.
186
+ * Can return a subproblem `Model` (with linking constraints registered via `sub.link(...)`) for automatic Benders cut generation,
187
+ * or manual `BendersCut | BendersCut[] | null | undefined`.
188
+ */
189
+ subproblem: (context: BendersSubproblemContext) => Promise<BendersSubproblemResult> | BendersSubproblemResult;
190
+ /**
191
+ * Optional reference to the auxiliary theta variable in the master model.
192
+ * If not provided, WaSHI automatically detects a variable named "theta" / "__benders_theta"
193
+ * or injects an auxiliary continuous theta variable into the master objective.
194
+ */
195
+ theta?: Var | string;
196
+ /** Maximum number of Benders iterations (default: 100) */
197
+ maxIterations?: number;
198
+ /** Relative optimality gap convergence tolerance `|upper - lower| / (|upper| + 1e-10)` (default: 1e-4) */
199
+ gapTolerance?: number;
200
+ /** Solver name or instance to use for master problem */
201
+ solver?: Solver | string;
202
+ /** Solver options passed to master solves */
203
+ solverOptions?: SolverOptions;
204
+ /** Optional callback invoked on each iteration */
205
+ onIteration?: (info: BendersIterationInfo) => void;
206
+ }
207
+ /**
208
+ * Result returned by `solveBenders`
209
+ */
210
+ export interface BendersResult {
211
+ /** Final solver status ("Optimal", "Feasible", "Infeasible", etc.) */
212
+ status: SolverStatus;
213
+ /** Final objective value */
214
+ objectiveValue: number | null;
215
+ /** Best lower bound achieved */
216
+ lowerBound?: number;
217
+ /** Best upper bound achieved */
218
+ upperBound?: number;
219
+ /** Final relative optimality gap */
220
+ gap?: number;
221
+ /** Number of iterations performed */
222
+ iterations: number;
223
+ /** Number of Benders cuts added to the master problem */
224
+ cutsAdded: number;
225
+ /** Master model containing all generated cuts and final solution */
226
+ master: Model;
227
+ /** Final primal values of master decision variables */
228
+ values: Record<string, number>;
229
+ }
230
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/decomposition/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,EACV,YAAY,EACZ,cAAc,EACd,aAAa,EACb,MAAM,EACN,OAAO,EACR,MAAM,qBAAqB,CAAC;AAE7B;;GAEG;AACH,MAAM,WAAW,cAAc,CAAC,WAAW,GAAG,OAAO;IACnD,4CAA4C;IAC5C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mIAAmI;IACnI,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,wCAAwC;IACxC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,+CAA+C;IAC/C,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,YAAY,EACR,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACtB,GAAG,CAAC,UAAU,GAAG,MAAM,EAAE,MAAM,CAAC,GAChC,KAAK,CAAC,CAAC,UAAU,GAAG,MAAM,EAAE,MAAM,CAAC,CAAC,GACpC,KAAK,CAAC;QAAE,UAAU,EAAE,UAAU,GAAG,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC9D;;;;OAIG;IACH,WAAW,CAA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6C;IAC7C,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,kDAAkD;IAClD,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,oBAAoB,KAAK,IAAI,CAAC;CACpD;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,sEAAsE;IACtE,MAAM,EAAE,YAAY,CAAC;IACrB,4BAA4B;IAC5B,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,gCAAgC;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gCAAgC;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oCAAoC;IACpC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,qCAAqC;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,yDAAyD;IACzD,SAAS,EAAE,MAAM,CAAC;IAClB,oEAAoE;IACpE,MAAM,EAAE,KAAK,CAAC;IACd,uDAAuD;IACvD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChC"}
@@ -4,8 +4,9 @@
4
4
  * Domain-pure algebraic modeling with WebAssembly (HiGHS, Z3, GLPK) and pluggable solvers.
5
5
  * Supports LP (Linear Programming), MIP (Mixed-Integer Programming), QP (Quadratic Programming), and SMT.
6
6
  */
7
- export { Model, type ModelOptions, type BoundsOptions, Var, type VarOptions, LinExpr, QuadExpr, type Expr, type QuadTerm, sum, dot, Constraint, BoolVar, BoolExpr, BoolOp, and, or, not, implies, xor, parseExpr, parseConstraint, expr, c, generateLpString, type LpModelData, type LpExportResult, } from "./modeler/index.js";
8
- export { normalizeSense, type VarType, type OptimizationSense, type ComparisonSense, type SolverStatus, type SolveOptions, type SolverSolution, } from "./modeler/types.js";
9
- export { type Solver, type SolverOptions, type SolverResult, type SolverCheckResult, type SolverCapabilities, HighsSolver, HiGHS, MockSolver, registerSolver, getSolver, setDefaultSolver, listAvailableSolvers, } from "./modeler/solvers/index.js";
10
- export { getHighs, solveLpWithHighs, setHighsWasmUrl, getHighsWasmUrl, OFFICIAL_HIGHS_CDN_WASM_URL, isValidWasmHeader, probeWasmUrl, resolveBrowserWasmUrl, } from "./modeler/solvers/highs/index.js";
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";
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
+ 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
+ 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";
11
+ export { getHighs, solveLpWithHighs, setHighsWasmUrl, getHighsWasmUrl, Highs, type HighsSolutionResult, type HighsSolutionColumn, type HighsSolutionRow, } from "./modeler/solvers/highs/index.js";
11
12
  //# sourceMappingURL=index.d.ts.map
@@ -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,GAAG,EACH,KAAK,UAAU,EACf,OAAO,EACP,QAAQ,EACR,KAAK,IAAI,EACT,KAAK,QAAQ,EACb,GAAG,EACH,GAAG,EACH,UAAU,EACV,OAAO,EACP,QAAQ,EACR,MAAM,EACN,GAAG,EACH,EAAE,EACF,GAAG,EACH,OAAO,EACP,GAAG,EACH,SAAS,EACT,eAAe,EACf,IAAI,EACJ,CAAC,EACD,gBAAgB,EAChB,KAAK,WAAW,EAChB,KAAK,cAAc,GACpB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,cAAc,EACd,KAAK,OAAO,EACZ,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,cAAc,GACpB,MAAM,oBAAoB,CAAC;AAI5B,OAAO,EACL,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,WAAW,EACX,KAAK,EACL,UAAU,EACV,cAAc,EACd,SAAS,EACT,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EACL,QAAQ,EACR,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,2BAA2B,EAC3B,iBAAiB,EACjB,YAAY,EACZ,qBAAqB,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,KAA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AAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,KAAK,aAAa,GACnB,MAAM,0BAA0B,CAAC;AAIlC,OAAO,EACL,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC1B,WAAW,EACX,KAAK,EACL,UAAU,EACV,KAAK,iBAAiB,EACtB,cAAc,EACd,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"}
@@ -0,0 +1,75 @@
1
+ import { LinExpr } from "./expression.js";
2
+ import { Var } from "./variable.js";
3
+ /**
4
+ * Options for indicator constraints with Big-M linearization.
5
+ */
6
+ export interface IndicatorOptions {
7
+ /**
8
+ * The binary variable value (0 or 1) that activates the constraint.
9
+ * Defaults to 1 (i.e. constraint holds when binVar == 1).
10
+ */
11
+ activeValue?: 0 | 1;
12
+ /**
13
+ * Explicit Big-M scalar value override.
14
+ * If omitted, WaSHI automatically derives a safe, tight Big-M from the
15
+ * linear expression terms and finite variable bounds.
16
+ * If provided, it must be a finite positive number.
17
+ *
18
+ * Note: The user is responsible for ensuring that a custom M is sufficiently
19
+ * large to avoid truncating valid solutions while small enough to maintain
20
+ * numerical stability.
21
+ */
22
+ M?: number;
23
+ /**
24
+ * Base name for generated linear constraints.
25
+ */
26
+ name?: string;
27
+ }
28
+ /**
29
+ * Validates a user-supplied Big-M override value.
30
+ * Must be a finite positive number (> 0).
31
+ */
32
+ export declare function validateUserBigM(M: number, constraintName: string): void;
33
+ /**
34
+ * Derives a sufficient, tight Big-M value for a "<=" linear inequality:
35
+ * lhs <= rhs (or terms <= effectiveRhs)
36
+ *
37
+ * When the indicator variable is inactive, the relaxed constraint becomes:
38
+ * terms <= effectiveRhs + M
39
+ *
40
+ * For the constraint to be trivially satisfied over all domain values x in [lb, ub]:
41
+ * effectiveRhs + M >= max(terms) <=> M >= max(terms) - effectiveRhs
42
+ *
43
+ * Therefore, the safe tight non-negative Big-M is:
44
+ * M = max(0, max(terms) - effectiveRhs)
45
+ *
46
+ * Fails with an actionable error if any variable lacks a required finite bound
47
+ * or if finite arithmetic overflows.
48
+ */
49
+ export declare function deriveBigMForLe(lhs: LinExpr, rhs: number, constraintName: string): number;
50
+ /**
51
+ * Derives a sufficient, tight Big-M value for a ">=" linear inequality:
52
+ * lhs >= rhs (or terms >= effectiveRhs)
53
+ *
54
+ * When the indicator variable is inactive, the relaxed constraint becomes:
55
+ * terms >= effectiveRhs - M
56
+ *
57
+ * For the constraint to be trivially satisfied over all domain values x in [lb, ub]:
58
+ * effectiveRhs - M <= min(terms) <=> M >= effectiveRhs - min(terms)
59
+ *
60
+ * Therefore, the safe tight non-negative Big-M is:
61
+ * M = max(0, effectiveRhs - min(terms))
62
+ *
63
+ * Fails with an actionable error if any variable lacks a required finite bound
64
+ * or if finite arithmetic overflows.
65
+ */
66
+ export declare function deriveBigMForGe(lhs: LinExpr, rhs: number, constraintName: string): number;
67
+ /**
68
+ * Constructs the linearized LHS and RHS for a single directional indicator constraint
69
+ * and verifies that all resulting coefficients and shifted RHS values remain finite.
70
+ */
71
+ export declare function buildIndicatorLinearization(binVar: Var, lhs: LinExpr, sense: "<=" | ">=", rhs: number, activeVal: 0 | 1, M: number, constraintName: string): {
72
+ lhs: LinExpr;
73
+ rhs: number;
74
+ };
75
+ //# sourceMappingURL=big-m.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"big-m.d.ts","sourceRoot":"","sources":["../../../src/modeler/big-m.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,WAAW,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IAEpB;;;;;;;;;OASG;IACH,CAAC,CAAC,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,IAAI,CAMxE;AA6CD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,MAAM,EACX,cAAc,EAAE,MAAM,GACrB,MAAM,CAyDR;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,MAAM,EACX,cAAc,EAAE,MAAM,GACrB,MAAM,CAyDR;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,GAAG,EACX,GAAG,EAAE,OAAO,EACZ,KAAK,EAAE,IAAI,GAAG,IAAI,EAClB,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,CAAC,GAAG,CAAC,EAChB,CAAC,EAAE,MAAM,EACT,cAAc,EAAE,MAAM,GACrB;IAAE,GAAG,EAAE,OAAO,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAsF/B"}
@@ -1,18 +1,31 @@
1
- import type { Constraint } from "./constraint.js";
1
+ import { Constraint } from "./constraint.js";
2
+ import type { LinExpr } from "./expression.js";
3
+ import type { QuadExpr } from "./quad-expr.js";
2
4
  export type LogicalOpType = "and" | "or" | "not" | "implies" | "xor" | "eq";
3
5
  export type LogicElement = BoolExpr | Constraint;
6
+ export type LogicInput = LogicElement | LinExpr | QuadExpr;
4
7
  /**
5
- * Base abstract class for Boolean expressions in SMT / SAT
8
+ * Base abstract class for propositional / SMT Boolean expressions (`BoolVar` and `BoolOp`).
9
+ *
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.
6
12
  */
7
13
  export declare abstract class BoolExpr {
8
- and(other: LogicElement): BoolOp;
9
- or(other: LogicElement): BoolOp;
10
- implies(consequent: LogicElement): BoolOp;
11
- xor(other: LogicElement): BoolOp;
14
+ /** Logical conjunction (`this AND other`). Requires a `BoolVar`, `BoolExpr`, or comparison `Constraint`. */
15
+ and(other: LogicInput): BoolOp;
16
+ /** Logical disjunction (`this OR other`). Requires a `BoolVar`, `BoolExpr`, or comparison `Constraint`. */
17
+ or(other: LogicInput): BoolOp;
18
+ /** Logical implication (`this => consequent`). Requires a `BoolVar`, `BoolExpr`, or comparison `Constraint`. */
19
+ implies(consequent: LogicInput): BoolOp;
20
+ /** Logical exclusive-or (`this XOR other`). Requires a `BoolVar`, `BoolExpr`, or comparison `Constraint`. */
21
+ xor(other: LogicInput): BoolOp;
22
+ /** Logical negation (`NOT this`). */
12
23
  not(): BoolOp;
13
24
  }
14
25
  /**
15
- * Boolean variable (propositional variable in SAT / SMT)
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.
16
29
  */
17
30
  export declare class BoolVar extends BoolExpr {
18
31
  readonly id: number;
@@ -22,17 +35,93 @@ export declare class BoolVar extends BoolExpr {
22
35
  toString(): string;
23
36
  }
24
37
  /**
25
- * Compound Boolean operator AST node (And, Or, Not, Implies, Xor)
38
+ * Compound Boolean operator AST node (`and`, `or`, `not`, `implies`, `xor`).
26
39
  */
27
40
  export declare class BoolOp extends BoolExpr {
28
41
  readonly op: LogicalOpType;
29
42
  readonly children: LogicElement[];
30
- constructor(op: LogicalOpType, children: LogicElement[]);
43
+ constructor(op: LogicalOpType, children: LogicInput[]);
31
44
  toString(): string;
32
45
  }
33
- export declare function and(...exprs: LogicElement[]): BoolOp;
34
- export declare function or(...exprs: LogicElement[]): BoolOp;
35
- export declare function not(expr: LogicElement): BoolOp;
36
- export declare function implies(antecedent: LogicElement, consequent: LogicElement): BoolOp;
37
- export declare function xor(...exprs: LogicElement[]): BoolOp;
46
+ /**
47
+ * Logical conjunction (`e1 AND e2 AND ...`) over `BoolVar`, `BoolExpr`, or linear comparison `Constraint`s.
48
+ *
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.
53
+ *
54
+ * @example
55
+ * ```ts
56
+ * const m = new Model("AndExample", { solver: "z3" });
57
+ * const a = m.bool("a");
58
+ * const x = m.integer("x", { lb: 0, ub: 20 });
59
+ * m.constraint(and(a, expr`${x} >= 10`), "both_active");
60
+ * ```
61
+ */
62
+ export declare function and(...exprs: LogicInput[]): BoolOp;
63
+ /**
64
+ * Logical disjunction (`e1 OR e2 OR ...`) over `BoolVar`, `BoolExpr`, or linear comparison `Constraint`s.
65
+ *
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.
70
+ *
71
+ * @example
72
+ * ```ts
73
+ * const m = new Model("OrExample", { solver: "z3" });
74
+ * const x = m.integer("x", { lb: 0, ub: 20 });
75
+ * m.constraint(or(expr`${x} <= 5`, expr`${x} >= 15`), "disjoint_range");
76
+ * ```
77
+ */
78
+ export declare function or(...exprs: LogicInput[]): BoolOp;
79
+ /**
80
+ * Logical negation (`NOT e`) of a `BoolVar`, `BoolExpr`, or linear comparison `Constraint`.
81
+ *
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.
85
+ *
86
+ * @example
87
+ * ```ts
88
+ * const m = new Model("NotExample", { solver: "z3" });
89
+ * const blocked = m.bool("blocked");
90
+ * m.constraint(not(blocked), "must_not_be_blocked");
91
+ * ```
92
+ */
93
+ export declare function not(expr: LogicInput): BoolOp;
94
+ /**
95
+ * Logical implication (`antecedent => consequent`) over `BoolVar`, `BoolExpr`, or linear comparison `Constraint`s.
96
+ *
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).
101
+ *
102
+ * @example
103
+ * ```ts
104
+ * const m = new Model("ImpliesExample", { solver: "z3" });
105
+ * const vip = m.bool("vip");
106
+ * const discount = m.integer("discount", { lb: 0, ub: 50 });
107
+ * m.constraint(implies(vip, expr`${discount} >= 20`), "vip_min_discount");
108
+ * ```
109
+ */
110
+ export declare function implies(antecedent: LogicInput, consequent: LogicInput): BoolOp;
111
+ /**
112
+ * Logical exclusive-or (`e1 XOR e2 ...`) over `BoolVar`, `BoolExpr`, or linear comparison `Constraint`s.
113
+ *
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.
117
+ *
118
+ * @example
119
+ * ```ts
120
+ * const m = new Model("XorExample", { solver: "z3" });
121
+ * const shiftA = m.bool("shiftA");
122
+ * const shiftB = m.bool("shiftB");
123
+ * m.constraint(xor(shiftA, shiftB), "exactly_one_shift");
124
+ * ```
125
+ */
126
+ export declare function xor(...exprs: LogicInput[]): BoolOp;
38
127
  //# 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,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAIlD,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;;GAEG;AACH,8BAAsB,QAAQ;IACrB,GAAG,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,CAEtC;IAEM,EAAE,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,CAErC;IAEM,OAAO,CAAC,UAAU,EAAE,YAAY,GAAG,MAAM,CAE/C;IAEM,GAAG,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,CAEtC;IAEM,GAAG,IAAI,MAAM,CAEnB;CACF;AAED;;GAEG;AACH,qBAAa,OAAQ,SAAQ,QAAQ;IACnC,SAAgB,EAAE,EAAE,MAAM,CAAC;IAC3B,SAAgB,IAAI,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,OAAO,GAAG,IAAI,CAAQ;IAEpC,YAAY,IAAI,CAAC,EAAE,MAAM,EAIxB;IAED,QAAQ,IAAI,MAAM,CAEjB;CACF;AAED;;GAEG;AACH,qBAAa,MAAO,SAAQ,QAAQ;IAClC,SAAgB,EAAE,EAAE,aAAa,CAAC;IAClC,SAAgB,QAAQ,EAAE,YAAY,EAAE,CAAC;IAEzC,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