-
-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fast remake #140
Comments
One fix we can do without waiting for the compiler to be improved is to switch to @jw3126's https://github.com/jw3126/Setfield.jl which internally uses positional-only constructor. So it was type-stable even with Julia 0.6. Setfield.jl is based on the abstraction of getter and setter called lens (see new_prob = @set prob.u0[1] = 1.0 provided that we define positional-only constructors for all structs. Also, I think we can get rid of all integrator.sol = @set sol.code = code Lens is well-defined and composable. It's developed in the Haskell world so I guess there is no wonder why :) https://github.com/ekmett/lens (I found that this approach was great so soon after Setfield.jl is released I ditched my Reconstructables.jl, which was a spin-off package of But there are some caveats (although I think they are solvable):
@set! integrator.sol.code = code for creating new
which is a bit cumbersome. Also, since |
Yes thanks for opening this. This is definitely one of the big issues right now. |
You listed it in SciML/DifferentialEquations.jl#318 which means API change. So you want to switch to Setfield.jl? Also, I think we can (temporary) have both |
I listed it in SciML/DifferentialEquations.jl#318 because I was hoping we could have this done in time. I do want to switch to SetField.jl and get it inferring well. But I don't get what's so bad about the keyword argument methods. While Julia doesn't dispatch on keyword arguments, it now specializes on them: what are we doing that is not allowing this? |
One thing we get from SetField "for free" is the nested-field support. If we make DiffEqBase SetField-compatible we can do: old :: ODEProblem
new = @set old.f.jac = new_jacobian
new :: ODEProblem Technically we can do it with
when
Yeah, I was surprised that BTW, just for curiosity: what's the usecase where |
Ah, so the If I create julia> f = (u, p, t) -> -u; u0 = [1.0, -0.5]; tspan = (0.0, 5.0);
julia> of = ODEFunction(f);
julia> @inferred ODEProblem(of, u0, tspan)
ODEProblem with uType Array{Float64,1} and tType Float64. In-place: false
timespan: (0.0, 5.0)
u0: [1.0, -0.5] |
Oh okay, so remake just needs to use the ODEFunction as the default? |
I think there are three cases:
(But I still need to catch up to the recent changes in DiffEqBase so I may be missing something.) |
Okay, is that already true? I'll check this. If it's true, then we can consider this already done. |
Sorry, it still does not work: julia> @inferred remake(prob, u0=[10.0, 10.0])
ERROR: return type ODEProblem{Array{Float64,1},Tuple{Float64,Float64},false,Nothing,ODEFunction{false,getfield(Main, Symbol("##13#14")),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Nothing,DiffEqBase.StandardODEProblem} does not match inferred return type Any and I forgot that we have type-unstable branch in remake: We tried to remove it in #89 using We can try the |
Let's track performance issue with
remake
here. But, at the moment, the problem is still in the inner constructor since the@inferred
tests, e.g.,https://github.com/JuliaDiffEq/DiffEqBase.jl/blob/b3260af1545c13351e334a29f1868a28f9aa6ff1/test/problem_creation_tests.jl#L20-L21
are still broken.
(I just noticed that @ChrisRackauckas mentioned performance issue with
remake
in #114 so opening an issue here.)The text was updated successfully, but these errors were encountered: