Repository navigation
Description
Relative loop scores are normalized within a cycle partition: the set of stocks connected by feedback.
A loop whose only state is inside a module instance (a SMOOTH, DELAY, or a user sub-model's stock) has no parent-level stock, so it gets no partition and is normalized alone.
Its relative loop score is always +1 or -1 when active, even when another loop through the same variables competes with it.
Example
perceived_demand = SMTH1(demand, 3)
expected_cost = SMTH1(cost, 5)
price = expected_cost * perceived_demand / normal_demand
demand = normal_demand * (normal_price / price) ^ elasticity
cost = unit_cost * demand / capacity
Two loops: demand -> perceived_demand -> price -> demand and demand -> cost -> expected_cost -> price -> demand.
Both run through price and demand and compete, but each relative loop score reads +/-1, so neither can be compared with the other.
Absolute loop scores are correct.
(Illustrative model; the behavior is from reading partition_for_loop and NormGroup, not from a run.)
Why it matters
Smoothed perceptions with no parent stock on the loop are a common SD structure, so models built from SMOOTH and DELAY lose the main thing relative scores provide.
Not seen reported on a real model.
Normalizing each such loop alone is deliberate (#750): putting all unresolved loops in one shared group mixed unrelated loops.
Fix
Treat each state-carrying module instance as a node in the stock-coupling graph that partitions are built from, and map its internal stocks (sub·stock) to that partition.
Loops then join the partition their module instances belong to; only truly isolated loops stay alone.
The partition's stock-name set is the identity exposed through libsimlin, pysimlin and MCP (#685), so the module-instance names become part of that contract.
Partitions are built in three places (exhaustive, element-level, discovery) and all three must change together.
Treating PREVIOUS-holding variables as state nodes too (#773) fits the same change.
Pointers
src/simlin-engine/src/db/analysis.rs:model_cycle_partitions,model_element_cycle_partitionssrc/simlin-engine/src/ltm/graph.rs:CausalGraph::compute_cycle_partitionssrc/simlin-engine/src/ltm/partitions.rs:partition_for_loopsrc/simlin-engine/src/ltm_post.rs:NormGroup
Activity
ltm: scoring-correctness and visibility batch from epic #488 (#775)
[-]ltm: resolve cycle partitions for state-carrying module instances (Solo backstop under-merges genuinely-coupled module-internal-stock loops)[/-][+]ltm: relative score is always ±1 for loops whose state is in a module[/+]