numopt-js 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 (80) hide show
  1. package/CODING_RULES.md +161 -0
  2. package/LICENSE +22 -0
  3. package/README.md +807 -0
  4. package/dist/core/adjointGradientDescent.d.ts +61 -0
  5. package/dist/core/adjointGradientDescent.d.ts.map +1 -0
  6. package/dist/core/adjointGradientDescent.js +764 -0
  7. package/dist/core/adjointGradientDescent.js.map +1 -0
  8. package/dist/core/constrainedGaussNewton.d.ts +44 -0
  9. package/dist/core/constrainedGaussNewton.d.ts.map +1 -0
  10. package/dist/core/constrainedGaussNewton.js +314 -0
  11. package/dist/core/constrainedGaussNewton.js.map +1 -0
  12. package/dist/core/constrainedLevenbergMarquardt.d.ts +46 -0
  13. package/dist/core/constrainedLevenbergMarquardt.d.ts.map +1 -0
  14. package/dist/core/constrainedLevenbergMarquardt.js +469 -0
  15. package/dist/core/constrainedLevenbergMarquardt.js.map +1 -0
  16. package/dist/core/constrainedUtils.d.ts +92 -0
  17. package/dist/core/constrainedUtils.d.ts.map +1 -0
  18. package/dist/core/constrainedUtils.js +364 -0
  19. package/dist/core/constrainedUtils.js.map +1 -0
  20. package/dist/core/convergence.d.ts +35 -0
  21. package/dist/core/convergence.d.ts.map +1 -0
  22. package/dist/core/convergence.js +51 -0
  23. package/dist/core/convergence.js.map +1 -0
  24. package/dist/core/createGradientFunction.d.ts +85 -0
  25. package/dist/core/createGradientFunction.d.ts.map +1 -0
  26. package/dist/core/createGradientFunction.js +93 -0
  27. package/dist/core/createGradientFunction.js.map +1 -0
  28. package/dist/core/effectiveJacobian.d.ts +90 -0
  29. package/dist/core/effectiveJacobian.d.ts.map +1 -0
  30. package/dist/core/effectiveJacobian.js +128 -0
  31. package/dist/core/effectiveJacobian.js.map +1 -0
  32. package/dist/core/finiteDiff.d.ts +171 -0
  33. package/dist/core/finiteDiff.d.ts.map +1 -0
  34. package/dist/core/finiteDiff.js +363 -0
  35. package/dist/core/finiteDiff.js.map +1 -0
  36. package/dist/core/gaussNewton.d.ts +29 -0
  37. package/dist/core/gaussNewton.d.ts.map +1 -0
  38. package/dist/core/gaussNewton.js +151 -0
  39. package/dist/core/gaussNewton.js.map +1 -0
  40. package/dist/core/gradientDescent.d.ts +35 -0
  41. package/dist/core/gradientDescent.d.ts.map +1 -0
  42. package/dist/core/gradientDescent.js +204 -0
  43. package/dist/core/gradientDescent.js.map +1 -0
  44. package/dist/core/jacobianComputation.d.ts +24 -0
  45. package/dist/core/jacobianComputation.d.ts.map +1 -0
  46. package/dist/core/jacobianComputation.js +38 -0
  47. package/dist/core/jacobianComputation.js.map +1 -0
  48. package/dist/core/levenbergMarquardt.d.ts +36 -0
  49. package/dist/core/levenbergMarquardt.d.ts.map +1 -0
  50. package/dist/core/levenbergMarquardt.js +286 -0
  51. package/dist/core/levenbergMarquardt.js.map +1 -0
  52. package/dist/core/lineSearch.d.ts +42 -0
  53. package/dist/core/lineSearch.d.ts.map +1 -0
  54. package/dist/core/lineSearch.js +106 -0
  55. package/dist/core/lineSearch.js.map +1 -0
  56. package/dist/core/logger.d.ts +77 -0
  57. package/dist/core/logger.d.ts.map +1 -0
  58. package/dist/core/logger.js +162 -0
  59. package/dist/core/logger.js.map +1 -0
  60. package/dist/core/types.d.ts +427 -0
  61. package/dist/core/types.d.ts.map +1 -0
  62. package/dist/core/types.js +15 -0
  63. package/dist/core/types.js.map +1 -0
  64. package/dist/index.d.ts +26 -0
  65. package/dist/index.d.ts.map +1 -0
  66. package/dist/index.js +29 -0
  67. package/dist/index.js.map +1 -0
  68. package/dist/utils/formatting.d.ts +27 -0
  69. package/dist/utils/formatting.d.ts.map +1 -0
  70. package/dist/utils/formatting.js +54 -0
  71. package/dist/utils/formatting.js.map +1 -0
  72. package/dist/utils/matrix.d.ts +63 -0
  73. package/dist/utils/matrix.d.ts.map +1 -0
  74. package/dist/utils/matrix.js +129 -0
  75. package/dist/utils/matrix.js.map +1 -0
  76. package/dist/utils/resultFormatter.d.ts +122 -0
  77. package/dist/utils/resultFormatter.d.ts.map +1 -0
  78. package/dist/utils/resultFormatter.js +342 -0
  79. package/dist/utils/resultFormatter.js.map +1 -0
  80. package/package.json +74 -0
@@ -0,0 +1,427 @@
1
+ /**
2
+ * This file defines the core type definitions for the numopt-js library.
3
+ *
4
+ * Role in system:
5
+ * - Provides type contracts for all optimization algorithms
6
+ * - Defines function signatures for cost functions, gradients, and Jacobians
7
+ * - Establishes option and result interfaces for consistent API design
8
+ *
9
+ * For first-time readers:
10
+ * - Start with ResidualFn and CostFn to understand function signatures
11
+ * - Check option interfaces to see what can be configured
12
+ * - Review result interfaces to understand what each algorithm returns
13
+ */
14
+ import { Matrix } from 'ml-matrix';
15
+ /**
16
+ * Function that computes the residual vector for nonlinear least squares problems.
17
+ * Takes parameter vector and returns residual vector.
18
+ *
19
+ * Note: Uses Float64Array for performance and type safety in numerical computations.
20
+ */
21
+ export type ResidualFn = (parameters: Float64Array) => Float64Array;
22
+ /**
23
+ * Function that computes the Jacobian matrix for nonlinear least squares problems.
24
+ * Takes parameter vector and returns Jacobian matrix (ml-matrix Matrix type).
25
+ *
26
+ * Note: Uses Matrix from ml-matrix package for efficient matrix operations.
27
+ * The Matrix type provides optimized linear algebra operations and is browser-compatible.
28
+ */
29
+ export type JacobianFn = (parameters: Float64Array) => Matrix;
30
+ /**
31
+ * Function that computes the cost (objective function value) for general optimization.
32
+ * Takes parameter vector and returns scalar cost value.
33
+ *
34
+ * Note: Uses Float64Array for parameter vector to ensure 64-bit floating-point precision
35
+ * and better performance in numerical computations.
36
+ */
37
+ export type CostFn = (parameters: Float64Array) => number;
38
+ /**
39
+ * Function that computes the gradient vector for general optimization.
40
+ * Takes parameter vector and returns gradient vector.
41
+ *
42
+ * Note: Uses Float64Array for performance and memory efficiency in numerical computations.
43
+ */
44
+ export type GradientFn = (parameters: Float64Array) => Float64Array;
45
+ /**
46
+ * Function that computes the constraint vector for constrained optimization problems.
47
+ * Takes parameter vector and state vector, returns constraint vector.
48
+ * The constraint c(p, x) = 0 must be satisfied.
49
+ *
50
+ * Note: The constraint vector length and state vector length can differ.
51
+ * The adjoint method supports both square and non-square constraint Jacobians.
52
+ */
53
+ export type ConstraintFn = (parameters: Float64Array, states: Float64Array) => Float64Array;
54
+ /**
55
+ * Function that computes the cost (objective function value) for constrained optimization.
56
+ * Takes parameter vector and state vector, returns scalar cost value.
57
+ *
58
+ * Note: The state vector x must satisfy c(p, x) = 0.
59
+ */
60
+ export type ConstrainedCostFn = (parameters: Float64Array, states: Float64Array) => number;
61
+ /**
62
+ * Function that computes the residual vector for constrained nonlinear least squares problems.
63
+ * Takes parameter vector and state vector, returns residual vector.
64
+ * The cost function is f(p, x) = 1/2 r(p, x)^T r(p, x).
65
+ *
66
+ * Note: The state vector x must satisfy c(p, x) = 0.
67
+ */
68
+ export type ConstrainedResidualFn = (parameters: Float64Array, states: Float64Array) => Float64Array;
69
+ /**
70
+ * Common options shared across optimization algorithms.
71
+ */
72
+ export interface CommonOptimizationOptions {
73
+ /**
74
+ * Maximum number of iterations before stopping.
75
+ * Default: 1000
76
+ */
77
+ maxIterations?: number;
78
+ /**
79
+ * Tolerance for convergence check (gradient norm, step size, etc.).
80
+ * Default: 1e-6
81
+ */
82
+ tolerance?: number;
83
+ /**
84
+ * Callback function called at each iteration for progress monitoring.
85
+ * Useful for debugging and monitoring convergence.
86
+ */
87
+ onIteration?: (iteration: number, cost: number, parameters: Float64Array) => void;
88
+ /**
89
+ * Enable verbose logging for debugging.
90
+ * When true, detailed information is logged to console.
91
+ * Default: false
92
+ *
93
+ * @deprecated Use logLevel instead for more fine-grained control.
94
+ * If both logLevel and verbose are specified, logLevel takes precedence.
95
+ */
96
+ verbose?: boolean;
97
+ /**
98
+ * Log level for detailed logging output.
99
+ * Controls which log messages are displayed:
100
+ * - DEBUG: Detailed progress information (cost, gradient norm, step size, etc.)
101
+ * - INFO: Convergence messages and important state changes
102
+ * - WARN: Warnings (singular matrix, max iterations reached, line search failure, etc.)
103
+ * - ERROR: Fatal errors (currently not used, reserved for future extensions)
104
+ *
105
+ * If verbose is true and logLevel is not specified, logLevel defaults to INFO.
106
+ * If both logLevel and verbose are specified, logLevel takes precedence.
107
+ * Default: undefined (no logging)
108
+ */
109
+ logLevel?: 'DEBUG' | 'INFO' | 'WARN' | 'ERROR';
110
+ }
111
+ /**
112
+ * Options specific to gradient descent algorithm.
113
+ */
114
+ export interface GradientDescentOptions extends CommonOptimizationOptions {
115
+ /**
116
+ * Step size (learning rate) for gradient descent.
117
+ * If not provided, line search will be used to determine step size.
118
+ * Default: undefined (use line search)
119
+ */
120
+ stepSize?: number;
121
+ /**
122
+ * Use line search to determine optimal step size.
123
+ * Default: true
124
+ */
125
+ useLineSearch?: boolean;
126
+ }
127
+ /**
128
+ * Options for line search algorithm.
129
+ */
130
+ export interface LineSearchOptions {
131
+ /**
132
+ * Initial step size to try.
133
+ * If not provided, the initial step size is automatically scaled by the gradient norm:
134
+ * α₀ = 1.0 / ||∇f(x)||
135
+ * This prevents steps from being too large when gradients are large, improving
136
+ * convergence performance. If the gradient norm is very small (< 1e-10) or the
137
+ * computed step size is not finite, the default value of 1.0 is used.
138
+ */
139
+ initialStepSize?: number;
140
+ /**
141
+ * Contraction factor for backtracking line search.
142
+ * Step size is multiplied by this factor when condition is not met.
143
+ * Default: 0.5
144
+ */
145
+ contractionFactor?: number;
146
+ /**
147
+ * Armijo condition parameter (sufficient decrease).
148
+ * Default: 0.1
149
+ */
150
+ armijoParameter?: number;
151
+ /**
152
+ * Maximum number of line search iterations.
153
+ * Default: 50
154
+ */
155
+ maxIterations?: number;
156
+ }
157
+ /**
158
+ * Options for numerical differentiation.
159
+ */
160
+ export interface NumericalDifferentiationOptions {
161
+ /**
162
+ * Step size for finite difference approximation.
163
+ * Default: 1e-6
164
+ */
165
+ stepSize?: number;
166
+ }
167
+ /**
168
+ * Options for Gauss-Newton method.
169
+ */
170
+ export interface GaussNewtonOptions extends CommonOptimizationOptions {
171
+ /**
172
+ * Analytical Jacobian function. If provided, this will be used instead of numerical differentiation.
173
+ * If not provided, numerical Jacobian will be used (if useNumericJacobian is true).
174
+ */
175
+ jacobian?: JacobianFn;
176
+ /**
177
+ * Use numerical differentiation to compute Jacobian if user doesn't provide it.
178
+ * Default: true
179
+ */
180
+ useNumericJacobian?: boolean;
181
+ /**
182
+ * Step size for numerical Jacobian computation.
183
+ * Default: 1e-6
184
+ */
185
+ jacobianStep?: number;
186
+ }
187
+ /**
188
+ * Options for Levenberg-Marquardt algorithm.
189
+ */
190
+ export interface LevenbergMarquardtOptions extends GaussNewtonOptions {
191
+ /**
192
+ * Initial value of damping parameter lambda.
193
+ * Default: 1e-3
194
+ */
195
+ lambdaInitial?: number;
196
+ /**
197
+ * Factor for updating lambda (success: divide, failure: multiply).
198
+ * Default: 10.0
199
+ */
200
+ lambdaFactor?: number;
201
+ /**
202
+ * Tolerance for gradient norm convergence check.
203
+ * Default: 1e-6
204
+ */
205
+ tolGradient?: number;
206
+ /**
207
+ * Tolerance for step size convergence check.
208
+ * Default: 1e-6
209
+ */
210
+ tolStep?: number;
211
+ /**
212
+ * Tolerance for residual norm convergence check.
213
+ * Default: 1e-6
214
+ */
215
+ tolResidual?: number;
216
+ }
217
+ /**
218
+ * Result returned by optimization algorithms.
219
+ */
220
+ export interface OptimizationResult {
221
+ /**
222
+ * Optimized parameter vector.
223
+ */
224
+ parameters: Float64Array;
225
+ /**
226
+ * Number of iterations performed.
227
+ */
228
+ iterations: number;
229
+ /**
230
+ * Whether the algorithm converged successfully.
231
+ */
232
+ converged: boolean;
233
+ /**
234
+ * Final cost (objective function value).
235
+ */
236
+ finalCost: number;
237
+ /**
238
+ * Final gradient norm (if applicable).
239
+ */
240
+ finalGradientNorm?: number;
241
+ /**
242
+ * Final residual norm (for least squares problems).
243
+ * Available for algorithms that work with residual functions.
244
+ */
245
+ finalResidualNorm?: number;
246
+ }
247
+ /**
248
+ * Result returned by Levenberg-Marquardt algorithm.
249
+ */
250
+ export interface LevenbergMarquardtResult extends OptimizationResult {
251
+ /**
252
+ * Final residual norm.
253
+ */
254
+ finalResidualNorm: number;
255
+ /**
256
+ * Final lambda (damping parameter) value.
257
+ */
258
+ finalLambda: number;
259
+ }
260
+ /**
261
+ * Result returned by gradient descent algorithm.
262
+ */
263
+ export interface GradientDescentResult extends OptimizationResult {
264
+ /**
265
+ * Whether line search was used.
266
+ */
267
+ usedLineSearch: boolean;
268
+ }
269
+ /**
270
+ * Options for adjoint gradient descent algorithm.
271
+ */
272
+ export interface AdjointGradientDescentOptions extends GradientDescentOptions {
273
+ /**
274
+ * Analytical partial derivative of cost function with respect to parameters.
275
+ * If provided, this will be used instead of numerical differentiation.
276
+ * Function signature: (p: Float64Array, x: Float64Array) => Float64Array
277
+ */
278
+ dfdp?: (parameters: Float64Array, states: Float64Array) => Float64Array;
279
+ /**
280
+ * Analytical partial derivative of cost function with respect to states.
281
+ * If provided, this will be used instead of numerical differentiation.
282
+ * Function signature: (p: Float64Array, x: Float64Array) => Float64Array
283
+ */
284
+ dfdx?: (parameters: Float64Array, states: Float64Array) => Float64Array;
285
+ /**
286
+ * Analytical partial derivative of constraint function with respect to parameters.
287
+ * If provided, this will be used instead of numerical differentiation.
288
+ * Returns a Matrix of size (constraintCount × parameterCount).
289
+ */
290
+ dcdp?: (parameters: Float64Array, states: Float64Array) => Matrix;
291
+ /**
292
+ * Analytical partial derivative of constraint function with respect to states.
293
+ * If provided, this will be used instead of numerical differentiation.
294
+ * Returns a Matrix of size (constraintCount × stateCount).
295
+ * Must be square (constraintCount == stateCount) for the adjoint method.
296
+ */
297
+ dcdx?: (parameters: Float64Array, states: Float64Array) => Matrix;
298
+ /**
299
+ * Step size for numerical differentiation with respect to parameters.
300
+ * Default: 1e-6
301
+ */
302
+ stepSizeP?: number;
303
+ /**
304
+ * Step size for numerical differentiation with respect to states.
305
+ * Default: 1e-6
306
+ */
307
+ stepSizeX?: number;
308
+ /**
309
+ * Tolerance for checking constraint satisfaction c(p, x) = 0.
310
+ * If ||c(p, x)|| exceeds this value, a warning will be issued.
311
+ * Default: 1e-6
312
+ */
313
+ constraintTolerance?: number;
314
+ }
315
+ /**
316
+ * Result returned by adjoint gradient descent algorithm.
317
+ */
318
+ export interface AdjointGradientDescentResult extends GradientDescentResult {
319
+ /**
320
+ * Final state vector (satisfies constraint c(p, x) = 0).
321
+ */
322
+ finalStates: Float64Array;
323
+ /**
324
+ * Final constraint violation norm ||c(p, x)||.
325
+ */
326
+ finalConstraintNorm?: number;
327
+ }
328
+ /**
329
+ * Options for constrained Gauss-Newton method.
330
+ */
331
+ export interface ConstrainedGaussNewtonOptions extends CommonOptimizationOptions {
332
+ /**
333
+ * Analytical partial derivative of residual function with respect to parameters.
334
+ * If provided, this will be used instead of numerical differentiation.
335
+ * Returns a Matrix of size (residualCount × parameterCount).
336
+ */
337
+ drdp?: (parameters: Float64Array, states: Float64Array) => Matrix;
338
+ /**
339
+ * Analytical partial derivative of residual function with respect to states.
340
+ * If provided, this will be used instead of numerical differentiation.
341
+ * Returns a Matrix of size (residualCount × stateCount).
342
+ */
343
+ drdx?: (parameters: Float64Array, states: Float64Array) => Matrix;
344
+ /**
345
+ * Analytical partial derivative of constraint function with respect to parameters.
346
+ * If provided, this will be used instead of numerical differentiation.
347
+ * Returns a Matrix of size (constraintCount × parameterCount).
348
+ */
349
+ dcdp?: (parameters: Float64Array, states: Float64Array) => Matrix;
350
+ /**
351
+ * Analytical partial derivative of constraint function with respect to states.
352
+ * If provided, this will be used instead of numerical differentiation.
353
+ * Returns a Matrix of size (constraintCount × stateCount).
354
+ * Supports both square (constraintCount == stateCount) and non-square matrices.
355
+ * For non-square matrices, the adjoint method uses normal equations with Cholesky decomposition.
356
+ */
357
+ dcdx?: (parameters: Float64Array, states: Float64Array) => Matrix;
358
+ /**
359
+ * Step size for numerical differentiation with respect to parameters.
360
+ * Default: 1e-6
361
+ */
362
+ stepSizeP?: number;
363
+ /**
364
+ * Step size for numerical differentiation with respect to states.
365
+ * Default: 1e-6
366
+ */
367
+ stepSizeX?: number;
368
+ /**
369
+ * Tolerance for checking constraint satisfaction c(p, x) = 0.
370
+ * If ||c(p, x)|| exceeds this value, a warning will be issued.
371
+ * Default: 1e-6
372
+ */
373
+ constraintTolerance?: number;
374
+ }
375
+ /**
376
+ * Result returned by constrained Gauss-Newton algorithm.
377
+ */
378
+ export interface ConstrainedGaussNewtonResult extends OptimizationResult {
379
+ /**
380
+ * Final state vector (satisfies constraint c(p, x) = 0).
381
+ */
382
+ finalStates: Float64Array;
383
+ /**
384
+ * Final constraint violation norm ||c(p, x)||.
385
+ */
386
+ finalConstraintNorm?: number;
387
+ }
388
+ /**
389
+ * Options for constrained Levenberg-Marquardt algorithm.
390
+ */
391
+ export interface ConstrainedLevenbergMarquardtOptions extends ConstrainedGaussNewtonOptions {
392
+ /**
393
+ * Initial value of damping parameter lambda.
394
+ * Default: 1e-3
395
+ */
396
+ lambdaInitial?: number;
397
+ /**
398
+ * Factor for updating lambda (success: divide, failure: multiply).
399
+ * Default: 10.0
400
+ */
401
+ lambdaFactor?: number;
402
+ /**
403
+ * Tolerance for gradient norm convergence check.
404
+ * Default: 1e-6
405
+ */
406
+ tolGradient?: number;
407
+ /**
408
+ * Tolerance for step size convergence check.
409
+ * Default: 1e-6
410
+ */
411
+ tolStep?: number;
412
+ /**
413
+ * Tolerance for residual norm convergence check.
414
+ * Default: 1e-6
415
+ */
416
+ tolResidual?: number;
417
+ }
418
+ /**
419
+ * Result returned by constrained Levenberg-Marquardt algorithm.
420
+ */
421
+ export interface ConstrainedLevenbergMarquardtResult extends ConstrainedGaussNewtonResult {
422
+ /**
423
+ * Final lambda (damping parameter) value.
424
+ */
425
+ finalLambda: number;
426
+ }
427
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,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AAM,CAAC;IAElE;;;;OAIG;IACH,IAAI,CAAC,EAAE,CAAC,UAAU,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,KAAK,MAAM,CAAC;IAElE;;;;OAIG;IACH,IAAI,CAAC,EAAE,CAAC,UAAU,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,KAAK,MAAM,CAAC;IAElE;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,CAAC,UAAU,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,KAAK,MAAM,CAAC;IAElE;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,4BAA6B,SAAQ,kBAAkB;IACtE;;OAEG;IACH,WAAW,EAAE,YAAY,CAAC;IAE1B;;OAEG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,oCAAqC,SAAQ,6BAA6B;IACzF;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,mCAAoC,SAAQ,4BAA4B;IACvF;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;CACrB"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * This file defines the core type definitions for the numopt-js library.
3
+ *
4
+ * Role in system:
5
+ * - Provides type contracts for all optimization algorithms
6
+ * - Defines function signatures for cost functions, gradients, and Jacobians
7
+ * - Establishes option and result interfaces for consistent API design
8
+ *
9
+ * For first-time readers:
10
+ * - Start with ResidualFn and CostFn to understand function signatures
11
+ * - Check option interfaces to see what can be configured
12
+ * - Review result interfaces to understand what each algorithm returns
13
+ */
14
+ export {};
15
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * This file is the main entry point for the numopt-js library.
3
+ *
4
+ * Role in system:
5
+ * - Exports all public API functions and types
6
+ * - Provides clean, focused interface for users
7
+ * - Single import point for the entire library
8
+ *
9
+ * For first-time readers:
10
+ * - Import everything you need from this file
11
+ * - Check individual algorithm files for detailed documentation
12
+ * - All algorithms follow consistent patterns
13
+ */
14
+ export { gradientDescent } from './core/gradientDescent.js';
15
+ export { backtrackingLineSearch } from './core/lineSearch.js';
16
+ export { gaussNewton } from './core/gaussNewton.js';
17
+ export { levenbergMarquardt } from './core/levenbergMarquardt.js';
18
+ export { adjointGradientDescent } from './core/adjointGradientDescent.js';
19
+ export { constrainedGaussNewton } from './core/constrainedGaussNewton.js';
20
+ export { constrainedLevenbergMarquardt } from './core/constrainedLevenbergMarquardt.js';
21
+ export { finiteDiffGradient, finiteDiffJacobian, finiteDiffPartialP, finiteDiffPartialX, finiteDiffConstraintPartialP, finiteDiffConstraintPartialX, finiteDiffResidualPartialP, finiteDiffResidualPartialX } from './core/finiteDiff.js';
22
+ export { createFiniteDiffGradient, createFiniteDiffJacobian } from './core/createGradientFunction.js';
23
+ export type { ResidualFn, JacobianFn, CostFn, GradientFn, ConstraintFn, ConstrainedCostFn, ConstrainedResidualFn, CommonOptimizationOptions, GradientDescentOptions, LineSearchOptions, NumericalDifferentiationOptions, GaussNewtonOptions, LevenbergMarquardtOptions, AdjointGradientDescentOptions, ConstrainedGaussNewtonOptions, ConstrainedLevenbergMarquardtOptions, OptimizationResult, LevenbergMarquardtResult, GradientDescentResult, AdjointGradientDescentResult, ConstrainedGaussNewtonResult, ConstrainedLevenbergMarquardtResult } from './core/types.js';
24
+ export { float64ArrayToMatrix, matrixToFloat64Array, matrixToFloat64Array2D, vectorNorm, dotProduct, addVectors, subtractVectors, scaleVector } from './utils/matrix.js';
25
+ export { formatOptimizationResult, formatGradientDescentResult, formatLevenbergMarquardtResult, formatConstrainedGaussNewtonResult, formatConstrainedLevenbergMarquardtResult, formatAdjointGradientDescentResult, formatResult, printOptimizationResult, printGradientDescentResult, printLevenbergMarquardtResult, printConstrainedGaussNewtonResult, printConstrainedLevenbergMarquardtResult, printAdjointGradientDescentResult, printResult, type ResultFormatterOptions } from './utils/resultFormatter.js';
26
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EAAE,6BAA6B,EAAE,MAAM,yCAAyC,CAAC;AAGxF,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,4BAA4B,EAC5B,4BAA4B,EAC5B,0BAA0B,EAC1B,0BAA0B,EAC3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAGtG,YAAY,EACV,UAAU,EACV,UAAU,EACV,MAAM,EACN,UAAU,EACV,YAAY,EACZ,iBAAiB,EACjB,qBAAqB,EACrB,yBAAyB,EACzB,sBAAsB,EACtB,iBAAiB,EACjB,+BAA+B,EAC/B,kBAAkB,EAClB,yBAAyB,EACzB,6BAA6B,EAC7B,6BAA6B,EAC7B,oCAAoC,EACpC,kBAAkB,EAClB,wBAAwB,EACxB,qBAAqB,EACrB,4BAA4B,EAC5B,4BAA4B,EAC5B,mCAAmC,EACpC,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,EACtB,UAAU,EACV,UAAU,EACV,UAAU,EACV,eAAe,EACf,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,wBAAwB,EACxB,2BAA2B,EAC3B,8BAA8B,EAC9B,kCAAkC,EAClC,yCAAyC,EACzC,kCAAkC,EAClC,YAAY,EACZ,uBAAuB,EACvB,0BAA0B,EAC1B,6BAA6B,EAC7B,iCAAiC,EACjC,wCAAwC,EACxC,iCAAiC,EACjC,WAAW,EACX,KAAK,sBAAsB,EAC5B,MAAM,4BAA4B,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,29 @@
1
+ /**
2
+ * This file is the main entry point for the numopt-js library.
3
+ *
4
+ * Role in system:
5
+ * - Exports all public API functions and types
6
+ * - Provides clean, focused interface for users
7
+ * - Single import point for the entire library
8
+ *
9
+ * For first-time readers:
10
+ * - Import everything you need from this file
11
+ * - Check individual algorithm files for detailed documentation
12
+ * - All algorithms follow consistent patterns
13
+ */
14
+ // Core algorithms
15
+ export { gradientDescent } from './core/gradientDescent.js';
16
+ export { backtrackingLineSearch } from './core/lineSearch.js';
17
+ export { gaussNewton } from './core/gaussNewton.js';
18
+ export { levenbergMarquardt } from './core/levenbergMarquardt.js';
19
+ export { adjointGradientDescent } from './core/adjointGradientDescent.js';
20
+ export { constrainedGaussNewton } from './core/constrainedGaussNewton.js';
21
+ export { constrainedLevenbergMarquardt } from './core/constrainedLevenbergMarquardt.js';
22
+ // Numerical differentiation utilities
23
+ export { finiteDiffGradient, finiteDiffJacobian, finiteDiffPartialP, finiteDiffPartialX, finiteDiffConstraintPartialP, finiteDiffConstraintPartialX, finiteDiffResidualPartialP, finiteDiffResidualPartialX } from './core/finiteDiff.js';
24
+ export { createFiniteDiffGradient, createFiniteDiffJacobian } from './core/createGradientFunction.js';
25
+ // Utility functions (exported for advanced users)
26
+ export { float64ArrayToMatrix, matrixToFloat64Array, matrixToFloat64Array2D, vectorNorm, dotProduct, addVectors, subtractVectors, scaleVector } from './utils/matrix.js';
27
+ // Result formatting utilities
28
+ export { formatOptimizationResult, formatGradientDescentResult, formatLevenbergMarquardtResult, formatConstrainedGaussNewtonResult, formatConstrainedLevenbergMarquardtResult, formatAdjointGradientDescentResult, formatResult, printOptimizationResult, printGradientDescentResult, printLevenbergMarquardtResult, printConstrainedGaussNewtonResult, printConstrainedLevenbergMarquardtResult, printAdjointGradientDescentResult, printResult } from './utils/resultFormatter.js';
29
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,kBAAkB;AAClB,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EAAE,6BAA6B,EAAE,MAAM,yCAAyC,CAAC;AAExF,sCAAsC;AACtC,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,4BAA4B,EAC5B,4BAA4B,EAC5B,0BAA0B,EAC1B,0BAA0B,EAC3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AA4BtG,kDAAkD;AAClD,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,EACtB,UAAU,EACV,UAAU,EACV,UAAU,EACV,eAAe,EACf,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAE3B,8BAA8B;AAC9B,OAAO,EACL,wBAAwB,EACxB,2BAA2B,EAC3B,8BAA8B,EAC9B,kCAAkC,EAClC,yCAAyC,EACzC,kCAAkC,EAClC,YAAY,EACZ,uBAAuB,EACvB,0BAA0B,EAC1B,6BAA6B,EAC7B,iCAAiC,EACjC,wCAAwC,EACxC,iCAAiC,EACjC,WAAW,EAEZ,MAAM,4BAA4B,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * This file provides number formatting utilities for consistent display
3
+ * of optimization results across the library.
4
+ *
5
+ * Role in system:
6
+ * - Shared formatting logic used by Logger and ResultFormatter
7
+ * - Ensures consistent number representation in console output
8
+ * - Handles edge cases (NaN, Infinity, very small/large numbers)
9
+ *
10
+ * For first-time readers:
11
+ * - formatNumber() is the main function for formatting numbers
12
+ * - Uses scientific notation for very small/large numbers
13
+ * - Uses fixed notation for standard range numbers
14
+ */
15
+ /**
16
+ * Formats a number using scientific notation for readability.
17
+ * Small numbers (< 0.01) and large numbers (> 1000) use scientific notation.
18
+ * Otherwise, uses standard decimal notation.
19
+ * Handles non-numeric values gracefully.
20
+ */
21
+ export declare function formatNumber(value: number | string): string;
22
+ /**
23
+ * Formats a number with a specific number of decimal places.
24
+ * Used when precise control over formatting is needed.
25
+ */
26
+ export declare function formatNumberWithPrecision(value: number, precision: number): string;
27
+ //# sourceMappingURL=formatting.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatting.d.ts","sourceRoot":"","sources":["../../src/utils/formatting.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAOH;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAgB3D;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAUlF"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * This file provides number formatting utilities for consistent display
3
+ * of optimization results across the library.
4
+ *
5
+ * Role in system:
6
+ * - Shared formatting logic used by Logger and ResultFormatter
7
+ * - Ensures consistent number representation in console output
8
+ * - Handles edge cases (NaN, Infinity, very small/large numbers)
9
+ *
10
+ * For first-time readers:
11
+ * - formatNumber() is the main function for formatting numbers
12
+ * - Uses scientific notation for very small/large numbers
13
+ * - Uses fixed notation for standard range numbers
14
+ */
15
+ const SCIENTIFIC_NOTATION_LOWER_THRESHOLD = 0.01;
16
+ const SCIENTIFIC_NOTATION_UPPER_THRESHOLD = 1000;
17
+ const SCIENTIFIC_NOTATION_FRACTION_DIGITS = 3;
18
+ const FIXED_NOTATION_FRACTION_DIGITS = 6;
19
+ /**
20
+ * Formats a number using scientific notation for readability.
21
+ * Small numbers (< 0.01) and large numbers (> 1000) use scientific notation.
22
+ * Otherwise, uses standard decimal notation.
23
+ * Handles non-numeric values gracefully.
24
+ */
25
+ export function formatNumber(value) {
26
+ // Handle non-numeric values
27
+ if (typeof value !== 'number' || !isFinite(value)) {
28
+ return String(value);
29
+ }
30
+ const absoluteValue = Math.abs(value);
31
+ if (absoluteValue === 0) {
32
+ return '0';
33
+ }
34
+ // Use scientific notation for very small or very large numbers to avoid long strings of zeros
35
+ if (absoluteValue < SCIENTIFIC_NOTATION_LOWER_THRESHOLD || absoluteValue >= SCIENTIFIC_NOTATION_UPPER_THRESHOLD) {
36
+ return value.toExponential(SCIENTIFIC_NOTATION_FRACTION_DIGITS);
37
+ }
38
+ // Use fixed notation for standard range numbers for easier reading
39
+ return value.toFixed(FIXED_NOTATION_FRACTION_DIGITS).replace(/\.?0+$/, '');
40
+ }
41
+ /**
42
+ * Formats a number with a specific number of decimal places.
43
+ * Used when precise control over formatting is needed.
44
+ */
45
+ export function formatNumberWithPrecision(value, precision) {
46
+ if (typeof value !== 'number' || !isFinite(value)) {
47
+ return String(value);
48
+ }
49
+ if (value === 0) {
50
+ return '0.' + '0'.repeat(precision);
51
+ }
52
+ return value.toFixed(precision);
53
+ }
54
+ //# sourceMappingURL=formatting.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatting.js","sourceRoot":"","sources":["../../src/utils/formatting.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,MAAM,mCAAmC,GAAG,IAAI,CAAC;AACjD,MAAM,mCAAmC,GAAG,IAAI,CAAC;AACjD,MAAM,mCAAmC,GAAG,CAAC,CAAC;AAC9C,MAAM,8BAA8B,GAAG,CAAC,CAAC;AAEzC;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,KAAsB;IACjD,4BAA4B;IAC5B,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QAClD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IAED,MAAM,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACtC,IAAI,aAAa,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO,GAAG,CAAC;IACb,CAAC;IACD,8FAA8F;IAC9F,IAAI,aAAa,GAAG,mCAAmC,IAAI,aAAa,IAAI,mCAAmC,EAAE,CAAC;QAChH,OAAO,KAAK,CAAC,aAAa,CAAC,mCAAmC,CAAC,CAAC;IAClE,CAAC;IACD,mEAAmE;IACnE,OAAO,KAAK,CAAC,OAAO,CAAC,8BAA8B,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;AAC7E,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,yBAAyB,CA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