Problem
When writing arrayed variables back to MDL format, the MDL writer (src/simlin-engine/src/mdl/writer.rs, around line 785 in the Equation::Arrayed branch) emits individual resolved element equations instead of reconstructing the original GET DIRECT CONSTANTS/GET DIRECT DATA/GET DIRECT LOOKUPS call. This breaks MDL-to-MDL round-trip fidelity for models with arrayed external data references.
For example, an arrayed variable originally defined as:
variable name[DimA] = GET DIRECT CONSTANTS('file.xlsx', 'Sheet1', 'B2*', 'A2')
gets written back as individual element equations rather than the single GET DIRECT call.
Why it matters
- Round-trip fidelity: Models exported back to MDL lose their external data references, making the output structurally different from the input.
- Interoperability: Other tools (Vensim, SyntheSim) expect GET DIRECT calls and would not understand the expanded element-by-element form.
- Data locality: The GET DIRECT pattern is a deliberate design choice by modelers to keep data in external files; expanding it defeats that intent.
Components affected
src/simlin-engine/src/mdl/writer.rs (the Equation::Arrayed match arm)
Possible approach
The compat.data_source metadata is now preserved on arrayed variables (added in the close-array-gaps branch). The MDL writer's Equation::Arrayed branch should check whether compat.data_source is Some, and if so, reconstruct the original GET DIRECT ... expression from the DataSource fields (kind, file, tab_or_delimiter, row_or_col, cell) instead of emitting per-element equations.
Context
Identified during the close-array-gaps branch work. Related but distinct from:
Problem
When writing arrayed variables back to MDL format, the MDL writer (
src/simlin-engine/src/mdl/writer.rs, around line 785 in theEquation::Arrayedbranch) emits individual resolved element equations instead of reconstructing the originalGET DIRECT CONSTANTS/GET DIRECT DATA/GET DIRECT LOOKUPScall. This breaks MDL-to-MDL round-trip fidelity for models with arrayed external data references.For example, an arrayed variable originally defined as:
gets written back as individual element equations rather than the single GET DIRECT call.
Why it matters
Components affected
src/simlin-engine/src/mdl/writer.rs(theEquation::Arrayedmatch arm)Possible approach
The
compat.data_sourcemetadata is now preserved on arrayed variables (added in theclose-array-gapsbranch). The MDL writer'sEquation::Arrayedbranch should check whethercompat.data_sourceisSome, and if so, reconstruct the originalGET DIRECT ...expression from theDataSourcefields (kind,file,tab_or_delimiter,row_or_col,cell) instead of emitting per-element equations.Context
Identified during the
close-array-gapsbranch work. Related but distinct from: