Skip to content

pysimlin: Run.loops shares for arrayed loops do not sum to 1 #672

Open

Description

@bpowers

For an arrayed loop, pysimlin's Run.loops fills behavior_time_series from Sim.get_relative_loop_score(id) with no element.
That call returns, at each step, the element value with the largest magnitude, and the chosen element differs from loop to loop.
The per-loop series therefore no longer add up to 1 within a partition, so a "share of total activity" reading is wrong, and Run.dominant_periods is built on these series.

Example

C-LEARN with 9 pinned arrayed loops: the default relative scores summed to 1.27-1.55 at a timestep instead of 1.0.
Asking per element (get_relative_loop_score(id, element="deterministic")) gave shares that summed correctly.

Why it matters

Arrayed loops are common in real models (C-LEARN, regional models).
Any user who reads Run.loops or dominant_periods on such a model gets shares that look valid but are not, with no error.

Fix

Have Run.loops return one Loop per element of an arrayed loop, each tagged with its element and carrying that element's relative score series.
Then shares add up to 1 per element, and dominant periods can group by each element's own partition, which also removes the "first element's partition" caveat in the dominant_periods docstring.

Alternative: keep one Loop per arrayed loop but add the per-element series alongside the aggregate, and say clearly in the docs that the aggregate is not a share.

Pointers

  • src/pysimlin/simlin/run.py (_populate_loop_behavior, dominant_periods docstring)
  • src/pysimlin/simlin/sim.py (get_relative_loop_score, no-element default)
  • src/libsimlin/src/analysis.rs (simlin_analyze_get_loop_element_count, simlin_analyze_get_relative_loop_score)
  • Seen in notebooks/clearn_ltm_experience.ipynb.

Activity

  1. added
    ltm
    on Jun 2, 2026
  2. added
    bug
    on Oct 12, 2026
  3. changed the title [-]ltm: arrayed pinned loops' no-element default aggregate breaks share-based analysis (Run.loops behavior_time_series)[/-] [+]pysimlin: Run.loops shares for arrayed loops do not sum to 1[/+] 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

    bugltm

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions