@sdeverywhere/runtime 0.2.7 → 0.2.9
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/README.md +1 -1
- package/dist/index.cjs +320 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +88 -4
- package/dist/index.d.ts +88 -4
- package/dist/index.js +313 -15
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -179,6 +179,24 @@ declare class Outputs {
|
|
|
179
179
|
getSeriesForVar(varId: OutputVarId): Series | undefined;
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
+
/**
|
|
183
|
+
* Specifies the constant value that will be used to override a constant in a
|
|
184
|
+
* generated model.
|
|
185
|
+
*/
|
|
186
|
+
interface ConstantDef {
|
|
187
|
+
/** The reference that identifies the constant variable to be modified. */
|
|
188
|
+
varRef: VarRef;
|
|
189
|
+
/** The new constant value. */
|
|
190
|
+
value: number;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Create a `ConstantDef` instance.
|
|
194
|
+
*
|
|
195
|
+
* @param varRef The reference to the constant variable to be modified.
|
|
196
|
+
* @param value The new constant value.
|
|
197
|
+
*/
|
|
198
|
+
declare function createConstantDef(varRef: VarRef, value: number): ConstantDef;
|
|
199
|
+
|
|
182
200
|
/**
|
|
183
201
|
* Specifies the data that will be used to set or override a lookup definition.
|
|
184
202
|
*/
|
|
@@ -216,6 +234,41 @@ declare function getEncodedVarIndicesLength(varSpecs: VarSpec[]): number;
|
|
|
216
234
|
* @param varSpecs The `VarSpec` instances to encode.
|
|
217
235
|
*/
|
|
218
236
|
declare function encodeVarIndices(varSpecs: VarSpec[], indicesArray: Int32Array): void;
|
|
237
|
+
/**
|
|
238
|
+
* Return the lengths of the arrays that are required to store the constant values
|
|
239
|
+
* and indices for the given `ConstantDef` instances.
|
|
240
|
+
*
|
|
241
|
+
* @hidden This is not part of the public API; it is exposed here for use by
|
|
242
|
+
* the synchronous and asynchronous model runner implementations.
|
|
243
|
+
*
|
|
244
|
+
* @param constantDefs The `ConstantDef` instances to encode.
|
|
245
|
+
*/
|
|
246
|
+
declare function getEncodedConstantBufferLengths(constantDefs: ConstantDef[]): {
|
|
247
|
+
constantIndicesLength: number;
|
|
248
|
+
constantsLength: number;
|
|
249
|
+
};
|
|
250
|
+
/**
|
|
251
|
+
* Encode constant values and indices to the given arrays.
|
|
252
|
+
*
|
|
253
|
+
* @hidden This is not part of the public API; it is exposed here for use by
|
|
254
|
+
* the synchronous and asynchronous model runner implementations.
|
|
255
|
+
*
|
|
256
|
+
* @param constantDefs The `ConstantDef` instances to encode.
|
|
257
|
+
* @param constantIndicesArray The view on the constant indices buffer.
|
|
258
|
+
* @param constantsArray The view on the constant values buffer.
|
|
259
|
+
*/
|
|
260
|
+
declare function encodeConstants(constantDefs: ConstantDef[], constantIndicesArray: Int32Array, constantsArray: Float64Array): void;
|
|
261
|
+
/**
|
|
262
|
+
* Decode constant values and indices from the given buffer views and return the
|
|
263
|
+
* reconstructed `ConstantDef` instances.
|
|
264
|
+
*
|
|
265
|
+
* @hidden This is not part of the public API; it is exposed here for use by
|
|
266
|
+
* the synchronous and asynchronous model runner implementations.
|
|
267
|
+
*
|
|
268
|
+
* @param constantIndicesArray The view on the constant indices buffer.
|
|
269
|
+
* @param constantsArray The view on the constant values buffer.
|
|
270
|
+
*/
|
|
271
|
+
declare function decodeConstants(constantIndicesArray: Int32Array, constantsArray: Float64Array): ConstantDef[];
|
|
219
272
|
/**
|
|
220
273
|
* Return the lengths of the arrays that are required to store the lookup data
|
|
221
274
|
* and indices for the given `LookupDef` instances.
|
|
@@ -305,6 +358,17 @@ declare class ModelListing {
|
|
|
305
358
|
* Additional options that can be passed to a `runModel` call to influence the model run.
|
|
306
359
|
*/
|
|
307
360
|
interface RunModelOptions {
|
|
361
|
+
/**
|
|
362
|
+
* If defined, override the values for the specified constant variables.
|
|
363
|
+
*
|
|
364
|
+
* Note that constant overrides do not persist after the `runModel` call. Because
|
|
365
|
+
* `initConstants` is called at the beginning of each `runModel` call, all constants
|
|
366
|
+
* are reset to their default values before each model run. If you want to override
|
|
367
|
+
* constants, you must provide them in the options for each `runModel` call. To
|
|
368
|
+
* reset constants to their original values, simply stop passing them in the options
|
|
369
|
+
* (or pass an empty array).
|
|
370
|
+
*/
|
|
371
|
+
constants?: ConstantDef[];
|
|
308
372
|
/**
|
|
309
373
|
* If defined, override the data for the specified lookups and/or data variables.
|
|
310
374
|
*
|
|
@@ -383,6 +447,11 @@ interface RunModelParams {
|
|
|
383
447
|
* @param array The array that contains the output values.
|
|
384
448
|
*/
|
|
385
449
|
storeOutputs(array: Float64Array): void;
|
|
450
|
+
/**
|
|
451
|
+
* Return an array containing constant overrides, or undefined if no constants were passed
|
|
452
|
+
* to the latest `runModel` call.
|
|
453
|
+
*/
|
|
454
|
+
getConstants(): ConstantDef[] | undefined;
|
|
386
455
|
/**
|
|
387
456
|
* Return an array containing lookup overrides, or undefined if no lookups were passed to
|
|
388
457
|
* the latest `runModel` call.
|
|
@@ -419,6 +488,8 @@ declare class BufferedRunModelParams implements RunModelParams {
|
|
|
419
488
|
* inputs
|
|
420
489
|
* outputs
|
|
421
490
|
* outputIndices
|
|
491
|
+
* constants (values)
|
|
492
|
+
* constantIndices
|
|
422
493
|
* lookups (data)
|
|
423
494
|
* lookupIndices
|
|
424
495
|
*/
|
|
@@ -436,6 +507,10 @@ declare class BufferedRunModelParams implements RunModelParams {
|
|
|
436
507
|
private readonly outputs;
|
|
437
508
|
/** The output indices section of the `encoded` buffer. */
|
|
438
509
|
private readonly outputIndices;
|
|
510
|
+
/** The constant values section of the `encoded` buffer. */
|
|
511
|
+
private readonly constants;
|
|
512
|
+
/** The constant indices section of the `encoded` buffer. */
|
|
513
|
+
private readonly constantIndices;
|
|
439
514
|
/** The lookup data section of the `encoded` buffer. */
|
|
440
515
|
private readonly lookups;
|
|
441
516
|
/** The lookup indices section of the `encoded` buffer. */
|
|
@@ -459,6 +534,7 @@ declare class BufferedRunModelParams implements RunModelParams {
|
|
|
459
534
|
getOutputs(): Float64Array | undefined;
|
|
460
535
|
getOutputsObject(): Outputs | undefined;
|
|
461
536
|
storeOutputs(array: Float64Array): void;
|
|
537
|
+
getConstants(): ConstantDef[] | undefined;
|
|
462
538
|
getLookups(): LookupDef[] | undefined;
|
|
463
539
|
getElapsedTime(): number;
|
|
464
540
|
storeElapsedTime(elapsed: number): void;
|
|
@@ -501,6 +577,7 @@ declare class ReferencedRunModelParams implements RunModelParams {
|
|
|
501
577
|
private outputs;
|
|
502
578
|
private outputsLengthInElements;
|
|
503
579
|
private outputIndicesLengthInElements;
|
|
580
|
+
private constants;
|
|
504
581
|
private lookups;
|
|
505
582
|
/**
|
|
506
583
|
* @param listing The model listing that is used to locate a variable that is referenced by
|
|
@@ -517,6 +594,7 @@ declare class ReferencedRunModelParams implements RunModelParams {
|
|
|
517
594
|
getOutputs(): Float64Array | undefined;
|
|
518
595
|
getOutputsObject(): Outputs | undefined;
|
|
519
596
|
storeOutputs(array: Float64Array): void;
|
|
597
|
+
getConstants(): ConstantDef[] | undefined;
|
|
520
598
|
getLookups(): LookupDef[] | undefined;
|
|
521
599
|
getElapsedTime(): number;
|
|
522
600
|
storeElapsedTime(elapsed: number): void;
|
|
@@ -692,6 +770,7 @@ interface JsModelFunctions {
|
|
|
692
770
|
GAME(inputs: JsModelLookup, x: number): number;
|
|
693
771
|
INTEG(value: number, rate: number): number;
|
|
694
772
|
INTEGER(x: number): number;
|
|
773
|
+
INVERT_MATRIX(matrix: number[][], n: number): number[][];
|
|
695
774
|
LN(x: number): number;
|
|
696
775
|
MAX(x: number, y: number): number;
|
|
697
776
|
MIN(x: number, y: number): number;
|
|
@@ -764,6 +843,8 @@ interface JsModel {
|
|
|
764
843
|
/** @hidden */
|
|
765
844
|
setInputs(inputValue: (index: number) => number): void;
|
|
766
845
|
/** @hidden */
|
|
846
|
+
setConstant(varSpec: VarSpec, value: number): void;
|
|
847
|
+
/** @hidden */
|
|
767
848
|
setLookup(varSpec: VarSpec, points: Float64Array | undefined): void;
|
|
768
849
|
/** @hidden */
|
|
769
850
|
storeOutputs(storeValue: (value: number) => void): void;
|
|
@@ -802,7 +883,7 @@ declare function execJsModel(jsModel: JsModel): void;
|
|
|
802
883
|
* @hidden This type is not part of the public API; it is exposed only for use in
|
|
803
884
|
* tests in the runtime-async package.
|
|
804
885
|
*/
|
|
805
|
-
type OnEvalAux = (vars: Map<VarId, number>, lookups: Map<VarId, JsModelLookup>) => void;
|
|
886
|
+
type OnEvalAux = (vars: Map<VarId, number>, constants: Map<VarId, number> | undefined, lookups: Map<VarId, JsModelLookup>) => void;
|
|
806
887
|
/**
|
|
807
888
|
* @hidden This type is not part of the public API; it is exposed only for use in
|
|
808
889
|
* tests in the runtime-async package.
|
|
@@ -816,6 +897,7 @@ declare class MockJsModel implements JsModel {
|
|
|
816
897
|
private readonly initialTime;
|
|
817
898
|
private readonly finalTime;
|
|
818
899
|
private readonly vars;
|
|
900
|
+
private readonly constants;
|
|
819
901
|
private readonly lookups;
|
|
820
902
|
private fns;
|
|
821
903
|
readonly onEvalAux: OnEvalAux;
|
|
@@ -835,6 +917,7 @@ declare class MockJsModel implements JsModel {
|
|
|
835
917
|
setModelFunctions(fns: JsModelFunctions): void;
|
|
836
918
|
setTime(time: number): void;
|
|
837
919
|
setInputs(): void;
|
|
920
|
+
setConstant(varSpec: VarSpec, value: number): void;
|
|
838
921
|
setLookup(varSpec: VarSpec, points: Float64Array | undefined): void;
|
|
839
922
|
storeOutputs(storeValue: (value: number) => void): void;
|
|
840
923
|
storeOutput(varSpec: VarSpec, storeValue: (value: number) => void): void;
|
|
@@ -880,7 +963,7 @@ declare function initWasmModel(wasmModule: WasmModule): RunnableModel;
|
|
|
880
963
|
* @hidden This type is not part of the public API; it is exposed only for use in
|
|
881
964
|
* tests in the runtime-async package.
|
|
882
965
|
*/
|
|
883
|
-
type OnRunModel = (inputs: Float64Array, outputs: Float64Array, lookups: Map<VarId, JsModelLookup>, outputIndices?: Int32Array) => void;
|
|
966
|
+
type OnRunModel = (inputs: Float64Array, outputs: Float64Array, constants: Map<VarId, number> | undefined, lookups: Map<VarId, JsModelLookup>, outputIndices?: Int32Array) => void;
|
|
884
967
|
/**
|
|
885
968
|
* @hidden This type is not part of the public API; it is exposed only for use in
|
|
886
969
|
* tests in the runtime-async package.
|
|
@@ -898,6 +981,7 @@ declare class MockWasmModule implements WasmModule {
|
|
|
898
981
|
private mallocOffset;
|
|
899
982
|
private readonly allocs;
|
|
900
983
|
private readonly lookups;
|
|
984
|
+
private readonly constants;
|
|
901
985
|
readonly onRunModel: OnRunModel;
|
|
902
986
|
constructor(options: {
|
|
903
987
|
initialTime: number;
|
|
@@ -907,7 +991,7 @@ declare class MockWasmModule implements WasmModule {
|
|
|
907
991
|
onRunModel: OnRunModel;
|
|
908
992
|
});
|
|
909
993
|
varIdForSpec(varSpec: VarSpec): VarId;
|
|
910
|
-
cwrap(fname: string): (
|
|
994
|
+
cwrap(fname: string): (inputsAddress: number, _inputIndicesAddress: number, outputsAddress: number, outputIndicesAddress: number, constantValuesAddress: number, constantIndicesAddress: number) => void;
|
|
911
995
|
_malloc(lengthInBytes: number): number;
|
|
912
996
|
_free(): void;
|
|
913
997
|
private getHeapView;
|
|
@@ -1137,4 +1221,4 @@ declare function perfNow(): unknown;
|
|
|
1137
1221
|
*/
|
|
1138
1222
|
declare function perfElapsed(t0: unknown): number;
|
|
1139
1223
|
|
|
1140
|
-
export { BufferedRunModelParams, type DataMap, type GeneratedModel, type InputCallbacks, type InputValue, type InputVarId, type JsModel, type JsModelFunctionContext, type JsModelFunctions, type LookupDef, MockJsModel, MockWasmModule, type ModelContext, ModelListing, type ModelListingSpecs, type ModelRunner, ModelScheduler, MultiContextModelScheduler, type OnEvalAux, type OnRunModel, type OutputVarId, Outputs, type ParseError, type Point, ReferencedRunModelParams, type RunModelOptions, type RunModelParams, type RunnableModel, Series, type SeriesMap, type SourceName, type VarId, type VarName, type VarRef, type VarSpec, type WasmModule, createInputValue, createLookupDef, createRunnableModel, createSynchronousModelRunner, decodeLookups, encodeLookups, encodeVarIndices, execJsModel, getEncodedLookupBufferLengths, getEncodedVarIndicesLength, getJsModelFunctions, initJsModel, initWasmModel, perfElapsed, perfNow };
|
|
1224
|
+
export { BufferedRunModelParams, type ConstantDef, type DataMap, type GeneratedModel, type InputCallbacks, type InputValue, type InputVarId, type JsModel, type JsModelFunctionContext, type JsModelFunctions, type LookupDef, MockJsModel, MockWasmModule, type ModelContext, ModelListing, type ModelListingSpecs, type ModelRunner, ModelScheduler, MultiContextModelScheduler, type OnEvalAux, type OnRunModel, type OutputVarId, Outputs, type ParseError, type Point, ReferencedRunModelParams, type RunModelOptions, type RunModelParams, type RunnableModel, Series, type SeriesMap, type SourceName, type VarId, type VarName, type VarRef, type VarSpec, type WasmModule, createConstantDef, createInputValue, createLookupDef, createRunnableModel, createSynchronousModelRunner, decodeConstants, decodeLookups, encodeConstants, encodeLookups, encodeVarIndices, execJsModel, getEncodedConstantBufferLengths, getEncodedLookupBufferLengths, getEncodedVarIndicesLength, getJsModelFunctions, initJsModel, initWasmModel, perfElapsed, perfNow };
|
package/dist/index.d.ts
CHANGED
|
@@ -179,6 +179,24 @@ declare class Outputs {
|
|
|
179
179
|
getSeriesForVar(varId: OutputVarId): Series | undefined;
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
+
/**
|
|
183
|
+
* Specifies the constant value that will be used to override a constant in a
|
|
184
|
+
* generated model.
|
|
185
|
+
*/
|
|
186
|
+
interface ConstantDef {
|
|
187
|
+
/** The reference that identifies the constant variable to be modified. */
|
|
188
|
+
varRef: VarRef;
|
|
189
|
+
/** The new constant value. */
|
|
190
|
+
value: number;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Create a `ConstantDef` instance.
|
|
194
|
+
*
|
|
195
|
+
* @param varRef The reference to the constant variable to be modified.
|
|
196
|
+
* @param value The new constant value.
|
|
197
|
+
*/
|
|
198
|
+
declare function createConstantDef(varRef: VarRef, value: number): ConstantDef;
|
|
199
|
+
|
|
182
200
|
/**
|
|
183
201
|
* Specifies the data that will be used to set or override a lookup definition.
|
|
184
202
|
*/
|
|
@@ -216,6 +234,41 @@ declare function getEncodedVarIndicesLength(varSpecs: VarSpec[]): number;
|
|
|
216
234
|
* @param varSpecs The `VarSpec` instances to encode.
|
|
217
235
|
*/
|
|
218
236
|
declare function encodeVarIndices(varSpecs: VarSpec[], indicesArray: Int32Array): void;
|
|
237
|
+
/**
|
|
238
|
+
* Return the lengths of the arrays that are required to store the constant values
|
|
239
|
+
* and indices for the given `ConstantDef` instances.
|
|
240
|
+
*
|
|
241
|
+
* @hidden This is not part of the public API; it is exposed here for use by
|
|
242
|
+
* the synchronous and asynchronous model runner implementations.
|
|
243
|
+
*
|
|
244
|
+
* @param constantDefs The `ConstantDef` instances to encode.
|
|
245
|
+
*/
|
|
246
|
+
declare function getEncodedConstantBufferLengths(constantDefs: ConstantDef[]): {
|
|
247
|
+
constantIndicesLength: number;
|
|
248
|
+
constantsLength: number;
|
|
249
|
+
};
|
|
250
|
+
/**
|
|
251
|
+
* Encode constant values and indices to the given arrays.
|
|
252
|
+
*
|
|
253
|
+
* @hidden This is not part of the public API; it is exposed here for use by
|
|
254
|
+
* the synchronous and asynchronous model runner implementations.
|
|
255
|
+
*
|
|
256
|
+
* @param constantDefs The `ConstantDef` instances to encode.
|
|
257
|
+
* @param constantIndicesArray The view on the constant indices buffer.
|
|
258
|
+
* @param constantsArray The view on the constant values buffer.
|
|
259
|
+
*/
|
|
260
|
+
declare function encodeConstants(constantDefs: ConstantDef[], constantIndicesArray: Int32Array, constantsArray: Float64Array): void;
|
|
261
|
+
/**
|
|
262
|
+
* Decode constant values and indices from the given buffer views and return the
|
|
263
|
+
* reconstructed `ConstantDef` instances.
|
|
264
|
+
*
|
|
265
|
+
* @hidden This is not part of the public API; it is exposed here for use by
|
|
266
|
+
* the synchronous and asynchronous model runner implementations.
|
|
267
|
+
*
|
|
268
|
+
* @param constantIndicesArray The view on the constant indices buffer.
|
|
269
|
+
* @param constantsArray The view on the constant values buffer.
|
|
270
|
+
*/
|
|
271
|
+
declare function decodeConstants(constantIndicesArray: Int32Array, constantsArray: Float64Array): ConstantDef[];
|
|
219
272
|
/**
|
|
220
273
|
* Return the lengths of the arrays that are required to store the lookup data
|
|
221
274
|
* and indices for the given `LookupDef` instances.
|
|
@@ -305,6 +358,17 @@ declare class ModelListing {
|
|
|
305
358
|
* Additional options that can be passed to a `runModel` call to influence the model run.
|
|
306
359
|
*/
|
|
307
360
|
interface RunModelOptions {
|
|
361
|
+
/**
|
|
362
|
+
* If defined, override the values for the specified constant variables.
|
|
363
|
+
*
|
|
364
|
+
* Note that constant overrides do not persist after the `runModel` call. Because
|
|
365
|
+
* `initConstants` is called at the beginning of each `runModel` call, all constants
|
|
366
|
+
* are reset to their default values before each model run. If you want to override
|
|
367
|
+
* constants, you must provide them in the options for each `runModel` call. To
|
|
368
|
+
* reset constants to their original values, simply stop passing them in the options
|
|
369
|
+
* (or pass an empty array).
|
|
370
|
+
*/
|
|
371
|
+
constants?: ConstantDef[];
|
|
308
372
|
/**
|
|
309
373
|
* If defined, override the data for the specified lookups and/or data variables.
|
|
310
374
|
*
|
|
@@ -383,6 +447,11 @@ interface RunModelParams {
|
|
|
383
447
|
* @param array The array that contains the output values.
|
|
384
448
|
*/
|
|
385
449
|
storeOutputs(array: Float64Array): void;
|
|
450
|
+
/**
|
|
451
|
+
* Return an array containing constant overrides, or undefined if no constants were passed
|
|
452
|
+
* to the latest `runModel` call.
|
|
453
|
+
*/
|
|
454
|
+
getConstants(): ConstantDef[] | undefined;
|
|
386
455
|
/**
|
|
387
456
|
* Return an array containing lookup overrides, or undefined if no lookups were passed to
|
|
388
457
|
* the latest `runModel` call.
|
|
@@ -419,6 +488,8 @@ declare class BufferedRunModelParams implements RunModelParams {
|
|
|
419
488
|
* inputs
|
|
420
489
|
* outputs
|
|
421
490
|
* outputIndices
|
|
491
|
+
* constants (values)
|
|
492
|
+
* constantIndices
|
|
422
493
|
* lookups (data)
|
|
423
494
|
* lookupIndices
|
|
424
495
|
*/
|
|
@@ -436,6 +507,10 @@ declare class BufferedRunModelParams implements RunModelParams {
|
|
|
436
507
|
private readonly outputs;
|
|
437
508
|
/** The output indices section of the `encoded` buffer. */
|
|
438
509
|
private readonly outputIndices;
|
|
510
|
+
/** The constant values section of the `encoded` buffer. */
|
|
511
|
+
private readonly constants;
|
|
512
|
+
/** The constant indices section of the `encoded` buffer. */
|
|
513
|
+
private readonly constantIndices;
|
|
439
514
|
/** The lookup data section of the `encoded` buffer. */
|
|
440
515
|
private readonly lookups;
|
|
441
516
|
/** The lookup indices section of the `encoded` buffer. */
|
|
@@ -459,6 +534,7 @@ declare class BufferedRunModelParams implements RunModelParams {
|
|
|
459
534
|
getOutputs(): Float64Array | undefined;
|
|
460
535
|
getOutputsObject(): Outputs | undefined;
|
|
461
536
|
storeOutputs(array: Float64Array): void;
|
|
537
|
+
getConstants(): ConstantDef[] | undefined;
|
|
462
538
|
getLookups(): LookupDef[] | undefined;
|
|
463
539
|
getElapsedTime(): number;
|
|
464
540
|
storeElapsedTime(elapsed: number): void;
|
|
@@ -501,6 +577,7 @@ declare class ReferencedRunModelParams implements RunModelParams {
|
|
|
501
577
|
private outputs;
|
|
502
578
|
private outputsLengthInElements;
|
|
503
579
|
private outputIndicesLengthInElements;
|
|
580
|
+
private constants;
|
|
504
581
|
private lookups;
|
|
505
582
|
/**
|
|
506
583
|
* @param listing The model listing that is used to locate a variable that is referenced by
|
|
@@ -517,6 +594,7 @@ declare class ReferencedRunModelParams implements RunModelParams {
|
|
|
517
594
|
getOutputs(): Float64Array | undefined;
|
|
518
595
|
getOutputsObject(): Outputs | undefined;
|
|
519
596
|
storeOutputs(array: Float64Array): void;
|
|
597
|
+
getConstants(): ConstantDef[] | undefined;
|
|
520
598
|
getLookups(): LookupDef[] | undefined;
|
|
521
599
|
getElapsedTime(): number;
|
|
522
600
|
storeElapsedTime(elapsed: number): void;
|
|
@@ -692,6 +770,7 @@ interface JsModelFunctions {
|
|
|
692
770
|
GAME(inputs: JsModelLookup, x: number): number;
|
|
693
771
|
INTEG(value: number, rate: number): number;
|
|
694
772
|
INTEGER(x: number): number;
|
|
773
|
+
INVERT_MATRIX(matrix: number[][], n: number): number[][];
|
|
695
774
|
LN(x: number): number;
|
|
696
775
|
MAX(x: number, y: number): number;
|
|
697
776
|
MIN(x: number, y: number): number;
|
|
@@ -764,6 +843,8 @@ interface JsModel {
|
|
|
764
843
|
/** @hidden */
|
|
765
844
|
setInputs(inputValue: (index: number) => number): void;
|
|
766
845
|
/** @hidden */
|
|
846
|
+
setConstant(varSpec: VarSpec, value: number): void;
|
|
847
|
+
/** @hidden */
|
|
767
848
|
setLookup(varSpec: VarSpec, points: Float64Array | undefined): void;
|
|
768
849
|
/** @hidden */
|
|
769
850
|
storeOutputs(storeValue: (value: number) => void): void;
|
|
@@ -802,7 +883,7 @@ declare function execJsModel(jsModel: JsModel): void;
|
|
|
802
883
|
* @hidden This type is not part of the public API; it is exposed only for use in
|
|
803
884
|
* tests in the runtime-async package.
|
|
804
885
|
*/
|
|
805
|
-
type OnEvalAux = (vars: Map<VarId, number>, lookups: Map<VarId, JsModelLookup>) => void;
|
|
886
|
+
type OnEvalAux = (vars: Map<VarId, number>, constants: Map<VarId, number> | undefined, lookups: Map<VarId, JsModelLookup>) => void;
|
|
806
887
|
/**
|
|
807
888
|
* @hidden This type is not part of the public API; it is exposed only for use in
|
|
808
889
|
* tests in the runtime-async package.
|
|
@@ -816,6 +897,7 @@ declare class MockJsModel implements JsModel {
|
|
|
816
897
|
private readonly initialTime;
|
|
817
898
|
private readonly finalTime;
|
|
818
899
|
private readonly vars;
|
|
900
|
+
private readonly constants;
|
|
819
901
|
private readonly lookups;
|
|
820
902
|
private fns;
|
|
821
903
|
readonly onEvalAux: OnEvalAux;
|
|
@@ -835,6 +917,7 @@ declare class MockJsModel implements JsModel {
|
|
|
835
917
|
setModelFunctions(fns: JsModelFunctions): void;
|
|
836
918
|
setTime(time: number): void;
|
|
837
919
|
setInputs(): void;
|
|
920
|
+
setConstant(varSpec: VarSpec, value: number): void;
|
|
838
921
|
setLookup(varSpec: VarSpec, points: Float64Array | undefined): void;
|
|
839
922
|
storeOutputs(storeValue: (value: number) => void): void;
|
|
840
923
|
storeOutput(varSpec: VarSpec, storeValue: (value: number) => void): void;
|
|
@@ -880,7 +963,7 @@ declare function initWasmModel(wasmModule: WasmModule): RunnableModel;
|
|
|
880
963
|
* @hidden This type is not part of the public API; it is exposed only for use in
|
|
881
964
|
* tests in the runtime-async package.
|
|
882
965
|
*/
|
|
883
|
-
type OnRunModel = (inputs: Float64Array, outputs: Float64Array, lookups: Map<VarId, JsModelLookup>, outputIndices?: Int32Array) => void;
|
|
966
|
+
type OnRunModel = (inputs: Float64Array, outputs: Float64Array, constants: Map<VarId, number> | undefined, lookups: Map<VarId, JsModelLookup>, outputIndices?: Int32Array) => void;
|
|
884
967
|
/**
|
|
885
968
|
* @hidden This type is not part of the public API; it is exposed only for use in
|
|
886
969
|
* tests in the runtime-async package.
|
|
@@ -898,6 +981,7 @@ declare class MockWasmModule implements WasmModule {
|
|
|
898
981
|
private mallocOffset;
|
|
899
982
|
private readonly allocs;
|
|
900
983
|
private readonly lookups;
|
|
984
|
+
private readonly constants;
|
|
901
985
|
readonly onRunModel: OnRunModel;
|
|
902
986
|
constructor(options: {
|
|
903
987
|
initialTime: number;
|
|
@@ -907,7 +991,7 @@ declare class MockWasmModule implements WasmModule {
|
|
|
907
991
|
onRunModel: OnRunModel;
|
|
908
992
|
});
|
|
909
993
|
varIdForSpec(varSpec: VarSpec): VarId;
|
|
910
|
-
cwrap(fname: string): (
|
|
994
|
+
cwrap(fname: string): (inputsAddress: number, _inputIndicesAddress: number, outputsAddress: number, outputIndicesAddress: number, constantValuesAddress: number, constantIndicesAddress: number) => void;
|
|
911
995
|
_malloc(lengthInBytes: number): number;
|
|
912
996
|
_free(): void;
|
|
913
997
|
private getHeapView;
|
|
@@ -1137,4 +1221,4 @@ declare function perfNow(): unknown;
|
|
|
1137
1221
|
*/
|
|
1138
1222
|
declare function perfElapsed(t0: unknown): number;
|
|
1139
1223
|
|
|
1140
|
-
export { BufferedRunModelParams, type DataMap, type GeneratedModel, type InputCallbacks, type InputValue, type InputVarId, type JsModel, type JsModelFunctionContext, type JsModelFunctions, type LookupDef, MockJsModel, MockWasmModule, type ModelContext, ModelListing, type ModelListingSpecs, type ModelRunner, ModelScheduler, MultiContextModelScheduler, type OnEvalAux, type OnRunModel, type OutputVarId, Outputs, type ParseError, type Point, ReferencedRunModelParams, type RunModelOptions, type RunModelParams, type RunnableModel, Series, type SeriesMap, type SourceName, type VarId, type VarName, type VarRef, type VarSpec, type WasmModule, createInputValue, createLookupDef, createRunnableModel, createSynchronousModelRunner, decodeLookups, encodeLookups, encodeVarIndices, execJsModel, getEncodedLookupBufferLengths, getEncodedVarIndicesLength, getJsModelFunctions, initJsModel, initWasmModel, perfElapsed, perfNow };
|
|
1224
|
+
export { BufferedRunModelParams, type ConstantDef, type DataMap, type GeneratedModel, type InputCallbacks, type InputValue, type InputVarId, type JsModel, type JsModelFunctionContext, type JsModelFunctions, type LookupDef, MockJsModel, MockWasmModule, type ModelContext, ModelListing, type ModelListingSpecs, type ModelRunner, ModelScheduler, MultiContextModelScheduler, type OnEvalAux, type OnRunModel, type OutputVarId, Outputs, type ParseError, type Point, ReferencedRunModelParams, type RunModelOptions, type RunModelParams, type RunnableModel, Series, type SeriesMap, type SourceName, type VarId, type VarName, type VarRef, type VarSpec, type WasmModule, createConstantDef, createInputValue, createLookupDef, createRunnableModel, createSynchronousModelRunner, decodeConstants, decodeLookups, encodeConstants, encodeLookups, encodeVarIndices, execJsModel, getEncodedConstantBufferLengths, getEncodedLookupBufferLengths, getEncodedVarIndicesLength, getJsModelFunctions, initJsModel, initWasmModel, perfElapsed, perfNow };
|