Repository navigation
Description
A feedback loop over a dimension is reported as one arrayed loop (r1, with a score per element r1[widgets]) only when every variable on it is subscripted by the same dimension.
If the loop also passes through a scalar variable, such as a SUM over the dimension, LTM reports one separate scalar loop per element instead.
These loops should be reported as one arrayed loop too.
Example
inventory[Product] = INTEG(production[Product] - shipments[Product], 100)
total_inventory = SUM(inventory[*])
pressure = total_inventory / target
production[Product] = base[Product] * pressure
Each element closes its own loop inventory[p] -> total_inventory -> pressure -> production[p] -> inventory[p].
With 3 products LTM reports r1, r2, r3 (and pins report pin1⁚0..pin1⁚2).
Expected: one loop r1 with scores r1[p1]..r1[p3], as for a loop with no scalar step.
The scores themselves are correct; only how they are grouped differs.
Why it matters
Aggregate feedback through a total is a common arrayed structure, and the loop list gets one entry per element.
How often this shows up in the real models under test/ has not been checked.
The same happens when a loop crosses a dimension mapping (stock[State] -> x[Region] -> stock[State] with State -> Region mapped): each circuit is one loop per element, because elements are compared by name and s1 and r1 differ (#755).
Fix
Widen the test that groups element circuits into one arrayed loop: allow scalar nodes shared by every circuit, and compare elements through the dimension mapping (DimensionsContext::executed_read_correspondence) rather than by name.
The arrayed loop-score output already exists (Loop.slot_links), and pinned loops reuse the same builder, so they follow.
Partition assignment and anything assuming one scalar loop per circuit needs checking.
Alternative: leave as is; it is presentation only.
Pointers
src/simlin-engine/src/db/ltm/loops.rs:build_element_level_loops, theis_cross_elementchecksrc/simlin-engine/src/ltm_augment.rs:generate_loop_score_variablessrc/simlin-engine/src/dimensions.rs:executed_read_correspondence,mapped_read_correspondencesrc/simlin-engine/src/db/ltm/pinned.rs
Activity
ltm: core-algorithm batch of root-caused fixes from epic #488 (#761)
[-]ltm: collapse mixed-diagonal loop families into one arrayed loop score (enumerator + pins)[/-][+]ltm: a loop through a SUM is reported once per element[/+]