JuliaDynamics / NetworkDynamics.jl

Julia package for simulating Dynamics on Networks
https://juliadynamics.github.io/NetworkDynamics.jl/dev/
MIT License
124 stars 12 forks source link

passing heterogenious edge parameters in presense of a stochastic layer #99

Open sho7014 opened 3 years ago

sho7014 commented 3 years ago

Hello,

When the size of an array of heterogeneous edge parameters does not match the number of edges of a stochastic layer (e.g. in case of a static layer without any edges), an error arises.

ERROR: Error: The size of the parameter array does not match the number of edges. Make sure the correct number of parameters is given when using the tuple syntax.

The error is getting trapped at L88 of: https://github.com/PIK-ICoNe/NetworkDynamics.jl/blob/57635388611caddabc47f7bfd64899b3aaf1f1c8/src/nd_ODE_Static.jl

If they match, then everything is fine. This might be unintended behavior for some cases because vertex-independent noise is widely used for sde modeling. Some remarks regarding the behavior in the tutorial might be helpful.

lindnemi commented 2 years ago

Hello,

thank you for raising this issue, it's indeed unintended behaviour. As an immediate fix i suggest a closure:

sde_prob = SDEProblem(nd, (dx,x,p,t) -> nd_noise(dx,x,nothing,t), u0, (0., 500.), p)
sho7014 commented 2 years ago

Thank you for the concise and smart fix.