@elaraai/east-py-datascience 0.0.2-beta.84 → 1.0.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.
- package/CLA.md +26 -0
- package/CONTRIBUTING.md +28 -0
- package/LICENSE.md +2 -2
- package/README.md +51 -15
- package/dist/src/google_or/google_or.d.ts +35 -0
- package/dist/src/google_or/google_or.d.ts.map +1 -1
- package/dist/src/google_or/google_or.js +5 -0
- package/dist/src/google_or/google_or.js.map +1 -1
- package/dist/src/index.d.ts +3 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +3 -3
- package/dist/src/index.js.map +1 -1
- package/dist/src/optimization/optimization.d.ts +280 -0
- package/dist/src/optimization/optimization.d.ts.map +1 -1
- package/dist/src/optimization/optimization.js +154 -0
- package/dist/src/optimization/optimization.js.map +1 -1
- package/dist/src/simulation/simulation.d.ts +1 -208
- package/dist/src/simulation/simulation.d.ts.map +1 -1
- package/dist/src/simulation/simulation.js +1 -118
- package/dist/src/simulation/simulation.js.map +1 -1
- package/package.json +15 -36
|
@@ -10,9 +10,8 @@
|
|
|
10
10
|
* - E (Events): user-defined variant where each case is an economic activity
|
|
11
11
|
* - Process handler: defines how events affect resources (match dispatch)
|
|
12
12
|
*
|
|
13
|
-
*
|
|
13
|
+
* Entry point:
|
|
14
14
|
* - `simulation_run`: single deterministic run
|
|
15
|
-
* - `simulation_run_trajectories`: Monte Carlo with multiple seeds
|
|
16
15
|
*
|
|
17
16
|
* @packageDocumentation
|
|
18
17
|
*/
|
|
@@ -37,33 +36,6 @@ export declare const SimulationResultType: StructType<{
|
|
|
37
36
|
/** Date of the last event processed */
|
|
38
37
|
readonly final_date: DateTimeType;
|
|
39
38
|
}>;
|
|
40
|
-
/**
|
|
41
|
-
* Configuration for Monte Carlo simulation trajectories.
|
|
42
|
-
*/
|
|
43
|
-
export declare const SimulationTrajectoriesConfigType: StructType<{
|
|
44
|
-
/** Number of trajectories to run (required) */
|
|
45
|
-
readonly trajectories: IntegerType;
|
|
46
|
-
/** Base RNG seed — trajectory i uses seed + i */
|
|
47
|
-
readonly seed: OptionType<IntegerType>;
|
|
48
|
-
/** Safety limit on events per trajectory (default: 100000) */
|
|
49
|
-
readonly max_events: OptionType<IntegerType>;
|
|
50
|
-
/** Stop processing events after this date */
|
|
51
|
-
readonly end_date: OptionType<DateTimeType>;
|
|
52
|
-
}>;
|
|
53
|
-
/**
|
|
54
|
-
* Result of Monte Carlo simulation trajectories.
|
|
55
|
-
*/
|
|
56
|
-
export declare const SimulationTrajectoriesResultType: StructType<{
|
|
57
|
-
/** Array of per-trajectory results */
|
|
58
|
-
readonly trajectories: ArrayType<StructType<{
|
|
59
|
-
/** Final resource state */
|
|
60
|
-
readonly final_state: "R";
|
|
61
|
-
/** Number of events processed */
|
|
62
|
-
readonly events_processed: IntegerType;
|
|
63
|
-
/** Date of last event processed */
|
|
64
|
-
readonly final_date: DateTimeType;
|
|
65
|
-
}>>;
|
|
66
|
-
}>;
|
|
67
39
|
/**
|
|
68
40
|
* Run a single deterministic discrete event simulation.
|
|
69
41
|
*
|
|
@@ -115,51 +87,6 @@ export declare const simulation_run: import("@elaraai/east").GenericPlatformDefi
|
|
|
115
87
|
/** Date of the last event processed */
|
|
116
88
|
readonly final_date: DateTimeType;
|
|
117
89
|
}>>;
|
|
118
|
-
/**
|
|
119
|
-
* Run Monte Carlo simulation trajectories.
|
|
120
|
-
*
|
|
121
|
-
* Each trajectory runs the same DES engine with a different RNG seed
|
|
122
|
-
* (base_seed + trajectory_index), enabling stochastic scenario analysis.
|
|
123
|
-
*
|
|
124
|
-
* @example
|
|
125
|
-
* ```ts
|
|
126
|
-
* const result = $.let(Simulation.runTrajectories(
|
|
127
|
-
* [Resources, Events],
|
|
128
|
-
* initialState, initialEvents, stochasticProcess,
|
|
129
|
-
* { trajectories: 100n, seed: variant('some', 42n), max_events: variant('none', null), end_date: variant('none', null) },
|
|
130
|
-
* ));
|
|
131
|
-
* result.trajectories.get(0n).final_state.cash
|
|
132
|
-
* ```
|
|
133
|
-
*/
|
|
134
|
-
export declare const simulation_run_trajectories: import("@elaraai/east").GenericPlatformDefinition<readonly ["R", "E"], readonly ["R", ArrayType<StructType<{
|
|
135
|
-
readonly date: DateTimeType;
|
|
136
|
-
readonly event: "E";
|
|
137
|
-
}>>, FunctionType<["R", DateTimeType, "E"], StructType<{
|
|
138
|
-
readonly state: "R";
|
|
139
|
-
readonly events: ArrayType<StructType<{
|
|
140
|
-
readonly date: DateTimeType;
|
|
141
|
-
readonly event: "E";
|
|
142
|
-
}>>;
|
|
143
|
-
}>>, StructType<{
|
|
144
|
-
/** Number of trajectories to run (required) */
|
|
145
|
-
readonly trajectories: IntegerType;
|
|
146
|
-
/** Base RNG seed — trajectory i uses seed + i */
|
|
147
|
-
readonly seed: OptionType<IntegerType>;
|
|
148
|
-
/** Safety limit on events per trajectory (default: 100000) */
|
|
149
|
-
readonly max_events: OptionType<IntegerType>;
|
|
150
|
-
/** Stop processing events after this date */
|
|
151
|
-
readonly end_date: OptionType<DateTimeType>;
|
|
152
|
-
}>], StructType<{
|
|
153
|
-
/** Array of per-trajectory results */
|
|
154
|
-
readonly trajectories: ArrayType<StructType<{
|
|
155
|
-
/** Final resource state */
|
|
156
|
-
readonly final_state: "R";
|
|
157
|
-
/** Number of events processed */
|
|
158
|
-
readonly events_processed: IntegerType;
|
|
159
|
-
/** Date of last event processed */
|
|
160
|
-
readonly final_date: DateTimeType;
|
|
161
|
-
}>>;
|
|
162
|
-
}>>;
|
|
163
90
|
/**
|
|
164
91
|
* Type definitions for simulation functions.
|
|
165
92
|
*/
|
|
@@ -180,29 +107,6 @@ export declare const SimulationTypes: {
|
|
|
180
107
|
/** Date of the last event processed */
|
|
181
108
|
readonly final_date: DateTimeType;
|
|
182
109
|
}>;
|
|
183
|
-
/** Monte Carlo configuration */
|
|
184
|
-
readonly TrajectoriesConfigType: StructType<{
|
|
185
|
-
/** Number of trajectories to run (required) */
|
|
186
|
-
readonly trajectories: IntegerType;
|
|
187
|
-
/** Base RNG seed — trajectory i uses seed + i */
|
|
188
|
-
readonly seed: OptionType<IntegerType>;
|
|
189
|
-
/** Safety limit on events per trajectory (default: 100000) */
|
|
190
|
-
readonly max_events: OptionType<IntegerType>;
|
|
191
|
-
/** Stop processing events after this date */
|
|
192
|
-
readonly end_date: OptionType<DateTimeType>;
|
|
193
|
-
}>;
|
|
194
|
-
/** Monte Carlo result */
|
|
195
|
-
readonly TrajectoriesResultType: StructType<{
|
|
196
|
-
/** Array of per-trajectory results */
|
|
197
|
-
readonly trajectories: ArrayType<StructType<{
|
|
198
|
-
/** Final resource state */
|
|
199
|
-
readonly final_state: "R";
|
|
200
|
-
/** Number of events processed */
|
|
201
|
-
readonly events_processed: IntegerType;
|
|
202
|
-
/** Date of last event processed */
|
|
203
|
-
readonly final_date: DateTimeType;
|
|
204
|
-
}>>;
|
|
205
|
-
}>;
|
|
206
110
|
};
|
|
207
111
|
/**
|
|
208
112
|
* Discrete Event Simulation (DES) — REA Economic Ontology.
|
|
@@ -295,94 +199,6 @@ export declare const Simulation: {
|
|
|
295
199
|
/** Date of the last event processed */
|
|
296
200
|
readonly final_date: DateTimeType;
|
|
297
201
|
}>>;
|
|
298
|
-
/**
|
|
299
|
-
* Run Monte Carlo simulation trajectories.
|
|
300
|
-
*
|
|
301
|
-
* Each trajectory runs the same DES engine with a different RNG seed
|
|
302
|
-
* (base_seed + trajectory_index), enabling stochastic scenario analysis.
|
|
303
|
-
* Use this when the process handler uses Random functions — each trajectory
|
|
304
|
-
* gets a deterministic but distinct seed.
|
|
305
|
-
*
|
|
306
|
-
* @example
|
|
307
|
-
* ```ts
|
|
308
|
-
* import { East, StructType, VariantType, ArrayType, FloatType, DateTimeType, variant } from "@elaraai/east";
|
|
309
|
-
* import { Simulation, SimulationTrajectoriesConfigType } from "@elaraai/east-py-datascience";
|
|
310
|
-
*
|
|
311
|
-
* const Resources = StructType({ cash: FloatType });
|
|
312
|
-
* const Events = VariantType({ income: FloatType, expense: FloatType });
|
|
313
|
-
* const ScheduledEvent = StructType({ date: DateTimeType, event: Events });
|
|
314
|
-
* const ProcessResult = StructType({ state: Resources, events: ArrayType(ScheduledEvent) });
|
|
315
|
-
*
|
|
316
|
-
* const simulate = East.function([], Simulation.Types.TrajectoriesResultType, ($) => {
|
|
317
|
-
* const process = East.function(
|
|
318
|
-
* [Resources, DateTimeType, Events],
|
|
319
|
-
* ProcessResult,
|
|
320
|
-
* ($, state, date, event) => {
|
|
321
|
-
* const empty = $.let([] as const, ArrayType(ScheduledEvent));
|
|
322
|
-
* return $.return(event.match({
|
|
323
|
-
* income: ($, amount) => ({
|
|
324
|
-
* state: { cash: state.cash.add(amount) },
|
|
325
|
-
* events: empty,
|
|
326
|
-
* }),
|
|
327
|
-
* expense: ($, amount) => ({
|
|
328
|
-
* state: { cash: state.cash.subtract(amount) },
|
|
329
|
-
* events: empty,
|
|
330
|
-
* }),
|
|
331
|
-
* }));
|
|
332
|
-
* }
|
|
333
|
-
* );
|
|
334
|
-
*
|
|
335
|
-
* const initialState = $.let({ cash: 1000.0 });
|
|
336
|
-
* const initialEvents = $.let([
|
|
337
|
-
* { date: $.let(new Date("2025-01-01")), event: $.let(variant("income", 500.0), Events) },
|
|
338
|
-
* { date: $.let(new Date("2025-01-15")), event: $.let(variant("expense", 200.0), Events) },
|
|
339
|
-
* ], ArrayType(ScheduledEvent));
|
|
340
|
-
* const config = $.let({
|
|
341
|
-
* trajectories: 100n,
|
|
342
|
-
* seed: variant("some", 42n),
|
|
343
|
-
* max_events: variant("none", null),
|
|
344
|
-
* end_date: variant("some", new Date("2025-12-31")),
|
|
345
|
-
* }, SimulationTrajectoriesConfigType);
|
|
346
|
-
*
|
|
347
|
-
* const result = $.let(Simulation.runTrajectories(
|
|
348
|
-
* [Resources, Events],
|
|
349
|
-
* initialState, initialEvents, process, config,
|
|
350
|
-
* ));
|
|
351
|
-
* // result.trajectories.length() => 100n
|
|
352
|
-
* // result.trajectories.get(0n).final_state.cash
|
|
353
|
-
* return $.return(result);
|
|
354
|
-
* });
|
|
355
|
-
* ```
|
|
356
|
-
*/
|
|
357
|
-
readonly runTrajectories: import("@elaraai/east").GenericPlatformDefinition<readonly ["R", "E"], readonly ["R", ArrayType<StructType<{
|
|
358
|
-
readonly date: DateTimeType;
|
|
359
|
-
readonly event: "E";
|
|
360
|
-
}>>, FunctionType<["R", DateTimeType, "E"], StructType<{
|
|
361
|
-
readonly state: "R";
|
|
362
|
-
readonly events: ArrayType<StructType<{
|
|
363
|
-
readonly date: DateTimeType;
|
|
364
|
-
readonly event: "E";
|
|
365
|
-
}>>;
|
|
366
|
-
}>>, StructType<{
|
|
367
|
-
/** Number of trajectories to run (required) */
|
|
368
|
-
readonly trajectories: IntegerType;
|
|
369
|
-
/** Base RNG seed — trajectory i uses seed + i */
|
|
370
|
-
readonly seed: OptionType<IntegerType>;
|
|
371
|
-
/** Safety limit on events per trajectory (default: 100000) */
|
|
372
|
-
readonly max_events: OptionType<IntegerType>;
|
|
373
|
-
/** Stop processing events after this date */
|
|
374
|
-
readonly end_date: OptionType<DateTimeType>;
|
|
375
|
-
}>], StructType<{
|
|
376
|
-
/** Array of per-trajectory results */
|
|
377
|
-
readonly trajectories: ArrayType<StructType<{
|
|
378
|
-
/** Final resource state */
|
|
379
|
-
readonly final_state: "R";
|
|
380
|
-
/** Number of events processed */
|
|
381
|
-
readonly events_processed: IntegerType;
|
|
382
|
-
/** Date of last event processed */
|
|
383
|
-
readonly final_date: DateTimeType;
|
|
384
|
-
}>>;
|
|
385
|
-
}>>;
|
|
386
202
|
/**
|
|
387
203
|
* Type definitions for simulation functions.
|
|
388
204
|
*/
|
|
@@ -403,29 +219,6 @@ export declare const Simulation: {
|
|
|
403
219
|
/** Date of the last event processed */
|
|
404
220
|
readonly final_date: DateTimeType;
|
|
405
221
|
}>;
|
|
406
|
-
/** Monte Carlo configuration */
|
|
407
|
-
readonly TrajectoriesConfigType: StructType<{
|
|
408
|
-
/** Number of trajectories to run (required) */
|
|
409
|
-
readonly trajectories: IntegerType;
|
|
410
|
-
/** Base RNG seed — trajectory i uses seed + i */
|
|
411
|
-
readonly seed: OptionType<IntegerType>;
|
|
412
|
-
/** Safety limit on events per trajectory (default: 100000) */
|
|
413
|
-
readonly max_events: OptionType<IntegerType>;
|
|
414
|
-
/** Stop processing events after this date */
|
|
415
|
-
readonly end_date: OptionType<DateTimeType>;
|
|
416
|
-
}>;
|
|
417
|
-
/** Monte Carlo result */
|
|
418
|
-
readonly TrajectoriesResultType: StructType<{
|
|
419
|
-
/** Array of per-trajectory results */
|
|
420
|
-
readonly trajectories: ArrayType<StructType<{
|
|
421
|
-
/** Final resource state */
|
|
422
|
-
readonly final_state: "R";
|
|
423
|
-
/** Number of events processed */
|
|
424
|
-
readonly events_processed: IntegerType;
|
|
425
|
-
/** Date of last event processed */
|
|
426
|
-
readonly final_date: DateTimeType;
|
|
427
|
-
}>>;
|
|
428
|
-
}>;
|
|
429
222
|
};
|
|
430
223
|
};
|
|
431
224
|
//# sourceMappingURL=simulation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simulation.d.ts","sourceRoot":"","sources":["../../../src/simulation/simulation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH
|
|
1
|
+
{"version":3,"file":"simulation.d.ts","sourceRoot":"","sources":["../../../src/simulation/simulation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;GAYG;AAEH,OAAO,EAEH,UAAU,EACV,UAAU,EACV,SAAS,EACT,WAAW,EACX,YAAY,EACZ,YAAY,EACf,MAAM,eAAe,CAAC;AAmCvB;;GAEG;AACH,eAAO,MAAM,oBAAoB;IAC7B,mEAAmE;;IAEnE,6CAA6C;;EAE/C,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,oBAAoB;IAC7B,sDAAsD;;IAEtD,iCAAiC;;IAEjC,uCAAuC;;EAEzC,CAAC;AAMH;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;IAnDvB,mEAAmE;;IAEnE,6CAA6C;;;IAQ7C,sDAAsD;;IAEtD,iCAAiC;;IAEjC,uCAAuC;;GA+C1C,CAAC;AAMF;;GAEG;AACH,eAAO,MAAM,eAAe;IACxB,+BAA+B;;QAvE/B,mEAAmE;;QAEnE,6CAA6C;;;IAuE7C,wBAAwB;;QA/DxB,sDAAsD;;QAEtD,iCAAiC;;QAEjC,uCAAuC;;;CA6DjC,CAAC;AAEX;;;;;;;;;;GAUG;AACH,eAAO,MAAM,UAAU;IACnB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwDG;;;;;;;;;;;QAjJH,mEAAmE;;QAEnE,6CAA6C;;;QAQ7C,sDAAsD;;QAEtD,iCAAiC;;QAEjC,uCAAuC;;;IAsIvC;;OAEG;;QA/EH,+BAA+B;;YAvE/B,mEAAmE;;YAEnE,6CAA6C;;;QAuE7C,wBAAwB;;YA/DxB,sDAAsD;;YAEtD,iCAAiC;;YAEjC,uCAAuC;;;;CA0IjC,CAAC"}
|
|
@@ -10,9 +10,8 @@
|
|
|
10
10
|
* - E (Events): user-defined variant where each case is an economic activity
|
|
11
11
|
* - Process handler: defines how events affect resources (match dispatch)
|
|
12
12
|
*
|
|
13
|
-
*
|
|
13
|
+
* Entry point:
|
|
14
14
|
* - `simulation_run`: single deterministic run
|
|
15
|
-
* - `simulation_run_trajectories`: Monte Carlo with multiple seeds
|
|
16
15
|
*
|
|
17
16
|
* @packageDocumentation
|
|
18
17
|
*/
|
|
@@ -63,36 +62,6 @@ export const SimulationResultType = StructType({
|
|
|
63
62
|
final_date: DateTimeType,
|
|
64
63
|
});
|
|
65
64
|
// ============================================================================
|
|
66
|
-
// Monte Carlo Types
|
|
67
|
-
// ============================================================================
|
|
68
|
-
/**
|
|
69
|
-
* Configuration for Monte Carlo simulation trajectories.
|
|
70
|
-
*/
|
|
71
|
-
export const SimulationTrajectoriesConfigType = StructType({
|
|
72
|
-
/** Number of trajectories to run (required) */
|
|
73
|
-
trajectories: IntegerType,
|
|
74
|
-
/** Base RNG seed — trajectory i uses seed + i */
|
|
75
|
-
seed: OptionType(IntegerType),
|
|
76
|
-
/** Safety limit on events per trajectory (default: 100000) */
|
|
77
|
-
max_events: OptionType(IntegerType),
|
|
78
|
-
/** Stop processing events after this date */
|
|
79
|
-
end_date: OptionType(DateTimeType),
|
|
80
|
-
});
|
|
81
|
-
/**
|
|
82
|
-
* Result of Monte Carlo simulation trajectories.
|
|
83
|
-
*/
|
|
84
|
-
export const SimulationTrajectoriesResultType = StructType({
|
|
85
|
-
/** Array of per-trajectory results */
|
|
86
|
-
trajectories: ArrayType(StructType({
|
|
87
|
-
/** Final resource state */
|
|
88
|
-
final_state: "R",
|
|
89
|
-
/** Number of events processed */
|
|
90
|
-
events_processed: IntegerType,
|
|
91
|
-
/** Date of last event processed */
|
|
92
|
-
final_date: DateTimeType,
|
|
93
|
-
})),
|
|
94
|
-
});
|
|
95
|
-
// ============================================================================
|
|
96
65
|
// Platform Functions
|
|
97
66
|
// ============================================================================
|
|
98
67
|
/**
|
|
@@ -130,28 +99,6 @@ export const simulation_run = East.genericPlatform("simulation_run", ["R", "E"],
|
|
|
130
99
|
ProcessFnType, // process handler
|
|
131
100
|
SimulationConfigType, // config
|
|
132
101
|
], SimulationResultType);
|
|
133
|
-
/**
|
|
134
|
-
* Run Monte Carlo simulation trajectories.
|
|
135
|
-
*
|
|
136
|
-
* Each trajectory runs the same DES engine with a different RNG seed
|
|
137
|
-
* (base_seed + trajectory_index), enabling stochastic scenario analysis.
|
|
138
|
-
*
|
|
139
|
-
* @example
|
|
140
|
-
* ```ts
|
|
141
|
-
* const result = $.let(Simulation.runTrajectories(
|
|
142
|
-
* [Resources, Events],
|
|
143
|
-
* initialState, initialEvents, stochasticProcess,
|
|
144
|
-
* { trajectories: 100n, seed: variant('some', 42n), max_events: variant('none', null), end_date: variant('none', null) },
|
|
145
|
-
* ));
|
|
146
|
-
* result.trajectories.get(0n).final_state.cash
|
|
147
|
-
* ```
|
|
148
|
-
*/
|
|
149
|
-
export const simulation_run_trajectories = East.genericPlatform("simulation_run_trajectories", ["R", "E"], [
|
|
150
|
-
"R", // initial_state
|
|
151
|
-
ArrayType(ScheduledEventType), // initial_events
|
|
152
|
-
ProcessFnType, // process handler
|
|
153
|
-
SimulationTrajectoriesConfigType, // config
|
|
154
|
-
], SimulationTrajectoriesResultType);
|
|
155
102
|
// ============================================================================
|
|
156
103
|
// Grouped Export
|
|
157
104
|
// ============================================================================
|
|
@@ -163,10 +110,6 @@ export const SimulationTypes = {
|
|
|
163
110
|
ConfigType: SimulationConfigType,
|
|
164
111
|
/** Single run result */
|
|
165
112
|
ResultType: SimulationResultType,
|
|
166
|
-
/** Monte Carlo configuration */
|
|
167
|
-
TrajectoriesConfigType: SimulationTrajectoriesConfigType,
|
|
168
|
-
/** Monte Carlo result */
|
|
169
|
-
TrajectoriesResultType: SimulationTrajectoriesResultType,
|
|
170
113
|
};
|
|
171
114
|
/**
|
|
172
115
|
* Discrete Event Simulation (DES) — REA Economic Ontology.
|
|
@@ -238,66 +181,6 @@ export const Simulation = {
|
|
|
238
181
|
* ```
|
|
239
182
|
*/
|
|
240
183
|
run: simulation_run,
|
|
241
|
-
/**
|
|
242
|
-
* Run Monte Carlo simulation trajectories.
|
|
243
|
-
*
|
|
244
|
-
* Each trajectory runs the same DES engine with a different RNG seed
|
|
245
|
-
* (base_seed + trajectory_index), enabling stochastic scenario analysis.
|
|
246
|
-
* Use this when the process handler uses Random functions — each trajectory
|
|
247
|
-
* gets a deterministic but distinct seed.
|
|
248
|
-
*
|
|
249
|
-
* @example
|
|
250
|
-
* ```ts
|
|
251
|
-
* import { East, StructType, VariantType, ArrayType, FloatType, DateTimeType, variant } from "@elaraai/east";
|
|
252
|
-
* import { Simulation, SimulationTrajectoriesConfigType } from "@elaraai/east-py-datascience";
|
|
253
|
-
*
|
|
254
|
-
* const Resources = StructType({ cash: FloatType });
|
|
255
|
-
* const Events = VariantType({ income: FloatType, expense: FloatType });
|
|
256
|
-
* const ScheduledEvent = StructType({ date: DateTimeType, event: Events });
|
|
257
|
-
* const ProcessResult = StructType({ state: Resources, events: ArrayType(ScheduledEvent) });
|
|
258
|
-
*
|
|
259
|
-
* const simulate = East.function([], Simulation.Types.TrajectoriesResultType, ($) => {
|
|
260
|
-
* const process = East.function(
|
|
261
|
-
* [Resources, DateTimeType, Events],
|
|
262
|
-
* ProcessResult,
|
|
263
|
-
* ($, state, date, event) => {
|
|
264
|
-
* const empty = $.let([] as const, ArrayType(ScheduledEvent));
|
|
265
|
-
* return $.return(event.match({
|
|
266
|
-
* income: ($, amount) => ({
|
|
267
|
-
* state: { cash: state.cash.add(amount) },
|
|
268
|
-
* events: empty,
|
|
269
|
-
* }),
|
|
270
|
-
* expense: ($, amount) => ({
|
|
271
|
-
* state: { cash: state.cash.subtract(amount) },
|
|
272
|
-
* events: empty,
|
|
273
|
-
* }),
|
|
274
|
-
* }));
|
|
275
|
-
* }
|
|
276
|
-
* );
|
|
277
|
-
*
|
|
278
|
-
* const initialState = $.let({ cash: 1000.0 });
|
|
279
|
-
* const initialEvents = $.let([
|
|
280
|
-
* { date: $.let(new Date("2025-01-01")), event: $.let(variant("income", 500.0), Events) },
|
|
281
|
-
* { date: $.let(new Date("2025-01-15")), event: $.let(variant("expense", 200.0), Events) },
|
|
282
|
-
* ], ArrayType(ScheduledEvent));
|
|
283
|
-
* const config = $.let({
|
|
284
|
-
* trajectories: 100n,
|
|
285
|
-
* seed: variant("some", 42n),
|
|
286
|
-
* max_events: variant("none", null),
|
|
287
|
-
* end_date: variant("some", new Date("2025-12-31")),
|
|
288
|
-
* }, SimulationTrajectoriesConfigType);
|
|
289
|
-
*
|
|
290
|
-
* const result = $.let(Simulation.runTrajectories(
|
|
291
|
-
* [Resources, Events],
|
|
292
|
-
* initialState, initialEvents, process, config,
|
|
293
|
-
* ));
|
|
294
|
-
* // result.trajectories.length() => 100n
|
|
295
|
-
* // result.trajectories.get(0n).final_state.cash
|
|
296
|
-
* return $.return(result);
|
|
297
|
-
* });
|
|
298
|
-
* ```
|
|
299
|
-
*/
|
|
300
|
-
runTrajectories: simulation_run_trajectories,
|
|
301
184
|
/**
|
|
302
185
|
* Type definitions for simulation functions.
|
|
303
186
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simulation.js","sourceRoot":"","sources":["../../../src/simulation/simulation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH
|
|
1
|
+
{"version":3,"file":"simulation.js","sourceRoot":"","sources":["../../../src/simulation/simulation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;GAYG;AAEH,OAAO,EACH,IAAI,EACJ,UAAU,EACV,UAAU,EACV,SAAS,EACT,WAAW,EACX,YAAY,EACZ,YAAY,GACf,MAAM,eAAe,CAAC;AAEvB,+EAA+E;AAC/E,wBAAwB;AACxB,+EAA+E;AAE/E;;;GAGG;AACH,MAAM,kBAAkB,GAAG,UAAU,CAAC;IAClC,IAAI,EAAE,YAAY;IAClB,KAAK,EAAE,GAAG;CACb,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,iBAAiB,GAAG,UAAU,CAAC;IACjC,KAAK,EAAE,GAAG;IACV,MAAM,EAAE,SAAS,CAAC,kBAAkB,CAAC;CACxC,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,aAAa,GAAG,YAAY,CAC9B,CAAC,GAAG,EAAE,YAAY,EAAE,GAAG,CAAC,EACxB,iBAAiB,CACpB,CAAC;AAEF,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAE/E;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,UAAU,CAAC;IAC3C,mEAAmE;IACnE,UAAU,EAAE,UAAU,CAAC,WAAW,CAAC;IACnC,6CAA6C;IAC7C,QAAQ,EAAE,UAAU,CAAC,YAAY,CAAC;CACrC,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,UAAU,CAAC;IAC3C,sDAAsD;IACtD,WAAW,EAAE,GAAG;IAChB,iCAAiC;IACjC,gBAAgB,EAAE,WAAW;IAC7B,uCAAuC;IACvC,UAAU,EAAE,YAAY;CAC3B,CAAC,CAAC;AAEH,+EAA+E;AAC/E,qBAAqB;AACrB,+EAA+E;AAE/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,CAAC,eAAe,CAC9C,gBAAgB,EAChB,CAAC,GAAG,EAAE,GAAG,CAAC,EACV;IACI,GAAG,EAA6B,gBAAgB;IAChD,SAAS,CAAC,kBAAkB,CAAC,EAAG,iBAAiB;IACjD,aAAa,EAAmB,kBAAkB;IAClD,oBAAoB,EAAY,SAAS;CAC5C,EACD,oBAAoB,CACvB,CAAC;AAEF,+EAA+E;AAC/E,iBAAiB;AACjB,+EAA+E;AAE/E;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC3B,+BAA+B;IAC/B,UAAU,EAAE,oBAAoB;IAChC,wBAAwB;IACxB,UAAU,EAAE,oBAAoB;CAC1B,CAAC;AAEX;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwDG;IACH,GAAG,EAAE,cAAc;IAEnB;;OAEG;IACH,KAAK,EAAE,eAAe;CAChB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elaraai/east-py-datascience",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "East Data Science - ML/optimization platform functions for East (TypeScript definitions)",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -18,39 +18,10 @@
|
|
|
18
18
|
"CONTRIBUTING.md",
|
|
19
19
|
"CLA.md"
|
|
20
20
|
],
|
|
21
|
-
"scripts": {
|
|
22
|
-
"build": "tsc",
|
|
23
|
-
"test": "npm run build && node --enable-source-maps --test 'dist/test/**/*.spec.js' 'dist/src/**/*.spec.js'",
|
|
24
|
-
"test:coverage": "npm run build && node --enable-source-maps --test --experimental-test-coverage 'dist/test/**/*.spec.js' 'dist/src/**/*.spec.js'",
|
|
25
|
-
"test:export": "npm run build && EXPORT_TEST_IR=/tmp/east-py-datascience node --enable-source-maps --test 'dist/test/**/*.spec.js'",
|
|
26
|
-
"lint": "eslint .",
|
|
27
|
-
"lint:fix": "eslint . --fix",
|
|
28
|
-
"version:patch": "npm version patch -m 'chore: bump version to %s'",
|
|
29
|
-
"version:minor": "npm version minor -m 'chore: bump version to %s'",
|
|
30
|
-
"version:major": "npm version major -m 'chore: bump version to %s'",
|
|
31
|
-
"version:prepatch": "npm version prepatch --preid=beta -m 'chore: bump version to %s'",
|
|
32
|
-
"version:preminor": "npm version preminor --preid=beta -m 'chore: bump version to %s'",
|
|
33
|
-
"version:premajor": "npm version premajor --preid=beta -m 'chore: bump version to %s'",
|
|
34
|
-
"version:prerelease": "npm version prerelease --preid=beta -m 'chore: bump version to %s'",
|
|
35
|
-
"version:patch:dry": "npm version patch --no-git-tag-version",
|
|
36
|
-
"version:minor:dry": "npm version minor --no-git-tag-version",
|
|
37
|
-
"version:major:dry": "npm version major --no-git-tag-version",
|
|
38
|
-
"version:prepatch:dry": "npm version prepatch --preid=beta --no-git-tag-version",
|
|
39
|
-
"version:preminor:dry": "npm version preminor --preid=beta --no-git-tag-version",
|
|
40
|
-
"version:premajor:dry": "npm version premajor --preid=beta --no-git-tag-version",
|
|
41
|
-
"version:prerelease:dry": "npm version prerelease --preid=beta --no-git-tag-version",
|
|
42
|
-
"release:patch": "npm run version:patch && git push && git push --tags",
|
|
43
|
-
"release:minor": "npm run version:minor && git push && git push --tags",
|
|
44
|
-
"release:major": "npm run version:major && git push && git push --tags",
|
|
45
|
-
"release:prepatch": "npm run version:prepatch && git push && git push --tags",
|
|
46
|
-
"release:preminor": "npm run version:preminor && git push && git push --tags",
|
|
47
|
-
"release:premajor": "npm run version:premajor && git push && git push --tags",
|
|
48
|
-
"release:prerelease": "npm run version:prerelease && git push && git push --tags"
|
|
49
|
-
},
|
|
50
21
|
"repository": {
|
|
51
22
|
"type": "git",
|
|
52
|
-
"url": "https://github.com/elaraai/east-
|
|
53
|
-
"directory": "packages/east-py-datascience"
|
|
23
|
+
"url": "git+https://github.com/elaraai/east-workspace.git",
|
|
24
|
+
"directory": "libs/east-py/packages/east-py-datascience"
|
|
54
25
|
},
|
|
55
26
|
"keywords": [
|
|
56
27
|
"east",
|
|
@@ -62,7 +33,7 @@
|
|
|
62
33
|
"pynomad"
|
|
63
34
|
],
|
|
64
35
|
"author": "Elara AI Pty Ltd",
|
|
65
|
-
"license": "SEE LICENSE IN LICENSE",
|
|
36
|
+
"license": "SEE LICENSE IN LICENSE.md",
|
|
66
37
|
"type": "module",
|
|
67
38
|
"engines": {
|
|
68
39
|
"node": ">=22.0.0"
|
|
@@ -76,7 +47,15 @@
|
|
|
76
47
|
"typescript": "~5.9.2"
|
|
77
48
|
},
|
|
78
49
|
"peerDependencies": {
|
|
79
|
-
"@elaraai/east": "
|
|
80
|
-
"@elaraai/east-node-std": "
|
|
50
|
+
"@elaraai/east": "1.0.0",
|
|
51
|
+
"@elaraai/east-node-std": "1.0.0"
|
|
52
|
+
},
|
|
53
|
+
"scripts": {
|
|
54
|
+
"build": "tsc",
|
|
55
|
+
"test": "npm run build && node --enable-source-maps --test-reporter=spec --test 'dist/test/**/*.spec.js' 'dist/src/**/*.spec.js'",
|
|
56
|
+
"test:coverage": "npm run build && node --enable-source-maps --test-reporter=spec --test --experimental-test-coverage 'dist/test/**/*.spec.js' 'dist/src/**/*.spec.js'",
|
|
57
|
+
"test:export": "npm run build && rm -rf /tmp/east-py-datascience && EXPORT_TEST_IR=/tmp/east-py-datascience node --enable-source-maps --test-reporter=spec --test 'dist/test/**/*.spec.js'",
|
|
58
|
+
"lint": "eslint .",
|
|
59
|
+
"lint:fix": "eslint . --fix"
|
|
81
60
|
}
|
|
82
|
-
}
|
|
61
|
+
}
|