Skip to content
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

anyeltypedual(::Type{Union{}}) is ambiguous #1003

Closed
daviehh opened this issue Feb 12, 2024 · 1 comment · Fixed by #1004
Closed

anyeltypedual(::Type{Union{}}) is ambiguous #1003

daviehh opened this issue Feb 12, 2024 · 1 comment · Fixed by #1004
Labels

Comments

@daviehh
Copy link
Contributor

daviehh commented Feb 12, 2024

Describe the bug 🐞
Regression: 6.146.0 works fine, v6.146.1 errors:

When the parameter p of ode solver contains the soltion to another ode, with the #999 it now errors w/

anyeltypedual(::Type{Union{}}) is ambiguous

Expected behavior

Allow p to contain ode solutions

Minimal Reproducible Example 👇

using OrdinaryDiffEq

f(u,p,t) = 1.01*u
u0=1/2
tspan = (0.0,1.0)
prob = ODEProblem(f,u0,tspan)
sol = solve(prob,Tsit5(),reltol=1e-8,abstol=1e-8)

OrdinaryDiffEq.DiffEqBase.anyeltypedual((;x=sol))

Error & Stacktrace ⚠️

ERROR: MethodError: anyeltypedual(::Type{Union{}}) is ambiguous.

Candidates:
  anyeltypedual(::Type{T}) where T<:ForwardDiff.Dual
    @ DiffEqBase ~/.julia/packages/DiffEqBase/UoaYd/src/forwarddiff.jl:130
  anyeltypedual(::Type{T}) where T<:(Tuple{Vararg{T, N}} where {N, T})
    @ DiffEqBase ~/.julia/packages/DiffEqBase/UoaYd/src/forwarddiff.jl:144
  anyeltypedual(x::Type{T}) where T<:ForwardDiff.AbstractConfig
    @ DiffEqBase ~/.julia/packages/DiffEqBase/UoaYd/src/forwarddiff.jl:117
  anyeltypedual(::Type{T}) where T<:Union{Set, AbstractArray}
    @ DiffEqBase ~/.julia/packages/DiffEqBase/UoaYd/src/forwarddiff.jl:131

Possible fix, define
  anyeltypedual(::Type{Union{}})

Stacktrace:
  [1] (::Base.MappingRF{typeof(DiffEqBase.anyeltypedual), Base.BottomRF{typeof(DiffEqBase.promote_dual)}})(acc::Type, x::Type)
    @ Base ./reduce.jl:100
  [2] _foldl_impl(op::Base.MappingRF{typeof(DiffEqBase.anyeltypedual), Base.BottomRF{typeof(DiffEqBase.promote_dual)}}, init::Type, itr::Core.SimpleVector)
    @ Base ./reduce.jl:62
  [3] foldl_impl
    @ Base ./reduce.jl:48 [inlined]
  [4] mapfoldl_impl
    @ Base ./reduce.jl:44 [inlined]
  [5] mapfoldl
    @ Base ./reduce.jl:175 [inlined]
  [6] mapreduce
    @ Base ./reduce.jl:307 [inlined]
  [7] __anyeltypedual(::Type{@Kwargs{}})
    @ DiffEqBase ~/.julia/packages/DiffEqBase/UoaYd/src/forwarddiff.jl:126
  [8] anyeltypedual(::Type{@Kwargs{}}, ::Type{Val{0}})
    @ DiffEqBase ~/.julia/packages/DiffEqBase/UoaYd/src/forwarddiff.jl:129
  [9] anyeltypedual(::Type{@Kwargs{}})
    @ DiffEqBase ~/.julia/packages/DiffEqBase/UoaYd/src/forwarddiff.jl:129
 [10] (::Base.MappingRF{typeof(DiffEqBase.anyeltypedual), Base.BottomRF{typeof(DiffEqBase.promote_dual)}})(acc::Type, x::Type)
    @ Base ./reduce.jl:100
 [11] _foldl_impl(op::Base.MappingRF{typeof(DiffEqBase.anyeltypedual), Base.BottomRF{typeof(DiffEqBase.promote_dual)}}, init::Type, itr::Core.SimpleVector)
    @ Base ./reduce.jl:62
 [12] foldl_impl
    @ Base ./reduce.jl:48 [inlined]
 [13] mapfoldl_impl
    @ Base ./reduce.jl:44 [inlined]
 [14] mapfoldl
    @ Base ./reduce.jl:175 [inlined]
 [15] mapreduce
    @ Base ./reduce.jl:307 [inlined]
 [16] __anyeltypedual(::Type{ODEProblem{Float64, Tuple{…}, false, SciMLBase.NullParameters, ODEFunction{…}, @Kwargs{}, SciMLBase.StandardODEProblem}})
    @ DiffEqBase ~/.julia/packages/DiffEqBase/UoaYd/src/forwarddiff.jl:126
 [17] anyeltypedual(::Type{ODEProblem{Float64, Tuple{…}, false, SciMLBase.NullParameters, ODEFunction{…}, @Kwargs{}, SciMLBase.StandardODEProblem}}, ::Type{Val{1}})
    @ DiffEqBase ~/.julia/packages/DiffEqBase/UoaYd/src/forwarddiff.jl:129
 [18] (::DiffEqBase.var"#69#70"{Int64})(x::Type)
    @ DiffEqBase ~/.julia/packages/DiffEqBase/UoaYd/src/forwarddiff.jl:102
 [19] (::Base.MappingRF{DiffEqBase.var"#69#70"{Int64}, Base.BottomRF{typeof(DiffEqBase.promote_dual)}})(acc::Type, x::Type)
    @ Base ./reduce.jl:100
 [20] _foldl_impl(op::Base.MappingRF{DiffEqBase.var"#69#70"{Int64}, Base.BottomRF{typeof(DiffEqBase.promote_dual)}}, init::Type, itr::Core.SimpleVector)
    @ Base ./reduce.jl:62
 [21] foldl_impl
    @ Base ./reduce.jl:48 [inlined]
 [22] mapfoldl_impl
    @ Base ./reduce.jl:44 [inlined]
 [23] mapfoldl
    @ Base ./reduce.jl:175 [inlined]
 [24] mapreduce
    @ Base ./reduce.jl:307 [inlined]
 [25] diffeqmapreduce(f::DiffEqBase.var"#69#70"{Int64}, op::typeof(DiffEqBase.promote_dual), x::Core.SimpleVector)
    @ DiffEqBase ~/.julia/packages/DiffEqBase/UoaYd/src/forwarddiff.jl:55
 [26] #s87#68
    @ ~/.julia/packages/DiffEqBase/UoaYd/src/forwarddiff.jl:102 [inlined]
 [27] var"#s87#68"(counter::Any, ::Any, x::Any, ::Any)
    @ DiffEqBase ./none:0
 [28] (::Core.GeneratedFunctionStub)(::UInt64, ::LineNumberNode, ::Any, ::Vararg{Any})
    @ Core ./boot.jl:602
 [29] anyeltypedual
    @ DiffEqBase ~/.julia/packages/DiffEqBase/UoaYd/src/forwarddiff.jl:95 [inlined]
 [30] map
    @ Base ./tuple.jl:291 [inlined]
 [31] diffeqmapreduce
    @ DiffEqBase ~/.julia/packages/DiffEqBase/UoaYd/src/forwarddiff.jl:50 [inlined]
 [32] anyeltypedual
    @ DiffEqBase ~/.julia/packages/DiffEqBase/UoaYd/src/forwarddiff.jl:210 [inlined]
 [33] anyeltypedual(x::@NamedTuple{x::ODESolution{Float64, 1, Vector{…}, Nothing, Nothing, Vector{…}, Vector{…}, ODEProblem{…}, Tsit5{…}, OrdinaryDiffEq.InterpolationData{…}, SciMLBase.DEStats, Nothing}})
    @ DiffEqBase ~/.julia/packages/DiffEqBase/UoaYd/src/forwarddiff.jl:210
 [34] top-level scope
    @ REPL[7]:1
Some type information was truncated. Use `show(err)` to see complete types.

Environment (please complete the following information):

  • Output of using Pkg; Pkg.status()
[1dea7af3] OrdinaryDiffEq v6.70.1
  • Output of versioninfo()
Julia Version 1.10.0
Commit 3120989f39b (2023-12-25 18:01 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (arm64-apple-darwin22.4.0)
  CPU: 10 × Apple M1 Pro
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, apple-m1)
  Threads: 11 on 8 virtual cores

Additional context

Add any other context about the problem here.

@daviehh daviehh added the bug label Feb 12, 2024
@daviehh
Copy link
Contributor Author

daviehh commented Feb 13, 2024

also, mwe with ode.jl only:

using OrdinaryDiffEq

f(u,p,t) = 1.01*u
u0=1/2
tspan = (0.0,1.0)
prob = ODEProblem(f,u0,tspan)
sol = solve(prob,Tsit5(),reltol=1e-8,abstol=1e-8)

prob2 = ODEProblem((du,u,p,t) -> du[1]=1, [0.0], (0,10), (;x=sol))
solve(prob2, Tsit5())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant