Skip to content

Commit 58d35d8

Browse files
committed
Optimize domain expansion
1 parent 58f4450 commit 58d35d8

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/systems/connectors.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ struct SystemDomainGraph{T, C <: AbstractVector{<:ConnectionSet}} <:
357357
Graphs.AbstractGraph{Int}
358358
ts::T
359359
lineqs::BitSet
360+
var2idx::Dict{Any, Int}
360361
id2cset::Vector{NTuple{2, Int}}
361362
cset2id::Vector{Vector{Int}}
362363
csets::C
@@ -368,15 +369,14 @@ Graphs.nv(g::SystemDomainGraph) = length(g.id2cset)
368369
function Graphs.outneighbors(g::SystemDomainGraph, n::Int)
369370
i, j = g.id2cset[n]
370371
ids = copy(g.cset2id[i])
371-
@unpack ts, lineqs = g
372+
@unpack ts, lineqs, var2idx = g
372373
@unpack fullvars, structure = ts
373374
@unpack graph = structure
374375
visited = BitSet(n)
375376
for s in g.csets[i].set
376377
s.sys.namespace === nothing && continue
377378
sys = s.sys.sys
378379
is_domain_connector(sys) && continue
379-
var2idx = Dict(reverse(en) for en in enumerate(ts.fullvars))
380380
vidx = get(var2idx, states(s.sys.namespace, states(sys, s.v)), 0)
381381
iszero(vidx) && continue
382382
ies = 𝑑neighbors(graph, vidx)
@@ -421,7 +421,8 @@ function rooted_system_domain_graph!(ts, csets::AbstractVector{<:ConnectionSet})
421421
outne = Vector{Union{Nothing, Vector{Int}}}(undef, length(id2cset))
422422
mm = linear_subsys_adjmat!(ts)
423423
lineqs = BitSet(mm.nzrows)
424-
SystemDomainGraph(ts, lineqs, id2cset, cset2id, csets, sys2id, outne), roots
424+
var2idx = Dict{Any, Int}(reverse(en) for en in enumerate(ts.fullvars))
425+
SystemDomainGraph(ts, lineqs, var2idx, id2cset, cset2id, csets, sys2id, outne), roots
425426
end
426427

427428
function generate_connection_equations_and_stream_connections(csets::AbstractVector{

0 commit comments

Comments
 (0)