Skip to content

Commit fc5075a

Browse files
committed
Improved heuristics, so that equation systems on highest derivative level are ALWAYS assumed to be linear (gives a warning)
1 parent a590632 commit fc5075a

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/StateSelection.jl

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,7 +1220,7 @@ function getSortedAndSolvedAST(G, # Typically ::Vector{Vector{Int}}
12201220
# Analyze all equation sets eConstraints[i] from lowest-order to highest-order derivatives
12211221
for i in eachindex(eConstraints)
12221222
if log
1223-
println("\n... Equation set $j.$i ..............................")
1223+
println("\n... Equation set $j.$i (highest derivative level = $j.", length(eConstraints), ") ...................")
12241224
println("Equations: ")
12251225
printEquations(eq, eConstraints[i])
12261226
println("Unknown variables: ")
@@ -1336,6 +1336,19 @@ function getSortedAndSolvedAST(G, # Typically ::Vector{Vector{Int}}
13361336
# Check that equation system is linear in the unknowns
13371337
(isLinear, hasConstantCoefficients) = isLinearEquationSystem!(eq, eConstraints[i], vConstraints[i])
13381338
if !isLinear
1339+
# Temporary fix for Rectifier
1340+
if i == length(eConstraints)
1341+
# On highest derivative level:
1342+
# Assume that the equation system is linear
1343+
isLinear = true
1344+
hasConstantCoefficients = false
1345+
showMessage2("It is heuristically assumed that equation system is linear (although isLinearEquation returned isLinear=false).";
1346+
severity = WARNING,
1347+
variables = vConstraints[i],
1348+
equations = eConstraints[i])
1349+
end
1350+
1351+
#=
13391352
if i == length(eConstraints)
13401353
# On highest derivative level:
13411354
# Assume that the equation system is linear, if at least one of the unknowns is a derivative
@@ -1355,7 +1368,7 @@ function getSortedAndSolvedAST(G, # Typically ::Vector{Vector{Int}}
13551368
equations = eConstraints[i])
13561369
end
13571370
end
1358-
1371+
=#
13591372
if !isLinear
13601373
showMessage2("Cannot transform to ODE, because equation system is not linear.";
13611374
severity = ERROR,

0 commit comments

Comments
 (0)