@elaraai/east-py-datascience 1.0.1 → 1.0.3
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/src/alns/alns.d.ts +528 -0
- package/dist/src/alns/alns.d.ts.map +1 -0
- package/dist/src/alns/alns.js +238 -0
- package/dist/src/alns/alns.js.map +1 -0
- package/dist/src/google_or/google_or.d.ts +2457 -0
- package/dist/src/google_or/google_or.d.ts.map +1 -0
- package/dist/src/google_or/google_or.js +547 -0
- package/dist/src/google_or/google_or.js.map +1 -0
- package/dist/src/gp/gp.d.ts +447 -0
- package/dist/src/gp/gp.d.ts.map +1 -0
- package/dist/src/gp/gp.js +222 -0
- package/dist/src/gp/gp.js.map +1 -0
- package/dist/src/index.d.ts +34 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +57 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/lightgbm/lightgbm.d.ts +575 -0
- package/dist/src/lightgbm/lightgbm.d.ts.map +1 -0
- package/dist/src/lightgbm/lightgbm.js +241 -0
- package/dist/src/lightgbm/lightgbm.js.map +1 -0
- package/dist/src/lightning/lightning.d.ts +1594 -0
- package/dist/src/lightning/lightning.d.ts.map +1 -0
- package/dist/src/lightning/lightning.js +468 -0
- package/dist/src/lightning/lightning.js.map +1 -0
- package/dist/src/mads/mads.d.ts +410 -0
- package/dist/src/mads/mads.d.ts.map +1 -0
- package/dist/src/mads/mads.js +219 -0
- package/dist/src/mads/mads.js.map +1 -0
- package/dist/src/mapie/mapie.d.ts +3680 -0
- package/dist/src/mapie/mapie.d.ts.map +1 -0
- package/dist/src/mapie/mapie.js +616 -0
- package/dist/src/mapie/mapie.js.map +1 -0
- package/dist/src/ngboost/ngboost.d.ts +483 -0
- package/dist/src/ngboost/ngboost.d.ts.map +1 -0
- package/dist/src/ngboost/ngboost.js +231 -0
- package/dist/src/ngboost/ngboost.js.map +1 -0
- package/dist/src/optimization/optimization.d.ts +700 -0
- package/dist/src/optimization/optimization.d.ts.map +1 -0
- package/dist/src/optimization/optimization.js +411 -0
- package/dist/src/optimization/optimization.js.map +1 -0
- package/dist/src/optuna/optuna.d.ts +857 -0
- package/dist/src/optuna/optuna.d.ts.map +1 -0
- package/dist/src/optuna/optuna.js +270 -0
- package/dist/src/optuna/optuna.js.map +1 -0
- package/dist/src/pymc/pymc.d.ts +2932 -0
- package/dist/src/pymc/pymc.d.ts.map +1 -0
- package/dist/src/pymc/pymc.js +688 -0
- package/dist/src/pymc/pymc.js.map +1 -0
- package/dist/src/scipy/scipy.d.ts +2205 -0
- package/dist/src/scipy/scipy.d.ts.map +1 -0
- package/dist/src/scipy/scipy.js +884 -0
- package/dist/src/scipy/scipy.js.map +1 -0
- package/dist/src/shap/shap.d.ts +4611 -0
- package/dist/src/shap/shap.d.ts.map +1 -0
- package/dist/src/shap/shap.js +552 -0
- package/dist/src/shap/shap.js.map +1 -0
- package/dist/src/simanneal/simanneal.d.ts +628 -0
- package/dist/src/simanneal/simanneal.d.ts.map +1 -0
- package/dist/src/simanneal/simanneal.js +328 -0
- package/dist/src/simanneal/simanneal.js.map +1 -0
- package/dist/src/simulation/simulation.d.ts +224 -0
- package/dist/src/simulation/simulation.d.ts.map +1 -0
- package/dist/src/simulation/simulation.js +189 -0
- package/dist/src/simulation/simulation.js.map +1 -0
- package/dist/src/sklearn/sklearn.d.ts +6362 -0
- package/dist/src/sklearn/sklearn.d.ts.map +1 -0
- package/dist/src/sklearn/sklearn.js +1508 -0
- package/dist/src/sklearn/sklearn.js.map +1 -0
- package/dist/src/torch/torch.d.ts +1205 -0
- package/dist/src/torch/torch.d.ts.map +1 -0
- package/dist/src/torch/torch.js +440 -0
- package/dist/src/torch/torch.js.map +1 -0
- package/dist/src/types.d.ts +43 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +44 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/xgboost/xgboost.d.ts +1424 -0
- package/dist/src/xgboost/xgboost.d.ts.map +1 -0
- package/dist/src/xgboost/xgboost.js +432 -0
- package/dist/src/xgboost/xgboost.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,700 @@
|
|
|
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
|
+
* Iterative coordinate descent optimization for discrete combinatorial problems.
|
|
7
|
+
*
|
|
8
|
+
* Provides element-wise optimization over vectors of discrete integer values.
|
|
9
|
+
* Each element is independently optimized by trying all candidate values
|
|
10
|
+
* while holding other elements fixed. Multi-start sampling improves
|
|
11
|
+
* exploration of the search space.
|
|
12
|
+
*
|
|
13
|
+
* Ported from the Julia IterativeDecisionAlgorithm (ArrayParameterSpace branch).
|
|
14
|
+
*
|
|
15
|
+
* @packageDocumentation
|
|
16
|
+
*/
|
|
17
|
+
import { StructType, VariantType, OptionType, ArrayType, VectorType, IntegerType, BooleanType, FloatType, NullType, FunctionType } from "@elaraai/east";
|
|
18
|
+
/** Parameter vector: Vector<Integer> */
|
|
19
|
+
export declare const ParameterVectorType: VectorType<IntegerType>;
|
|
20
|
+
/** Objective function: Vector<Integer> -> Float */
|
|
21
|
+
export declare const IterativeObjectiveType: FunctionType<[VectorType<IntegerType>], FloatType>;
|
|
22
|
+
/** Per-element contribution function: (Vector<Integer>, Integer) -> Float */
|
|
23
|
+
export declare const ElementObjectiveType: FunctionType<[VectorType<IntegerType>, IntegerType], FloatType>;
|
|
24
|
+
/** Per-element candidate spaces: Array<Vector<Integer>> */
|
|
25
|
+
export declare const ParameterSpacesType: ArrayType<VectorType<IntegerType>>;
|
|
26
|
+
/**
|
|
27
|
+
* Initial value strategy for parameters.
|
|
28
|
+
*
|
|
29
|
+
* - `first`: Use the first candidate value from each space
|
|
30
|
+
* - `random`: Randomly select from each space
|
|
31
|
+
*/
|
|
32
|
+
export declare const InitialStrategyType: VariantType<{
|
|
33
|
+
readonly first: NullType;
|
|
34
|
+
readonly random: NullType;
|
|
35
|
+
}>;
|
|
36
|
+
/**
|
|
37
|
+
* Evaluation order for candidate values within each element's space.
|
|
38
|
+
*
|
|
39
|
+
* - `sequential`: Try candidates in the order they appear
|
|
40
|
+
* - `random`: Shuffle candidates before trying
|
|
41
|
+
*/
|
|
42
|
+
export declare const EvaluationOrderType: VariantType<{
|
|
43
|
+
readonly sequential: NullType;
|
|
44
|
+
readonly random: NullType;
|
|
45
|
+
}>;
|
|
46
|
+
/**
|
|
47
|
+
* Optimization mode.
|
|
48
|
+
*
|
|
49
|
+
* - `coordinate`: Standard coordinate descent — optimize each element independently (default)
|
|
50
|
+
* - `swap`: Swap-based moves — swap pairs of elements, preserving valid permutations
|
|
51
|
+
*/
|
|
52
|
+
export declare const ModeType: VariantType<{
|
|
53
|
+
readonly coordinate: NullType;
|
|
54
|
+
readonly swap: NullType;
|
|
55
|
+
}>;
|
|
56
|
+
/**
|
|
57
|
+
* Configuration for iterative optimization.
|
|
58
|
+
*
|
|
59
|
+
* All fields are optional with sensible defaults.
|
|
60
|
+
*/
|
|
61
|
+
export declare const IterativeConfigType: StructType<{
|
|
62
|
+
/** Maximum coordinate descent iterations per sample (default: 100) */
|
|
63
|
+
readonly iterations: OptionType<IntegerType>;
|
|
64
|
+
/** Number of independent restarts (default: 1) */
|
|
65
|
+
readonly samples: OptionType<IntegerType>;
|
|
66
|
+
/** How to initialize parameter values (default: first) */
|
|
67
|
+
readonly initial: OptionType<VariantType<{
|
|
68
|
+
readonly first: NullType;
|
|
69
|
+
readonly random: NullType;
|
|
70
|
+
}>>;
|
|
71
|
+
/** Order to evaluate candidates (default: sequential) */
|
|
72
|
+
readonly order: OptionType<VariantType<{
|
|
73
|
+
readonly sequential: NullType;
|
|
74
|
+
readonly random: NullType;
|
|
75
|
+
}>>;
|
|
76
|
+
/** Random seed for reproducibility */
|
|
77
|
+
readonly random_state: OptionType<IntegerType>;
|
|
78
|
+
/** Optimization mode: coordinate (default) or swap for permutations */
|
|
79
|
+
readonly mode: OptionType<VariantType<{
|
|
80
|
+
readonly coordinate: NullType;
|
|
81
|
+
readonly swap: NullType;
|
|
82
|
+
}>>;
|
|
83
|
+
}>;
|
|
84
|
+
/**
|
|
85
|
+
* Result of iterative optimization.
|
|
86
|
+
*/
|
|
87
|
+
export declare const IterativeResultType: StructType<{
|
|
88
|
+
/** Best parameter values found */
|
|
89
|
+
readonly best_parameters: VectorType<IntegerType>;
|
|
90
|
+
/** Objective value at best parameters */
|
|
91
|
+
readonly best_objective: FloatType;
|
|
92
|
+
/** Total coordinate descent iterations across all samples */
|
|
93
|
+
readonly iterations: IntegerType;
|
|
94
|
+
/** Total number of objective evaluations */
|
|
95
|
+
readonly evaluations: IntegerType;
|
|
96
|
+
/** Whether optimization succeeded */
|
|
97
|
+
readonly success: BooleanType;
|
|
98
|
+
}>;
|
|
99
|
+
/**
|
|
100
|
+
* Iterative optimization over integer parameter vectors.
|
|
101
|
+
*
|
|
102
|
+
* Maximizes an objective function over a vector of discrete integer parameters.
|
|
103
|
+
* Each parameter position has its own set of candidate values (vector).
|
|
104
|
+
*
|
|
105
|
+
* Two modes are available:
|
|
106
|
+
* - **coordinate** (default): Coordinate descent — optimizes each element independently
|
|
107
|
+
* by trying all candidate values while holding others fixed. Best for assignment problems
|
|
108
|
+
* where each position can take any value independently.
|
|
109
|
+
* - **swap**: Swap-based moves — swaps pairs of elements, preserving valid permutations.
|
|
110
|
+
* Use this for permutation problems (scheduling, ordering) where each value must appear
|
|
111
|
+
* exactly once.
|
|
112
|
+
*
|
|
113
|
+
* @example Coordinate mode (assignment)
|
|
114
|
+
* ```ts
|
|
115
|
+
* const config = $.let({
|
|
116
|
+
* iterations: variant('some', 10n),
|
|
117
|
+
* samples: variant('some', 3n),
|
|
118
|
+
* initial: variant('some', variant('random', null)),
|
|
119
|
+
* order: variant('some', variant('sequential', null)),
|
|
120
|
+
* random_state: variant('some', 42n),
|
|
121
|
+
* mode: variant('none', null), // coordinate is the default
|
|
122
|
+
* });
|
|
123
|
+
* const result = $.let(Optimization.iterative(objective, spaces, config));
|
|
124
|
+
* ```
|
|
125
|
+
*
|
|
126
|
+
* @example Swap mode (permutation)
|
|
127
|
+
* ```ts
|
|
128
|
+
* const config = $.let({
|
|
129
|
+
* iterations: variant('some', 50n),
|
|
130
|
+
* samples: variant('some', 10n),
|
|
131
|
+
* initial: variant('some', variant('random', null)),
|
|
132
|
+
* order: variant('some', variant('random', null)),
|
|
133
|
+
* random_state: variant('some', 42n),
|
|
134
|
+
* mode: variant('some', variant('swap', null)),
|
|
135
|
+
* });
|
|
136
|
+
* const result = $.let(Optimization.iterative(objective, spaces, config));
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
export declare const optimization_iterative: import("@elaraai/east").PlatformDefinition<[FunctionType<[VectorType<IntegerType>], FloatType>, ArrayType<VectorType<IntegerType>>, StructType<{
|
|
140
|
+
/** Maximum coordinate descent iterations per sample (default: 100) */
|
|
141
|
+
readonly iterations: OptionType<IntegerType>;
|
|
142
|
+
/** Number of independent restarts (default: 1) */
|
|
143
|
+
readonly samples: OptionType<IntegerType>;
|
|
144
|
+
/** How to initialize parameter values (default: first) */
|
|
145
|
+
readonly initial: OptionType<VariantType<{
|
|
146
|
+
readonly first: NullType;
|
|
147
|
+
readonly random: NullType;
|
|
148
|
+
}>>;
|
|
149
|
+
/** Order to evaluate candidates (default: sequential) */
|
|
150
|
+
readonly order: OptionType<VariantType<{
|
|
151
|
+
readonly sequential: NullType;
|
|
152
|
+
readonly random: NullType;
|
|
153
|
+
}>>;
|
|
154
|
+
/** Random seed for reproducibility */
|
|
155
|
+
readonly random_state: OptionType<IntegerType>;
|
|
156
|
+
/** Optimization mode: coordinate (default) or swap for permutations */
|
|
157
|
+
readonly mode: OptionType<VariantType<{
|
|
158
|
+
readonly coordinate: NullType;
|
|
159
|
+
readonly swap: NullType;
|
|
160
|
+
}>>;
|
|
161
|
+
}>], StructType<{
|
|
162
|
+
/** Best parameter values found */
|
|
163
|
+
readonly best_parameters: VectorType<IntegerType>;
|
|
164
|
+
/** Objective value at best parameters */
|
|
165
|
+
readonly best_objective: FloatType;
|
|
166
|
+
/** Total coordinate descent iterations across all samples */
|
|
167
|
+
readonly iterations: IntegerType;
|
|
168
|
+
/** Total number of objective evaluations */
|
|
169
|
+
readonly evaluations: IntegerType;
|
|
170
|
+
/** Whether optimization succeeded */
|
|
171
|
+
readonly success: BooleanType;
|
|
172
|
+
}>>;
|
|
173
|
+
/**
|
|
174
|
+
* Incremental iterative optimization over integer parameter vectors.
|
|
175
|
+
*
|
|
176
|
+
* Like {@link optimization_iterative}, but takes a **per-element contribution function**
|
|
177
|
+
* instead of a full objective. The optimizer maintains a running sum and only
|
|
178
|
+
* recomputes contributions for changed indices — dramatically faster when
|
|
179
|
+
* individual moves affect only a small part of the total cost.
|
|
180
|
+
*
|
|
181
|
+
* The total objective is `sum(elementObjective(vector, i) for all i)`.
|
|
182
|
+
*
|
|
183
|
+
* Two modes are available:
|
|
184
|
+
* - **coordinate** (default): When changing element `i`, recomputes 1 contribution.
|
|
185
|
+
* - **swap**: When swapping elements `i` and `j`, recomputes 2 contributions.
|
|
186
|
+
*
|
|
187
|
+
* @example Incremental rostering
|
|
188
|
+
* ```ts
|
|
189
|
+
* // Per-person cost: only recomputes the changed person
|
|
190
|
+
* const elementObjective = East.function(
|
|
191
|
+
* [VectorType(IntegerType), IntegerType], FloatType,
|
|
192
|
+
* ($, assignments, personIdx) => {
|
|
193
|
+
* const role = $.let(assignments.get(personIdx));
|
|
194
|
+
* return $.return(salaryLookup.get(personIdx).get(role).negate());
|
|
195
|
+
* }
|
|
196
|
+
* );
|
|
197
|
+
* const result = $.let(Optimization.iterativeIncremental(
|
|
198
|
+
* elementObjective, spaces, config
|
|
199
|
+
* ));
|
|
200
|
+
* ```
|
|
201
|
+
*/
|
|
202
|
+
export declare const optimization_iterative_incremental: import("@elaraai/east").PlatformDefinition<[FunctionType<[VectorType<IntegerType>, IntegerType], FloatType>, ArrayType<VectorType<IntegerType>>, StructType<{
|
|
203
|
+
/** Maximum coordinate descent iterations per sample (default: 100) */
|
|
204
|
+
readonly iterations: OptionType<IntegerType>;
|
|
205
|
+
/** Number of independent restarts (default: 1) */
|
|
206
|
+
readonly samples: OptionType<IntegerType>;
|
|
207
|
+
/** How to initialize parameter values (default: first) */
|
|
208
|
+
readonly initial: OptionType<VariantType<{
|
|
209
|
+
readonly first: NullType;
|
|
210
|
+
readonly random: NullType;
|
|
211
|
+
}>>;
|
|
212
|
+
/** Order to evaluate candidates (default: sequential) */
|
|
213
|
+
readonly order: OptionType<VariantType<{
|
|
214
|
+
readonly sequential: NullType;
|
|
215
|
+
readonly random: NullType;
|
|
216
|
+
}>>;
|
|
217
|
+
/** Random seed for reproducibility */
|
|
218
|
+
readonly random_state: OptionType<IntegerType>;
|
|
219
|
+
/** Optimization mode: coordinate (default) or swap for permutations */
|
|
220
|
+
readonly mode: OptionType<VariantType<{
|
|
221
|
+
readonly coordinate: NullType;
|
|
222
|
+
readonly swap: NullType;
|
|
223
|
+
}>>;
|
|
224
|
+
}>], StructType<{
|
|
225
|
+
/** Best parameter values found */
|
|
226
|
+
readonly best_parameters: VectorType<IntegerType>;
|
|
227
|
+
/** Objective value at best parameters */
|
|
228
|
+
readonly best_objective: FloatType;
|
|
229
|
+
/** Total coordinate descent iterations across all samples */
|
|
230
|
+
readonly iterations: IntegerType;
|
|
231
|
+
/** Total number of objective evaluations */
|
|
232
|
+
readonly evaluations: IntegerType;
|
|
233
|
+
/** Whether optimization succeeded */
|
|
234
|
+
readonly success: BooleanType;
|
|
235
|
+
}>>;
|
|
236
|
+
/**
|
|
237
|
+
* Group-based incremental iterative optimization.
|
|
238
|
+
*
|
|
239
|
+
* Like {@link optimization_iterative_incremental}, but contributions are grouped
|
|
240
|
+
* by **value** rather than by index. The group objective receives the full vector
|
|
241
|
+
* and a group key (a value that appears in the vector), and returns the total
|
|
242
|
+
* contribution of all elements assigned to that group.
|
|
243
|
+
*
|
|
244
|
+
* When element `i` changes from value A to value B, only 2 groups are recomputed:
|
|
245
|
+
* `groupObjective(vector, A)` and `groupObjective(vector, B)`.
|
|
246
|
+
*
|
|
247
|
+
* Use this when cost is associated with values (e.g., employees, bins, vehicles)
|
|
248
|
+
* rather than positions (e.g., slots, items, stops).
|
|
249
|
+
*
|
|
250
|
+
* @example Rostering — slot → employee assignment
|
|
251
|
+
* ```ts
|
|
252
|
+
* const groupObjective = East.function(
|
|
253
|
+
* [VectorType(IntegerType), IntegerType], FloatType,
|
|
254
|
+
* ($, slotAssignments, employeeId) => {
|
|
255
|
+
* const cost = $.let(0.0);
|
|
256
|
+
* $.for(East.Array.range(0n, nSlots), ($, slot) => {
|
|
257
|
+
* $.if(East.equal(slotAssignments.get(slot), employeeId), $ => {
|
|
258
|
+
* $.assign(cost, cost.add(shiftRates.get(slot)));
|
|
259
|
+
* });
|
|
260
|
+
* });
|
|
261
|
+
* return $.return(cost.negate());
|
|
262
|
+
* }
|
|
263
|
+
* );
|
|
264
|
+
* const result = $.let(Optimization.iterativeGrouped(
|
|
265
|
+
* groupObjective, spaces, config
|
|
266
|
+
* ));
|
|
267
|
+
* ```
|
|
268
|
+
*/
|
|
269
|
+
export declare const optimization_iterative_grouped: import("@elaraai/east").PlatformDefinition<[FunctionType<[VectorType<IntegerType>, IntegerType], FloatType>, ArrayType<VectorType<IntegerType>>, StructType<{
|
|
270
|
+
/** Maximum coordinate descent iterations per sample (default: 100) */
|
|
271
|
+
readonly iterations: OptionType<IntegerType>;
|
|
272
|
+
/** Number of independent restarts (default: 1) */
|
|
273
|
+
readonly samples: OptionType<IntegerType>;
|
|
274
|
+
/** How to initialize parameter values (default: first) */
|
|
275
|
+
readonly initial: OptionType<VariantType<{
|
|
276
|
+
readonly first: NullType;
|
|
277
|
+
readonly random: NullType;
|
|
278
|
+
}>>;
|
|
279
|
+
/** Order to evaluate candidates (default: sequential) */
|
|
280
|
+
readonly order: OptionType<VariantType<{
|
|
281
|
+
readonly sequential: NullType;
|
|
282
|
+
readonly random: NullType;
|
|
283
|
+
}>>;
|
|
284
|
+
/** Random seed for reproducibility */
|
|
285
|
+
readonly random_state: OptionType<IntegerType>;
|
|
286
|
+
/** Optimization mode: coordinate (default) or swap for permutations */
|
|
287
|
+
readonly mode: OptionType<VariantType<{
|
|
288
|
+
readonly coordinate: NullType;
|
|
289
|
+
readonly swap: NullType;
|
|
290
|
+
}>>;
|
|
291
|
+
}>], StructType<{
|
|
292
|
+
/** Best parameter values found */
|
|
293
|
+
readonly best_parameters: VectorType<IntegerType>;
|
|
294
|
+
/** Objective value at best parameters */
|
|
295
|
+
readonly best_objective: FloatType;
|
|
296
|
+
/** Total coordinate descent iterations across all samples */
|
|
297
|
+
readonly iterations: IntegerType;
|
|
298
|
+
/** Total number of objective evaluations */
|
|
299
|
+
readonly evaluations: IntegerType;
|
|
300
|
+
/** Whether optimization succeeded */
|
|
301
|
+
readonly success: BooleanType;
|
|
302
|
+
}>>;
|
|
303
|
+
/**
|
|
304
|
+
* Type definitions for iterative optimization.
|
|
305
|
+
*/
|
|
306
|
+
export declare const OptimizationTypes: {
|
|
307
|
+
/** Parameter vector type */
|
|
308
|
+
readonly ParameterVectorType: VectorType<IntegerType>;
|
|
309
|
+
/** Objective function type */
|
|
310
|
+
readonly ObjectiveType: FunctionType<[VectorType<IntegerType>], FloatType>;
|
|
311
|
+
/** Per-element contribution function type */
|
|
312
|
+
readonly ElementObjectiveType: FunctionType<[VectorType<IntegerType>, IntegerType], FloatType>;
|
|
313
|
+
/** Parameter spaces type */
|
|
314
|
+
readonly SpacesType: ArrayType<VectorType<IntegerType>>;
|
|
315
|
+
/** Initial value strategy variant */
|
|
316
|
+
readonly InitialStrategyType: VariantType<{
|
|
317
|
+
readonly first: NullType;
|
|
318
|
+
readonly random: NullType;
|
|
319
|
+
}>;
|
|
320
|
+
/** Evaluation order variant */
|
|
321
|
+
readonly EvaluationOrderType: VariantType<{
|
|
322
|
+
readonly sequential: NullType;
|
|
323
|
+
readonly random: NullType;
|
|
324
|
+
}>;
|
|
325
|
+
/** Optimization mode variant */
|
|
326
|
+
readonly ModeType: VariantType<{
|
|
327
|
+
readonly coordinate: NullType;
|
|
328
|
+
readonly swap: NullType;
|
|
329
|
+
}>;
|
|
330
|
+
/** Configuration type */
|
|
331
|
+
readonly ConfigType: StructType<{
|
|
332
|
+
/** Maximum coordinate descent iterations per sample (default: 100) */
|
|
333
|
+
readonly iterations: OptionType<IntegerType>;
|
|
334
|
+
/** Number of independent restarts (default: 1) */
|
|
335
|
+
readonly samples: OptionType<IntegerType>;
|
|
336
|
+
/** How to initialize parameter values (default: first) */
|
|
337
|
+
readonly initial: OptionType<VariantType<{
|
|
338
|
+
readonly first: NullType;
|
|
339
|
+
readonly random: NullType;
|
|
340
|
+
}>>;
|
|
341
|
+
/** Order to evaluate candidates (default: sequential) */
|
|
342
|
+
readonly order: OptionType<VariantType<{
|
|
343
|
+
readonly sequential: NullType;
|
|
344
|
+
readonly random: NullType;
|
|
345
|
+
}>>;
|
|
346
|
+
/** Random seed for reproducibility */
|
|
347
|
+
readonly random_state: OptionType<IntegerType>;
|
|
348
|
+
/** Optimization mode: coordinate (default) or swap for permutations */
|
|
349
|
+
readonly mode: OptionType<VariantType<{
|
|
350
|
+
readonly coordinate: NullType;
|
|
351
|
+
readonly swap: NullType;
|
|
352
|
+
}>>;
|
|
353
|
+
}>;
|
|
354
|
+
/** Result type */
|
|
355
|
+
readonly ResultType: StructType<{
|
|
356
|
+
/** Best parameter values found */
|
|
357
|
+
readonly best_parameters: VectorType<IntegerType>;
|
|
358
|
+
/** Objective value at best parameters */
|
|
359
|
+
readonly best_objective: FloatType;
|
|
360
|
+
/** Total coordinate descent iterations across all samples */
|
|
361
|
+
readonly iterations: IntegerType;
|
|
362
|
+
/** Total number of objective evaluations */
|
|
363
|
+
readonly evaluations: IntegerType;
|
|
364
|
+
/** Whether optimization succeeded */
|
|
365
|
+
readonly success: BooleanType;
|
|
366
|
+
}>;
|
|
367
|
+
};
|
|
368
|
+
/**
|
|
369
|
+
* Iterative optimization for discrete combinatorial problems.
|
|
370
|
+
*
|
|
371
|
+
* Supports two modes:
|
|
372
|
+
* - **coordinate** (default): Element-wise coordinate descent. Best for
|
|
373
|
+
* assignment problems where positions are independent.
|
|
374
|
+
* - **swap**: Pair-wise swap moves preserving permutations. Best for
|
|
375
|
+
* scheduling/ordering where each value must appear exactly once.
|
|
376
|
+
*
|
|
377
|
+
* Use cases:
|
|
378
|
+
* - Task-worker assignment (coordinate mode)
|
|
379
|
+
* - Scheduling and ordering (swap mode)
|
|
380
|
+
* - Combinatorial selection problems
|
|
381
|
+
* - Any discrete optimization with per-element candidate sets
|
|
382
|
+
*/
|
|
383
|
+
export declare const Optimization: {
|
|
384
|
+
/**
|
|
385
|
+
* Iterative optimization over integer parameter vectors.
|
|
386
|
+
*
|
|
387
|
+
* `Optimization.iterative(objective, spaces, config)`
|
|
388
|
+
*
|
|
389
|
+
* @example Coordinate mode — task-worker assignment
|
|
390
|
+
* ```ts
|
|
391
|
+
* // 3 tasks, 2 workers. Maximize total skill match.
|
|
392
|
+
* const skill = $.let([[3.0, 1.0], [1.0, 3.0], [2.0, 2.0]]);
|
|
393
|
+
* const objective = East.function(
|
|
394
|
+
* [VectorType(IntegerType)], FloatType,
|
|
395
|
+
* ($, assignments) => {
|
|
396
|
+
* const total = $.let(0.0);
|
|
397
|
+
* $.for(East.Array.range(0n, East.value(3n)), ($, i) => {
|
|
398
|
+
* $.assign(total, total.add(skill.get(i).get(assignments.get(i))));
|
|
399
|
+
* });
|
|
400
|
+
* return $.return(total);
|
|
401
|
+
* }
|
|
402
|
+
* );
|
|
403
|
+
* const spaces = $.let([
|
|
404
|
+
* new BigInt64Array([0n, 1n]),
|
|
405
|
+
* new BigInt64Array([0n, 1n]),
|
|
406
|
+
* new BigInt64Array([0n, 1n]),
|
|
407
|
+
* ]);
|
|
408
|
+
* const config = $.let({
|
|
409
|
+
* iterations: variant('some', 10n),
|
|
410
|
+
* samples: variant('some', 3n),
|
|
411
|
+
* initial: variant('some', variant('random', null)),
|
|
412
|
+
* order: variant('some', variant('sequential', null)),
|
|
413
|
+
* random_state: variant('some', 42n),
|
|
414
|
+
* mode: variant('none', null),
|
|
415
|
+
* });
|
|
416
|
+
* const result = $.let(Optimization.iterative(objective, spaces, config));
|
|
417
|
+
* // result.best_objective = 8.0 (task 0→worker 0, task 1→worker 1, task 2→either)
|
|
418
|
+
* ```
|
|
419
|
+
*
|
|
420
|
+
* @example Swap mode — scheduling permutation
|
|
421
|
+
* ```ts
|
|
422
|
+
* // 4 jobs: find execution order minimizing weighted completion time.
|
|
423
|
+
* const durations = $.let([10.0, 5.0, 20.0, 3.0]);
|
|
424
|
+
* const values = $.let([1.0, 8.0, 2.0, 10.0]);
|
|
425
|
+
* const objective = East.function(
|
|
426
|
+
* [VectorType(IntegerType)], FloatType,
|
|
427
|
+
* ($, perm) => {
|
|
428
|
+
* const cum = $.let(0.0);
|
|
429
|
+
* const total = $.let(0.0);
|
|
430
|
+
* $.for(East.Array.range(0n, East.value(4n)), ($, i) => {
|
|
431
|
+
* const idx = $.let(perm.get(i));
|
|
432
|
+
* $.assign(cum, cum.add(durations.get(idx)));
|
|
433
|
+
* $.assign(total, total.add(values.get(idx).multiply(cum)));
|
|
434
|
+
* });
|
|
435
|
+
* return $.return(total.negate());
|
|
436
|
+
* }
|
|
437
|
+
* );
|
|
438
|
+
* const spaces = $.let([
|
|
439
|
+
* new BigInt64Array([0n, 1n, 2n, 3n]),
|
|
440
|
+
* new BigInt64Array([0n, 1n, 2n, 3n]),
|
|
441
|
+
* new BigInt64Array([0n, 1n, 2n, 3n]),
|
|
442
|
+
* new BigInt64Array([0n, 1n, 2n, 3n]),
|
|
443
|
+
* ]);
|
|
444
|
+
* const config = $.let({
|
|
445
|
+
* iterations: variant('some', 50n),
|
|
446
|
+
* samples: variant('some', 10n),
|
|
447
|
+
* initial: variant('some', variant('random', null)),
|
|
448
|
+
* order: variant('some', variant('random', null)),
|
|
449
|
+
* random_state: variant('some', 42n),
|
|
450
|
+
* mode: variant('some', variant('swap', null)),
|
|
451
|
+
* });
|
|
452
|
+
* const result = $.let(Optimization.iterative(objective, spaces, config));
|
|
453
|
+
* // result.best_objective = -188.0 (optimal WSPT order)
|
|
454
|
+
* ```
|
|
455
|
+
*/
|
|
456
|
+
readonly iterative: import("@elaraai/east").PlatformDefinition<[FunctionType<[VectorType<IntegerType>], FloatType>, ArrayType<VectorType<IntegerType>>, StructType<{
|
|
457
|
+
/** Maximum coordinate descent iterations per sample (default: 100) */
|
|
458
|
+
readonly iterations: OptionType<IntegerType>;
|
|
459
|
+
/** Number of independent restarts (default: 1) */
|
|
460
|
+
readonly samples: OptionType<IntegerType>;
|
|
461
|
+
/** How to initialize parameter values (default: first) */
|
|
462
|
+
readonly initial: OptionType<VariantType<{
|
|
463
|
+
readonly first: NullType;
|
|
464
|
+
readonly random: NullType;
|
|
465
|
+
}>>;
|
|
466
|
+
/** Order to evaluate candidates (default: sequential) */
|
|
467
|
+
readonly order: OptionType<VariantType<{
|
|
468
|
+
readonly sequential: NullType;
|
|
469
|
+
readonly random: NullType;
|
|
470
|
+
}>>;
|
|
471
|
+
/** Random seed for reproducibility */
|
|
472
|
+
readonly random_state: OptionType<IntegerType>;
|
|
473
|
+
/** Optimization mode: coordinate (default) or swap for permutations */
|
|
474
|
+
readonly mode: OptionType<VariantType<{
|
|
475
|
+
readonly coordinate: NullType;
|
|
476
|
+
readonly swap: NullType;
|
|
477
|
+
}>>;
|
|
478
|
+
}>], StructType<{
|
|
479
|
+
/** Best parameter values found */
|
|
480
|
+
readonly best_parameters: VectorType<IntegerType>;
|
|
481
|
+
/** Objective value at best parameters */
|
|
482
|
+
readonly best_objective: FloatType;
|
|
483
|
+
/** Total coordinate descent iterations across all samples */
|
|
484
|
+
readonly iterations: IntegerType;
|
|
485
|
+
/** Total number of objective evaluations */
|
|
486
|
+
readonly evaluations: IntegerType;
|
|
487
|
+
/** Whether optimization succeeded */
|
|
488
|
+
readonly success: BooleanType;
|
|
489
|
+
}>>;
|
|
490
|
+
/**
|
|
491
|
+
* Incremental iterative optimization with per-element contributions.
|
|
492
|
+
*
|
|
493
|
+
* `Optimization.iterativeIncremental(elementObjective, spaces, config)`
|
|
494
|
+
*
|
|
495
|
+
* Takes a per-element contribution function `(Vector<Integer>, Integer) -> Float`
|
|
496
|
+
* instead of a full objective. The total objective is the sum of all element
|
|
497
|
+
* contributions. Only recomputes contributions for changed indices during search.
|
|
498
|
+
*
|
|
499
|
+
* Use this when individual moves (coordinate or swap) affect only a small
|
|
500
|
+
* part of the total cost — e.g., rostering where changing one person's
|
|
501
|
+
* allocation only changes that person's salary.
|
|
502
|
+
*
|
|
503
|
+
* @example Incremental task-worker assignment
|
|
504
|
+
* ```ts
|
|
505
|
+
* // Per-task skill score: only recomputes the changed task
|
|
506
|
+
* const skill = $.let([[3.0, 1.0], [1.0, 3.0], [2.0, 2.0]]);
|
|
507
|
+
* const elementObjective = East.function(
|
|
508
|
+
* [VectorType(IntegerType), IntegerType], FloatType,
|
|
509
|
+
* ($, assignments, taskIdx) => {
|
|
510
|
+
* const worker = $.let(assignments.get(taskIdx));
|
|
511
|
+
* return $.return(skill.get(taskIdx).get(worker));
|
|
512
|
+
* }
|
|
513
|
+
* );
|
|
514
|
+
* const spaces = $.let([
|
|
515
|
+
* new BigInt64Array([0n, 1n]),
|
|
516
|
+
* new BigInt64Array([0n, 1n]),
|
|
517
|
+
* new BigInt64Array([0n, 1n]),
|
|
518
|
+
* ]);
|
|
519
|
+
* const config = $.let({
|
|
520
|
+
* iterations: variant('some', 10n),
|
|
521
|
+
* samples: variant('some', 3n),
|
|
522
|
+
* initial: variant('some', variant('random', null)),
|
|
523
|
+
* order: variant('some', variant('sequential', null)),
|
|
524
|
+
* random_state: variant('some', 42n),
|
|
525
|
+
* mode: variant('none', null),
|
|
526
|
+
* });
|
|
527
|
+
* const result = $.let(Optimization.iterativeIncremental(
|
|
528
|
+
* elementObjective, spaces, config
|
|
529
|
+
* ));
|
|
530
|
+
* // result.best_objective = 8.0 (same result, fewer evaluations)
|
|
531
|
+
* ```
|
|
532
|
+
*/
|
|
533
|
+
readonly iterativeIncremental: import("@elaraai/east").PlatformDefinition<[FunctionType<[VectorType<IntegerType>, IntegerType], FloatType>, ArrayType<VectorType<IntegerType>>, StructType<{
|
|
534
|
+
/** Maximum coordinate descent iterations per sample (default: 100) */
|
|
535
|
+
readonly iterations: OptionType<IntegerType>;
|
|
536
|
+
/** Number of independent restarts (default: 1) */
|
|
537
|
+
readonly samples: OptionType<IntegerType>;
|
|
538
|
+
/** How to initialize parameter values (default: first) */
|
|
539
|
+
readonly initial: OptionType<VariantType<{
|
|
540
|
+
readonly first: NullType;
|
|
541
|
+
readonly random: NullType;
|
|
542
|
+
}>>;
|
|
543
|
+
/** Order to evaluate candidates (default: sequential) */
|
|
544
|
+
readonly order: OptionType<VariantType<{
|
|
545
|
+
readonly sequential: NullType;
|
|
546
|
+
readonly random: NullType;
|
|
547
|
+
}>>;
|
|
548
|
+
/** Random seed for reproducibility */
|
|
549
|
+
readonly random_state: OptionType<IntegerType>;
|
|
550
|
+
/** Optimization mode: coordinate (default) or swap for permutations */
|
|
551
|
+
readonly mode: OptionType<VariantType<{
|
|
552
|
+
readonly coordinate: NullType;
|
|
553
|
+
readonly swap: NullType;
|
|
554
|
+
}>>;
|
|
555
|
+
}>], StructType<{
|
|
556
|
+
/** Best parameter values found */
|
|
557
|
+
readonly best_parameters: VectorType<IntegerType>;
|
|
558
|
+
/** Objective value at best parameters */
|
|
559
|
+
readonly best_objective: FloatType;
|
|
560
|
+
/** Total coordinate descent iterations across all samples */
|
|
561
|
+
readonly iterations: IntegerType;
|
|
562
|
+
/** Total number of objective evaluations */
|
|
563
|
+
readonly evaluations: IntegerType;
|
|
564
|
+
/** Whether optimization succeeded */
|
|
565
|
+
readonly success: BooleanType;
|
|
566
|
+
}>>;
|
|
567
|
+
/**
|
|
568
|
+
* Group-based incremental optimization with per-value contributions.
|
|
569
|
+
*
|
|
570
|
+
* `Optimization.iterativeGrouped(groupObjective, spaces, config)`
|
|
571
|
+
*
|
|
572
|
+
* Takes a group objective `(Vector<Integer>, Integer) -> Float` where the
|
|
573
|
+
* second argument is a **value** (group key), not an index. Returns the total
|
|
574
|
+
* contribution of all elements assigned to that value.
|
|
575
|
+
*
|
|
576
|
+
* When element `i` changes from value A to B, recomputes only groups A and B.
|
|
577
|
+
* Use this when cost is per-value (employee, bin, vehicle) not per-position.
|
|
578
|
+
*
|
|
579
|
+
* @example Group-based task assignment
|
|
580
|
+
* ```ts
|
|
581
|
+
* // 6 tasks assigned to workers 0-2. Cost = per-worker total.
|
|
582
|
+
* const taskCosts = $.let([10.0, 20.0, 15.0, 25.0, 30.0, 5.0]);
|
|
583
|
+
* const groupObjective = East.function(
|
|
584
|
+
* [VectorType(IntegerType), IntegerType], FloatType,
|
|
585
|
+
* ($, assignments, workerId) => {
|
|
586
|
+
* const total = $.let(0.0);
|
|
587
|
+
* $.for(East.Array.range(0n, East.value(6n)), ($, task) => {
|
|
588
|
+
* $.if(East.equal(assignments.get(task), workerId), $ => {
|
|
589
|
+
* $.assign(total, total.add(taskCosts.get(task)));
|
|
590
|
+
* });
|
|
591
|
+
* });
|
|
592
|
+
* return $.return(total.negate());
|
|
593
|
+
* }
|
|
594
|
+
* );
|
|
595
|
+
* const result = $.let(Optimization.iterativeGrouped(
|
|
596
|
+
* groupObjective, spaces, config
|
|
597
|
+
* ));
|
|
598
|
+
* ```
|
|
599
|
+
*/
|
|
600
|
+
readonly iterativeGrouped: import("@elaraai/east").PlatformDefinition<[FunctionType<[VectorType<IntegerType>, IntegerType], FloatType>, ArrayType<VectorType<IntegerType>>, StructType<{
|
|
601
|
+
/** Maximum coordinate descent iterations per sample (default: 100) */
|
|
602
|
+
readonly iterations: OptionType<IntegerType>;
|
|
603
|
+
/** Number of independent restarts (default: 1) */
|
|
604
|
+
readonly samples: OptionType<IntegerType>;
|
|
605
|
+
/** How to initialize parameter values (default: first) */
|
|
606
|
+
readonly initial: OptionType<VariantType<{
|
|
607
|
+
readonly first: NullType;
|
|
608
|
+
readonly random: NullType;
|
|
609
|
+
}>>;
|
|
610
|
+
/** Order to evaluate candidates (default: sequential) */
|
|
611
|
+
readonly order: OptionType<VariantType<{
|
|
612
|
+
readonly sequential: NullType;
|
|
613
|
+
readonly random: NullType;
|
|
614
|
+
}>>;
|
|
615
|
+
/** Random seed for reproducibility */
|
|
616
|
+
readonly random_state: OptionType<IntegerType>;
|
|
617
|
+
/** Optimization mode: coordinate (default) or swap for permutations */
|
|
618
|
+
readonly mode: OptionType<VariantType<{
|
|
619
|
+
readonly coordinate: NullType;
|
|
620
|
+
readonly swap: NullType;
|
|
621
|
+
}>>;
|
|
622
|
+
}>], StructType<{
|
|
623
|
+
/** Best parameter values found */
|
|
624
|
+
readonly best_parameters: VectorType<IntegerType>;
|
|
625
|
+
/** Objective value at best parameters */
|
|
626
|
+
readonly best_objective: FloatType;
|
|
627
|
+
/** Total coordinate descent iterations across all samples */
|
|
628
|
+
readonly iterations: IntegerType;
|
|
629
|
+
/** Total number of objective evaluations */
|
|
630
|
+
readonly evaluations: IntegerType;
|
|
631
|
+
/** Whether optimization succeeded */
|
|
632
|
+
readonly success: BooleanType;
|
|
633
|
+
}>>;
|
|
634
|
+
/**
|
|
635
|
+
* Type definitions for optimization functions.
|
|
636
|
+
*/
|
|
637
|
+
readonly Types: {
|
|
638
|
+
/** Parameter vector type */
|
|
639
|
+
readonly ParameterVectorType: VectorType<IntegerType>;
|
|
640
|
+
/** Objective function type */
|
|
641
|
+
readonly ObjectiveType: FunctionType<[VectorType<IntegerType>], FloatType>;
|
|
642
|
+
/** Per-element contribution function type */
|
|
643
|
+
readonly ElementObjectiveType: FunctionType<[VectorType<IntegerType>, IntegerType], FloatType>;
|
|
644
|
+
/** Parameter spaces type */
|
|
645
|
+
readonly SpacesType: ArrayType<VectorType<IntegerType>>;
|
|
646
|
+
/** Initial value strategy variant */
|
|
647
|
+
readonly InitialStrategyType: VariantType<{
|
|
648
|
+
readonly first: NullType;
|
|
649
|
+
readonly random: NullType;
|
|
650
|
+
}>;
|
|
651
|
+
/** Evaluation order variant */
|
|
652
|
+
readonly EvaluationOrderType: VariantType<{
|
|
653
|
+
readonly sequential: NullType;
|
|
654
|
+
readonly random: NullType;
|
|
655
|
+
}>;
|
|
656
|
+
/** Optimization mode variant */
|
|
657
|
+
readonly ModeType: VariantType<{
|
|
658
|
+
readonly coordinate: NullType;
|
|
659
|
+
readonly swap: NullType;
|
|
660
|
+
}>;
|
|
661
|
+
/** Configuration type */
|
|
662
|
+
readonly ConfigType: StructType<{
|
|
663
|
+
/** Maximum coordinate descent iterations per sample (default: 100) */
|
|
664
|
+
readonly iterations: OptionType<IntegerType>;
|
|
665
|
+
/** Number of independent restarts (default: 1) */
|
|
666
|
+
readonly samples: OptionType<IntegerType>;
|
|
667
|
+
/** How to initialize parameter values (default: first) */
|
|
668
|
+
readonly initial: OptionType<VariantType<{
|
|
669
|
+
readonly first: NullType;
|
|
670
|
+
readonly random: NullType;
|
|
671
|
+
}>>;
|
|
672
|
+
/** Order to evaluate candidates (default: sequential) */
|
|
673
|
+
readonly order: OptionType<VariantType<{
|
|
674
|
+
readonly sequential: NullType;
|
|
675
|
+
readonly random: NullType;
|
|
676
|
+
}>>;
|
|
677
|
+
/** Random seed for reproducibility */
|
|
678
|
+
readonly random_state: OptionType<IntegerType>;
|
|
679
|
+
/** Optimization mode: coordinate (default) or swap for permutations */
|
|
680
|
+
readonly mode: OptionType<VariantType<{
|
|
681
|
+
readonly coordinate: NullType;
|
|
682
|
+
readonly swap: NullType;
|
|
683
|
+
}>>;
|
|
684
|
+
}>;
|
|
685
|
+
/** Result type */
|
|
686
|
+
readonly ResultType: StructType<{
|
|
687
|
+
/** Best parameter values found */
|
|
688
|
+
readonly best_parameters: VectorType<IntegerType>;
|
|
689
|
+
/** Objective value at best parameters */
|
|
690
|
+
readonly best_objective: FloatType;
|
|
691
|
+
/** Total coordinate descent iterations across all samples */
|
|
692
|
+
readonly iterations: IntegerType;
|
|
693
|
+
/** Total number of objective evaluations */
|
|
694
|
+
readonly evaluations: IntegerType;
|
|
695
|
+
/** Whether optimization succeeded */
|
|
696
|
+
readonly success: BooleanType;
|
|
697
|
+
}>;
|
|
698
|
+
};
|
|
699
|
+
};
|
|
700
|
+
//# sourceMappingURL=optimization.d.ts.map
|