# Delay Differential Equations Networks with different delay per edge

**URL:** https://discourse.julialang.org/t/delay-differential-equations-networks-with-different-delay-per-edge/69787
**Category:** Modelling & Simulations
**Tags:** diffeq, performance
**Created:** [October 14, 2021, 10:41pm UTC](https://discourse.julialang.org/t/delay-differential-equations-networks-with-different-delay-per-edge/69787 "2021-10-14T22:41:49Z")
**Posts on this page:** 1
**Showing post:** 7

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [October 15, 2021, 2:37pm UTC](https://discourse.julialang.org/t/delay-differential-equations-networks-with-different-delay-per-edge/69787/7 "2021-10-15T14:37:27Z")

</div>

Oh interesting, one thing that is happening is Julia’s function handling heuristics are getting in the way.

```julia
function f!(dθ, θ, h::H, p, t) where H
    ω, A = p
    n = length(θ)
    lags = reshape(lag, n,n)
    @inbounds for j in 1:n
        coupling = 0.0
        @inbounds for i in 1:n
            coupling += A[i,j]*sin(h(p, t-lags[i,j]; idxs=i) - θ[j])
        end
        dθ[j] = ω[j] + coupling
    end
    nothing
end

```

is 6 times faster. Before:

```julia
julia> @time solve(prob, MethodOfSteps(BS3()), saveat=0.01, reltol=0, abstol=1e-5)
 56.409539 seconds (1.96 G allocations: 32.454 GiB, 7.17% gc time)

```

After:

```julia
julia> @time solve(prob, MethodOfSteps(BS3()), saveat=0.01, reltol=0, abstol=1e-5)
 12.284248 seconds (5.79 M allocations: 455.702 MiB, 1.67% gc time)

```

[https://github.com/SciML/SciMLBase.jl/pull/110](https://github.com/SciML/SciMLBase.jl/pull/110) fixes that.

---

_[View the full topic](https://discourse.julialang.org/t/delay-differential-equations-networks-with-different-delay-per-edge/69787)._
