Skip to content

Algebraic tearing is equation-order sensitive with no user control; connect-statement reordering flips a model from solvable to InitialFailure #4612

@baggepinnen

Description

@baggepinnen

Summary

Algebraic tearing is equation-order sensitive, and there is currently no user-facing mechanism to control it: state_priority is consulted only by dummy-derivative (continuous state) selection, not by the tearing of algebraic loops.

Minimal observed consequence (multibody suspension model, 11 states after mtkcompile): reordering four semantically-identical connect statements inside one component (moving two frame connections after two rotational-flange connections; connection sets unchanged) flips the model from solves reliably to InitialFailure for every initialization random seed tried (12/12).

Mechanism

Diffing the two orderings via missing_guess_value = MissingGuessValue.Error() shows the cyclic-guess (tear-variable) sets differ by exactly one variable:

  • working ordering tears body_upright.frame_b.f[3] (a cut force),
  • failing ordering tears excited_suspension.suspension.b1.frame_a.tau[2] (a cut torque).

Everything else is identical. The tearing matching made a different (order-driven) tie-break, and the default HashedRandom guess for the alternative tear variable lands the initialization in an infeasible basin.

Why there is no workaround today

  1. state_priority has no effect: it is only used in dummy_derivative_graph! (StateSelection partial_state_selection.jl); grep state_priority over ModelingToolkitTearing finds nothing. The flipped variables are algebraic connector flows, not state candidates.
  2. Guesses do not influence simplification, only the numeric start point — and the tear-variable set itself moves with equation order (we observed a third variable, r2.frame_b.tau[3], appear after providing guesses for the first two), so guess-based hardening chases a moving target.
  3. Model authors cannot, in general, control equation ordering: it is produced by code generators / graphical front-ends, and reordering statements with identical semantics must not change solvability.

Request

Priority-aware tie-breaking in algebraic tearing: when the tearing matching has freedom in which variable an equation is solved for (equivalently, which variables remain as tear/iteration variables), consult variable priorities (either state_priority or a dedicated tearing_priority metadata) so that model libraries can express e.g. "prefer joint coordinates, avoid cut forces/torques as tear variables". This would make simplification results deterministic under semantically-neutral equation reordering whenever the modeler has expressed a preference.

We are attempting a local prototype of such a tie-break and can report results / open a PR if it works out.

Versions

Julia 1.12.6, ModelingToolkit v11.26.8, ModelingToolkitBase v1.43.1, ModelingToolkitTearing v1.14.1, StateSelection v1.9.3.

Related context: #4237, JuliaComputing/StateSelection.jl#95 (same model family).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions