Skip to content

C-LEARN: residual Ref.vdf numeric divergence after element-cycle-resolution (SAMPLE UNTIL / INIT-:NA: / numeric tail / NaN-vs-NA) #591

@bpowers

Description

@bpowers

Summary

Umbrella tracking item for the smaller residual clusters of C-LEARN's numeric divergence from the genuine-Vensim reference output (test/xmutil_test_models/Ref.vdf) that remain after the element-cycle-resolution work. C-LEARN now compiles, runs to FINAL TIME, and matches Ref.vdf within 1% on 96.3% of matched cells (after the per-element-GF mapping fix #589 / commit 61573545 and a :NA:-aware + near-zero-robust comparator in ensure_vdf_results). The decision was made to bank the 96.3% and track the residual: every variable below is excluded from the simulates_clearn gate via the documented EXPECTED_VDF_RESIDUAL exclusion constant, so the test passes on the reconciled set.

The dominant residual cluster (whole variables importing as a literal 0+0 stub) is tracked in a separate issue. This umbrella collects everything else.

Discovered on branch clearn-hero-model, HEAD 8775ae97; element-cycle-resolution AC8.1.

Residual clusters

1. SAMPLE UNTIL / INIT-of-:NA: / target-policy (COP dimension, often cop_developing_b)

A :NA:-arithmetic edge and/or SAMPLE UNTIL semantics. Vensim performs NA-arithmetic yielding e.g. -2*NA where Simlin yields a bare :NA: sentinel or 0:

  • last_set_target_year -- Vensim = -1.298e33 (i.e. -2*NA) vs Simlin = 0; equation is INIT(VECTOR SELECT(...))
  • last_active_target_year -- INIT with a -6.49e32 (:NA:) guard
  • time_from_target_to_ultimate_target -- rel ~ 0.96
  • target_emissions_for_rate / ultimate_target_value_from_rate -- SAMPLE UNTIL
  • depth_at_bottom -- INIT recurrence
  • emissions_with_stopped_growth

This subsumes the 2-variable "NA-mismatch" bucket (spurious :NA:, e.g. last_set_target_year).

2. Genuine ~25% numeric tail (meaningful-value divergence, not near-zero)

A connected chain that diverges by rel ~ 0.247 on substantial values -- needs a numeric root-cause, not comparator tuning:

  • im_3_emissions / im_3_ff_co2 / im_3_emissions_vs_rs / relative_emissions_to_equity / relative_emissions_to_equity_target -- e.g. oecd_us @ step 187
  • co2eq_gap_closing_percentage -- large rel but tiny absolute (~1.4e-3); a near-zero-ratio percentage, mostly comparator-ish rather than a true divergence.

3. other-NaN (NaN-vs-:NA: representation mismatch)

~9 variables, led by slr_inches_from_2000[deterministic] (sea-level-rise), where Vensim writes literal IEEE NaN for all 251 steps while Simlin writes the :NA: sentinel (-6.49e32). A NaN-vs-:NA: representation mismatch on a deterministic-scenario series.

Why it matters

  • Correctness / Vensim fidelity: :NA:-arithmetic (e.g. -2*NA), SAMPLE UNTIL semantics, and NaN-vs-:NA: representation are each places where Simlin's runtime diverges from genuine Vensim on real model logic.
  • The ~25% im_3_emissions chain is a meaningful-magnitude divergence (not near-zero noise) and is the most likely to indicate a substantive engine bug rather than a representation/comparator nuance.

Components affected

  • src/simlin-engine/src/ -- builtins / SAMPLE UNTIL, :NA:-arithmetic, VDF NaN handling
  • Test fixtures: test/xmutil_test_models/C-LEARN v77 for Vensim.mdl, test/xmutil_test_models/Ref.vdf
  • src/simlin-engine/tests/simulate.rs -- simulates_clearn; the exact exhaustive list of excluded vars lives in its EXPECTED_VDF_RESIDUAL exclusion constant.

Discovery context

Identified during the C-LEARN hero-model element-cycle-resolution work (branch clearn-hero-model, HEAD 8775ae97), element-cycle-resolution AC8.1. All variables above are excluded from the simulates_clearn gate and tracked here.

Relationship to existing issues (all DISTINCT)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingengineIssues with the rust-based simulation engine

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions