Skip to content

ltm: link score is split when an equation reads one element twice #1061

Open

Description

@bpowers

When an arrayed equation reads the same source element in two spellings (pop and pop[nyc] in nyc's equation), LTM emits one link score per spelling, each varying its own read and holding the other fixed.
The right link score varies every read of that element together, as the same model written element by element would.

Example

Region = {nyc, boston, la}
pop[Region]    stock, initial 100, 200, 300, inflow growth
growth[Region] = pop * 0.02 + pop[nyc] * spill
spill          = 0.01

For nyc, growth[nyc] = 0.03 * pop[nyc], and pop[nyc] -> growth[nyc] -> pop[nyc] is the only loop on that stock, so its loop score must be 1 (section 4.1 of the LTM reference).
Simlin emits two link scores for that one link, 2/3 for the pop read and 1/3 for the pop[nyc] read; the loop uses the 2/3 one and scores 0.667 at every step.

A reducer beside a direct read (pop[r] * 0.02 * (1 - MEAN(pop[*]) / 1000)) also gives two links and two loops where the inline-MEAN scalar model has one.
That is only wrong if an inline reducer is not its own node; the single-mode plan (docs/design-plans/2026-09-07-ltm-single-mode.md, "A reducer is a node", not implemented) makes it one, which would make today's two loops correct; decide that first.

Why it matters

Silent wrong loop scores for a common shape: a broadcast term next to a per-element term.
Seen only on constructed models (a comparison of about 20 small arrayed models with their element-by-element twins, never checked in).

Fix

When several reads in one equation reach the same (source element, target element) pair with no reducer between, build one link-score equation that varies all of them and emit one link.
Reads of other elements stay held fixed; the per-spelling split exists because an earlier version varied those too (docs/tech-debt.md, "The Bare-vs-FixedIndex per-shape split survives").
Medium.
Add the model above as an integration test expecting a loop score of 1.

Alternative: the fragments plan (docs/design-plans/2026-09-04-link-scores-from-fragments.md, not started) varies one input slot of the compiled target, so every read of it varies by construction; larger, but deletes most per-spelling builders.

Pointers

  • src/simlin-engine/src/db/ltm_ir.rs: collect_all_reference_sites (one entry per read)
  • src/simlin-engine/src/db/ltm/link_scores.rs: emit_link_scores_for_edge
  • src/simlin-engine/src/ltm_augment.rs: build_partial_equation_shaped
  • src/simlin-engine/src/ltm_finding.rs: parse_link_offsets (which split score a loop uses)

Activity

  1. added
    engine
    ltm
    on Sep 10, 2026
  2. changed the title [-]ltm: one causal link read through two reference sites is scored as two split partials (isolated loop scores 0.667, not 1)[/-] [+]ltm: link score is split when an equation reads one element twice[/+] 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