Browse Source

Fixed Symbol support for BilaryNetwork compilation and added tests

pull/50/head
bosonbaas 1 month ago
parent
commit
c27f35b501
  1. 6
      src/BilayerNetworks.jl
  2. 8
      test/bilayernetworks.jl

6
src/BilayerNetworks.jl

@ -221,7 +221,11 @@ evaluate(bn::AbstractLabelledBilayerNetwork, state; params...) = evaluate!(zeros
function paramexps(bn::AbstractLabelledBilayerNetwork, params::Symbol)
map(parts(bn, :Box)) do i
p = bn[i, :parameter]
:(ϕ[$i] *= params[$p])
if p isa Symbol
:(ϕ[$i] *= params[$(Meta.quot(p))])
else
:(ϕ[$i] *= params[$p])
end
end
end

8
test/bilayernetworks.jl

@ -121,3 +121,11 @@ comp_ϕ = [0.0,0.0,0.0]
f!(comp_du, comp_ϕ, u, 0)
@test all(abs.(comp_du .- du[[:S,:I,:R]]) .< 1e-9)
eval(AlgebraicPetri.BilayerNetworks.compile(lab_bnsir, :du, :ϕ, :u, :params))
comp_du = [0.0,0.0,0.0]
comp_ϕ = [0.0,0.0,0.0]
f!(comp_du, comp_ϕ, u, params, 0)
@test all(abs.(comp_du .- du[[:S,:I,:R]]) .< 1e-9)
Loading…
Cancel
Save