Skip to content

Commit

Permalink
Merge pull request #2216 from SciML/fb/linfix
Browse files Browse the repository at this point in the history
handle outputs that depend directly on inputs in `linearize`
  • Loading branch information
YingboMa authored Sep 4, 2023
2 parents 847af0d + bed9504 commit 80e1b95
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/systems/abstractsystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1416,7 +1416,12 @@ function markio!(state, orig_inputs, inputs, outputs; check = true)
outputset = Dict{Any, Bool}(o => false for o in outputs)
for (i, v) in enumerate(fullvars)
if v in keys(inputset)
v = setio(v, true, false)
if v in keys(outputset)
v = setio(v, true, true)
outputset[v] = true
else
v = setio(v, true, false)
end
inputset[v] = true
fullvars[i] = v
elseif v in keys(outputset)
Expand Down
7 changes: 7 additions & 0 deletions test/linearize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ lsys, ssys = linearize(sys, [r], [y])
@test lsys.C[] == 1
@test lsys.D[] == 0

lsys, ssys = linearize(sys, [r], [r])

@test lsys.A[] == -2
@test lsys.B[] == 1
@test lsys.C[] == 0
@test lsys.D[] == 1

##
```
Expand Down

0 comments on commit 80e1b95

Please sign in to comment.