Skip to content

Commit ff5348c

Browse files
committed
Relax linear equation criteria
1 parent 10aceac commit ff5348c

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

src/systems/alias_elimination.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ function alias_eliminate_graph(s::SystemStructure, is_linear_equations, eadj, ca
8787

8888
linear_equations = findall(is_linear_equations)
8989

90-
9190
rank1 = bareiss!(
9291
(eadj, cadj),
9392
old_cadj, linear_equations, is_linear_variables, 1
@@ -147,7 +146,7 @@ function alias_eliminate_graph(s::SystemStructure, is_linear_equations, eadj, ca
147146
end
148147

149148
for ei in rank2+1:length(linear_equations)
150-
eadj[ei] = old_cadj[ei]
149+
cadj[ei] = old_cadj[ei]
151150
end
152151

153152
for (ei, e) in enumerate(linear_equations)

src/systems/systemstructure.jl

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,10 @@ function find_linear_equations(sys)
182182
for (i, eq) in enumerate(eqs); isdiffeq(eq) && continue
183183
empty!(coeffs)
184184
linear_term = 0
185-
all_int_algvars = true
185+
all_int_vars = true
186186

187187
term = value(eq.rhs - eq.lhs)
188188
for j in 𝑠neighbors(graph, i)
189-
if !isalgvar(s, j)
190-
all_int_algvars = false
191-
continue
192-
end
193189
var = fullvars[j]
194190
c = expand_derivatives(Differential(var)(term), false)
195191
# test if `var` is linear in `eq`.
@@ -199,18 +195,18 @@ function find_linear_equations(sys)
199195
linear_term += c * var
200196
push!(coeffs, c)
201197
else
202-
all_int_algvars = false
198+
all_int_vars = false
203199
end
204200
end
205201
end
206202

207-
# Check if there are only algebraic variables and the equation is both
208-
# linear and homogeneous, i.e. it is in the form of
203+
# Check if all states in the equation is both linear and homogeneous,
204+
# i.e. it is in the form of
209205
#
210-
# ``∑ c_i * a_i = 0``,
206+
# ``∑ c_i * v_i = 0``,
211207
#
212-
# where ``c_i`` ∈ ℤ and ``a_i`` denotes algebraic variables.
213-
if all_int_algvars && isequal(linear_term, term)
208+
# where ``c_i`` ∈ ℤ and ``v_i`` denotes states.
209+
if all_int_vars && isequal(linear_term, term)
214210
is_linear_equations[i] = true
215211
push!(eadj, copy(𝑠neighbors(graph, i)))
216212
push!(cadj, copy(coeffs))

0 commit comments

Comments
 (0)