Skip to content

Commit 864ea0b

Browse files
committed
handle parameters in observed
1 parent c37a269 commit 864ea0b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/symbolicindexing.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ end
8585
const SymbolicEdgeIndex{C,S} = Union{EIndex{C,S}, EPIndex{C,S}}
8686
const SymbolicVertexIndex{C,S} = Union{VIndex{C,S}, VPIndex{C,S}}
8787

88+
idxtype(s::VIndex) = VIndex
89+
idxtype(s::EIndex) = EIndex
90+
8891
#=
8992
SciMLBase gets the index provider from ODEFunction.sys which defaults to f.sys so we provide it...
9093
SSI Maintainer assured that f.sys is really only used for symbolic indexig so method seems legit
@@ -417,6 +420,8 @@ function SII.observed(nw::Network, snis)
417420

418421
# mapping i -> index in state
419422
stateidx = Dict{Int, Int}()
423+
# mapping i -> index in p
424+
paraidx = Dict{Int, Int}()
420425
# mapping i -> index in output
421426
outidx = Dict{Int, Int}()
422427
# mapping i -> index in aggbuf
@@ -426,6 +431,8 @@ function SII.observed(nw::Network, snis)
426431
for (i, sni) in enumerate(_snis)
427432
if SII.is_variable(nw, sni)
428433
stateidx[i] = SII.variable_index(nw, sni)
434+
elseif SII.is_parameter(nw, sni)
435+
paraidx[i] = SII.parameter_index(nw, sni)
429436
else
430437
cf = getcomp(nw, sni)
431438

@@ -467,6 +474,9 @@ function SII.observed(nw::Network, snis)
467474
if !isempty(stateidx)
468475
idx = only(stateidx).second
469476
u[idx]
477+
elseif !isempty(paraidx)
478+
idx = only(paraidx).second
479+
p[idx]
470480
elseif !isempty(outidx)
471481
idx = only(outidx).second
472482
outbuf[idx]
@@ -489,6 +499,9 @@ function SII.observed(nw::Network, snis)
489499
for (i, statei) in stateidx
490500
out[i] = u[statei]
491501
end
502+
for (i, parai) in paraidx
503+
out[i] = p[parai]
504+
end
492505
for (i, outi) in outidx
493506
out[i] = outbuf[outi]
494507
end

0 commit comments

Comments
 (0)