@ohtaman/washi 0.0.0-stage → 0.1.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 (62) hide show
  1. package/LICENSE +21 -0
  2. package/README.ja.md +341 -0
  3. package/README.md +340 -2
  4. package/README.zh-CN.md +341 -0
  5. package/THIRD_PARTY_LICENSES.md +83 -0
  6. package/dist/lib/assets/highs-worker-D57nd9KC.js +3 -0
  7. package/dist/lib/glpk-BC32ZaPG.js +126 -0
  8. package/dist/lib/highs.wasm +0 -0
  9. package/dist/lib/highs.wasm.LICENSE +22 -0
  10. package/dist/lib/solvers/glpk.js +2 -0
  11. package/dist/lib/solvers/z3.js +2 -0
  12. package/dist/lib/washi.js +908 -0
  13. package/dist/lib/z3-C5DfllfD.js +562 -0
  14. package/dist/types/glpk-loader.d.ts +8 -0
  15. package/dist/types/glpk-loader.d.ts.map +1 -0
  16. package/dist/types/highs-loader.d.ts +39 -0
  17. package/dist/types/highs-loader.d.ts.map +1 -0
  18. package/dist/types/highs-worker-client.d.ts +12 -0
  19. package/dist/types/highs-worker-client.d.ts.map +1 -0
  20. package/dist/types/highs-worker.d.ts +2 -0
  21. package/dist/types/highs-worker.d.ts.map +1 -0
  22. package/dist/types/index.d.ts +14 -0
  23. package/dist/types/index.d.ts.map +1 -0
  24. package/dist/types/modeler/boolean-expr.d.ts +38 -0
  25. package/dist/types/modeler/boolean-expr.d.ts.map +1 -0
  26. package/dist/types/modeler/constraint.d.ts +28 -0
  27. package/dist/types/modeler/constraint.d.ts.map +1 -0
  28. package/dist/types/modeler/expression.d.ts +79 -0
  29. package/dist/types/modeler/expression.d.ts.map +1 -0
  30. package/dist/types/modeler/index.d.ts +14 -0
  31. package/dist/types/modeler/index.d.ts.map +1 -0
  32. package/dist/types/modeler/lp-writer.d.ts +30 -0
  33. package/dist/types/modeler/lp-writer.d.ts.map +1 -0
  34. package/dist/types/modeler/mip-compat.d.ts +43 -0
  35. package/dist/types/modeler/mip-compat.d.ts.map +1 -0
  36. package/dist/types/modeler/model.d.ts +156 -0
  37. package/dist/types/modeler/model.d.ts.map +1 -0
  38. package/dist/types/modeler/parser.d.ts +27 -0
  39. package/dist/types/modeler/parser.d.ts.map +1 -0
  40. package/dist/types/modeler/pulp-compat.d.ts +67 -0
  41. package/dist/types/modeler/pulp-compat.d.ts.map +1 -0
  42. package/dist/types/modeler/quad-expr.d.ts +55 -0
  43. package/dist/types/modeler/quad-expr.d.ts.map +1 -0
  44. package/dist/types/modeler/solvers/glpk.d.ts +22 -0
  45. package/dist/types/modeler/solvers/glpk.d.ts.map +1 -0
  46. package/dist/types/modeler/solvers/highs.d.ts +26 -0
  47. package/dist/types/modeler/solvers/highs.d.ts.map +1 -0
  48. package/dist/types/modeler/solvers/index.d.ts +7 -0
  49. package/dist/types/modeler/solvers/index.d.ts.map +1 -0
  50. package/dist/types/modeler/solvers/mock.d.ts +25 -0
  51. package/dist/types/modeler/solvers/mock.d.ts.map +1 -0
  52. package/dist/types/modeler/solvers/registry.d.ts +20 -0
  53. package/dist/types/modeler/solvers/registry.d.ts.map +1 -0
  54. package/dist/types/modeler/solvers/types.d.ts +86 -0
  55. package/dist/types/modeler/solvers/types.d.ts.map +1 -0
  56. package/dist/types/modeler/solvers/z3.d.ts +37 -0
  57. package/dist/types/modeler/solvers/z3.d.ts.map +1 -0
  58. package/dist/types/modeler/types.d.ts +27 -0
  59. package/dist/types/modeler/types.d.ts.map +1 -0
  60. package/dist/types/modeler/variable.d.ts +52 -0
  61. package/dist/types/modeler/variable.d.ts.map +1 -0
  62. package/package.json +97 -4
@@ -0,0 +1,26 @@
1
+ import type { Solver, SolverOptions, SolverResult } from "./types.js";
2
+ import type { LpModelData, LpExportResult } from "../lp-writer.js";
3
+ /**
4
+ * HiGHS Solver adapter (WebAssembly in Browser / Node.js)
5
+ * High-performance simplex / interior point / branch-and-cut solver.
6
+ */
7
+ export declare class HighsSolver implements Solver {
8
+ static readonly capabilities: {
9
+ supportsMIP: boolean;
10
+ supportsQP: boolean;
11
+ };
12
+ readonly name = "HiGHS";
13
+ readonly version = "1.15.3";
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
+ /**
23
+ * PuLP-style alias: pulp.HiGHS()
24
+ */
25
+ export declare const HiGHS: typeof HighsSolver;
26
+ //# sourceMappingURL=highs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"highs.d.ts","sourceRoot":"","sources":["../../../../src/modeler/solvers/highs.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,WAAY,YAAW,MAAM;IACxC,gBAAuB,YAAY;QACjC,WAAW;QACX,UAAU;MACV;IACF,SAAgB,IAAI,WAAW;IAC/B,SAAgB,OAAO,YAAY;IACnC,SAAgB,YAAY;;;MAA4B;IACjD,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,CAyEvB;CACF;AAED;;GAEG;AACH,eAAO,MAAM,KAAK,oBAAc,CAAC"}
@@ -0,0 +1,7 @@
1
+ export * from "./types.js";
2
+ export * from "./registry.js";
3
+ export * from "./highs.js";
4
+ export * from "./glpk.js";
5
+ export * from "./z3.js";
6
+ export * from "./mock.js";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/modeler/solvers/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC"}
@@ -0,0 +1,25 @@
1
+ import type { Solver, SolverOptions, SolverResult, SolverCapabilities } from "./types.js";
2
+ import type { LpModelData, LpExportResult } from "../lp-writer.js";
3
+ import type { SolverStatus } from "../types.js";
4
+ export interface MockSolverOptions extends SolverOptions {
5
+ name?: string;
6
+ capabilities?: SolverCapabilities;
7
+ status?: SolverStatus;
8
+ objectiveValue?: number;
9
+ values?: Record<string, number>;
10
+ reducedCosts?: Record<string, number>;
11
+ duals?: Record<string, number>;
12
+ slacks?: Record<string, number>;
13
+ delayMs?: number;
14
+ }
15
+ /**
16
+ * Mock / Dummy Solver for deterministic testing, CI/CD, or offline usage without WASM.
17
+ */
18
+ export declare class MockSolver implements Solver {
19
+ readonly name: string;
20
+ readonly capabilities: SolverCapabilities;
21
+ options: MockSolverOptions;
22
+ constructor(options?: MockSolverOptions);
23
+ solve(_modelData: LpModelData, _lpResult: LpExportResult, options?: SolverOptions): Promise<SolverResult>;
24
+ }
25
+ //# sourceMappingURL=mock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../../../src/modeler/solvers/mock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAC1F,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,WAAW,iBAAkB,SAAQ,aAAa;IACtD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAClC,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,qBAAa,UAAW,YAAW,MAAM;IACvC,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,YAAY,EAAE,kBAAkB,CAAC;IAC1C,OAAO,EAAE,iBAAiB,CAAC;IAElC,YAAY,OAAO,GAAE,iBAAsB,EAI1C;IAEK,KAAK,CACT,UAAU,EAAE,WAAW,EACvB,SAAS,EAAE,cAAc,EACzB,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,YAAY,CAAC,CAgBvB;CACF"}
@@ -0,0 +1,20 @@
1
+ import type { Solver, SolverOptions } from "./types.js";
2
+ type SolverFactory = (options?: SolverOptions) => Solver;
3
+ /**
4
+ * Register a new solver factory by name
5
+ */
6
+ export declare function registerSolver(name: string, factory: SolverFactory): void;
7
+ /**
8
+ * Set the default solver used when no solver is specified
9
+ */
10
+ export declare function setDefaultSolver(solverOrName: string | SolverFactory | Solver): void;
11
+ /**
12
+ * Get an instance of a solver by name or instance
13
+ */
14
+ export declare function getSolver(solverOrName?: string | Solver, options?: SolverOptions): Solver;
15
+ /**
16
+ * List all registered solver names
17
+ */
18
+ export declare function listAvailableSolvers(): string[];
19
+ export {};
20
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../../src/modeler/solvers/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAKxD,KAAK,aAAa,GAAG,CAAC,OAAO,CAAC,EAAE,aAAa,KAAK,MAAM,CAAC;AAWzD;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,IAAI,CAEzE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,aAAa,GAAG,MAAM,GAAG,IAAI,CAYpF;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,MAAM,CAgBzF;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,EAAE,CAE/C"}
@@ -0,0 +1,86 @@
1
+ import type { SolverStatus } from "../types.js";
2
+ import type { LpModelData, LpExportResult } from "../lp-writer.js";
3
+ /**
4
+ * Normalized solution result returned by any solver adapter
5
+ */
6
+ export interface SolverResult {
7
+ status: SolverStatus;
8
+ objectiveValue: number | null;
9
+ /** Variable primal values (keyed by variable name or ID) */
10
+ values: Record<string, number>;
11
+ /** Variable reduced costs (optional) */
12
+ reducedCosts?: Record<string, number>;
13
+ /** Constraint dual values (optional) */
14
+ duals?: Record<string, number>;
15
+ /** Constraint slacks (optional) */
16
+ slacks?: Record<string, number>;
17
+ /** Solution time in seconds */
18
+ runTime?: number;
19
+ /** Raw solver output or diagnostic logs */
20
+ logs?: string[];
21
+ raw?: any;
22
+ }
23
+ /**
24
+ * Common solver options supported across solvers
25
+ */
26
+ export interface SolverOptions {
27
+ /** Maximum solve time limit in seconds */
28
+ timeLimit?: number;
29
+ /** Presolve mode */
30
+ presolve?: "on" | "off" | "choose";
31
+ /** Relative MIP gap tolerance (e.g. 0.01 for 1%) */
32
+ mipGap?: number;
33
+ /** Number of parallel threads */
34
+ threads?: number;
35
+ /** Enable verbose solver logging */
36
+ verbose?: boolean;
37
+ /** Use Web Worker for non-blocking browser execution */
38
+ useWorker?: boolean;
39
+ /** Additional solver-specific options */
40
+ [key: string]: any;
41
+ }
42
+ /**
43
+ * Problem classes and features supported by a solver engine
44
+ */
45
+ export interface SolverCapabilities {
46
+ /** Supports mixed-integer programming (integer/binary variables) */
47
+ supportsMIP?: boolean;
48
+ /** Supports quadratic objectives (QP) */
49
+ supportsQP?: boolean;
50
+ /** Supports quadratic constraints (QCQP / SOCP) */
51
+ supportsQCQP?: boolean;
52
+ /** Supports satisfiability modulo theories / logical constraints */
53
+ supportsSMT?: boolean;
54
+ /** Supports extracting minimal unsatisfiable core */
55
+ supportsUnsatCore?: boolean;
56
+ }
57
+ export interface SolverCheckResult {
58
+ status: "Sat" | "Unsat" | "Unknown";
59
+ values: Record<string, number | boolean>;
60
+ unsatCore?: string[];
61
+ runTime?: number;
62
+ logs?: string[];
63
+ raw?: any;
64
+ }
65
+ /**
66
+ * Universal Solver interface.
67
+ * Any optimization engine (HiGHS WASM, GLPK, Gurobi Remote, CBC, SCIP, custom JS)
68
+ * implements this interface to be used interchangeably with Model and LpProblem.
69
+ */
70
+ export interface Solver {
71
+ /** Identifier name of the solver engine */
72
+ readonly name: string;
73
+ /** Version string of the solver */
74
+ readonly version?: string;
75
+ /** Feature capabilities of this solver */
76
+ readonly capabilities?: SolverCapabilities;
77
+ /**
78
+ * Solve the given mathematical programming model data
79
+ */
80
+ solve(modelData: LpModelData, lpResult: LpExportResult, options?: SolverOptions): Promise<SolverResult>;
81
+ /**
82
+ * Check satisfiability of the model and logical constraints (optional)
83
+ */
84
+ check?(modelData: any, options?: SolverOptions): Promise<SolverCheckResult>;
85
+ }
86
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/modeler/solvers/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,a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AC;IACrB,mDAAmD;IACnD,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,oEAAoE;IACpE,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,qDAAqD;IACrD,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,KAAK,GAAG,OAAO,GAAG,SAAS,CAAC;IACpC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC;IACzC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,GAAG,CAAC,EAAE,GAAG,CAAC;CACX;AAED;;;;GAIG;AACH,MAAM,WAAW,MAAM;IACrB,2CAA2C;IAC3C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,mCAAmC;IACnC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,0CAA0C;IAC1C,QAAQ,CAAC,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAC3C;;OAEG;IACH,KAAK,CACH,SAAS,EAAE,WAAW,EACtB,QAAQ,EAAE,cAAc,EACxB,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,YAAY,CAAC,CAAC;IACzB;;OAEG;IACH,KAAK,CAAC,CACJ,SAAS,EAAE,GAAG,EACd,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,iBAAiB,CAAC,CAAC;CAC/B"}
@@ -0,0 +1,37 @@
1
+ import type { Solver, SolverCapabilities, SolverOptions, SolverResult, SolverCheckResult } from "./types.js";
2
+ /**
3
+ * Z3 SMT / SAT / MIP Solver Adapter
4
+ *
5
+ * Supports:
6
+ * - SAT & SMT logical formulas (And, Or, Not, Implies, Xor)
7
+ * - Feasibility checking via check()
8
+ * - Unsatisfiable core extraction (unsatCore) for conflict diagnosis
9
+ * - Mixed-Integer Programming (MIP) optimization via Z3 Optimize
10
+ */
11
+ export declare class Z3Solver implements Solver {
12
+ readonly name = "z3";
13
+ readonly capabilities: SolverCapabilities;
14
+ /**
15
+ * Helper to build AST translations for a given Z3 Context
16
+ */
17
+ private createContextTranslator;
18
+ /**
19
+ * Check feasibility & propositional satisfaction without an objective function.
20
+ * Tracks constraints to return an unsatCore if infeasible.
21
+ */
22
+ check(modelData: any, _options?: SolverOptions): Promise<SolverCheckResult>;
23
+ /**
24
+ * Lightweight in-memory SMT / SAT reasoning engine for browser environments
25
+ * or when z3-solver native WASM is not available.
26
+ */
27
+ private fallbackCheck;
28
+ /**
29
+ * Solve optimization problem (MIP) or feasibility problem
30
+ */
31
+ solve(modelData: any, _lpResult: any, options?: SolverOptions): Promise<SolverResult>;
32
+ }
33
+ /**
34
+ * Register Z3 solver into global solver registry
35
+ */
36
+ export declare function registerZ3Solver(): void;
37
+ //# sourceMappingURL=z3.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"z3.d.ts","sourceRoot":"","sources":["../../../../src/modeler/solvers/z3.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,MAAM,EACN,kBAAkB,EAClB,aAAa,EACb,YAAY,EACZ,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAuBpB;;;;;;;;GAQG;AACH,qBAAa,QAAS,YAAW,MAAM;IACrC,QAAQ,CAAC,IAAI,QAAQ;IACrB,QAAQ,CAAC,YAAY,EAAE,kBAAkB,CAKvC;IAEF;;OAEG;IACH,OAAO,CAAC,uBAAuB;IA8I/B;;;OAGG;IACG,KAAK,CAAC,SAAS,EAAE,GAAG,EAAE,QAAQ,GAAE,aAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAiGpF;IAED;;;OAGG;IACH,OAAO,CAAC,aAAa;IAuLrB;;OAEG;IACG,KAAK,CACT,SAAS,EAAE,GAAG,EACd,SAAS,EAAE,GAAG,EACd,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,YAAY,CAAC,CAiHvB;CACF;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * HiGHS & Model Types
3
+ */
4
+ export type VarType = "Continuous" | "Integer" | "Binary";
5
+ export type OptimizationSense = "Minimize" | "Maximize";
6
+ export type ComparisonSense = "<=" | ">=" | "==";
7
+ export type SolverStatus = "Optimal" | "Feasible" | "Infeasible" | "Unbounded" | "TimeLimit" | "IterationLimit" | "Error" | "NotSolved" | "Sat" | "Unsat" | "Unknown";
8
+ export interface SolveOptions {
9
+ timeLimit?: number;
10
+ outputFlag?: boolean;
11
+ presolve?: "on" | "off" | "choose";
12
+ solver?: "choose" | "simplex" | "ipm" | "pdlp";
13
+ relGap?: number;
14
+ absGap?: number;
15
+ wasmUrl?: string;
16
+ }
17
+ export interface SolverSolution {
18
+ status: SolverStatus;
19
+ objectiveValue: number | null;
20
+ values: Record<string, number>;
21
+ duals: Record<string, number>;
22
+ reducedCosts: Record<string, number>;
23
+ slacks: Record<string, number>;
24
+ runTime: number;
25
+ raw?: any;
26
+ }
27
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/modeler/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,OAAO,GAAG,YAAY,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE1D,MAAM,MAAM,iBAAiB,GAAG,UAAU,GAAG,UAAU,CAAC;AAExD,MAAM,MAAM,eAAe,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAEjD,MAAM,MAAM,YAAY,GACpB,SAAS,GACT,UAAU,GACV,YAAY,GACZ,WAAW,GACX,WAAW,GACX,gBAAgB,GAChB,OAAO,GACP,WAAW,GACX,KAAK,GACL,OAAO,GACP,SAAS,CAAC;AAEd,MAAM,WAAW,YAAY;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,IAAI,GAAG,KAAK,GAAG,QAAQ,CAAC;IACnC,MAAM,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,KAAK,GAAG,MAAM,CAAC;IAC/C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,YAAY,CAAC;IACrB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,GAAG,CAAC;CACX"}
@@ -0,0 +1,52 @@
1
+ import type { VarType } from "./types.js";
2
+ import { LinExpr } from "./expression.js";
3
+ import { Constraint } from "./constraint.js";
4
+ import { QuadExpr } from "./quad-expr.js";
5
+ export interface VarOptions {
6
+ name?: string;
7
+ prefix?: string;
8
+ type?: VarType;
9
+ lb?: number;
10
+ ub?: number;
11
+ }
12
+ /**
13
+ * Represents a decision variable in an optimization problem.
14
+ * Compatible with both PuLP (LpVariable) and python-mip (Var).
15
+ */
16
+ export declare class Var {
17
+ readonly id: number;
18
+ readonly name: string;
19
+ type: VarType;
20
+ lb: number;
21
+ ub: number;
22
+ /** Optimal primal value after solve */
23
+ value: number | null;
24
+ /** Reduced cost from dual solution */
25
+ reducedCost: number | null;
26
+ constructor(options?: VarOptions);
27
+ /** python-mip style value accessor */
28
+ get x(): number | null;
29
+ /** PuLP style value accessor */
30
+ get varValue(): number | null;
31
+ /** Multiply variable by a scalar coefficient or another variable/expression */
32
+ mul(coeff: number): LinExpr;
33
+ mul(other: Var): QuadExpr;
34
+ mul(other: LinExpr): QuadExpr;
35
+ /** Add variable with another variable, linear/quadratic expression, or number */
36
+ add(other: Var | LinExpr | QuadExpr | number): LinExpr | QuadExpr;
37
+ /** Subtract another variable, linear/quadratic expression, or number from this variable */
38
+ sub(other: Var | LinExpr | QuadExpr | number): LinExpr | QuadExpr;
39
+ /** Negate this variable: -x */
40
+ neg(): LinExpr;
41
+ /** Create a less-than-or-equal constraint: this <= rhs */
42
+ le(rhs: number | Var | LinExpr, name?: string): Constraint;
43
+ lessThanOrEqual(rhs: number | Var | LinExpr, name?: string): Constraint;
44
+ /** Create a greater-than-or-equal constraint: this >= rhs */
45
+ ge(rhs: number | Var | LinExpr, name?: string): Constraint;
46
+ greaterThanOrEqual(rhs: number | Var | LinExpr, name?: string): Constraint;
47
+ /** Create an equality constraint: this == rhs */
48
+ eq(rhs: number | Var | LinExpr, name?: string): Constraint;
49
+ equalTo(rhs: number | Var | LinExpr, name?: string): Constraint;
50
+ toString(): string;
51
+ }
52
+ //# sourceMappingURL=variable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variable.d.ts","sourceRoot":"","sources":["../../../src/modeler/variable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAI1C,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,EAAE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CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,GAAG,OAAO,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,UAAU,CAEzD;IACD,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,GAAG,OAAO,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,UAAU,CAEzE;IAED,iDAAiD;IACjD,EAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,GAAG,OAAO,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,UAAU,CAEzD;IACD,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,GAAG,OAAO,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,UAAU,CAE9D;IAED,QAAQ,IAAI,MAAM,CAEjB;CACF"}
package/package.json CHANGED
@@ -1,6 +1,99 @@
1
1
  {
2
2
  "name": "@ohtaman/washi",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "WaSHI: WebAssembly Algebraic System for Hybrid & Integer modeling (LP, MIP, QP, SMT)",
5
+ "type": "module",
6
+ "main": "./dist/lib/washi.js",
7
+ "module": "./dist/lib/washi.js",
8
+ "types": "./dist/types/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/types/index.d.ts",
12
+ "import": "./dist/lib/washi.js",
13
+ "default": "./dist/lib/washi.js"
14
+ },
15
+ "./solvers/z3": {
16
+ "types": "./dist/types/modeler/solvers/z3.d.ts",
17
+ "import": "./dist/lib/solvers/z3.js",
18
+ "default": "./dist/lib/solvers/z3.js"
19
+ },
20
+ "./solvers/glpk": {
21
+ "types": "./dist/types/modeler/solvers/glpk.d.ts",
22
+ "import": "./dist/lib/solvers/glpk.js",
23
+ "default": "./dist/lib/solvers/glpk.js"
24
+ }
25
+ },
26
+ "files": [
27
+ "dist/lib",
28
+ "dist/types",
29
+ "README.md",
30
+ "README.ja.md",
31
+ "README.zh-CN.md",
32
+ "LICENSE",
33
+ "THIRD_PARTY_LICENSES.md"
34
+ ],
35
+ "scripts": {
36
+ "dev": "vite",
37
+ "build:demo": "vite build",
38
+ "build:types": "tsc -p tsconfig.lib.json",
39
+ "build:lib": "vite build --config vite.config.lib.ts",
40
+ "build": "npm run build:types && npm run build:lib && npm run build:demo",
41
+ "preview": "vite preview",
42
+ "test": "vitest run",
43
+ "test:e2e": "vitest run test/e2e.test.ts",
44
+ "prepublishOnly": "npm run build:types && npm run build:lib"
45
+ },
46
+ "keywords": [
47
+ "optimization",
48
+ "mathematical-programming",
49
+ "linear-programming",
50
+ "mixed-integer-programming",
51
+ "quadratic-programming",
52
+ "lp",
53
+ "mip",
54
+ "qp",
55
+ "highs",
56
+ "pulp",
57
+ "wasm",
58
+ "webassembly",
59
+ "typescript"
60
+ ],
61
+ "author": "",
62
+ "license": "MIT",
63
+ "publishConfig": {
64
+ "access": "public",
65
+ "registry": "https://registry.npmjs.org/"
66
+ },
67
+ "repository": {
68
+ "type": "git",
69
+ "url": "git+https://github.com/ohtaman/washi.git"
70
+ },
71
+ "bugs": {
72
+ "url": "https://github.com/ohtaman/washi/issues"
73
+ },
74
+ "homepage": "https://github.com/ohtaman/washi#readme",
75
+ "dependencies": {
76
+ "highs": "^1.15.3"
77
+ },
78
+ "peerDependencies": {
79
+ "glpk.js": "^5.0.0",
80
+ "z3-solver": "^5.2.0"
81
+ },
82
+ "peerDependenciesMeta": {
83
+ "glpk.js": {
84
+ "optional": true
85
+ },
86
+ "z3-solver": {
87
+ "optional": true
88
+ }
89
+ },
90
+ "devDependencies": {
91
+ "@types/node": "^26.6.3",
92
+ "glpk.js": "^5.0.0",
93
+ "playwright": "^1.63.0",
94
+ "typescript": "^7.0.2",
95
+ "vite": "^8.3.1",
96
+ "vitest": "^5.0.2",
97
+ "z3-solver": "^5.2.0"
98
+ }
99
+ }