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: unordered or NaN graphical-function x values are not rejected #715
A graphical function whose x values are out of order, NaN, or infinite reached the VM without any error.
The lookup's binary search assumes ascending x, so such a table gave an arbitrary interpolated value.
Example
XMILE <xpts>0,10,5,20</xpts> compiled and simulated with no diagnostic.
The only out-of-order table in the test corpus is Vensim's lookup2dim[B,E]((2,-3),(1,-7),(0,-1)) in test/test-models/tests/subscripted_lookups/test_subscripted_lookups.mdl.
Status
On main, parse_table (src/simlin-engine/src/variable.rs) rejects a NaN or infinite x and any x that is lower than the one before it, with a BadTable error naming the values.
The MDL importer sorts out-of-order points into x order, matching Vensim's own output for the model above (simulates_subscripted_lookups_mdl and a_vensim_lookup_listed_out_of_x_order_is_imported_in_x_order in src/simlin-engine/tests/integration/simulate.rs).
XMILE 1.0 section 4.1.3 requires ascending x, so XMILE input is rejected rather than sorted.
A corpus census of every graphical function the engine can read (558 tables across 64 files, via open_vensim/open_xmile so the shapes are the ones the compiler sees) turns up exactly one unsorted table, and it is a live instance of this issue rather than a near-miss:
test/test-models/tests/subscripted_lookups/test_subscripted_lookups.mdl — a 3-point table whose x-coordinates are [2.0, 1.0, 0.0], i.e. strictly descending. It reaches the VM with no diagnostic and produces an arbitrary interpolation today.
Two facts that matter for prioritizing:
Nothing covers it. That model is not in the gated TEST_MODELS corpus, which is why this has never surfaced as a failure. So the current behaviour is not merely undefined, it is unobserved.
557 of 558 corpus tables are strictly ascending (0 have duplicate x). So validation would reject or repair exactly one known model, not a long tail — the back-compat surface for stored projects is the open question, not the corpus.
For the census record, since it bears on any fix that wants a fast path: 483 tables (86.6%) are exactly uniform in x, 26 (4.7%) are uniform only to within a 1e-9 relative tolerance — the 0.1, 0.2, 0.3 binary-floating-point case, which includes 8 of WORLD3's 55 tables — and 48 (8.6%) are genuinely non-uniform.
changed the title [-]engine: graphical-function tables with unsorted/NaN x-coordinates are accepted silently and produce undefined lookup results[/-][+]engine: unordered or NaN graphical-function x values are not rejected[/+]on Oct 12, 2026
parse_table (src/simlin-engine/src/variable.rs:356-382, 610cb2c / #1071) returns BadTable for a NaN x, an infinite x, or any x below its predecessor, citing XMILE 1.0 section 4.1.3; tests x_values_out_of_ascending_order_are_a_bad_table, a_model_with_decreasing_x_reports_a_bad_table_on_its_variable and a_model_with_a_nan_x_reports_a_bad_table_on_its_variable (variable.rs:995, 1146, 1166) pin it down to the model diagnostic. The MDL importer sorts instead (points_in_x_order, mdl/convert/variables.rs:1564), checked against Vensim's own output by simulates_subscripted_lookups_mdl and a_vensim_lookup_listed_out_of_x_order_is_imported_in_x_order (tests/integration/simulate.rs:2933, 2946).
Activity
bpowers commentedon Aug 10, 2026
A corpus census of every graphical function the engine can read (558 tables across 64 files, via
open_vensim/open_xmileso the shapes are the ones the compiler sees) turns up exactly one unsorted table, and it is a live instance of this issue rather than a near-miss:test/test-models/tests/subscripted_lookups/test_subscripted_lookups.mdl— a 3-point table whose x-coordinates are [2.0, 1.0, 0.0], i.e. strictly descending. It reaches the VM with no diagnostic and produces an arbitrary interpolation today.Two facts that matter for prioritizing:
TEST_MODELScorpus, which is why this has never surfaced as a failure. So the current behaviour is not merely undefined, it is unobserved.For the census record, since it bears on any fix that wants a fast path: 483 tables (86.6%) are exactly uniform in x, 26 (4.7%) are uniform only to within a 1e-9 relative tolerance — the
0.1, 0.2, 0.3binary-floating-point case, which includes 8 of WORLD3's 55 tables — and 48 (8.6%) are genuinely non-uniform.engine: performance pass on compile, simulation, and the LTM path (#1021
[-]engine: graphical-function tables with unsorted/NaN x-coordinates are accepted silently and produce undefined lookup results[/-][+]engine: unordered or NaN graphical-function x values are not rejected[/+]bpowers commentedon Oct 12, 2026
Closing: already fixed on main.
parse_table(src/simlin-engine/src/variable.rs:356-382, 610cb2c / #1071) returnsBadTablefor a NaN x, an infinite x, or any x below its predecessor, citing XMILE 1.0 section 4.1.3; testsx_values_out_of_ascending_order_are_a_bad_table,a_model_with_decreasing_x_reports_a_bad_table_on_its_variableanda_model_with_a_nan_x_reports_a_bad_table_on_its_variable(variable.rs:995, 1146, 1166) pin it down to the model diagnostic. The MDL importer sorts instead (points_in_x_order, mdl/convert/variables.rs:1564), checked against Vensim's own output bysimulates_subscripted_lookups_mdlanda_vensim_lookup_listed_out_of_x_order_is_imported_in_x_order(tests/integration/simulate.rs:2933, 2946).