Skip to content

ltm: get_links reports only the first element's link score for arrays #665

Open

Description

@bpowers

For arrayed models, get_links returns one link per pair of variables and a single score series for it.
The engine computes a separate link score for each element, but get_links reads only the first element's series, and the per-target relative link scores are computed from those first-element series too.
It should report link scores per element.

Example

births[region] = population[region] * birth_rate with regions {north, south}.
The link-score variable for population -> births holds one series per region, but Sim.get_links() returns one population -> births link whose score is north's series; south's is not reachable.
A link whose score variable is named for one source element (population[north] -> total) is probably not matched at all and comes back with no score; this is from reading the code, not checked by running it.

Why it matters

Arrayed models are common (C-LEARN, regional and cohort models).
On them every element's link reports the same first-element number, with no hint that the others differ.
This also blocks a usable path-score helper (#669), which needs per-element link scores to multiply along a path.

Fix

Give each returned link an optional element subscript and return one entry per element (or one per element pair for cross-element links), each with its own score series.
Then compute relative link scores per target element.
get_relative_loop_score(id, element=...) already does the same per-element lookup for loops, so follow its shape for naming elements.

Pointers

  • src/simlin-engine/src/analysis.rs (model_links: looks up the bare link-score name, which flatten_model in src/simlin-engine/src/db/layout.rs maps to the first slot)
  • src/simlin-engine/src/ltm_augment.rs (link_score_var_name, the link-score naming rules)
  • src/libsimlin/src/ffi.rs (SimlinLink), src/pysimlin/simlin/sim.py (get_links)

Activity

  1. added
    engine
    ltm
    on Jun 2, 2026
  2. added
    enhancement
    on Oct 12, 2026
  3. changed the title [-]libsimlin: get_links is variable-level / slot-0 only for arrayed models[/-] [+]ltm: get_links reports only the first element's link score for arrays[/+] 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

    engineenhancementltm

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions