@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,189 @@
|
|
|
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
|
+
* Discrete Event Simulation (DES) — Economic Ontology.
|
|
7
|
+
*
|
|
8
|
+
* Provides a generic priority-queue DES engine grounded in an economic ontology:
|
|
9
|
+
* - R (Resources): user-defined struct representing business state
|
|
10
|
+
* - E (Events): user-defined variant where each case is an economic activity
|
|
11
|
+
* - Process handler: defines how events affect resources (match dispatch)
|
|
12
|
+
*
|
|
13
|
+
* Entry point:
|
|
14
|
+
* - `simulation_run`: single deterministic run
|
|
15
|
+
*
|
|
16
|
+
* @packageDocumentation
|
|
17
|
+
*/
|
|
18
|
+
import { East, StructType, OptionType, ArrayType, IntegerType, DateTimeType, FunctionType, } from "@elaraai/east";
|
|
19
|
+
// ============================================================================
|
|
20
|
+
// Internal Helper Types
|
|
21
|
+
// ============================================================================
|
|
22
|
+
/**
|
|
23
|
+
* Scheduled event — a date + event pair.
|
|
24
|
+
* Not exported; users construct these inline.
|
|
25
|
+
*/
|
|
26
|
+
const ScheduledEventType = StructType({
|
|
27
|
+
date: DateTimeType,
|
|
28
|
+
event: "E",
|
|
29
|
+
});
|
|
30
|
+
/**
|
|
31
|
+
* Handler return type — new state + new events to schedule.
|
|
32
|
+
*/
|
|
33
|
+
const ProcessResultType = StructType({
|
|
34
|
+
state: "R",
|
|
35
|
+
events: ArrayType(ScheduledEventType),
|
|
36
|
+
});
|
|
37
|
+
/**
|
|
38
|
+
* Handler function type — (state, date, event) -> ProcessResult.
|
|
39
|
+
*/
|
|
40
|
+
const ProcessFnType = FunctionType(["R", DateTimeType, "E"], ProcessResultType);
|
|
41
|
+
// ============================================================================
|
|
42
|
+
// Single Run Types
|
|
43
|
+
// ============================================================================
|
|
44
|
+
/**
|
|
45
|
+
* Configuration for a single simulation run.
|
|
46
|
+
*/
|
|
47
|
+
export const SimulationConfigType = StructType({
|
|
48
|
+
/** Safety limit on number of events processed (default: 100000) */
|
|
49
|
+
max_events: OptionType(IntegerType),
|
|
50
|
+
/** Stop processing events after this date */
|
|
51
|
+
end_date: OptionType(DateTimeType),
|
|
52
|
+
});
|
|
53
|
+
/**
|
|
54
|
+
* Result of a single simulation run.
|
|
55
|
+
*/
|
|
56
|
+
export const SimulationResultType = StructType({
|
|
57
|
+
/** Final resource state after all events processed */
|
|
58
|
+
final_state: "R",
|
|
59
|
+
/** Number of events processed */
|
|
60
|
+
events_processed: IntegerType,
|
|
61
|
+
/** Date of the last event processed */
|
|
62
|
+
final_date: DateTimeType,
|
|
63
|
+
});
|
|
64
|
+
// ============================================================================
|
|
65
|
+
// Platform Functions
|
|
66
|
+
// ============================================================================
|
|
67
|
+
/**
|
|
68
|
+
* Run a single deterministic discrete event simulation.
|
|
69
|
+
*
|
|
70
|
+
* Events are processed in chronological order from a priority queue.
|
|
71
|
+
* The handler function dispatches on event type (match) and can
|
|
72
|
+
* mutate state and schedule new events.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* import { East, StructType, VariantType, FloatType, DateTimeType, variant } from "@elaraai/east";
|
|
77
|
+
* import { Simulation } from "@elaraai/east-py-datascience";
|
|
78
|
+
*
|
|
79
|
+
* const Resources = StructType({ cash: FloatType });
|
|
80
|
+
* const Events = VariantType({ income: FloatType, expense: FloatType });
|
|
81
|
+
*
|
|
82
|
+
* const process = East.function(
|
|
83
|
+
* [Resources, DateTimeType, Events],
|
|
84
|
+
* StructType({ state: Resources, events: ArrayType(StructType({ date: DateTimeType, event: Events })) }),
|
|
85
|
+
* ($, state, date, event) => {
|
|
86
|
+
* return $.return(event.match({
|
|
87
|
+
* income: ($, amount) => $.return({ state: state.spread({ cash: state.cash.add(amount) }), events: [] }),
|
|
88
|
+
* expense: ($, amount) => $.return({ state: state.spread({ cash: state.cash.subtract(amount) }), events: [] }),
|
|
89
|
+
* }));
|
|
90
|
+
* }
|
|
91
|
+
* );
|
|
92
|
+
*
|
|
93
|
+
* const result = $.let(Simulation.run([Resources, Events], initialState, initialEvents, process, config));
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
export const simulation_run = East.genericPlatform("simulation_run", ["R", "E"], [
|
|
97
|
+
"R", // initial_state
|
|
98
|
+
ArrayType(ScheduledEventType), // initial_events
|
|
99
|
+
ProcessFnType, // process handler
|
|
100
|
+
SimulationConfigType, // config
|
|
101
|
+
], SimulationResultType);
|
|
102
|
+
// ============================================================================
|
|
103
|
+
// Grouped Export
|
|
104
|
+
// ============================================================================
|
|
105
|
+
/**
|
|
106
|
+
* Type definitions for simulation functions.
|
|
107
|
+
*/
|
|
108
|
+
export const SimulationTypes = {
|
|
109
|
+
/** Single run configuration */
|
|
110
|
+
ConfigType: SimulationConfigType,
|
|
111
|
+
/** Single run result */
|
|
112
|
+
ResultType: SimulationResultType,
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Discrete Event Simulation (DES) — REA Economic Ontology.
|
|
116
|
+
*
|
|
117
|
+
* Generic over:
|
|
118
|
+
* - R: Resources (state struct — the economic resource ontology)
|
|
119
|
+
* - E: Events (variant type — the economic event ontology)
|
|
120
|
+
*
|
|
121
|
+
* The handler function uses match dispatch to define economic processes.
|
|
122
|
+
* Each match branch IS a separate economic process. Process-from-process
|
|
123
|
+
* triggering works by returning new events.
|
|
124
|
+
*/
|
|
125
|
+
export const Simulation = {
|
|
126
|
+
/**
|
|
127
|
+
* Run a single deterministic discrete event simulation.
|
|
128
|
+
*
|
|
129
|
+
* Events are processed chronologically from a priority queue.
|
|
130
|
+
* The handler function dispatches on event type via match and can
|
|
131
|
+
* mutate state and schedule new events (creating the directed
|
|
132
|
+
* cyclic economic graph).
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* ```ts
|
|
136
|
+
* import { East, StructType, VariantType, ArrayType, FloatType, DateTimeType, variant } from "@elaraai/east";
|
|
137
|
+
* import { Simulation, SimulationConfigType } from "@elaraai/east-py-datascience";
|
|
138
|
+
*
|
|
139
|
+
* const Resources = StructType({ cash: FloatType });
|
|
140
|
+
* const Events = VariantType({ income: FloatType, expense: FloatType });
|
|
141
|
+
* const ScheduledEvent = StructType({ date: DateTimeType, event: Events });
|
|
142
|
+
* const ProcessResult = StructType({ state: Resources, events: ArrayType(ScheduledEvent) });
|
|
143
|
+
*
|
|
144
|
+
* const simulate = East.function([], Simulation.Types.ResultType, ($) => {
|
|
145
|
+
* const process = East.function(
|
|
146
|
+
* [Resources, DateTimeType, Events],
|
|
147
|
+
* ProcessResult,
|
|
148
|
+
* ($, state, date, event) => {
|
|
149
|
+
* const empty = $.let([] as const, ArrayType(ScheduledEvent));
|
|
150
|
+
* return $.return(event.match({
|
|
151
|
+
* income: ($, amount) => ({
|
|
152
|
+
* state: { cash: state.cash.add(amount) },
|
|
153
|
+
* events: empty,
|
|
154
|
+
* }),
|
|
155
|
+
* expense: ($, amount) => ({
|
|
156
|
+
* state: { cash: state.cash.subtract(amount) },
|
|
157
|
+
* events: empty,
|
|
158
|
+
* }),
|
|
159
|
+
* }));
|
|
160
|
+
* }
|
|
161
|
+
* );
|
|
162
|
+
*
|
|
163
|
+
* const initialState = $.let({ cash: 1000.0 });
|
|
164
|
+
* const initialEvents = $.let([
|
|
165
|
+
* { date: $.let(new Date("2025-01-01")), event: $.let(variant("income", 500.0), Events) },
|
|
166
|
+
* { date: $.let(new Date("2025-01-15")), event: $.let(variant("expense", 200.0), Events) },
|
|
167
|
+
* ], ArrayType(ScheduledEvent));
|
|
168
|
+
* const config = $.let({
|
|
169
|
+
* max_events: variant("none", null),
|
|
170
|
+
* end_date: variant("none", null),
|
|
171
|
+
* }, SimulationConfigType);
|
|
172
|
+
*
|
|
173
|
+
* const result = $.let(Simulation.run(
|
|
174
|
+
* [Resources, Events],
|
|
175
|
+
* initialState, initialEvents, process, config,
|
|
176
|
+
* ));
|
|
177
|
+
* // result.final_state.cash => 1300.0
|
|
178
|
+
* // result.events_processed => 2n
|
|
179
|
+
* return $.return(result);
|
|
180
|
+
* });
|
|
181
|
+
* ```
|
|
182
|
+
*/
|
|
183
|
+
run: simulation_run,
|
|
184
|
+
/**
|
|
185
|
+
* Type definitions for simulation functions.
|
|
186
|
+
*/
|
|
187
|
+
Types: SimulationTypes,
|
|
188
|
+
};
|
|
189
|
+
//# sourceMappingURL=simulation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,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