@elaraai/east-py-datascience 0.0.2-beta.8 → 0.0.2-beta.80

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 (123) hide show
  1. package/README.md +58 -1
  2. package/dist/src/alns/alns.d.ts +528 -0
  3. package/dist/src/alns/alns.d.ts.map +1 -0
  4. package/dist/src/alns/alns.js +238 -0
  5. package/dist/src/alns/alns.js.map +1 -0
  6. package/dist/src/google_or/google_or.d.ts +2422 -0
  7. package/dist/src/google_or/google_or.d.ts.map +1 -0
  8. package/dist/src/google_or/google_or.js +542 -0
  9. package/dist/src/google_or/google_or.js.map +1 -0
  10. package/dist/{gp → src/gp}/gp.d.ts +185 -136
  11. package/dist/src/gp/gp.d.ts.map +1 -0
  12. package/dist/{gp → src/gp}/gp.js +64 -12
  13. package/dist/src/gp/gp.js.map +1 -0
  14. package/dist/src/index.d.ts +34 -0
  15. package/dist/src/index.d.ts.map +1 -0
  16. package/dist/src/index.js +57 -0
  17. package/dist/src/index.js.map +1 -0
  18. package/dist/src/lightgbm/lightgbm.d.ts +575 -0
  19. package/dist/src/lightgbm/lightgbm.d.ts.map +1 -0
  20. package/dist/{lightgbm → src/lightgbm}/lightgbm.js +104 -18
  21. package/dist/src/lightgbm/lightgbm.js.map +1 -0
  22. package/dist/src/lightning/lightning.d.ts +1594 -0
  23. package/dist/src/lightning/lightning.d.ts.map +1 -0
  24. package/dist/src/lightning/lightning.js +468 -0
  25. package/dist/src/lightning/lightning.js.map +1 -0
  26. package/dist/{mads → src/mads}/mads.d.ts +109 -112
  27. package/dist/src/mads/mads.d.ts.map +1 -0
  28. package/dist/{mads → src/mads}/mads.js +6 -8
  29. package/dist/src/mads/mads.js.map +1 -0
  30. package/dist/src/mapie/mapie.d.ts +3680 -0
  31. package/dist/src/mapie/mapie.d.ts.map +1 -0
  32. package/dist/src/mapie/mapie.js +616 -0
  33. package/dist/src/mapie/mapie.js.map +1 -0
  34. package/dist/{ngboost → src/ngboost}/ngboost.d.ts +192 -142
  35. package/dist/src/ngboost/ngboost.d.ts.map +1 -0
  36. package/dist/{ngboost → src/ngboost}/ngboost.js +67 -14
  37. package/dist/src/ngboost/ngboost.js.map +1 -0
  38. package/dist/src/optimization/optimization.d.ts +420 -0
  39. package/dist/src/optimization/optimization.d.ts.map +1 -0
  40. package/dist/src/optimization/optimization.js +257 -0
  41. package/dist/src/optimization/optimization.js.map +1 -0
  42. package/dist/{optuna → src/optuna}/optuna.d.ts +374 -314
  43. package/dist/src/optuna/optuna.d.ts.map +1 -0
  44. package/dist/{optuna → src/optuna}/optuna.js +2 -0
  45. package/dist/src/optuna/optuna.js.map +1 -0
  46. package/dist/src/pymc/pymc.d.ts +2932 -0
  47. package/dist/src/pymc/pymc.d.ts.map +1 -0
  48. package/dist/src/pymc/pymc.js +688 -0
  49. package/dist/src/pymc/pymc.js.map +1 -0
  50. package/dist/src/scipy/scipy.d.ts +2205 -0
  51. package/dist/src/scipy/scipy.d.ts.map +1 -0
  52. package/dist/src/scipy/scipy.js +884 -0
  53. package/dist/src/scipy/scipy.js.map +1 -0
  54. package/dist/src/shap/shap.d.ts +2988 -0
  55. package/dist/src/shap/shap.d.ts.map +1 -0
  56. package/dist/src/shap/shap.js +500 -0
  57. package/dist/src/shap/shap.js.map +1 -0
  58. package/dist/{simanneal → src/simanneal}/simanneal.d.ts +257 -160
  59. package/dist/src/simanneal/simanneal.d.ts.map +1 -0
  60. package/dist/{simanneal → src/simanneal}/simanneal.js +105 -8
  61. package/dist/src/simanneal/simanneal.js.map +1 -0
  62. package/dist/src/simulation/simulation.d.ts +431 -0
  63. package/dist/src/simulation/simulation.d.ts.map +1 -0
  64. package/dist/src/simulation/simulation.js +306 -0
  65. package/dist/src/simulation/simulation.js.map +1 -0
  66. package/dist/src/sklearn/sklearn.d.ts +6362 -0
  67. package/dist/src/sklearn/sklearn.d.ts.map +1 -0
  68. package/dist/src/sklearn/sklearn.js +1508 -0
  69. package/dist/src/sklearn/sklearn.js.map +1 -0
  70. package/dist/src/torch/torch.d.ts +1205 -0
  71. package/dist/src/torch/torch.d.ts.map +1 -0
  72. package/dist/{torch → src/torch}/torch.js +109 -18
  73. package/dist/src/torch/torch.js.map +1 -0
  74. package/dist/src/types.d.ts +43 -0
  75. package/dist/src/types.d.ts.map +1 -0
  76. package/dist/src/types.js +44 -0
  77. package/dist/src/types.js.map +1 -0
  78. package/dist/src/xgboost/xgboost.d.ts +1424 -0
  79. package/dist/src/xgboost/xgboost.d.ts.map +1 -0
  80. package/dist/src/xgboost/xgboost.js +432 -0
  81. package/dist/src/xgboost/xgboost.js.map +1 -0
  82. package/package.json +12 -12
  83. package/dist/gp/gp.d.ts.map +0 -1
  84. package/dist/gp/gp.js.map +0 -1
  85. package/dist/index.d.ts +0 -27
  86. package/dist/index.d.ts.map +0 -1
  87. package/dist/index.js +0 -41
  88. package/dist/index.js.map +0 -1
  89. package/dist/lightgbm/lightgbm.d.ts +0 -494
  90. package/dist/lightgbm/lightgbm.d.ts.map +0 -1
  91. package/dist/lightgbm/lightgbm.js.map +0 -1
  92. package/dist/mads/mads.d.ts.map +0 -1
  93. package/dist/mads/mads.js.map +0 -1
  94. package/dist/ngboost/ngboost.d.ts.map +0 -1
  95. package/dist/ngboost/ngboost.js.map +0 -1
  96. package/dist/optuna/optuna.d.ts.map +0 -1
  97. package/dist/optuna/optuna.js.map +0 -1
  98. package/dist/scipy/scipy.d.ts +0 -1260
  99. package/dist/scipy/scipy.d.ts.map +0 -1
  100. package/dist/scipy/scipy.js +0 -413
  101. package/dist/scipy/scipy.js.map +0 -1
  102. package/dist/shap/shap.d.ts +0 -657
  103. package/dist/shap/shap.d.ts.map +0 -1
  104. package/dist/shap/shap.js +0 -241
  105. package/dist/shap/shap.js.map +0 -1
  106. package/dist/simanneal/simanneal.d.ts.map +0 -1
  107. package/dist/simanneal/simanneal.js.map +0 -1
  108. package/dist/sklearn/sklearn.d.ts +0 -2691
  109. package/dist/sklearn/sklearn.d.ts.map +0 -1
  110. package/dist/sklearn/sklearn.js +0 -524
  111. package/dist/sklearn/sklearn.js.map +0 -1
  112. package/dist/torch/torch.d.ts +0 -1081
  113. package/dist/torch/torch.d.ts.map +0 -1
  114. package/dist/torch/torch.js.map +0 -1
  115. package/dist/tsconfig.tsbuildinfo +0 -1
  116. package/dist/types.d.ts +0 -80
  117. package/dist/types.d.ts.map +0 -1
  118. package/dist/types.js +0 -81
  119. package/dist/types.js.map +0 -1
  120. package/dist/xgboost/xgboost.d.ts +0 -504
  121. package/dist/xgboost/xgboost.d.ts.map +0 -1
  122. package/dist/xgboost/xgboost.js +0 -177
  123. package/dist/xgboost/xgboost.js.map +0 -1
@@ -0,0 +1,238 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
4
+ */
5
+ /**
6
+ * ALNS (Adaptive Large Neighborhood Search) metaheuristic optimization.
7
+ *
8
+ * Provides combinatorial optimization using destroy-repair operators.
9
+ * ALNS is designed for discrete optimization problems where:
10
+ * - Solutions are combinatorial (assignments, schedules, routes)
11
+ * - Domain-specific destroy/repair operators can be defined
12
+ * - The objective function may be complex or black-box
13
+ * - Local search alone gets stuck in local minima
14
+ *
15
+ * @packageDocumentation
16
+ */
17
+ import { East, StructType, VariantType, OptionType, ArrayType, IntegerType, BooleanType, FloatType, NullType, FunctionType, } from "@elaraai/east";
18
+ // ============================================================================
19
+ // Acceptance Criteria Types
20
+ // ============================================================================
21
+ /**
22
+ * Simulated annealing acceptance configuration.
23
+ */
24
+ export const SimulatedAnnealingConfigType = StructType({
25
+ /** Starting temperature (default: 100.0) */
26
+ start_temperature: OptionType(FloatType),
27
+ /** Ending temperature (default: 0.01) */
28
+ end_temperature: OptionType(FloatType),
29
+ /** Cooling step multiplier (default: 0.99) */
30
+ step: OptionType(FloatType),
31
+ });
32
+ /**
33
+ * Record-to-record travel acceptance configuration.
34
+ */
35
+ export const RecordToRecordConfigType = StructType({
36
+ /** Threshold as fraction of best objective (default: 0.05) */
37
+ threshold: OptionType(FloatType),
38
+ });
39
+ /**
40
+ * Acceptance criterion variant.
41
+ *
42
+ * Controls whether to accept or reject new solutions:
43
+ * - `simulated_annealing`: Probabilistic acceptance based on temperature
44
+ * - `hill_climbing`: Only accept improving solutions
45
+ * - `record_to_record`: Accept if within threshold of best
46
+ */
47
+ export const AcceptanceCriterionType = VariantType({
48
+ simulated_annealing: SimulatedAnnealingConfigType,
49
+ hill_climbing: NullType,
50
+ record_to_record: RecordToRecordConfigType,
51
+ });
52
+ // ============================================================================
53
+ // Operator Selection Types
54
+ // ============================================================================
55
+ /**
56
+ * Roulette wheel selection configuration.
57
+ *
58
+ * Scores are applied when an operator finds: [new_best, better, accepted, rejected]
59
+ */
60
+ export const RouletteWheelConfigType = StructType({
61
+ /** Scores for [new_best, better, accepted, rejected] (default: [33, 9, 3, 0]) */
62
+ scores: OptionType(ArrayType(IntegerType)),
63
+ /** Weight decay factor (default: 0.8) */
64
+ decay: OptionType(FloatType),
65
+ });
66
+ /**
67
+ * Operator selection strategy variant.
68
+ */
69
+ export const OperatorSelectionType = VariantType({
70
+ roulette_wheel: RouletteWheelConfigType,
71
+ });
72
+ // ============================================================================
73
+ // Stopping Criteria Types
74
+ // ============================================================================
75
+ /**
76
+ * Stopping criterion variant.
77
+ *
78
+ * Controls when to stop the optimization:
79
+ * - `max_iterations`: Stop after N iterations
80
+ * - `max_runtime`: Stop after N seconds
81
+ * - `no_improvement`: Stop after N iterations without improvement
82
+ */
83
+ export const StopCriterionType = VariantType({
84
+ max_iterations: IntegerType,
85
+ max_runtime: FloatType,
86
+ no_improvement: IntegerType,
87
+ });
88
+ // ============================================================================
89
+ // Configuration Types
90
+ // ============================================================================
91
+ /**
92
+ * ALNS optimization configuration.
93
+ */
94
+ export const ALNSConfigType = StructType({
95
+ /** Stopping criterion (default: max_iterations 1000) */
96
+ stop: OptionType(StopCriterionType),
97
+ /** Acceptance criterion (default: simulated_annealing) */
98
+ acceptance: OptionType(AcceptanceCriterionType),
99
+ /** Operator selection strategy (default: roulette_wheel) */
100
+ operator_selection: OptionType(OperatorSelectionType),
101
+ /** Random seed for reproducibility */
102
+ seed: OptionType(IntegerType),
103
+ });
104
+ // ============================================================================
105
+ // Result Types
106
+ // ============================================================================
107
+ /**
108
+ * ALNS optimization result type.
109
+ * Note: For generic platform usage, the result type is defined inline
110
+ * with "S" placeholder. This function is kept for backwards compatibility.
111
+ */
112
+ export const ALNSResultType = StructType({
113
+ /** Best solution found */
114
+ best_solution: "S",
115
+ /** Best objective value */
116
+ best_objective: FloatType,
117
+ /** Number of iterations performed */
118
+ iterations: IntegerType,
119
+ /** Total runtime in seconds */
120
+ runtime: FloatType,
121
+ /** Whether optimization succeeded */
122
+ success: BooleanType,
123
+ });
124
+ // ============================================================================
125
+ // Platform Functions
126
+ // ============================================================================
127
+ /**
128
+ * ALNS optimization platform function (generic over solution type S).
129
+ *
130
+ * Minimizes an objective function using destroy-repair operators.
131
+ * Operators are defined as S -> S functions that modify the solution.
132
+ *
133
+ * @example
134
+ * ```ts
135
+ * import { East, StructType, ArrayType, StringType, FloatType, variant } from "@elaraai/east";
136
+ * import { ALNS } from "@elaraai/east-py-datascience";
137
+ *
138
+ * const SolutionType = StructType({
139
+ * assignments: ArrayType(StringType),
140
+ * cost: FloatType,
141
+ * });
142
+ *
143
+ * const optimize = East.function([SolutionType], ALNS.Types.ResultType, ($, initial) => {
144
+ * // Define operators inline (they can access outer scope variables)
145
+ * const objective = East.function([SolutionType], FloatType, ($, s) => $.return(s.cost));
146
+ * const destroy = East.function([SolutionType], SolutionType, ($, s) => $.return(s));
147
+ * const repair = East.function([SolutionType], SolutionType, ($, s) => $.return(s));
148
+ *
149
+ * const config = $.let({
150
+ * stop: variant('some', variant('max_iterations', 1000n)),
151
+ * acceptance: variant('none', null),
152
+ * operator_selection: variant('none', null),
153
+ * seed: variant('some', 42n),
154
+ * });
155
+ *
156
+ * const result = $.let(ALNS.optimize([SolutionType], initial, objective, [destroy], [repair], config));
157
+ * $.return(result);
158
+ * });
159
+ * ```
160
+ */
161
+ export const alns_optimize = East.genericPlatform("alns_optimize", ["S"], [
162
+ "S", // initial_solution: S
163
+ FunctionType(["S"], FloatType), // objective: S -> Float
164
+ ArrayType(FunctionType(["S"], "S")), // destroy_operators: Array<S -> S>
165
+ ArrayType(FunctionType(["S"], "S")), // repair_operators: Array<S -> S>
166
+ ALNSConfigType,
167
+ ], ALNSResultType);
168
+ // ============================================================================
169
+ // Grouped Export
170
+ // ============================================================================
171
+ /**
172
+ * Type definitions for ALNS optimization.
173
+ */
174
+ export const ALNSTypes = {
175
+ /** Simulated annealing config */
176
+ SimulatedAnnealingConfigType,
177
+ /** Record-to-record config */
178
+ RecordToRecordConfigType,
179
+ /** Acceptance criterion variant */
180
+ AcceptanceCriterionType,
181
+ /** Roulette wheel selection config */
182
+ RouletteWheelConfigType,
183
+ /** Operator selection variant */
184
+ OperatorSelectionType,
185
+ /** Stop criterion variant */
186
+ StopCriterionType,
187
+ /** Main configuration type */
188
+ ConfigType: ALNSConfigType,
189
+ /** Result type (with "S" placeholder for solution type) */
190
+ ResultType: ALNSResultType,
191
+ };
192
+ /**
193
+ * ALNS (Adaptive Large Neighborhood Search) optimization.
194
+ *
195
+ * Provides combinatorial optimization using destroy-repair operators.
196
+ * ALNS is particularly effective for:
197
+ * - Scheduling and rostering problems
198
+ * - Vehicle routing problems
199
+ * - Resource allocation problems
200
+ * - Any problem where domain-specific operators can be designed
201
+ *
202
+ * @example
203
+ * ```ts
204
+ * import { East, StructType, FloatType, variant } from "@elaraai/east";
205
+ * import { ALNS } from "@elaraai/east-py-datascience";
206
+ *
207
+ * const SolutionType = StructType({ value: FloatType });
208
+ *
209
+ * const optimize = East.function([SolutionType], ALNS.Types.ResultType, ($, initial) => {
210
+ * const objective = East.function([SolutionType], FloatType, ($, s) => $.return(s.value));
211
+ * const destroy = East.function([SolutionType], SolutionType, ($, s) => $.return(s));
212
+ * const repair = East.function([SolutionType], SolutionType, ($, s) => $.return(s));
213
+ *
214
+ * const config = $.let({
215
+ * stop: variant('some', variant('max_iterations', 100n)),
216
+ * acceptance: variant('none', null),
217
+ * operator_selection: variant('none', null),
218
+ * seed: variant('some', 42n),
219
+ * });
220
+ *
221
+ * return $.return(ALNS.optimize([SolutionType], initial, objective, [destroy], [repair], config));
222
+ * });
223
+ * ```
224
+ */
225
+ export const ALNS = {
226
+ /**
227
+ * ALNS optimization (generic over solution type).
228
+ *
229
+ * Call with type parameter array first, then arguments:
230
+ * `ALNS.optimize([MySolutionType], initial, objective, destroys, repairs, config)`
231
+ */
232
+ optimize: alns_optimize,
233
+ /**
234
+ * Type definitions for ALNS functions.
235
+ */
236
+ Types: ALNSTypes,
237
+ };
238
+ //# sourceMappingURL=alns.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alns.js","sourceRoot":"","sources":["../../../src/alns/alns.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;GAWG;AAEH,OAAO,EACH,IAAI,EACJ,UAAU,EACV,WAAW,EACX,UAAU,EACV,SAAS,EACT,WAAW,EACX,WAAW,EACX,SAAS,EACT,QAAQ,EACR,YAAY,GACf,MAAM,eAAe,CAAC;AAEvB,+EAA+E;AAC/E,4BAA4B;AAC5B,+EAA+E;AAE/E;;GAEG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,UAAU,CAAC;IACnD,4CAA4C;IAC5C,iBAAiB,EAAE,UAAU,CAAC,SAAS,CAAC;IACxC,yCAAyC;IACzC,eAAe,EAAE,UAAU,CAAC,SAAS,CAAC;IACtC,8CAA8C;IAC9C,IAAI,EAAE,UAAU,CAAC,SAAS,CAAC;CAC9B,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,UAAU,CAAC;IAC/C,8DAA8D;IAC9D,SAAS,EAAE,UAAU,CAAC,SAAS,CAAC;CACnC,CAAC,CAAC;AAEH;;;;;;;GAO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