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
dummy_derivative_graph!: Jacobian columns not permuted after priority sort — vars[col_order[i]] indexes mismatched orders #102
In dummy_derivative_graph! (src/partial_state_selection.jl), when state_priority is
provided, the candidate variables are sorted by priority — but the integer Jacobian J
computed before the sort is never column-permuted. The bareiss col_order therefore
refers to columns in the original variable order while being used to index the sorted vars array, so the selected dummy derivatives can be arbitrary with respect to both the
priority ranking and the numerical pivoting.
Code path (StateSelection v1.9.3)
J =jac(eqs, vars) # columns follow `vars` in ORIGINAL order...if state_priority !==nothing&& isfirst
sp =extended_sp.(vars)
sortperm!(var_perm, sp)
permute!(vars, var_perm) # `vars` now sorted by prioritypermute!(sp, var_perm) # ... but `J` is NOT permuted...endif J !==nothing...
N = bareiss.nullspace(J; col_order) # col_order refers to ORIGINAL column order
rank =length(col_order) -size(N, 2)
for i in1:rank
push!(dummy_derivatives, vars[col_order[i]]) # indexes SORTED vars — mismatchend
Two consequences:
Correctness:vars[col_order[i]] selects a different variable than the one bareiss
actually pivoted on. The demoted set may not even correspond to a structurally valid
pivot set of J for the subsequent J = J[next_eq_idxs, next_var_idxs] iterations
(those index arrays are also built against the sorted vars).
Intent: even with the permutation fixed, for the priority sort to influence the
Jacobian path, bareiss.nullspace must prefer earlier columns as pivots; if it does,
adding J = J[:, var_perm] inside the sort branch restores the intended
"demote lowest-priority first" semantics on this path as well.
The bug is masked whenever jac returns nothing (any non-integer entry, e.g.
trigonometric kinematics → matching path), when the SCC is a singleton, or when priorities
are uniform within the SCC (sort is a no-op modulo stable-sort ties). It triggers for
multi-variable SCCs with an all-integer Jacobian and non-uniform priorities.
Found while investigating #101 (which is not caused by this — that model's loop SCC
falls back to the matching path).
Activity
Select dummy derivatives on merged Mattsson-Soderlind blocks, not mat…