@areb0s/scip.js 1.0.5 → 1.0.6

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.
package/dist/types.d.ts CHANGED
@@ -3,228 +3,170 @@
3
3
  * SCIP Optimization Solver for JavaScript/WebAssembly
4
4
  */
5
5
 
6
- declare module 'scip.js' {
7
- /**
8
- * Solution status
9
- */
10
- export enum Status {
11
- OPTIMAL = 'optimal',
12
- INFEASIBLE = 'infeasible',
13
- UNBOUNDED = 'unbounded',
14
- TIME_LIMIT = 'timelimit',
15
- UNKNOWN = 'unknown',
16
- ERROR = 'error'
17
- }
6
+ /**
7
+ * Solution status
8
+ */
9
+ export type StatusType = 'optimal' | 'infeasible' | 'unbounded' | 'timelimit' | 'unknown' | 'error';
18
10
 
19
- /**
20
- * Initialization options
21
- */
22
- export interface InitOptions {
23
- /** Path to scip.wasm file (default: './scip.wasm') */
24
- wasmPath?: string;
25
- /** Path to Web Worker script (for worker mode) */
26
- workerPath?: string;
27
- }
11
+ export const Status: {
12
+ OPTIMAL: 'optimal';
13
+ INFEASIBLE: 'infeasible';
14
+ UNBOUNDED: 'unbounded';
15
+ TIME_LIMIT: 'timelimit';
16
+ UNKNOWN: 'unknown';
17
+ ERROR: 'error';
18
+ };
28
19
 
29
- /**
30
- * Solver options
31
- */
32
- export interface SolveOptions {
33
- /** Input format: 'lp', 'mps', 'zpl' (default: 'lp') */
34
- format?: 'lp' | 'mps' | 'zpl';
35
- /** Time limit in seconds (default: 3600) */
36
- timeLimit?: number;
37
- /** Relative gap for MIP (e.g., 0.01 for 1%) */
38
- gap?: number | null;
39
- /** Enable verbose output */
40
- verbose?: boolean;
41
- /** Additional SCIP parameters */
42
- parameters?: Record<string, string | number | boolean>;
43
- /** Init options (for worker mode) */
44
- initOptions?: InitOptions;
45
- }
20
+ /**
21
+ * Initialization options
22
+ */
23
+ export interface InitOptions {
24
+ /** Path to scip.wasm file (default: CDN) */
25
+ wasmPath?: string;
26
+ }
46
27
 
47
- /**
48
- * Solver statistics
49
- */
50
- export interface Statistics {
51
- /** Solving time in seconds */
52
- solvingTime: number | null;
53
- /** Number of branch-and-bound nodes */
54
- nodes: number | null;
55
- /** Number of LP iterations */
56
- iterations: number | null;
57
- /** Final optimality gap (percentage) */
58
- gap: number | null;
59
- }
28
+ /**
29
+ * Solver options
30
+ */
31
+ export interface SolveOptions extends InitOptions {
32
+ /** Input format: 'lp', 'mps', 'zpl' (default: 'lp') */
33
+ format?: 'lp' | 'mps' | 'zpl';
34
+ /** Time limit in seconds (default: 3600) */
35
+ timeLimit?: number;
36
+ /** Relative gap for MIP (e.g., 0.01 for 1%) */
37
+ gap?: number | null;
38
+ /** Enable verbose output */
39
+ verbose?: boolean;
40
+ /** Additional SCIP parameters */
41
+ parameters?: Record<string, string | number | boolean>;
42
+ }
60
43
 
61
- /**
62
- * Solution result
63
- */
64
- export interface Solution {
65
- /** Solution status */
66
- status: Status;
67
- /** Objective function value */
68
- objective: number | null;
69
- /** Variable values */
70
- variables: Record<string, number>;
71
- /** Solver statistics */
72
- statistics: Statistics;
73
- /** Exit code from SCIP */
74
- exitCode?: number;
75
- /** Raw output (if verbose mode) */
76
- output?: string;
77
- /** Raw solution file content */
78
- rawSolution?: string | null;
79
- /** Error message (if status is ERROR) */
80
- error?: string;
81
- }
44
+ /**
45
+ * Solver statistics
46
+ */
47
+ export interface Statistics {
48
+ /** Solving time in seconds */
49
+ solvingTime: number | null;
50
+ /** Number of branch-and-bound nodes */
51
+ nodes: number | null;
52
+ /** Number of LP iterations */
53
+ iterations: number | null;
54
+ /** Final optimality gap (percentage) */
55
+ gap: number | null;
56
+ }
82
57
 
83
- /**
84
- * Initialize SCIP WASM module
85
- * @param options - Initialization options
86
- */
87
- export function init(options?: InitOptions): Promise<void>;
88
-
89
- /**
90
- * Promise that resolves when SCIP is initialized
91
- * Use like OpenCV's cv.ready
92
- * @example
93
- * await SCIP.ready;
94
- * const result = await SCIP.solve(`...`);
95
- */
96
- export const ready: Promise<void>;
97
-
98
- /**
99
- * Check if SCIP is initialized
100
- */
101
- export function isReady(): boolean;
102
-
103
- /**
104
- * Solve an optimization problem
105
- * @param problem - Problem in LP, MPS, or ZIMPL format
106
- * @param options - Solver options
107
- * @returns Solution object
108
- *
109
- * @example
110
- * ```typescript
111
- * const result = await solve(`
112
- * Minimize obj: x + 2 y
113
- * Subject To
114
- * c1: x + y >= 1
115
- * Bounds
116
- * 0 <= x <= 10
117
- * 0 <= y <= 10
118
- * End
119
- * `);
120
- *
121
- * if (result.status === Status.OPTIMAL) {
122
- * console.log('Optimal value:', result.objective);
123
- * console.log('x =', result.variables.x);
124
- * console.log('y =', result.variables.y);
125
- * }
126
- * ```
127
- */
128
- export function solve(problem: string, options?: SolveOptions): Promise<Solution>;
129
-
130
- /**
131
- * Solve a minimization problem
132
- * Convenience wrapper that ensures minimization
133
- */
134
- export function minimize(problem: string, options?: SolveOptions): Promise<Solution>;
135
-
136
- /**
137
- * Solve a maximization problem
138
- * Convenience wrapper that ensures maximization
139
- */
140
- export function maximize(problem: string, options?: SolveOptions): Promise<Solution>;
141
-
142
- /**
143
- * Get SCIP version info
144
- */
145
- export function version(): Promise<string>;
146
-
147
- /**
148
- * Get available SCIP parameters
149
- */
150
- export function getParameters(): Promise<string>;
151
-
152
- // Worker API
153
-
154
- /**
155
- * Initialize SCIP in a Web Worker
156
- */
157
- export function initWorker(options?: InitOptions): Promise<void>;
158
-
159
- /**
160
- * Solve in a Web Worker (non-blocking)
161
- */
162
- export function solveInWorker(problem: string, options?: SolveOptions): Promise<Solution>;
163
-
164
- /**
165
- * Minimize in a Web Worker
166
- */
167
- export function minimizeInWorker(problem: string, options?: SolveOptions): Promise<Solution>;
168
-
169
- /**
170
- * Maximize in a Web Worker
171
- */
172
- export function maximizeInWorker(problem: string, options?: SolveOptions): Promise<Solution>;
173
-
174
- /**
175
- * Terminate the Web Worker
176
- */
177
- export function terminateWorker(): void;
178
-
179
- /**
180
- * Worker solver instance
181
- */
182
- export interface WorkerSolver {
183
- solve(problem: string, options?: SolveOptions): Promise<Solution>;
184
- minimize(problem: string, options?: SolveOptions): Promise<Solution>;
185
- maximize(problem: string, options?: SolveOptions): Promise<Solution>;
186
- version(): Promise<string>;
187
- isReady(): Promise<boolean>;
188
- terminate(): void;
189
- }
58
+ /**
59
+ * Solution result
60
+ */
61
+ export interface Solution {
62
+ /** Solution status */
63
+ status: StatusType;
64
+ /** Objective function value */
65
+ objective: number | null;
66
+ /** Variable values */
67
+ variables: Record<string, number>;
68
+ /** Solver statistics */
69
+ statistics: Statistics;
70
+ /** Exit code from SCIP */
71
+ exitCode?: number;
72
+ /** Raw output (if verbose mode) */
73
+ output?: string;
74
+ /** Raw solution file content */
75
+ rawSolution?: string | null;
76
+ /** Error message (if status is ERROR) */
77
+ error?: string;
78
+ }
79
+
80
+ /**
81
+ * Initialize SCIP WASM module
82
+ * @param options - Initialization options
83
+ */
84
+ export function init(options?: InitOptions): Promise<void>;
85
+
86
+ /**
87
+ * Promise that resolves when SCIP is initialized
88
+ * Use like OpenCV's cv.ready
89
+ * @example
90
+ * await SCIP.ready;
91
+ * const result = await SCIP.solve(`...`);
92
+ */
93
+ export const ready: Promise<void>;
94
+
95
+ /**
96
+ * Check if SCIP is initialized
97
+ */
98
+ export function isReady(): boolean;
99
+
100
+ /**
101
+ * Solve an optimization problem
102
+ * @param problem - Problem in LP, MPS, or ZIMPL format
103
+ * @param options - Solver options
104
+ * @returns Solution object
105
+ *
106
+ * @example
107
+ * ```typescript
108
+ * const result = await SCIP.solve(`
109
+ * Minimize obj: x + 2 y
110
+ * Subject To
111
+ * c1: x + y >= 1
112
+ * Bounds
113
+ * 0 <= x <= 10
114
+ * 0 <= y <= 10
115
+ * End
116
+ * `);
117
+ *
118
+ * if (result.status === 'optimal') {
119
+ * console.log('Optimal value:', result.objective);
120
+ * }
121
+ * ```
122
+ */
123
+ export function solve(problem: string, options?: SolveOptions): Promise<Solution>;
124
+
125
+ /**
126
+ * Solve a minimization problem
127
+ */
128
+ export function minimize(problem: string, options?: SolveOptions): Promise<Solution>;
129
+
130
+ /**
131
+ * Solve a maximization problem
132
+ */
133
+ export function maximize(problem: string, options?: SolveOptions): Promise<Solution>;
134
+
135
+ /**
136
+ * Get SCIP version info
137
+ */
138
+ export function version(): Promise<string>;
139
+
140
+ /**
141
+ * Get available SCIP parameters
142
+ */
143
+ export function getParameters(): Promise<string>;
190
144
 
191
- /**
192
- * Create a worker-based solver instance
193
- * Use for long-running optimizations to avoid blocking the main thread
194
- */
195
- export function createWorkerSolver(options?: InitOptions): Promise<WorkerSolver>;
196
-
197
- // Default export
198
- const SCIP: {
199
- init: typeof init;
200
- ready: typeof ready;
201
- isReady: typeof isReady;
202
- solve: typeof solve;
203
- minimize: typeof minimize;
204
- maximize: typeof maximize;
205
- version: typeof version;
206
- getParameters: typeof getParameters;
207
- Status: typeof Status;
208
- };
209
-
210
- export default SCIP;
145
+ /**
146
+ * SCIP module interface
147
+ */
148
+ export interface SCIPModule {
149
+ init: typeof init;
150
+ ready: typeof ready;
151
+ isReady: typeof isReady;
152
+ solve: typeof solve;
153
+ minimize: typeof minimize;
154
+ maximize: typeof maximize;
155
+ version: typeof version;
156
+ getParameters: typeof getParameters;
157
+ Status: typeof Status;
211
158
  }
212
159
 
213
- // LP Format Problem Helper Types
214
- declare module 'scip.js/lp' {
215
- /**
216
- * LP Problem builder (optional convenience API)
217
- */
218
- export interface LPProblem {
219
- minimize(expression: string): LPProblem;
220
- maximize(expression: string): LPProblem;
221
- subjectTo(name: string, constraint: string): LPProblem;
222
- bounds(variable: string, lower?: number, upper?: number): LPProblem;
223
- binary(...variables: string[]): LPProblem;
224
- integer(...variables: string[]): LPProblem;
225
- general(...variables: string[]): LPProblem;
226
- toString(): string;
227
- }
160
+ declare const SCIP: SCIPModule;
161
+ export default SCIP;
228
162
 
229
- export function createProblem(): LPProblem;
163
+ // Global declaration for CDN usage
164
+ declare global {
165
+ interface Window {
166
+ SCIP: SCIPModule;
167
+ SCIP_BASE_URL?: string;
168
+ }
169
+
170
+ var SCIP: SCIPModule;
171
+ var SCIP_BASE_URL: string | undefined;
230
172
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@areb0s/scip.js",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "SCIP Optimization Solver compiled to WebAssembly - LP, MIP, and MINLP support",
5
5
  "main": "dist/index.mjs",
6
6
  "module": "dist/index.mjs",