Repository navigation
array support #25
Copy link
Copy link
Open
Labels
compatCompatibility (XMILE, Vensim, etc) problem or enhancementCompatibility (XMILE, Vensim, etc) problem or enhancementengineIssues with the rust-based simulation engineIssues with the rust-based simulation engineenhancementNew feature or requestNew feature or requestepicfrontendInvolved the React-based Typescript frontendInvolved the React-based Typescript frontend
Description
Activity
I had written a bunch of notes on sd.js a few years ago that are relevant (more or less)
- diagram changes (minimal)
- figure out if it makes sense to do single-dimensional first, or multi-
dimensional from the start - parser:
- array reference/slicing
- transpose operator
- semantic analysis/validation:
- validate indexing
- validate slicing
- transpose using dimension names
- transpose using positions
- array slicing (
A[1, *])
- optimization?
- the simple thing to do is have a nest of for loops for each individual
variable. This is simple, I worry it will be slow for large models (which
are very common users of arrays). If we're doing operations on multiple
variables with the same dimensions in a row, we can merge them into a
single loop. This is straightforward logically, but there is no
optimization framework in place yet, so that would need to be added.
- the simple thing to do is have a nest of for loops for each individual
- codegen:
- apply-to-all equations
- nested for loop
- non-A2A equations
- non-A2A graphical functions
- array slicing (
A[1, *]) - transpose using dimension names
- transpose using positions
- apply-to-all equations
- runtime:
- know about defined dimensions + their subscripts
- allocate correct amount of space for arrayed variables
- array builtins:
MIN,MEAN,MAX,RANK,SIZE,STDDEV,SUM. - be able to enumerate all subscripted values for CSV output
- be able to return results for
arrayed_variable[int_or_named_dimension] - right now, the runtime is pretty dead-simple. Every builtin
function expects one or more numbers as input. With the array
builtins, this is no longer the case.- index into arrays with non-constant offsets:
constants[INT(RANDOM(1, SIZE(foods)))] - create slices of arrays:
SUM(array[chosen_dim, *]), where
chosen_dimis an auxiliary variable. - this means runtime type checking, and I think runtime memory
allocation (right now memory is allocated once, in one chunk, when a
simulation is created, which is fast and optimial).
- index into arrays with non-constant offsets:
- addedcompatCompatibility (XMILE, Vensim, etc) problem or enhancementCompatibility (XMILE, Vensim, etc) problem or enhancementenhancementNew feature or requestNew feature or requestengineIssues with the rust-based simulation engineIssues with the rust-based simulation enginefrontendInvolved the React-based Typescript frontendInvolved the React-based Typescript frontend
on Aug 26, 2021
Metadata
Metadata
Assignees
Labels
compatCompatibility (XMILE, Vensim, etc) problem or enhancementCompatibility (XMILE, Vensim, etc) problem or enhancementengineIssues with the rust-based simulation engineIssues with the rust-based simulation engineenhancementNew feature or requestNew feature or requestepicfrontendInvolved the React-based Typescript frontendInvolved the React-based Typescript frontend
roughly in priority order
') unary postfix operatorDimension.SubscriptNamedirectly in equations to get the integer subscript value (1, 2, etc)A[1, *]andSUM(A[1:3])