Skip to content

sorted_incidence_matrix fails on a simplified scalar ODE #4961

Description

@ChrisRackauckas-Claude

sorted_incidence_matrix documents that a structurally simplified System with a schedule is sufficient. On current master (754b9679a017aae5d3a632d1d95dfd0c82229b41), a scalar ODE satisfies those preconditions but errors while applying the SCC column permutation.

Reproducer (Julia 1.12.6):

using ModelingToolkit

@independent_variables t
@variables x(t)
D = Differential(t)
@named sys = System([D(x) ~ -x], t)

compiled = mtkcompile(sys)
@assert ModelingToolkit.get_schedule(compiled) !== nothing
ModelingToolkit.sorted_incidence_matrix(compiled)

Observed error:

ERROR: DimensionMismatch: the length of column-permutation argument `q`, `length(q) (= 1)`, must match source argument `A`'s column count, `size(A, 2) (= 2)`

The failure is at src/structural_transformation/utils.jl:22, where the implementation passes reduce(vcat, sched.var_sccs) to permute!. git log -S sorted_incidence_matrix and blame identify 1e564207241814265fc9870a100625f382f84a60 (feat: implement sorted_incidence_matrix(sys)) as the introduction of this System overload and the failing line.

This was reproduced from a clean worktree after Pkg.instantiate(). No changes from the structural-transformation developer API documentation PR are involved.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions