Skip to content

using IntervalArithmetic invalidates a lot of code from ModelingToolkit.jl #708

@jaakkor2

Description

@jaakkor2

In my system, IntervalArithmetic.jl is pulled in when using GLMakie.jl.

(@v1.10) pkg> why IntervalArithmetic
  GLMakie → Makie → DelaunayTriangulation → ExactPredicates → IntervalArithmetic
  IntervalArithmetic

Taking the example from https://github.com/SciML/ModelingToolkit.jl front page (README.md) and omitting the plotting part, and naming it MTKdemo.jl

using OrdinaryDiffEqDefault, ModelingToolkit
using ModelingToolkit: t_nounits as t, D_nounits as D

@parameters σ ρ β
@variables x(t) y(t) z(t)

eqs = [D(D(x)) ~ σ * (y - x),
    D(y) ~ x * (ρ - z) - y,
    D(z) ~ x * y - β * z]

@mtkbuild sys = ODESystem(eqs, t)

u0 = [D(x) => 2.0,
    x => 1.0,
    y => 0.0,
    z => 0.0]

p = [σ => 28.0,
    ρ => 10.0,
    β => 8 / 3]

tspan = (0.0, 100.0)
prob = ODEProblem(sys, u0, tspan, p, jac = true)
sol = solve(prob)
nothing

Then a lot of code from the example above needs to recompiled after using IntervalArithmetic

julia> @time include("MTKdemo.jl")
 13.122820 seconds (25.34 M allocations: 1.698 GiB, 7.29% gc time, 63.39% compilation time: <1% of which was recompilation)

julia> @time include("MTKdemo.jl")
  0.019970 seconds (154.13 k allocations: 8.521 MiB, 0.00% compilation time)

julia> @time using IntervalArithmetic
  0.071065 seconds (79.87 k allocations: 4.100 MiB)

julia> @time include("MTKdemo.jl")
 11.524903 seconds (19.34 M allocations: 1.292 GiB, 2.09% gc time, 99.71% compilation time: 93% of which was recompilation)

julia> @time include("MTKdemo.jl")
  0.020549 seconds (153.11 k allocations: 8.454 MiB, 0.00% compilation time)
(@v1.10) pkg> st
  [d1acc4aa] IntervalArithmetic v0.22.31
  [961ee093] ModelingToolkit v9.76.0
  [50262376] OrdinaryDiffEqDefault v1.3.0

Julia v1.10.9.

Earlier I opened an issue at lairez/ExactPredicates.jl#27, but looks like the invalidations are coming from IntervalArithmetic.jl.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions