Skip to content

Commit 2113314

Browse files
committed
Very hacky fix
1 parent 21494ba commit 2113314

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/systems/alias_elimination.jl

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,19 @@ function alias_elimination!(state::TearingState)
5858
# D(y) appears in the equation, so that D(-D(x)) becomes -D(D(x)).
5959
to_expand = Int[]
6060
diff_to_var = invview(var_to_diff)
61+
# TODO/FIXME: this also needs to be computed recursively because we need to
62+
# follow the alias graph like `a => b => c` and make sure that the final
63+
# graph always contains the destination.
64+
extra_eqs = Equation[]
65+
extra_vars = BitSet()
6166
for (v, (coeff, alias)) in pairs(ag)
62-
subs[fullvars[v]] = iszero(coeff) ? 0 : coeff * fullvars[alias]
67+
if iszero(alias) || !(isempty(𝑑neighbors(graph, alias)) && isempty(𝑑neighbors(graph, v)))
68+
subs[fullvars[v]] = iszero(coeff) ? 0 : coeff * fullvars[alias]
69+
else
70+
push!(extra_eqs, 0 ~ coeff * fullvars[alias] - fullvars[v])
71+
push!(extra_vars, v)
72+
#@show fullvars[v] => fullvars[alias]
73+
end
6374
if coeff == -1
6475
# if `alias` is like -D(x)
6576
diff_to_var[alias] === nothing && continue

0 commit comments

Comments
 (0)