Skip to content

Commit 80e1b95

Browse files
authored
Merge pull request #2216 from SciML/fb/linfix
handle outputs that depend directly on inputs in `linearize`
2 parents 847af0d + bed9504 commit 80e1b95

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/systems/abstractsystem.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1416,7 +1416,12 @@ function markio!(state, orig_inputs, inputs, outputs; check = true)
14161416
outputset = Dict{Any, Bool}(o => false for o in outputs)
14171417
for (i, v) in enumerate(fullvars)
14181418
if v in keys(inputset)
1419-
v = setio(v, true, false)
1419+
if v in keys(outputset)
1420+
v = setio(v, true, true)
1421+
outputset[v] = true
1422+
else
1423+
v = setio(v, true, false)
1424+
end
14201425
inputset[v] = true
14211426
fullvars[i] = v
14221427
elseif v in keys(outputset)

test/linearize.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ lsys, ssys = linearize(sys, [r], [y])
1919
@test lsys.C[] == 1
2020
@test lsys.D[] == 0
2121

22+
lsys, ssys = linearize(sys, [r], [r])
23+
24+
@test lsys.A[] == -2
25+
@test lsys.B[] == 1
26+
@test lsys.C[] == 0
27+
@test lsys.D[] == 1
28+
2229
##
2330
```
2431

0 commit comments

Comments
 (0)