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
should_apply_default_to_missing heuristic fails for non-constant EXCEPT equations #356
The should_apply_default_to_missing heuristic in variable.rs uses text matching to distinguish EXCEPT-originated sparse arrays from override-style sparse arrays. The current all() heuristic checks whether ALL explicitly-specified elements match the default equation text. This works for constant equations but fails for non-constant EXCEPT equations where per-element substitution changes the text.
For example, in an equation like y[DimA] :EXCEPT: y[a2] = special_value, the EXCEPT expansion produces element equations where y[a2] differs from y[DimA] due to subscript substitution, causing the heuristic to incorrectly conclude that the array is override-style rather than EXCEPT-originated.
Why it matters
Correctness: When the heuristic misclassifies an EXCEPT-originated sparse array as override-style, array defaults are not applied to missing elements, producing incorrect simulation results.
Maintainability: Text-based inference of semantic intent is fragile and will break again as equation transformations become more sophisticated.
Add an explicit boolean flag (e.g., has_default: bool or from_except: bool) to Equation::Arrayed in the datamodel. The MDL converter should set this flag during EXCEPT expansion, making the semantics explicit rather than inferred from text comparison. This eliminates the fragile heuristic entirely.
Note: changes to Equation::Arrayed in the datamodel will require corresponding updates to the protobuf definition and serialization, since the datamodel is serialized to Firestore.
Context
Identified during review of the mdl-full-compat branch (PR #343 review feedback).
Activity