Skip to content

Commit 23390a5

Browse files
committed
Format and clean up
1 parent 0193676 commit 23390a5

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

src/structural_transformation/partial_state_selection.jl

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ function partial_state_selection_graph!(structure::SystemStructure, var_eq_match
148148
end
149149

150150
function dummy_derivative_graph!(state::TransformationState, jac = nothing; kwargs...)
151-
Main._state[] = state
152151
state.structure.solvable_graph === nothing && find_solvables!(state; kwargs...)
153152
var_eq_matching = complete(pantelides!(state))
154153
complete!(state.structure)
@@ -192,7 +191,6 @@ function dummy_derivative_graph!(structure::SystemStructure, var_eq_matching, ja
192191
iszero(maxlevel) && continue
193192

194193
rank_matching = Matching(nvars)
195-
isfirst = true
196194
for _ in maxlevel:-1:1
197195
eqs = filter(eq -> diff_to_eq[eq] !== nothing, eqs)
198196
nrows = length(eqs)
@@ -207,10 +205,6 @@ function dummy_derivative_graph!(structure::SystemStructure, var_eq_matching, ja
207205
# state selection.)
208206
#
209207
# 3. If the Jacobian is a polynomial matrix, use Gröbner basis (?)
210-
if isfirst
211-
vars = sort(vars, by=i->occursin("A", string(Main._state[].fullvars[i])))
212-
end
213-
isfirst = false
214208
if jac !== nothing && (_J = jac(eqs, vars); all(x -> unwrap(x) isa Integer, _J))
215209
J = Int.(unwrap.(_J))
216210
N = ModelingToolkit.nullspace(J; col_order) # modifies col_order
@@ -235,7 +229,6 @@ function dummy_derivative_graph!(structure::SystemStructure, var_eq_matching, ja
235229
if rank != nrows
236230
@warn "The DAE system is structurally singular!"
237231
end
238-
@info Main._state[].fullvars[vars]
239232

240233
# prepare the next iteration
241234
eqs = map(eq -> diff_to_eq[eq], eqs)

src/systems/alias_elimination.jl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,8 @@ function Base.setindex!(ag::AliasGraph, v::Integer, i::Integer)
243243
return 0 => 0
244244
end
245245

246-
function Base.setindex!(ag::AliasGraph, p::Union{Pair{Int, Int}, Tuple{Int, Int}}, i::Integer)
246+
function Base.setindex!(ag::AliasGraph, p::Union{Pair{Int, Int}, Tuple{Int, Int}},
247+
i::Integer)
247248
(c, v) = p
248249
if c == 0 || v == 0
249250
ag[i] = 0
@@ -323,7 +324,9 @@ struct DiffLevelState <: Traversals.AbstractTraversalState
323324
visited::BitSet
324325
end
325326

326-
DiffLevelState(g::SimpleDiGraph, var_to_diff) = DiffLevelState(fill(typemax(Int), nv(g)), var_to_diff, BitSet())
327+
function DiffLevelState(g::SimpleDiGraph, var_to_diff)
328+
DiffLevelState(fill(typemax(Int), nv(g)), var_to_diff, BitSet())
329+
end
327330

328331
@inline function Traversals.initfn!(s::DiffLevelState, u)
329332
push!(s.visited, u)
@@ -601,7 +604,7 @@ function alias_eliminate_graph!(graph, var_to_diff, mm_orig::SparseMatrixCLIL)
601604
end
602605
if r === nothing
603606
isempty(reach₌) && break
604-
idx = findfirst(x->x[1] == 1, reach₌)
607+
idx = findfirst(x -> x[1] == 1, reach₌)
605608
if idx === nothing
606609
c, dr = reach₌[1]
607610
@assert c == -1
@@ -640,9 +643,9 @@ function alias_eliminate_graph!(graph, var_to_diff, mm_orig::SparseMatrixCLIL)
640643
# edges.
641644
weighted_transitiveclosure!(eqg)
642645
# Canonicalize by preferring the lower differentiated variable
643-
for i in 1:length(stem) - 1
646+
for i in 1:(length(stem) - 1)
644647
r = stem[i]
645-
for dr in @view stem[i+1:end]
648+
for dr in @view stem[(i + 1):end]
646649
if has_edge(eqg, r, dr)
647650
c = get_weight(eqg, r, dr)
648651
dag[dr] = c => r

0 commit comments

Comments
 (0)