@ohtaman/washi 0.0.0-stage → 0.1.1

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 (65) hide show
  1. package/LICENSE +21 -0
  2. package/README.ja.md +381 -0
  3. package/README.md +380 -2
  4. package/README.zh-CN.md +381 -0
  5. package/THIRD_PARTY_LICENSES.md +83 -0
  6. package/dist/lib/assets/highs-worker-DeDWU6KI.js +3 -0
  7. package/dist/lib/demo/highs.wasm +0 -0
  8. package/dist/lib/glpk-BC32ZaPG.js +126 -0
  9. package/dist/lib/highs.wasm +0 -0
  10. package/dist/lib/highs.wasm.LICENSE +22 -0
  11. package/dist/lib/solvers/glpk.js +2 -0
  12. package/dist/lib/solvers/z3.js +2 -0
  13. package/dist/lib/washi-logo.png +0 -0
  14. package/dist/lib/washi-logo.svg +70 -0
  15. package/dist/lib/washi.js +908 -0
  16. package/dist/lib/z3-C8g-PtmP.js +582 -0
  17. package/dist/types/glpk-loader.d.ts +8 -0
  18. package/dist/types/glpk-loader.d.ts.map +1 -0
  19. package/dist/types/highs-loader.d.ts +55 -0
  20. package/dist/types/highs-loader.d.ts.map +1 -0
  21. package/dist/types/highs-worker-client.d.ts +12 -0
  22. package/dist/types/highs-worker-client.d.ts.map +1 -0
  23. package/dist/types/highs-worker.d.ts +2 -0
  24. package/dist/types/highs-worker.d.ts.map +1 -0
  25. package/dist/types/index.d.ts +14 -0
  26. package/dist/types/index.d.ts.map +1 -0
  27. package/dist/types/modeler/boolean-expr.d.ts +38 -0
  28. package/dist/types/modeler/boolean-expr.d.ts.map +1 -0
  29. package/dist/types/modeler/constraint.d.ts +28 -0
  30. package/dist/types/modeler/constraint.d.ts.map +1 -0
  31. package/dist/types/modeler/expression.d.ts +79 -0
  32. package/dist/types/modeler/expression.d.ts.map +1 -0
  33. package/dist/types/modeler/index.d.ts +14 -0
  34. package/dist/types/modeler/index.d.ts.map +1 -0
  35. package/dist/types/modeler/lp-writer.d.ts +30 -0
  36. package/dist/types/modeler/lp-writer.d.ts.map +1 -0
  37. package/dist/types/modeler/mip-compat.d.ts +43 -0
  38. package/dist/types/modeler/mip-compat.d.ts.map +1 -0
  39. package/dist/types/modeler/model.d.ts +156 -0
  40. package/dist/types/modeler/model.d.ts.map +1 -0
  41. package/dist/types/modeler/parser.d.ts +27 -0
  42. package/dist/types/modeler/parser.d.ts.map +1 -0
  43. package/dist/types/modeler/pulp-compat.d.ts +67 -0
  44. package/dist/types/modeler/pulp-compat.d.ts.map +1 -0
  45. package/dist/types/modeler/quad-expr.d.ts +55 -0
  46. package/dist/types/modeler/quad-expr.d.ts.map +1 -0
  47. package/dist/types/modeler/solvers/glpk.d.ts +22 -0
  48. package/dist/types/modeler/solvers/glpk.d.ts.map +1 -0
  49. package/dist/types/modeler/solvers/highs.d.ts +26 -0
  50. package/dist/types/modeler/solvers/highs.d.ts.map +1 -0
  51. package/dist/types/modeler/solvers/index.d.ts +7 -0
  52. package/dist/types/modeler/solvers/index.d.ts.map +1 -0
  53. package/dist/types/modeler/solvers/mock.d.ts +25 -0
  54. package/dist/types/modeler/solvers/mock.d.ts.map +1 -0
  55. package/dist/types/modeler/solvers/registry.d.ts +20 -0
  56. package/dist/types/modeler/solvers/registry.d.ts.map +1 -0
  57. package/dist/types/modeler/solvers/types.d.ts +86 -0
  58. package/dist/types/modeler/solvers/types.d.ts.map +1 -0
  59. package/dist/types/modeler/solvers/z3.d.ts +37 -0
  60. package/dist/types/modeler/solvers/z3.d.ts.map +1 -0
  61. package/dist/types/modeler/types.d.ts +27 -0
  62. package/dist/types/modeler/types.d.ts.map +1 -0
  63. package/dist/types/modeler/variable.d.ts +52 -0
  64. package/dist/types/modeler/variable.d.ts.map +1 -0
  65. package/package.json +98 -4
@@ -0,0 +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,GAAG,EACH,KAAK,UAAU,EACf,OAAO,EACP,GAAG,EACH,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,KAAK,QAAQ,EACb,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;AAG5B,YAAY,EACV,OAAO,EACP,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,cAAc,GACf,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,SAAS,EACT,UAAU,EACV,UAAU,EACV,UAAU,EACV,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,KAAK,GACN,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,OAAO,EACP,MAAM,EACN,QAAQ,EACR,QAAQ,GACT,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EACL,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,WAAW,EACX,KAAK,EACL,UAAU,EACV,QAAQ,EACR,gBAAgB,EAChB,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,mBAAmB,CAAC;AAC3B,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,38 @@
1
+ import type { Constraint } from "./constraint.js";
2
+ export type LogicalOpType = "and" | "or" | "not" | "implies" | "xor" | "eq";
3
+ export type LogicElement = BoolExpr | Constraint;
4
+ /**
5
+ * Base abstract class for Boolean expressions in SMT / SAT
6
+ */
7
+ 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;
12
+ not(): BoolOp;
13
+ }
14
+ /**
15
+ * Boolean variable (propositional variable in SAT / SMT)
16
+ */
17
+ export declare class BoolVar extends BoolExpr {
18
+ readonly id: number;
19
+ readonly name: string;
20
+ value: boolean | null;
21
+ constructor(name?: string);
22
+ toString(): string;
23
+ }
24
+ /**
25
+ * Compound Boolean operator AST node (And, Or, Not, Implies, Xor)
26
+ */
27
+ export declare class BoolOp extends BoolExpr {
28
+ readonly op: LogicalOpType;
29
+ readonly children: LogicElement[];
30
+ constructor(op: LogicalOpType, children: LogicElement[]);
31
+ toString(): string;
32
+ }
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;
38
+ //# sourceMappingURL=boolean-expr.d.ts.map
@@ -0,0 +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,YAAY,EAAE,EAAE,aAAa,EAAE,QAAQ,EAAE,YAAY,EAAE,EAItD;IAED,QAAQ,IAAI,MAAM,CAKjB;CACF;AAGD,wBAAgB,GAAG,CAAC,GAAG,KAAK,EAAE,YAAY,EAAE,GAAG,MAAM,CAGpD;AAED,wBAAgB,EAAE,CAAC,GAAG,KAAK,EAAE,YAAY,EAAE,GAAG,MAAM,CAGnD;AAED,wBAAgB,GAAG,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,CAE9C;AAED,wBAAgB,OAAO,CAAC,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,GAAG,MAAM,CAElF;AAED,wBAAgB,GAAG,CAAC,GAAG,KAAK,EAAE,YAAY,EAAE,GAAG,MAAM,CAGpD"}
@@ -0,0 +1,28 @@
1
+ import type { ComparisonSense } from "./types.js";
2
+ import type { LinExpr } from "./expression.js";
3
+ import { BoolOp, type LogicElement } from "./boolean-expr.js";
4
+ /**
5
+ * Represents a linear constraint: lhs (terms) <=, >=, or == rhs (constant)
6
+ * Compatible with PuLP (LpConstraint) and python-mip (Constr).
7
+ */
8
+ export declare class Constraint {
9
+ readonly id: number;
10
+ lhs: LinExpr;
11
+ sense: ComparisonSense;
12
+ rhs: number;
13
+ name: string;
14
+ /** Slack value after solve */
15
+ slack: number | null;
16
+ /** Dual value (shadow price) after solve */
17
+ dual: number | null;
18
+ constructor(lhs: LinExpr, sense: ComparisonSense, rhs: number, name?: string);
19
+ /** PuLP style dual price accessor */
20
+ get pi(): number | null;
21
+ and(other: LogicElement): BoolOp;
22
+ or(other: LogicElement): BoolOp;
23
+ implies(consequent: LogicElement): BoolOp;
24
+ xor(other: LogicElement): BoolOp;
25
+ not(): BoolOp;
26
+ toString(): string;
27
+ }
28
+ //# sourceMappingURL=constraint.d.ts.map
@@ -0,0 +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,EAAE,MAAM,EAAE,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAI9D;;;GAGG;AACH,qBAAa,UAAU;IACrB,SAAgB,EAAE,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,OAAO,CAAC;IACb,KAAK,EAAE,eAAe,CAAC;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IAEpB,8BAA8B;IACvB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAQ;IACnC,4CAA4C;IACrC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAQ;IAElC,YACE,GAAG,EAAE,OAAO,EACZ,KAAK,EAAE,eAAe,EACtB,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE,MAAM,EAOd;IAED,qCAAqC;IACrC,IAAI,EAAE,IAAI,MAAM,GAAG,IAAI,CAEtB;IAGM,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;IAED,QAAQ,IAAI,MAAM,CAGjB;CACF"}
@@ -0,0 +1,79 @@
1
+ import type { Var } from "./variable.js";
2
+ import { Constraint } from "./constraint.js";
3
+ import { QuadExpr } from "./quad-expr.js";
4
+ /**
5
+ * Represents a linear expression: c0 + c1*x1 + c2*x2 + ...
6
+ * Compatible with PuLP (LpAffineExpression) and python-mip (LinExpr).
7
+ */
8
+ export declare class LinExpr {
9
+ terms: Map<Var, number>;
10
+ constant: number;
11
+ constructor(terms?: Map<Var, number>, constant?: number);
12
+ /**
13
+ * Clone this linear expression
14
+ */
15
+ clone(): LinExpr;
16
+ /**
17
+ * Add another expression, variable, or number
18
+ */
19
+ add(other: QuadExpr): QuadExpr;
20
+ add(other: LinExpr | Var | number): LinExpr;
21
+ /**
22
+ * Subtract another expression, variable, or number
23
+ */
24
+ sub(other: QuadExpr): QuadExpr;
25
+ sub(other: LinExpr | Var | number): LinExpr;
26
+ /**
27
+ * Multiply this expression by a scalar coefficient or variable
28
+ */
29
+ mul(scalar: number): LinExpr;
30
+ mul(v: Var): QuadExpr;
31
+ /**
32
+ * Divide this expression by a non-zero scalar
33
+ */
34
+ div(scalar: number): LinExpr;
35
+ /**
36
+ * Negate this expression
37
+ */
38
+ neg(): LinExpr;
39
+ /**
40
+ * Compute the numerical value of this expression using current variable values
41
+ */
42
+ get value(): number | null;
43
+ /**
44
+ * PuLP style value accessor
45
+ */
46
+ getValue(): number | null;
47
+ /**
48
+ * Create constraint: this <= rhs
49
+ */
50
+ le(rhs: number | Var | LinExpr, name?: string): Constraint;
51
+ lessThanOrEqual(rhs: number | Var | LinExpr, name?: string): Constraint;
52
+ /**
53
+ * Create constraint: this >= rhs
54
+ */
55
+ ge(rhs: number | Var | LinExpr, name?: string): Constraint;
56
+ greaterThanOrEqual(rhs: number | Var | LinExpr, name?: string): Constraint;
57
+ /**
58
+ * Create constraint: this == rhs
59
+ */
60
+ eq(rhs: number | Var | LinExpr, name?: string): Constraint;
61
+ equalTo(rhs: number | Var | LinExpr, name?: string): Constraint;
62
+ private toConstraint;
63
+ toString(): string;
64
+ }
65
+ /**
66
+ * Sum an array or iterable of variables, expressions, or numbers.
67
+ * Also supports mapping functions: sum(items, item => expr)
68
+ * Compatible with PuLP's lpSum and python-mip's xsum.
69
+ */
70
+ export declare function sum<T = any>(items: Iterable<T>, mapFn?: (item: T, index: number) => LinExpr | Var | number): LinExpr;
71
+ /**
72
+ * python-mip style alias for sum
73
+ */
74
+ export declare const xsum: typeof sum;
75
+ /**
76
+ * PuLP style alias for sum
77
+ */
78
+ export declare const lpSum: typeof sum;
79
+ //# sourceMappingURL=expression.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expression.d.ts","sourceRoot":"","sources":["../../../src/modeler/expression.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C;;;GAGG;AACH,qBAAa,OAAO;IACX,KAAK,EAAE,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IAExB,YAAY,KAAK,GAAE,GAAG,CAAC,GAAG,EAAE,MAAM,CAAa,EAAE,QAAQ,GAAE,MAAU,EAGpE;IAED;;OAEG;IACH,KAAK,IAAI,OAAO,CAEf;IAED;;OAEG;IACH,GAAG,CAAC,KAAK,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC/B,GAAG,CAAC,KAAK,EAAE,OAAO,GAAG,GAAG,G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YAAY;IAuBpB,QAAQ,IAAI,MAAM,CAkBjB;CACF;AAED;;;;GAIG;AACH,wBAAgB,GAAG,CAAC,CAAC,GAAG,GAAG,EACzB,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,EAClB,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,GAAG,GAAG,GAAG,MAAM,GACzD,OAAO,CA+BT;AAED;;GAEG;AACH,eAAO,MAAM,IAAI,YAAM,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,KAAK,YAAM,CAAC"}
@@ -0,0 +1,14 @@
1
+ export { Model, type ModelOptions, type IndicatorOptions } from "./model.js";
2
+ export { Var, type VarOptions } from "./variable.js";
3
+ export { LinExpr, sum, xsum, lpSum } from "./expression.js";
4
+ export { QuadExpr, type QuadTerm } from "./quad-expr.js";
5
+ export { Constraint } from "./constraint.js";
6
+ export { BoolVar, BoolExpr, BoolOp, and, or, not, implies, xor, } from "./boolean-expr.js";
7
+ export { parseExpr, parseConstraint, expr, c } from "./parser.js";
8
+ export { generateLpString, type LpModelData, type LpExportResult } from "./lp-writer.js";
9
+ export type { VarType, OptimizationSense, ComparisonSense, SolverStatus, SolveOptions, SolverSolution, } from "./types.js";
10
+ export { LpProblem, LpVariable, LpMinimize, LpMaximize, LpContinuous, LpInteger, LpBinary, LpStatus, value, } from "./pulp-compat.js";
11
+ export { MipModel, MINIMIZE, MAXIMIZE, CONTINUOUS, INTEGER, BINARY, maximize, minimize, } from "./mip-compat.js";
12
+ export * from "./solvers/index.js";
13
+ export { getHighs, solveLpWithHighs, setHighsWasmUrl, getHighsWasmUrl } from "../highs-loader.js";
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modeler/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,KAAK,YAAY,EAAE,KAAK,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC7E,OAAO,EAAE,GAAG,EAAE,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EACL,OAAO,EACP,QAAQ,EACR,MAAM,EACN,GAAG,EACH,EAAE,EACF,GAAG,EACH,OAAO,EACP,GAAG,GACJ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,KAAK,WAAW,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGzF,YAAY,EACV,OAAO,EACP,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,cAAc,GACf,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,SAAS,EACT,UAAU,EACV,UAAU,EACV,UAAU,EACV,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,KAAK,GACN,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,OAAO,EACP,MAAM,EACN,QAAQ,EACR,QAAQ,GACT,MAAM,iBAAiB,CAAC;AAGzB,cAAc,oBAAoB,CAAC;AAGnC,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,30 @@
1
+ import type { Var } from "./variable.js";
2
+ import type { LinExpr } from "./expression.js";
3
+ import type { Constraint } from "./constraint.js";
4
+ import type { OptimizationSense } from "./types.js";
5
+ import { QuadExpr } from "./quad-expr.js";
6
+ export interface LpModelData {
7
+ name?: string;
8
+ sense: OptimizationSense;
9
+ objective: LinExpr | QuadExpr;
10
+ constraints: Constraint[];
11
+ variables: Var[];
12
+ }
13
+ export interface LpExportResult {
14
+ lpString: string;
15
+ /** Maps sanitized name in LP to original Var */
16
+ nameToVar: Map<string, Var>;
17
+ /** Maps sanitized name in LP to original Constraint */
18
+ nameToConstraint: Map<string, Constraint>;
19
+ }
20
+ /**
21
+ * Sanitize variable and constraint names to be valid CPLEX LP identifiers:
22
+ * Allowed chars: a-z, A-Z, 0-9, _, !, ", #, $, %, &, (, ), /, ?, @, ~, '
23
+ * Avoid +, -, *, :, <, >, =, [, ], spaces
24
+ */
25
+ export declare function sanitizeIdentifier(raw: string, fallbackPrefix: string, id: number): string;
26
+ /**
27
+ * Convert a linear or quadratic model to standard CPLEX LP format string
28
+ */
29
+ export declare function generateLpString(modelData: LpModelData): LpExportResult;
30
+ //# sourceMappingURL=lp-writer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lp-writer.d.ts","sourceRoot":"","sources":["../../../src/modeler/lp-writer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,iBAAiB,CAAC;IACzB,SAAS,EAAE,OAAO,GAAG,QAAQ,CAAC;IAC9B,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,SAAS,EAAE,GAAG,EAAE,CAAC;CAClB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,gDAAgD;IAChD,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,uDAAuD;IACvD,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CAC3C;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAW1F;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,WAAW,GAAG,cAAc,CAiLvE"}
@@ -0,0 +1,43 @@
1
+ import { Model as CoreModel } from "./model.js";
2
+ import { Var } from "./variable.js";
3
+ import { LinExpr, xsum } from "./expression.js";
4
+ import { Constraint } from "./constraint.js";
5
+ import type { VarType, OptimizationSense } from "./types.js";
6
+ export declare const MINIMIZE: OptimizationSense;
7
+ export declare const MAXIMIZE: OptimizationSense;
8
+ export declare const BINARY: VarType;
9
+ export declare const INTEGER: VarType;
10
+ export declare const CONTINUOUS: VarType;
11
+ export interface ObjectiveSpec {
12
+ expr: LinExpr | Var | number | string;
13
+ sense: OptimizationSense;
14
+ }
15
+ export declare function maximize(expr: LinExpr | Var | number | string): ObjectiveSpec;
16
+ export declare function minimize(expr: LinExpr | Var | number | string): ObjectiveSpec;
17
+ /**
18
+ * python-mip compatible Model class
19
+ */
20
+ export declare class MipModel extends CoreModel {
21
+ constructor(name?: string, sense?: OptimizationSense);
22
+ /**
23
+ * python-mip style variable creation: m.add_var(name="x", var_type=INTEGER, lb=0)
24
+ */
25
+ add_var(options?: {
26
+ name?: string;
27
+ var_type?: VarType;
28
+ lb?: number;
29
+ ub?: number;
30
+ }): Var;
31
+ /**
32
+ * python-mip style objective property setter:
33
+ * m.objective = maximize(30 * x + 50 * y)
34
+ */
35
+ set objective_spec(spec: ObjectiveSpec);
36
+ get objective_value(): number | null;
37
+ /**
38
+ * Add constraint alias
39
+ */
40
+ add_constr(constraint: Constraint | string, name?: string): Constraint;
41
+ }
42
+ export { xsum };
43
+ //# sourceMappingURL=mip-compat.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mip-compat.d.ts","sourceRoot":"","sources":["../../../src/modeler/mip-compat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAA8B,MAAM,YAAY,CAAC;AAEzF,eAAO,MAAM,QAAQ,EAAE,iBAA8B,CAAC;AACtD,eAAO,MAAM,QAAQ,EAAE,iBAA8B,CAAC;AAEtD,eAAO,MAAM,MAAM,EAAE,OAAkB,CAAC;AACxC,eAAO,MAAM,OAAO,EAAE,OAAmB,CAAC;AAC1C,eAAO,MAAM,UAAU,EAAE,OAAsB,CAAC;AAEhD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,OAAO,GAAG,GAAG,GAAG,MAAM,GAAG,MAAM,CAAC;IACtC,KAAK,EAAE,iBAAiB,CAAC;CAC1B;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,GAAG,GAAG,MAAM,GAAG,MAAM,GAAG,aAAa,CAE7E;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,GAAG,GAAG,MAAM,GAAG,MAAM,GAAG,aAAa,CAE7E;AAED;;GAEG;AACH,qBAAa,QAAS,SAAQ,SAAS;IACrC,YAAY,IAAI,GAAE,MAAmB,EAAE,KAAK,GAAE,iBAA4B,EAEzE;IAED;;OAEG;IACH,OAAO,CAAC,OAAO,GAAE;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,EAAE,CAAC,EAAE,MAAM,CAAC;QACZ,EAAE,CAAC,EAAE,MAAM,CAAC;KACR,GAAG,GAAG,CAOX;IAED;;;OAGG;IACH,IAAI,cAAc,CAAC,IAAI,EAAE,aAAa,EAErC;IAED,IAAI,eAAe,IAAI,MAAM,GAAG,IAAI,CAEnC;IAED;;OAEG;IACH,UAAU,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,UAAU,CAErE;CACF;AAED,OAAO,EAAE,IAAI,EAAE,CAAC"}
@@ -0,0 +1,156 @@
1
+ import type { VarType, OptimizationSense, SolverStatus, SolveOptions, SolverSolution } from "./types.js";
2
+ import { Var, type VarOptions } from "./variable.js";
3
+ import { LinExpr } from "./expression.js";
4
+ import { QuadExpr } from "./quad-expr.js";
5
+ import { Constraint } from "./constraint.js";
6
+ import { BoolVar, BoolExpr } from "./boolean-expr.js";
7
+ import { type Solver } from "./solvers/index.js";
8
+ export interface ModelOptions {
9
+ name?: string;
10
+ sense?: OptimizationSense;
11
+ solver?: Solver | string;
12
+ }
13
+ export interface IndicatorOptions {
14
+ activeValue?: 0 | 1;
15
+ M?: number;
16
+ name?: string;
17
+ }
18
+ /**
19
+ * High-level intuitive mathematical programming model.
20
+ * Inspired by PuLP (Python) and python-mip, running directly with HiGHS WASM in browser and Node.js.
21
+ */
22
+ export interface LogicalConstraint {
23
+ name: string;
24
+ expr: BoolExpr | Constraint;
25
+ }
26
+ export declare class Model {
27
+ name: string;
28
+ sense: OptimizationSense;
29
+ objective: LinExpr | QuadExpr;
30
+ variables: Var[];
31
+ constraints: Constraint[];
32
+ boolVars: BoolVar[];
33
+ logicalConstraints: LogicalConstraint[];
34
+ unsatCore: string[];
35
+ values: Map<string, number | boolean>;
36
+ private varMapByName;
37
+ private constrMapByName;
38
+ status: SolverStatus;
39
+ objectiveValue: number | null;
40
+ runTime: number;
41
+ solution: SolverSolution | null;
42
+ solver: Solver | null;
43
+ constructor(options?: ModelOptions);
44
+ get vars(): Var[];
45
+ get constrs(): Constraint[];
46
+ get numVars(): number;
47
+ get numConstrs(): number;
48
+ /**
49
+ * Add a decision variable to the model
50
+ */
51
+ addVar(options?: VarOptions): Var;
52
+ addVar(name: string, type?: VarType, lb?: number, ub?: number): Var;
53
+ /**
54
+ * Add multiple variables at once:
55
+ * - by count: addVars(5) -> Var[]
56
+ * - by key array: addVars(["apples", "oranges"]) -> Record<string, Var>
57
+ * - by 2D dimensions: addVars(factories, stores) -> Record<string, Record<string, Var>>
58
+ * - by 2D numeric grid: addVars(8, 8) -> Record<number, Record<number, Var>>
59
+ */
60
+ addVars(count: number, options?: VarOptions): Var[];
61
+ addVars<R extends string | number, C extends string | number>(dim1: R[] | number, dim2: C[] | number, options?: VarOptions): Record<R, Record<C, Var>>;
62
+ addVars<K extends string | number>(keys: K[], options?: VarOptions): Record<K, Var>;
63
+ /**
64
+ * Add a 2D matrix of decision variables: grid[row][col]
65
+ */
66
+ addVars2D<R extends string | number, C extends string | number>(rows: R[], cols: C[], options?: VarOptions): Record<R, Record<C, Var>>;
67
+ /**
68
+ * Find variable by name
69
+ */
70
+ getVarByName(name: string): Var | undefined;
71
+ /**
72
+ * Find a constraint by its name
73
+ */
74
+ getConstraintByName(name: string): Constraint | undefined;
75
+ /**
76
+ * Set the objective function
77
+ */
78
+ setObjective(expr: LinExpr | QuadExpr | Var | number | string, sense?: OptimizationSense): void;
79
+ /**
80
+ * Set objective to maximize
81
+ */
82
+ maximize(expr: LinExpr | QuadExpr | Var | number | string): void;
83
+ /**
84
+ * Set objective to minimize
85
+ */
86
+ minimize(expr: LinExpr | QuadExpr | Var | number | string): void;
87
+ /**
88
+ * Add a Boolean (propositional logic) variable for SMT / SAT modeling
89
+ */
90
+ addBoolVar(name?: string): BoolVar;
91
+ /**
92
+ * Add a linear or logical constraint to the model
93
+ */
94
+ addConstraint(constraint: Constraint | string, name?: string): Constraint;
95
+ addConstraint(constraint: BoolExpr, name?: string): BoolExpr;
96
+ addConstraint(constraint: Constraint | BoolExpr | string, name?: string): Constraint | BoolExpr;
97
+ /**
98
+ * python-mip / Gurobi style alias for addConstraint
99
+ */
100
+ addConstr(constraint: Constraint | BoolExpr | string, name?: string): Constraint | BoolExpr;
101
+ /**
102
+ * Add multiple constraints
103
+ */
104
+ addConstrs(constraints: (Constraint | BoolExpr | string)[]): (Constraint | BoolExpr)[];
105
+ /**
106
+ * Universal classical fluent adder for constraints, variables, or batches.
107
+ * Enables:
108
+ * - m.add(x.mul(2).add(y).le(10))
109
+ * - m.add(c`${x} + ${y} <= 10`)
110
+ * - m.add("x + y <= 10")
111
+ * - m.add([c1, c2, c3])
112
+ * - m.add(new Var(...))
113
+ * - m.add(c1).add(c2) (fluent chaining)
114
+ */
115
+ add(constraint: Constraint, name?: string): this;
116
+ add(expr: BoolExpr, name?: string): this;
117
+ add(strConstraint: string, name?: string): this;
118
+ add(variable: Var): this;
119
+ add(items: (Constraint | BoolExpr | string | Var)[]): this;
120
+ /**
121
+ * Add an indicator constraint via Big-M auto-linearization:
122
+ * "If binVar == activeValue, then constraint holds"
123
+ *
124
+ * Automatically handles <=, >=, and == constraints.
125
+ * Enables solving conditional logic in MIP solvers (HiGHS, GLPK) without requiring SMT.
126
+ */
127
+ addIndicator(binVar: Var, constraint: Constraint, options?: IndicatorOptions): Constraint[];
128
+ /**
129
+ * Export model to CPLEX LP format string
130
+ */
131
+ toLpString(): string;
132
+ /**
133
+ * Solve the optimization model using the configured solver (defaults to HiGHS WASM)
134
+ * or a solver passed dynamically (PuLP style: prob.solve(solver))
135
+ */
136
+ optimize(solverOrOptions?: Solver | string | SolveOptions, options?: SolveOptions): Promise<SolverStatus>;
137
+ /**
138
+ * PuLP style alias for optimize:
139
+ * await model.solve()
140
+ * await model.solve(new HiGHS())
141
+ * await model.solve(new GLPK())
142
+ * await model.solve(new RemoteSolver({ url: "..." }))
143
+ */
144
+ solve(solverOrOptions?: Solver | string | SolveOptions, options?: SolveOptions): Promise<SolverStatus>;
145
+ /**
146
+ * Check satisfiability of the model without requiring an objective function.
147
+ * Can be used to verify feasibility or diagnose infeasibilities / unsat core.
148
+ */
149
+ check(solverOrOptions?: Solver | string | SolveOptions, options?: SolveOptions): Promise<{
150
+ status: "Sat" | "Unsat" | "Unknown";
151
+ values: Record<string, number | boolean>;
152
+ unsatCore?: string[];
153
+ runTime?: number;
154
+ }>;
155
+ }
156
+ //# sourceMappingURL=model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../src/modeler/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,cAAc,EACf,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,GAAG,EAAE,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGtD,OAAO,EAAa,KAAK,MAAM,EAAyC,MAAM,oBAAoB,CAAC;AAEnG,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,gBAAgB;IAC/B,WAAW,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IACpB,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,IA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,CACZ,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,YAAY,EAChD,OAAO,CAAC,EAAE,YAAY,GACrB,OAAO,CAAC,YAAY,CAAC,CAqHvB;IAED;;;;;;OAMG;IACG,KAAK,CACT,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,YAAY,EAChD,OAAO,CAAC,EAAE,YAAY,GACrB,OAAO,CAAC,YAAY,CAAC,CAEvB;IAED;;;OAGG;IACG,KAAK,CACT,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,YAAY,EAChD,OAAO,CAAC,EAAE,YAAY,GACrB,OAAO,CAAC;QACT,MAAM,EAAE,KAAK,GAAG,OAAO,GAAG,SAAS,CAAC;QACpC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC;QACzC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;QACrB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC,CAuFD;CACF"}
@@ -0,0 +1,27 @@
1
+ import { Var } from "./variable.js";
2
+ import { LinExpr } from "./expression.js";
3
+ import { Constraint } from "./constraint.js";
4
+ type VarResolver = (name: string) => Var | undefined;
5
+ /**
6
+ * Parse a mathematical expression string into a LinExpr
7
+ */
8
+ export declare function parseExpr(text: string, resolver: VarResolver): LinExpr;
9
+ /**
10
+ * Parse a constraint string such as "chairs + 2 * tables <= 40"
11
+ */
12
+ export declare function parseConstraint(text: string, resolver: VarResolver, name?: string): Constraint;
13
+ /**
14
+ * Tagged template literal for constraints:
15
+ * c`${chairs} + 2 * ${tables} <= 40`
16
+ * c`3 * ${x} - ${y} >= 5`
17
+ * c`${x} == 2 * ${y} + 4`
18
+ */
19
+ export declare function c(strings: TemplateStringsArray, ...values: (Var | LinExpr | number)[]): Constraint;
20
+ /**
21
+ * Tagged template literal for linear expressions or inline constraints:
22
+ * expr`45 * ${chairs} + 80 * ${tables}` -> LinExpr
23
+ * expr`${x} + 2 * ${y} <= 40` -> Constraint
24
+ */
25
+ export declare function expr(strings: TemplateStringsArray, ...values: (Var | LinExpr | number)[]): LinExpr | Constraint;
26
+ export {};
27
+ //# sourceMappingURL=parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../../src/modeler/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C,KAAK,WAAW,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,GAAG,GAAG,SAAS,CAAC;AA4NrD;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,GAAG,OAAO,CAItE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,UAAU,CA4B9F;AAqCD;;;;;GAKG;AACH,wBAAgB,CAAC,CACf,OAAO,EAAE,oBAAoB,EAC7B,GAAG,MAAM,EAAE,CAAC,GAAG,GAAG,OAAO,GAAG,MAAM,CAAC,EAAE,GACpC,UAAU,CAGZ;AAED;;;;GAIG;AACH,wBAAgB,IAAI,CAClB,OAAO,EAAE,oBAAoB,EAC7B,GAAG,MAAM,EAAE,CAAC,GAAG,GAAG,OAAO,GAAG,MAAM,CAAC,EAAE,GACpC,OAAO,GAAG,UAAU,CAOtB"}
@@ -0,0 +1,67 @@
1
+ import { Model } from "./model.js";
2
+ import { Var } from "./variable.js";
3
+ import { LinExpr, lpSum } from "./expression.js";
4
+ import { QuadExpr } from "./quad-expr.js";
5
+ import { Constraint } from "./constraint.js";
6
+ import type { VarType, OptimizationSense, SolverStatus, SolveOptions } from "./types.js";
7
+ import { type Solver, HiGHS, MockSolver, getSolver, listAvailableSolvers } from "./solvers/index.js";
8
+ export declare const LpMinimize: OptimizationSense;
9
+ export declare const LpMaximize: OptimizationSense;
10
+ export declare const LpContinuous: VarType;
11
+ export declare const LpInteger: VarType;
12
+ export declare const LpBinary: VarType;
13
+ export declare const LpStatus: Record<SolverStatus, string>;
14
+ /**
15
+ * PuLP-compatible LpVariable
16
+ */
17
+ export declare class LpVariable extends Var {
18
+ constructor(name: string, lowBound?: number, upBound?: number, cat?: VarType);
19
+ /**
20
+ * PuLP-style LpVariable.dicts helper:
21
+ * LpVariable.dicts("x", [0, 1, 2], 0, 1, LpBinary)
22
+ */
23
+ static dicts<K extends string | number>(name: string, indices: K[], lowBound?: number, upBound?: number, cat?: VarType): Record<K, LpVariable>;
24
+ }
25
+ /**
26
+ * PuLP value() helper to extract value of variable or expression
27
+ */
28
+ export declare function value(item: Var | LinExpr | number | null | undefined): number | null;
29
+ /**
30
+ * PuLP-compatible LpProblem class
31
+ */
32
+ export declare class LpProblem {
33
+ model: Model;
34
+ constructor(name?: string, sense?: OptimizationSense);
35
+ get name(): string;
36
+ get sense(): OptimizationSense;
37
+ set sense(val: OptimizationSense);
38
+ get objective(): LinExpr | QuadExpr;
39
+ get variables(): Var[];
40
+ get constraints(): Constraint[];
41
+ get status(): SolverStatus;
42
+ get objectiveValue(): number | null;
43
+ /**
44
+ * Register a variable to the problem
45
+ */
46
+ addVariable(v: Var): Var;
47
+ /**
48
+ * Set objective function
49
+ */
50
+ setObjective(expr: LinExpr | Var | number | string): void;
51
+ /**
52
+ * Add a constraint
53
+ */
54
+ addConstraint(constraint: Constraint | string, name?: string): Constraint;
55
+ /**
56
+ * Convenient method to add either an objective or constraint
57
+ */
58
+ add(item: Constraint | LinExpr | Var | string, name?: string): void;
59
+ /**
60
+ * Solve the problem using specified solver (e.g. prob.solve(new HiGHS()), prob.solve(new GLPK()))
61
+ * or default solver
62
+ */
63
+ solve(solverOrOptions?: Solver | string | SolveOptions, options?: SolveOptions): Promise<SolverStatus>;
64
+ toLpString(): string;
65
+ }
66
+ export { lpSum, HiGHS, MockSolver, getSolver, listAvailableSolvers, };
67
+ //# sourceMappingURL=pulp-compat.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pulp-compat.d.ts","sourceRoot":"","sources":["../../../src/modeler/pulp-compat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,OAAO,EAAO,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACzF,OAAO,EACL,KAAK,MAAM,EACX,KAAK,EACL,UAAU,EACV,SAAS,EACT,oBAAoB,EACrB,MAAM,oBAAoB,CAAC;AAG5B,eAAO,MAAM,UAAU,EAAE,iBAA8B,CAAC;AACxD,eAAO,MAAM,UAAU,EAAE,iBAA8B,CAAC;AAExD,eAAO,MAAM,YAAY,EAAE,OAAsB,CAAC;AAClD,eAAO,MAAM,SAAS,EAAE,OAAmB,CAAC;AAC5C,eAAO,MAAM,QAAQ,EAAE,OAAkB,CAAC;AAE1C,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,YAAY,EAAE,MAAM,CAYjD,CAAC;AAEF;;GAEG;AACH,qBAAa,UAAW,SAAQ,GAAG;IACjC,YACE,IAAI,EAAE,MAAM,EACZ,QAAQ,CAAC,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,MAAM,EAChB,GAAG,GAAE,OAAsB,EAQ5B;IAED;;;OAGG;IACH,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EACpC,IAAI,EAAE,MAAM,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,GAAG,MAAM,GAAG,YAAY,EAChD,OAAO,CAAC,EAAE,YAAY,GACrB,OAAO,CAAC,YAAY,CAAC,CAEvB;IAED,UAAU,IAAI,MAAM,CAEnB;CACF;AAED,OAAO,EACL,KAAK,EACL,KAAK,EACL,UAAU,EACV,SAAS,EACT,oBAAoB,GACrB,CAAC"}
@@ -0,0 +1,55 @@
1
+ import type { Var } from "./variable.js";
2
+ import type { LinExpr } from "./expression.js";
3
+ export interface QuadTerm {
4
+ var1: Var;
5
+ var2: Var;
6
+ coeff: number;
7
+ }
8
+ /**
9
+ * Represents a quadratic expression:
10
+ * constant + sum(c_i * x_i) + sum(q_ij * x_i * x_j)
11
+ */
12
+ export declare class QuadExpr {
13
+ linearTerms: Map<Var, number>;
14
+ quadTerms: Map<string, QuadTerm>;
15
+ constant: number;
16
+ constructor(linearTerms?: Map<Var, number>, quadTerms?: Map<string, QuadTerm>, constant?: number);
17
+ /**
18
+ * Clone this quadratic expression
19
+ */
20
+ clone(): QuadExpr;
21
+ /**
22
+ * Get coefficient for a quadratic term x1 * x2
23
+ */
24
+ getQuadCoeff(v1: Var, v2: Var): number;
25
+ /**
26
+ * Add another expression, variable, or number
27
+ */
28
+ add(other: QuadExpr | LinExpr | Var | number): QuadExpr;
29
+ /**
30
+ * Subtract another expression, variable, or number
31
+ */
32
+ sub(other: QuadExpr | LinExpr | Var | number): QuadExpr;
33
+ /**
34
+ * Multiply by a scalar coefficient
35
+ */
36
+ mul(scalar: number): QuadExpr;
37
+ /**
38
+ * Divide by a non-zero scalar
39
+ */
40
+ div(scalar: number): QuadExpr;
41
+ /**
42
+ * Negate this quadratic expression
43
+ */
44
+ neg(): QuadExpr;
45
+ /**
46
+ * Compute the numerical value of this expression using current variable values
47
+ */
48
+ get value(): number | null;
49
+ getValue(): number | null;
50
+ /**
51
+ * Factory method to create a quadratic term v1 * v2 * coeff
52
+ */
53
+ static fromProduct(v1: Var, v2: Var, coeff?: number): QuadExpr;
54
+ }
55
+ //# sourceMapp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K,IAAI,MAAM,GAAG,IAAI,CAWzB;IAED,QAAQ,IAAI,MAAM,GAAG,IAAI,CAExB;IAED;;OAEG;IACH,MAAM,CAAC,WAAW,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,KAAK,GAAE,MAAU,GAAG,QAAQ,CAShE;CACF"}
@@ -0,0 +1,22 @@
1
+ import type { Solver, SolverOptions, SolverResult } from "./types.js";
2
+ import type { LpModelData, LpExportResult } from "../lp-writer.js";
3
+ /**
4
+ * GLPK Solver adapter (GNU Linear Programming Kit via WebAssembly / JS).
5
+ * Supports standard Linear Programming (LP) and Mixed-Integer Programming (MIP).
6
+ */
7
+ export declare class GLPKSolver implements Solver {
8
+ static readonly capabilities: {
9
+ supportsMIP: boolean;
10
+ supportsQP: boolean;
11
+ };
12
+ readonly name = "GLPK";
13
+ readonly version = "5.0.0";
14
+ readonly capabilities: {
15
+ supportsMIP: boolean;
16
+ supportsQP: boolean;
17
+ };
18
+ options: SolverOptions;
19
+ constructor(options?: SolverOptions);
20
+ solve(modelData: LpModelData, lpResult: LpExportResult, options?: SolverOptions): Promise<SolverResult>;
21
+ }
22
+ //# sourceMappingURL=glpk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glpk.d.ts","sourceRoot":"","sources":["../../../../src/modeler/solvers/glpk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAInE;;;GAGG;AACH,qBAAa,UAAW,YAAW,MAAM;IACvC,gBAAuB,YAAY;QACjC,WAAW;QACX,UAAU;MACV;IACF,SAAgB,IAAI,UAAU;IAC9B,SAAgB,OAAO,WAAW;IAClC,SAAgB,YAAY;;;MAA2B;IAChD,OAAO,EAAE,aAAa,CAAC;IAE9B,YAAY,OAAO,GAAE,aAAkB,EAEtC;IAEK,KAAK,CACT,SAAS,EAAE,WAAW,EACtB,QAAQ,EAAE,cAAc,EACxB,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,YAAY,CAAC,CAoLvB;CACF"}