Skip to content

Commit 2ffcf5b

Browse files
committed
Make sure var_eq_matching returned by Pantelides only matches whitelisted nodes
1 parent 5cfeeeb commit 2ffcf5b

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/structural_transformation/pantelides.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,11 @@ function pantelides!(state::TransformationState, ag::Union{AliasGraph, Nothing}
163163
pathfound ||
164164
error("maxiters=$maxiters reached! File a bug report if your system has a reasonable index (<100), and you are using the default `maxiters`. Try to increase the maxiters by `pantelides(sys::ODESystem; maxiters=1_000_000)` if your system has an incredibly high index and it is truly extremely large.")
165165
end # for k in 1:neqs′
166+
167+
for var in 1:ndsts(graph)
168+
varwhitelist[var] && continue
169+
var_eq_matching[var] = unassigned
170+
end
166171
return var_eq_matching
167172
end
168173

src/structural_transformation/partial_state_selection.jl

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,6 @@ function partial_state_selection_graph!(structure::SystemStructure, var_eq_match
143143
level
144144
end
145145

146-
# TODO: Should pantelides just return this?
147-
for var in 1:ndsts(graph)
148-
if varlevel[var] !== 0
149-
var_eq_matching[var] = unassigned
150-
end
151-
end
152-
153146
var_eq_matching = pss_graph_modia!(structure,
154147
complete(var_eq_matching), varlevel, inv_varlevel,
155148
inv_eqlevel)
@@ -267,6 +260,10 @@ function dummy_derivative_graph!(structure::SystemStructure, var_eq_matching, ja
267260
end
268261
end
269262

263+
if (n_diff_eqs = count(!isnothing, diff_to_eq)) !=
264+
(n_dummys = length(dummy_derivatives))
265+
@warn "The number of dummy derivatives ($n_dummys) does not match the number of differentiated equations ($n_diff_eqs)."
266+
end
270267
dummy_derivatives_set = BitSet(dummy_derivatives)
271268
# We can eliminate variables that are not a selected state (differential
272269
# variables). Selected states are differentiated variables that are not

0 commit comments

Comments
 (0)