Skip to content

array support #25

Description

@bpowers

roughly in priority order

  • lexer + parser support for subscripts
  • simulation support for single-dimensional arrays
  • show simulation results in diagram
  • edit a2a equations
  • edit subscripted equations
  • simulation support for multi-dimensional arrays
  • lexer + parser support for transpose (') unary postfix operator
  • use dimension names in A2A equations
  • use Dimension.SubscriptName directly in equations to get the integer subscript value (1, 2, etc)
  • Apply-to-all arrays with non-apply-to-all graphical functions
  • Slicing -- A[1, *] and SUM(A[1:3])
  • "Dimension positions"

Activity

  1. bpowers commented on Dec 17, 2020

    @bpowers
    OwnerAuthor

    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.
    • 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
    • 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_dim is 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).
  2. added
    compatCompatibility (XMILE, Vensim, etc) problem or enhancement
    enhancementNew feature or request
    engineIssues with the rust-based simulation engine
    frontendInvolved the React-based Typescript frontend
    on Aug 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    compatCompatibility (XMILE, Vensim, etc) problem or enhancementengineIssues with the rust-based simulation engineenhancementNew feature or requestepicfrontendInvolved the React-based Typescript frontend

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions