Skip to content

engine: Vensim unit equivalences like Resource unit/units are ignored #454

Closed

Description

@bpowers

World3 declares Resource unit and Resource units as the same unit (22:Resource unit,Resource units in the MDL footer), but unit checking treats them as different units and reports mismatches.

Example

simlin simulate --no-output test/metasd/WRLD3-03/wrld3-03.mdl printed:

units error in model 'main' variable 'resource_usage_rate': unit_mismatch -- computed units 'resource_unit/year' don't match specified units
error in model 'main': ... unit_mismatch -- unit checking failed; conflicting constraint:
    1 == resource_unit/resource_units

Why it matters

Singular/plural unit equivalences are a common Vensim idiom, so this produces false errors on otherwise valid models.
Seen on World3.

Fix

World3's footer lists each 22: line twice.
The units context rejected the repeat as a duplicate declaration and the engine fell back to an empty context, which drops every alias (and the model's time unit, see #455).
Repeating an identical equivalence should be accepted; only a contradictory redeclaration is an error, and even then the rest of the units should still be usable.

wrld3_resource_unit_alias_should_not_conflict checks this on World3.
Confirm with the CLI that no resource_unit vs resource_units mismatch remains.

Pointers

Activity

  1. added
    engine
    on Jun 8, 2026
  2. added
    bug
    on Oct 12, 2026
  3. changed the title [-]engine: resource_unit/resource_units alias not honored during unit inference[/-] [+]engine: Vensim unit equivalences like Resource unit/units are ignored[/+] on Oct 12, 2026
  4. added
    compat
    on Oct 12, 2026
  5. bpowers commented on Oct 12, 2026

    @bpowers
    OwnerAuthor

    Closing: already fixed on main.

    Context::new accepts an identical repeated declaration and only reports contradictory ones (src/simlin-engine/src/units.rs:329-410, 8bc2660), and project_units_context_result keeps the partial context instead of falling back to an empty one (src/simlin-engine/src/db/query.rs:69-83). wrld3_resource_unit_alias_should_not_conflict (tests/integration/wrld3_unit_errors.rs:122) runs un-ignored on World3, and test_redundant_duplicate_unit_declarations_are_benign (units.rs:1391) pins alias resolution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcompatengine

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions