You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
engine: non-negative stocks and flows are not enforced #545
A stock or flow marked non-negative simulates exactly as if it were unmarked: the engine reads and saves the marking but never clamps the value.
A model that relies on it, such as an inventory that should stop at zero, can go negative.
Example
A stock inventory with initial value 10, a constant outflow of 5 per time unit, and <non_negative/> reaches -40 at time 10.
XMILE 1.0 section 4.2 says non-negative "is not directly supported by XMILE"; the marking exists "partly for documentation, partly to allow a vendor to invoke a macro to implement the functionality".
What Stella does exactly (clamp the stock, or limit its outflows in priority order) is unverified.
Why it matters
Seen in a real model: an AI-generated model checked by the validation battery (#1077) has three flows marked non-negative that go far below zero in its own run.
The validation battery and the save check flag a marked series that goes below zero and say the engine does not enforce the marking.
LTM cannot show the balancing loop a non-negative constraint creates, because the constraint is not in the simulation (docs/reference/ltm--loops-that-matter.md, the Workers example).
Fix
Keep not enforcing it, as already decided; the battery and save check make the gap visible.
If that changes: settle stock and flow semantics against real Stella output first, then clamp in the stock update.
Pointers
src/simlin-engine/src/tools/battery.rs, src/simlin-engine/src/save_check.rs: where the gap is reported
src/simlin-engine/src/variable.rs: non_negative on Variable::Stock and Variable::Var
src/simlin-engine/src/compiler/mod.rs, src/simlin-engine/src/compiler/symbolic.rs: notes on how a clamp would fit the stock update
changed the title [-]engine: non_negative variable flag is parsed and stored but never enforced in the compiler or VM[/-][+]engine: non-negative stocks and flows are not enforced[/+]on Oct 12, 2026
You decided on 2026-10-01 to keep not enforcing it. XMILE 4.2 says it 'is not directly supported by XMILE', and the battery and save check (#1077) now report the gap.
Activity
engine: agent tool surface, phase 4 (the validation battery)
[-]engine: non_negative variable flag is parsed and stored but never enforced in the compiler or VM[/-][+]engine: non-negative stocks and flows are not enforced[/+]bpowers commentedon Oct 12, 2026
Closing as won't fix.
You decided on 2026-10-01 to keep not enforcing it. XMILE 4.2 says it 'is not directly supported by XMILE', and the battery and save check (#1077) now report the gap.