SciML / DifferentialEquations.jl

Multi-language suite for high-performance solvers of differential equations and scientific machine learning (SciML) components. Ordinary differential equations (ODEs), stochastic differential equations (SDEs), delay differential equations (DDEs), differential-algebraic equations (DAEs), and more in Julia.
https://docs.sciml.ai/DiffEqDocs/stable/
Other
2.82k stars 222 forks source link

Doc example for @ode_def is not working #186

Closed JackDevine closed 7 years ago

JackDevine commented 7 years ago

If I run the @ode_def example in the ordinary differential equations part of the docs, then I get the following:

g = @ode_def LorenzExample begin
  dx = σ*(y-x)
  dy = x*(ρ-z) - y
  dz = x*y - β*z
end σ=>10.0 ρ=>28.0 β=(8/3)

u0 = [1.0,0.0,0.0]
tspan = (0.0,1.0)
prob = ODEProblem(g,u0,tspan)

sol = solve(prob)
Timeseries Solution with uType Array{Float64,1} and tType Float64
retcode: Success
Error showing value of type DiffEqBase.ODESolution{Float64,2,Array{Array{Float64,1},1},Void,Void,Array{Float64,1},Array{Array{Array{Float64,1},1},1},DiffEqBase.ODEProblem{Array{Float64,1},Float64,true,LorenzExample,Void,UniformScaling{Int64}},OrdinaryDiffEq.Tsit5,OrdinaryDiffEq.InterpolationData{LorenzExample,Array{Array{Float64,1},1},Array{Float64,1},Array{Array{Array{Float64,1},1},1},OrdinaryDiffEq.Tsit5Cache{Array{Float64,1},Array{Float64,1},Array{Float64,1},Array{Float64,1},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}}}}:
ERROR: MethodError: no method matching interp_summary(::OrdinaryDiffEq.InterpolationData{LorenzExample,Array{Array{Float64,1},1},Array{Float64,1},Array{Array{Array{Float64,1},1},1},OrdinaryDiffEq.Tsit5Cache{Array{Float64,1},Array{Float64,1},Array{Float64,1},Array{Float64,1},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}}})
Closest candidates are:
  interp_summary(::Void) at /Users/jackdevine/.julia/v0.6/DiffEqBase/src/interpolation.jl:15
  interp_summary(::DiffEqBase.HermiteInterpolation) at /Users/jackdevine/.julia/v0.6/DiffEqBase/src/interpolation.jl:13
  interp_summary(::DiffEqBase.LinearInterpolation) at /Users/jackdevine/.julia/v0.6/DiffEqBase/src/interpolation.jl:14
  ...
Stacktrace:
 [1] display(::DiffEqBase.ODESolution{Float64,2,Array{Array{Float64,1},1},Void,Void,Array{Float64,1},Array{Array{Array{Float64,1},1},1},DiffEqBase.ODEProblem{Array{Float64,1},Float64,true,LorenzExample,Void,UniformScaling{Int64}},OrdinaryDiffEq.Tsit5,OrdinaryDiffEq.InterpolationData{LorenzExample,Array{Array{Float64,1},1},Array{Float64,1},Array{Array{Array{Float64,1},1},1},OrdinaryDiffEq.Tsit5Cache{Array{Float64,1},Array{Float64,1},Array{Float64,1},Array{Float64,1},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}}}}) at /Users/jackdevine/.julia/v0.6/DiffEqBase/src/solutions/solution_interface.jl:45
 [2] eval(::Module, ::Any) at ./boot.jl:235
 [3] print_response(::Base.Terminals.TTYTerminal, ::Any, ::Void, ::Bool, ::Bool, ::Void) at ./REPL.jl:144
 [4] print_response(::Base.REPL.LineEditREPL, ::Any, ::Void, ::Bool, ::Bool) at ./REPL.jl:129
 [5] (::Base.REPL.#do_respond#16{Bool,Base.REPL.##26#36{Base.REPL.LineEditREPL,Base.REPL.REPLHistoryProvider},Base.REPL.LineEditREPL,Base.LineEdit.Prompt})(::Base.LineEdit.MIState, ::Base.AbstractIOBuffer{Array{UInt8,1}}, ::Bool) at ./REPL.jl:646

I can of course fix this with:

DiffEqBase.interp_summary(::OrdinaryDiffEq.InterpolationData{LorenzExample}) = "42"

I would have thought that the interpolation of the LorenzExample would automatically be a subtype ofAbstractDiffEqInterpolation, but I find the following:

julia> OrdinaryDiffEq.InterpolationData{LorenzExample} <: AbstractDiffEqInterpolation
false

Maybe something has gone wrong on my laptop, so I will check on my work computer in the morning. As for version info et al, we have:

julia> versioninfo()
Julia Version 0.6.0
Commit 903644385b (2017-06-19 13:05 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin13.4.0)
  CPU: Intel(R) Core(TM) i7-3720QM CPU @ 2.60GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Sandybridge)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.9.1 (ORCJIT, ivybridge)

julia> Pkg.status("DifferentialEquations")
 - DifferentialEquations         2.2.1

And I am on OSX El Capitan, thanks in advance for any help and sorry in advance if I missed something really obvious. 😃

ChrisRackauckas commented 7 years ago

What's Pkg.status("OrdinaryDiffEq")?

JackDevine commented 7 years ago
julia> Pkg.status("OrdinaryDiffEq")
 - OrdinaryDiffEq                2.4.0
ChrisRackauckas commented 7 years ago

That's a few months back. If you Pkg.update() does it not update?

Note this is just an error with the display and doesn't affect anything else.

JackDevine commented 7 years ago
julia> Pkg.update()
INFO: Updating METADATA...
INFO: Computing changes...
INFO: No packages to install, update or remove
JackDevine commented 7 years ago

Ok, so something is probably wrong with my package manager. Sorry for the inconvenience.

ChrisRackauckas commented 7 years ago

It's odd it won't update though.

Do you have ReverseDiff.jl? That has an upper bound on ForwardDiff.jl which would hold it back and hold all of your other packages back I think.

JackDevine commented 7 years ago

No, but I do have ReverseDiffSparse

ChrisRackauckas commented 7 years ago

If you Pkg.pin("OrdinaryDiffEq",v"2.10.0") I think it'll tell you what version bounds aren't satisfied.

JackDevine commented 7 years ago
julia> Pkg.pin("OrdinaryDiffEq",v"2.10.0")
INFO: Creating OrdinaryDiffEq branch pinned.5750bb00.tmp
ERROR: Unsatisfiable requirements detected for package ForwardDiff:
├─version range [0.0.0-,∞) set by an explicit requirement
├─version range [0.5.0,∞) required by package OrdinaryDiffEq, whose only allowed version is 2.10.0:
│ └─version 2.10.0 set by fixed requirement (package is checked out, dirty or pinned)
└─version range [0.1.0,0.5.0) required by package JuMP, whose allowed version range is [0.0.0-,∞):
  └─version range [0.0.0-,∞) set by an explicit requirement
The intersection of the requirements is empty.
Stacktrace:
 [1] filter_versions(::Dict{String,Base.Pkg.Types.VersionSet}, ::Dict{String,Dict{VersionNumber,Base.Pkg.Types.Available}}, ::Dict{AbstractString,Base.Pkg.Types.ResolveBacktraceItem}) at ./pkg/query.jl:299
 [2] prune_versions(::Dict{String,Base.Pkg.Types.VersionSet}, ::Dict{String,Dict{VersionNumber,Base.Pkg.Types.Available}}, ::Dict{AbstractString,Base.Pkg.Types.ResolveBacktraceItem}) at ./pkg/query.jl:328
 [3] prune_dependencies(::Dict{String,Base.Pkg.Types.VersionSet}, ::Dict{String,Dict{VersionNumber,Base.Pkg.Types.Available}}, ::Dict{AbstractString,Base.Pkg.Types.ResolveBacktraceItem}) at ./pkg/query.jl:546
 [4] resolve(::Dict{String,Base.Pkg.Types.VersionSet}, ::Dict{String,Dict{VersionNumber,Base.Pkg.Types.Available}}, ::Dict{String,Tuple{VersionNumber,Bool}}, ::Dict{String,Base.Pkg.Types.Fixed}, ::Dict{String,VersionNumber}, ::Set{String}) at ./pkg/entry.jl:498
 [5] resolve(::Dict{String,Base.Pkg.Types.VersionSet}, ::Dict{String,Dict{VersionNumber,Base.Pkg.Types.Available}}, ::Dict{String,Tuple{VersionNumber,Bool}}, ::Dict{String,Base.Pkg.Types.Fixed}) at ./pkg/entry.jl:479
 [6] pin(::String, ::String) at ./pkg/entry.jl:338
 [7] pin(::String, ::VersionNumber) at ./pkg/entry.jl:349
 [8] (::Base.Pkg.Dir.##4#7{Array{Any,1},Base.Pkg.Entry.#pin,Tuple{String,VersionNumber}})() at ./pkg/dir.jl:36
 [9] cd(::Base.Pkg.Dir.##4#7{Array{Any,1},Base.Pkg.Entry.#pin,Tuple{String,VersionNumber}}, ::String) at ./file.jl:70
 [10] #cd#1(::Array{Any,1}, ::Function, ::Function, ::String, ::Vararg{Any,N} where N) at ./pkg/dir.jl:36
 [11] pin(::String, ::VersionNumber) at ./pkg/pkg.jl:216

I also tried

julia> Pkg.checkout("OrdinaryDiffEq")
INFO: Checking out OrdinaryDiffEq master...
INFO: Pulling OrdinaryDiffEq latest master...
ERROR: Unsatisfiable requirements detected for package ForwardDiff:
├─version range [0.0.0-,∞) set by an explicit requirement
├─version range [0.5.0,∞) required by package OrdinaryDiffEq, whose only allowed version is 2.10.0+:
│ └─version 2.10.0+ set by fixed requirement (package is checked out, dirty or pinned)
└─version range [0.1.0,0.5.0) required by package JuMP, whose allowed version range is [0.0.0-,∞):
  └─version range [0.0.0-,∞) set by an explicit requirement
The intersection of the requirements is empty.
Stacktrace:
 [1] filter_versions(::Dict{String,Base.Pkg.Types.VersionSet}, ::Dict{String,Dict{VersionNumber,Base.Pkg.Types.Available}}, ::Dict{AbstractString,Base.Pkg.Types.ResolveBacktraceItem}) at ./pkg/query.jl:299
 [2] prune_versions(::Dict{String,Base.Pkg.Types.VersionSet}, ::Dict{String,Dict{VersionNumber,Base.Pkg.Types.Available}}, ::Dict{AbstractString,Base.Pkg.Types.ResolveBacktraceItem}) at ./pkg/query.jl:328
 [3] prune_dependencies(::Dict{String,Base.Pkg.Types.VersionSet}, ::Dict{String,Dict{VersionNumber,Base.Pkg.Types.Available}}, ::Dict{AbstractString,Base.Pkg.Types.ResolveBacktraceItem}) at ./pkg/query.jl:546
 [4] resolve(::Dict{String,Base.Pkg.Types.VersionSet}, ::Dict{String,Dict{VersionNumber,Base.Pkg.Types.Available}}, ::Dict{String,Tuple{VersionNumber,Bool}}, ::Dict{String,Base.Pkg.Types.Fixed}, ::Dict{String,VersionNumber}, ::Set{String}) at ./pkg/entry.jl:498
 [5] resolve(::Dict{String,Base.Pkg.Types.VersionSet}, ::Dict{String,Dict{VersionNumber,Base.Pkg.Types.Available}}, ::Dict{String,Tuple{VersionNumber,Bool}}, ::Dict{String,Base.Pkg.Types.Fixed}) at ./pkg/entry.jl:479
 [6] (::Base.Pkg.Entry.##16#18{String,String,Bool,Bool})(::Base.LibGit2.GitRepo) at ./pkg/entry.jl:236
 [7] transact(::Base.Pkg.Entry.##16#18{String,String,Bool,Bool}, ::Base.LibGit2.GitRepo) at ./libgit2/libgit2.jl:882
 [8] with(::Base.Pkg.Entry.##15#17{String,String,Bool,Bool}, ::Base.LibGit2.GitRepo) at ./libgit2/types.jl:608
 [9] checkout(::String, ::String, ::Bool, ::Bool) at ./pkg/entry.jl:226
 [10] (::Base.Pkg.Dir.##4#7{Array{Any,1},Base.Pkg.Entry.#checkout,Tuple{String,String,Bool,Bool}})() at ./pkg/dir.jl:36
 [11] cd(::Base.Pkg.Dir.##4#7{Array{Any,1},Base.Pkg.Entry.#checkout,Tuple{String,String,Bool,Bool}}, ::String) at ./file.jl:70
 [12] #cd#1(::Array{Any,1}, ::Function, ::Function, ::String, ::Vararg{Any,N} where N) at ./pkg/dir.jl:36
 [13] #checkout#1(::Bool, ::Bool, ::Function, ::String, ::String) at ./pkg/pkg.jl:188
 [14] checkout(::String) at ./pkg/pkg.jl:188
ChrisRackauckas commented 7 years ago

https://github.com/JuliaOpt/JuMP.jl/blob/master/REQUIRE#L4

JuMP has a version bound on ForwardDiff v0.5 which drops you to the last OrdinaryDiffEq.jl release compatible with that. There's no a fix I can really do there except tell them to upgrade haha.

But I will note again that all that's broken there is that the solution object's print method is broken since the fix is in v2.5.0. So the examples and plots should work just fine, though it might be a little annoying.

JackDevine commented 7 years ago

You are a wizard.

Thanks for all of your help, I had no idea that I was not on the latest version of OrdinaryDiffEq.jl. Hopefully this can all get resolved soon. 😃

JackDevine commented 7 years ago

Like you say, this is just a problem with the print method and I can still get on with things. Also, since this is not really a DifferentialEquations problem I am happy for you to close this if you like.

ChrisRackauckas commented 7 years ago

Let me know if you need anything else.