SciML / SciMLBase.jl

The Base interface of the SciML ecosystem
https://docs.sciml.ai/SciMLBase/stable
MIT License
129 stars 95 forks source link

ERROR: MethodError: no method matching (ODEProblem{false, SciMLBase.FullSpecialize})(::ODEFunction{false, SciMLBase.FullSpecialize, var"#9#10", ...}, ::Vector{Float64}, ::Tuple{Float64, Float64}, ::Vector{Float64}, ::Tsit5{...}) #482

Open prbzrg opened 1 year ago

prbzrg commented 1 year ago

I think it must work, Am I missing something?

julia> fode = ODEFunction((u,p,t) -> identity(u))
(::ODEFunction{false, SciMLBase.FullSpecialize, var"#9#10", LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing}) (generic function with 1 method)

julia> ODEProblem{false, SciMLBase.FullSpecialize}(fode, ones(1), (0.0, 1.0), ones(1), Tsit5())
ERROR: MethodError: no method matching (ODEProblem{false, SciMLBase.FullSpecialize})(::ODEFunction{false, SciMLBase.FullSpecialize, var"#9#10", LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing}, ::Vector{Float64}, ::Tuple{Float64, Float64}, ::Vector{Float64}, ::Tsit5{typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False})

Closest candidates are:
  (ODEProblem{iip, recompile})(::Any, ::Any, ::Any, ::Any; kwargs...) where {iip, recompile}
   @ SciMLBase C:\Users\Hossein Pourbozorg\.julia\packages\SciMLBase\kTUaf\src\problems\ode_problems.jl:141
  (ODEProblem{iip, recompile})(::Any, ::Any, ::Any) where {iip, recompile}
   @ SciMLBase C:\Users\Hossein Pourbozorg\.julia\packages\SciMLBase\kTUaf\src\problems\ode_problems.jl:141

Stacktrace:
 [1] top-level scope
   @ REPL[42]:1
ErikQQY commented 1 year ago

To construct an ODEProblem, we use prob = ODEProblem(fun::ODEFunction, u0, tspan, p), the ODE solver Tsit5() should be called when we want to solve this ODEProblem.

For detailed usage, please refer to https://docs.sciml.ai/DiffEqDocs/stable/getting_started/

prbzrg commented 1 year ago

but

ODEProblem{false}(fode, ones(1), (0.0, 1.0), ones(1), Tsit5())

and

ODEProblem(fode, ones(1), (0.0, 1.0), ones(1), Tsit5())

both work.

ErikQQY commented 1 year ago

but

ODEProblem{false}(fode, ones(1), (0.0, 1.0), ones(1), Tsit5())

and

ODEProblem(fode, ones(1), (0.0, 1.0), ones(1), Tsit5())

Yeah, but I think both of them are incorrect usages, you can use this:

julia> ODEProblem{false, SciMLBase.FullSpecialize}(fode, ones(1), (0.0, 1.0), ones(1))
ODEProblem with uType Vector{Float64} and tType Float64. In-place: false
timespan: (0.0, 1.0)
u0: 1-element Vector{Float64}:
 1.0
prbzrg commented 1 year ago

Alright, should we add a warning to them? So it would be clear that solver should be given to solve function, not the problem definition.

ChrisRackauckas commented 1 year ago

I mean, if you want to add it sure. I would be surprised if anyone attempts this: this has never been the documented syntax.

prbzrg commented 1 year ago

Oh, it's a bug:

julia> pb = ODEProblem(fode, ones(1), (0.0, 1.0), ones(1), Tsit5())
ODEProblem with uType Vector{Float64} and tType Float64. In-place: false
timespan: (0.0, 1.0)
u0: 1-element Vector{Float64}:
 1.0

julia> pb.problem_type
Tsit5(; stage_limiter! = trivial_limiter!, step_limiter! = trivial_limiter!, thread = static(false),)

julia> pb2 = ODEProblem{false}(fode, ones(1), (0.0, 1.0), ones(1), Tsit5())
ODEProblem with uType Vector{Float64} and tType Float64. In-place: false
timespan: (0.0, 1.0)
u0: 1-element Vector{Float64}:
 1.0

julia> pb2.problem_type
Tsit5(; stage_limiter! = trivial_limiter!, step_limiter! = trivial_limiter!, thread = static(false),)
prbzrg commented 9 months ago

Accepting solver as problem type is definitely a bug that must be fixed. How can I help?