Skip to content

engine: DELAY FIXED ring-buffer semantics blocks 4 simulation tests #346

Description

@bpowers

Problem

4 simulation integration tests in src/simlin-engine/tests/simulate.rs are #[ignore] because DELAY FIXED uses a first-order approximation instead of proper ring-buffer semantics:

  • simulates_delayfixed_xmile
  • simulates_delayfixed_mdl
  • simulates_delayfixed2_xmile
  • simulates_delayfixed2_mdl

DELAY FIXED in Vensim uses an internal ring buffer to store historical values and return the value from exactly N time steps ago. The current engine implementation uses a first-order exponential approximation, which diverges from reference output.

Why it matters

DELAY FIXED is a commonly used Vensim builtin. Correctness requires exact delay semantics (ring buffer), not an approximation. Models relying on DELAY FIXED will produce incorrect simulation results.

Components affected

  • src/simlin-engine (VM runtime state, bytecode compilation for DELAY FIXED)

Possible approach

Implement VM-level ring buffer state for DELAY FIXED. This requires:

  1. Per-instance ring buffer allocation in the VM state
  2. Bytecode ops to push current value and read delayed value
  3. Proper initialization of the ring buffer with the initial value argument

Context

Identified during review of 15 ignored simulation tests on the mdl-full-compat branch.

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

    engineIssues with the rust-based simulation engine

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions