Skip to content

ltm: index of a held-fixed array read lags two steps instead of one #1060

Open

Description

@bpowers

When a link-score equation holds a subscripted read fixed and the subscript is itself a model variable, the subscript is lagged twice: q[ctr] becomes PREVIOUS(q[PREVIOUS(ctr)]), which reads q at t-1 at the element ctr had at t-2.
The paper's partial reads every held-fixed input at t-1, and PREVIOUS(target) was computed with ctr at t-1, so whenever ctr moves the difference is credited to the input being scored.
It should read PREVIOUS(q[ctr]): q and ctr both at t-1.

Example

Region = {nyc, boston, la}; Slot = {s1, s2}
counter        = INTEG(1, 0)
drive          = 1 + counter
ctr            = 1 + (INT(counter) MOD 2)     -- 1, 2, 1, 2, ...
q[s1] = 1 * drive;  q[s2] = 10 * drive
growth[nyc]    = pop[nyc] * 0.01
growth[boston] = q[ctr] * 0.002
growth[la]     = pop[la] * 0.03
pop[Region]    = INTEG(growth, 10)

growth[boston] does not read pop[nyc], so the boston slot of the pop[nyc] -> growth link score should be 0 at every step.
It exceeds 0.5 in magnitude at some steps.

Why it matters

Silent wrong link scores wherever a variable index selects an element of an array that the link-score equation holds fixed.
Seen only on constructed fixtures.

Fix

When the enclosing read is already being held fixed whole, leave its index as written.
This is the rule already used for a TIME index in the same position (arr[TIME], fixed with #1016).
A few lines in the subscript arm of wrap_non_matching_in_previous.
Keep the two neighbouring rules: an index naming an element of the axis (q[s1]) stays a static selector, and the index of the read being varied still gets its own PREVIOUS.

The tests that pin today's values must be re-derived by hand from the new equation, not re-captured.
Once the lag is exact, these slots really are PREVIOUS(target), and the check that omits provably-zero slots (#977) may start omitting them; that is then correct.

Pointers

  • src/simlin-engine/src/ltm_augment.rs: wrap_non_matching_in_previous (the Expr0::Subscript arm and its frozen flag; its rustdoc names this case)
  • src/simlin-engine/src/ltm_augment_index.rs: wrap_index_non_matching_in_previous
  • src/simlin-engine/src/ltm_augment_zero_slot.rs: reach_of (refuses these slots today because of the double lag)
  • Tests to re-derive: db::ltm_value_gate_tests::a_nested_freeze_arm_is_not_a_structural_zero (the model above), db::ltm_tests::pinned_double_lag_residual_is_not_a_structural_zero
  • tests/integration/ltm_frozen_clock.rs: a_clock_read_in_a_frozen_deps_index_is_lagged_once, the TIME version
  • Related: ltm: LOOKUP index is not held fixed if it shares an element's name #984 (the same walker, lookup-table indices)

Activity

  1. added
    engine
    ltm
    on Sep 10, 2026
  2. changed the title [-]ltm: a model dependency inside a frozen dependency's subscript index is lagged twice in the ceteris-paribus partial[/-] [+]ltm: index of a held-fixed array read lags two steps instead of one[/+] on Oct 12, 2026
  3. added
    bug
    on Oct 12, 2026
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

    bugengineltm

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions