Closed ChrisRackauckas closed 7 years ago
Hi @ChrisRackauckas !
Wow! You are fast! Amazing work, congratulations!
I will test this tonight and, if I could make everything work, then tomorrow I will update my simulator and compare with the old version. I will let you know the results.
Hi @ChrisRackauckas,
I am having a problem, I tried to run your example but I got this error:
ERROR: LoadError: MethodError: no method matching start(::OrdinaryDiffEq.Tsit5Cache{SimType{Float64},SimType{Float64},SimType{Float64},OrdinaryDiffEq.Tsit5ConstantCache{Float64}})
Closest candidates are:
start(::SimpleVector) at essentials.jl:170
start(::Base.MethodList) at reflection.jl:258
start(::IntSet) at intset.jl:184
...
in (::##3#4)(::OrdinaryDiffEq.ODEIntegrator{OrdinaryDiffEq.Tsit5,SimType{Float64},Float64,Float64,Float64,Array{SimType{Float64},1},DiffEqBase.ODESolution{Array{SimType{Float64},1},Array{Float64,1},Array{Array{SimType{Float64},1},1},DiffEqBase.ODEProblem{SimType{Float64},Float64,true,#f},OrdinaryDiffEq.Tsit5,OrdinaryDiffEq.InterpolationData{#f,Array{SimType{Float64},1},Array{Float64,1},Array{Array{SimType{Float64},1},1},OrdinaryDiffEq.Tsit5Cache{SimType{Float64},SimType{Float64},SimType{Float64},OrdinaryDiffEq.Tsit5ConstantCache{Float64}}}},SimType{Float64},#f,Void,OrdinaryDiffEq.Tsit5Cache{SimType{Float64},SimType{Float64},SimType{Float64},OrdinaryDiffEq.Tsit5ConstantCache{Float64}},OrdinaryDiffEq.DEOptions{Float64,Float64,Float64,Float64,OrdinaryDiffEq.#ODE_DEFAULT_NORM,DiffEqBase.CallbackSet{Tuple{},Tuple{DiffEqBase.DiscreteCallback{##1#2,##3#4}}},OrdinaryDiffEq.#ODE_DEFAULT_ISOUTOFDOMAIN,OrdinaryDiffEq.#ODE_DEFAULT_PROG_MESSAGE,DataStructures.BinaryHeap{Float64,DataStructures.LessThan},Void}}) at /home/ronan.arraes/tmp/teste_new_callbacks_01.jl:67
in apply_discrete_callback!(::OrdinaryDiffEq.ODEIntegrator{OrdinaryDiffEq.Tsit5,SimType{Float64},Float64,Float64,Float64,Array{SimType{Float64},1},DiffEqBase.ODESolution{Array{SimType{Float64},1},Array{Float64,1},Array{Array{SimType{Float64},1},1},DiffEqBase.ODEProblem{SimType{Float64},Float64,true,#f},OrdinaryDiffEq.Tsit5,OrdinaryDiffEq.InterpolationData{#f,Array{SimType{Float64},1},Array{Float64,1},Array{Array{SimType{Float64},1},1},OrdinaryDiffEq.Tsit5Cache{SimType{Float64},SimType{Float64},SimType{Float64},OrdinaryDiffEq.Tsit5ConstantCache{Float64}}}},SimType{Float64},#f,Void,OrdinaryDiffEq.Tsit5Cache{SimType{Float64},SimType{Float64},SimType{Float64},OrdinaryDiffEq.Tsit5ConstantCache{Float64}},OrdinaryDiffEq.DEOptions{Float64,Float64,Float64,Float64,OrdinaryDiffEq.#ODE_DEFAULT_NORM,DiffEqBase.CallbackSet{Tuple{},Tuple{DiffEqBase.DiscreteCallback{##1#2,##3#4}}},OrdinaryDiffEq.#ODE_DEFAULT_ISOUTOFDOMAIN,OrdinaryDiffEq.#ODE_DEFAULT_PROG_MESSAGE,DataStructures.BinaryHeap{Float64,DataStructures.LessThan},Void}}, ::DiffEqBase.DiscreteCallback{##1#2,##3#4}) at /home/ronan.arraes/.julia/v0.5/OrdinaryDiffEq/src/callbacks.jl:120
in handle_callbacks! at /home/ronan.arraes/.julia/v0.5/OrdinaryDiffEq/src/integrators/integrator_utils.jl:168 [inlined]
in loopfooter! at /home/ronan.arraes/.julia/v0.5/OrdinaryDiffEq/src/integrators/integrator_utils.jl:138 [inlined]
in solve!(::OrdinaryDiffEq.ODEIntegrator{OrdinaryDiffEq.Tsit5,SimType{Float64},Float64,Float64,Float64,Array{SimType{Float64},1},DiffEqBase.ODESolution{Array{SimType{Float64},1},Array{Float64,1},Array{Array{SimType{Float64},1},1},DiffEqBase.ODEProblem{SimType{Float64},Float64,true,#f},OrdinaryDiffEq.Tsit5,OrdinaryDiffEq.InterpolationData{#f,Array{SimType{Float64},1},Array{Float64,1},Array{Array{SimType{Float64},1},1},OrdinaryDiffEq.Tsit5Cache{SimType{Float64},SimType{Float64},SimType{Float64},OrdinaryDiffEq.Tsit5ConstantCache{Float64}}}},SimType{Float64},#f,Void,OrdinaryDiffEq.Tsit5Cache{SimType{Float64},SimType{Float64},SimType{Float64},OrdinaryDiffEq.Tsit5ConstantCache{Float64}},OrdinaryDiffEq.DEOptions{Float64,Float64,Float64,Float64,OrdinaryDiffEq.#ODE_DEFAULT_NORM,DiffEqBase.CallbackSet{Tuple{},Tuple{DiffEqBase.DiscreteCallback{##1#2,##3#4}}},OrdinaryDiffEq.#ODE_DEFAULT_ISOUTOFDOMAIN,OrdinaryDiffEq.#ODE_DEFAULT_PROG_MESSAGE,DataStructures.BinaryHeap{Float64,DataStructures.LessThan},Void}}) at /home/ronan.arraes/.julia/v0.5/OrdinaryDiffEq/src/solve.jl:221
in #solve#47(::Array{Any,1}, ::Function, ::DiffEqBase.ODEProblem{SimType{Float64},Float64,true,#f}, ::OrdinaryDiffEq.Tsit5, ::Array{Any,1}, ::Array{Any,1}, ::Array{Any,1}) at /home/ronan.arraes/.julia/v0.5/OrdinaryDiffEq/src/solve.jl:7
in (::DiffEqBase.#kw##solve)(::Array{Any,1}, ::DiffEqBase.#solve, ::DiffEqBase.ODEProblem{SimType{Float64},Float64,true,#f}, ::OrdinaryDiffEq.Tsit5, ::Array{Any,1}, ::Array{Any,1}, ::Array{Any,1}) at ./<missing>:0 (repeats 2 times)
in include_from_node1(::String) at ./loading.jl:488
while loading /home/ronan.arraes/tmp/teste_new_callbacks_01.jl, in expression starting on line 80
Both DiffEqBase
and OrdinaryDiffEq
are at master. I have no idea what is happening.
Nevermind, I deleted .julia
and started again. Now it is working. I only have one more comment. I could not find the cache
function you comment. I see a cache_iter
at DiffEqBase but it seems it is not implemented yet for OrdinaryDiffEq. Am I doing something wrong?
That said... I haven't gotten around to implementing all of the cache iterators yet because it will be tedious. I'll get to it (it means the size changing example is also broken on master right now too).
I meant cache_iter
. I just haven't gotten to it yet, so currently you'd have to look at the cache for the algorithm and use that knowledge to built it.
Hi @ChrisRackauckas,
In this new version, is it possible to let the solver define the algorithm? If I remove the algorithm from the solve
command, then it gives an error.
That will need the DifferentialEquations.jl tag to go through, which is last.
@ChrisRackauckas just to let you know that I ported my simulator to the new version of OrdinaryDiffEq and the new callback interface. Everything is exactly the same, no performance drop, no change at the results. And now I don't need a global variable to pass the time to the affect!
. Great work! :)
When we can select the absolute tolerance per state, I think this simulator will beat simulink execution time, which is fantastic!
Good to hear! Sounds like the callbacks are working well then. I'll close this and the rest is package-specific implementation issues.
@ronisbr , I expanded the cache iterator parts. There one for just the u
-like values, one for just the rate-like values, and one for all cache variables. It'll take some documentation and examples to really explain, but the idea is that in many cases you only need a certain part of the cache. In your example, you only needed to update the u
-like values, since those are the ones which have and use the discrete variable in your function. Thus on OrdinaryDiffEq master you can now do:
function affect!(integrator)
for c in u_cache(integrator)
c.f1 = 1.5
end
end
and that should work with all functions for which it's implemented (everything but Rosenbrock and the implicit methods), and will gain support as time goes on. Again, this is on master and may not be released for a bit.
Excellent @ChrisRackauckas! Good work :)
This is to discuss the callback interface separate from the clutter of #5. In there we started discussing a little about coming up with a common callback interface, but didn't get very far.