SciML / SciMLBase.jl

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

Error: IntervalNonlinearProblem has no field u0 #726

Closed nathanrboyer closed 1 day ago

nathanrboyer commented 4 days ago

Describe the example

I am trying to solve a series of simple IntervalNonlinearProblems where the parameters change. This used to work, but I cannot seem to get back to an environment where it works now. I followed the tutorials and got an implementation working previously, but that same code no longer works even if I pin SimpleNonlinearSolve to an older version. 😕

Minimal Reproducible Example 👇

Unable to change the parameters of the problem with remake. I don't remember the output from IntervalNonlinearProblem about uType being there before; that seems weird.

using SimpleNonlinearSolve
f(u, p) = u * u - 2.0 + p[1]
uspan = (1.0, 2.0)
prob_int = IntervalNonlinearProblem(f, uspan)  # "IntervalNonlinearProblem with uType nothing. In-place: false"
problem = remake(prob_int, p=[0])  # error here
solution = solve(problem)  # didn't make it this far

Error & Stacktrace ⚠️

ERROR: type IntervalNonlinearProblem has no field u0
Stacktrace:
 [1] getproperty
   @ C:\Users\nboyer.AIP\.julia\packages\SciMLBase\sakPO\src\problems\problem_interface.jl:5 [inlined]
 [2] state_values(prob::IntervalNonlinearProblem{…})
   @ SciMLBase C:\Users\nboyer.AIP\.julia\packages\SciMLBase\sakPO\src\problems\problem_interface.jl:19
 [3] updated_u0_p(prob::IntervalNonlinearProblem{…}, u0::Missing, p::Vector{…}; interpret_symbolicmap::Bool, use_defaults::Bool)
   @ SciMLBase C:\Users\nboyer.AIP\.julia\packages\SciMLBase\sakPO\src\remake.jl:548
 [4] remake(prob::IntervalNonlinearProblem{…}; u0::Missing, p::Vector{…}, interpret_symbolicmap::Bool, use_defaults::Bool, kwargs::@Kwargs{})
   @ SciMLBase C:\Users\nboyer.AIP\.julia\packages\SciMLBase\sakPO\src\remake.jl:62
 [5] top-level scope
   @ REPL[23]:1
 [6] top-level scope
   @ none:1
Some type information was truncated. Use `show(err)` to see complete types.

Not Working Environment (please complete the following information):

(Downloads) pkg> st
Status `C:\Users\nboyer.AIP\Downloads\Project.toml`
⌃ [727e6d20] SimpleNonlinearSolve v1.1.0
julia> Pkg.status(; mode = PKGMODE_MANIFEST)
Status `C:\Users\nboyer.AIP\Downloads\Manifest.toml`
⌅ [47edcb42] ADTypes v0.2.7
  [7d9f7c33] Accessors v0.1.36
  [79e6a3ab] Adapt v4.0.4
  [4fba245c] ArrayInterface v7.11.0
  [62783981] BitTwiddlingConvenienceFunctions v0.1.5
  [2a0fbf3d] CPUSummary v0.2.6
  [fb6a15b2] CloseOpenIntervals v0.1.12
  [38540f10] CommonSolve v0.2.4
  [bbf7d656] CommonSubexpressions v0.3.0
  [34da2185] Compat v4.15.0
  [a33af91c] CompositionsBase v0.1.2
  [2569d6c7] ConcreteStructs v0.2.3
  [187b0558] ConstructionBase v1.5.5
  [adafc99b] CpuId v0.3.1
  [9a962f9c] DataAPI v1.16.0
  [864edb3b] DataStructures v0.18.20
  [e2d170a0] DataValueInterfaces v1.0.0
  [2b5f629d] DiffEqBase v6.151.5
  [163ba53b] DiffResults v1.1.0
  [b552c78f] DiffRules v1.15.1
  [ffbed154] DocStringExtensions v0.9.3
  [4e289a0a] EnumX v1.0.4
  [f151be2c] EnzymeCore v0.7.6
  [e2ba6199] ExprTools v0.1.10
  [7034ab61] FastBroadcast v0.3.4
  [9aa1b823] FastClosures v0.3.2
  [6a86dc24] FiniteDiff v2.23.1
  [f6369f11] ForwardDiff v0.10.36
  [069b7b12] FunctionWrappers v1.1.3
  [77dc65aa] FunctionWrappersWrappers v0.1.3
  [46192b85] GPUArraysCore v0.1.6
  [615f187c] IfElse v0.1.1
  [3587e190] InverseFunctions v0.1.14
  [92d709cd] IrrationalConstants v0.2.2
  [82899510] IteratorInterfaceExtensions v1.0.0
  [692b3bcd] JLLWrappers v1.5.0
  [10f19ff3] LayoutPointers v0.1.17
  [2ab3a3ac] LogExpFunctions v0.3.28
  [1914dd2f] MacroTools v0.5.13
  [d125e4d3] ManualMemory v0.1.8
  [bb5d69b7] MaybeInplace v0.1.3
  [46d2c3a1] MuladdMacro v0.2.4
  [77ba4419] NaNMath v1.0.2
  [bac558e1] OrderedCollections v1.6.3
  [d96e819e] Parameters v0.12.3
  [f517fe37] Polyester v0.7.15
  [1d0040c9] PolyesterWeave v0.2.1
  [d236fae5] PreallocationTools v0.4.22
  [aea7be01] PrecompileTools v1.2.1
  [21216c6a] Preferences v1.4.3
  [3cdcf5f2] RecipesBase v1.3.4
⌃ [731186ca] RecursiveArrayTools v3.23.1
  [189a3867] Reexport v1.2.2
  [ae029012] Requires v1.3.0
  [7e49a35a] RuntimeGeneratedFunctions v0.5.13
  [94e857df] SIMDTypes v0.1.0
  [0bca4576] SciMLBase v2.41.3
  [c0aeaf25] SciMLOperators v0.3.8
  [53ae85a6] SciMLStructures v1.3.0
  [efcf1570] Setfield v1.1.1
⌃ [727e6d20] SimpleNonlinearSolve v1.1.0
  [276daf66] SpecialFunctions v2.4.0
⌅ [aedffcd0] Static v0.8.10
  [0d7ed370] StaticArrayInterface v1.5.1
  [1e83bf80] StaticArraysCore v1.4.3
  [10745b16] Statistics v1.11.1
  [7792a7ef] StrideArraysCore v0.5.6
  [2efcf032] SymbolicIndexingInterface v0.3.22
  [3783bdb8] TableTraits v1.0.1
  [bd369af6] Tables v1.11.1
  [8290d209] ThreadingUtilities v0.5.2
  [410a4b4d] Tricks v0.1.8
  [781d530d] TruncatedStacktraces v1.4.0
  [3a884ed6] UnPack v1.0.2
  [efe28fd5] OpenSpecFun_jll v0.5.5+0
  [0dad84c5] ArgTools v1.1.2
  [56f22d72] Artifacts v1.11.0
  [2a0f44e3] Base64 v1.11.0
  [ade2ca70] Dates v1.11.0
  [8ba89e20] Distributed v1.11.0
  [f43a241f] Downloads v1.6.0
  [7b1f6079] FileWatching v1.11.0
  [9fa8497b] Future v1.11.0
  [b77e0a4c] InteractiveUtils v1.11.0
  [b27032c2] LibCURL v0.6.4
  [76f85450] LibGit2 v1.11.0
  [8f399da3] Libdl v1.11.0
  [37e2e46d] LinearAlgebra v1.11.0
  [56ddb016] Logging v1.11.0
  [d6f4376e] Markdown v1.11.0
  [ca575930] NetworkOptions v1.2.0
  [44cfe95a] Pkg v1.11.0
  [de0858da] Printf v1.11.0
  [9a3f8284] Random v1.11.0
  [ea8e919c] SHA v0.7.0
  [9e88b42a] Serialization v1.11.0
  [6462fe0b] Sockets v1.11.0
  [2f01184e] SparseArrays v1.11.0
  [4607b0f0] SuiteSparse
  [fa267f1f] TOML v1.0.3
  [a4e569a6] Tar v1.10.0
  [8dfed614] Test v1.11.0
  [cf7118a7] UUIDs v1.11.0
  [4ec0a83e] Unicode v1.11.0
  [e66e0078] CompilerSupportLibraries_jll v1.1.1+0
  [deac9b47] LibCURL_jll v8.6.0+0
  [e37daf67] LibGit2_jll v1.7.2+0
  [29816b5a] LibSSH2_jll v1.11.0+1
  [c8ffd9c3] MbedTLS_jll v2.28.6+0
  [14a3606d] MozillaCACerts_jll v2023.12.12
  [4536629a] OpenBLAS_jll v0.3.27+1
  [05823500] OpenLibm_jll v0.8.1+2
  [bea87d4a] SuiteSparse_jll v7.6.0+0
  [83775a58] Zlib_jll v1.2.13+1
  [8e850b90] libblastrampoline_jll v5.8.0+1
  [8e850ede] nghttp2_jll v1.59.0+0
  [3f19e933] p7zip_jll v17.4.0+2
Info Packages marked with ⌃ and ⌅ have new versions available. Those with ⌃ may be upgradable, but those with ⌅ are restricted by compatibility constraints from upgrading. To see why use `status --outdated -m`
julia> versioninfo()
Julia Version 1.11.0-rc1
Commit 3a35aec36d (2024-06-25 10:23 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 8 × Intel(R) Core(TM) i7-9700 CPU @ 3.00GHz
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, skylake)
Threads: 1 default, 0 interactive, 1 GC (on 8 virtual cores)

Working Environment (please complete the following information):

I can't find one that works, but everything was working fine on the latest versions about 6 months ago. It must be a dependency that changed.

Additional context

Actual code:

function find_proportional_limit(table::DataFrame, searchrange::Tuple=(1e1, 1e6))
    @assert(
        (length(searchrange) == 2) && (typeof(first(searchrange)) == typeof(last(searchrange))),
        "`searchrange` must be a `Tuple{T,T} where T<:Number` (two elements of the same type)"
    )
    σ_p = Float64[]
    problem = IntervalNonlinearProblem(KM620.plasticity, searchrange)
    for row in eachrow(table)
        problem = remake(problem, p=row)
        solution = solve(problem)
        push!(σ_p, solution.u)
    end
    return σ_p
end

function plasticity(u, p)
    σ_t = u                                          # Solution Variable
    (; σ_ys, σ_uts, K, m_1, m_2, A_1, A_2, ϵ_p) = p  # Parameters
    H_value   = H(σ_t, σ_ys, σ_uts, K)               # KM-620.10
    ϵ_1_value = ϵ_1(σ_t, A_1, m_1)                   # KM-620.5
    ϵ_2_value = ϵ_2(σ_t, A_2, m_2)                   # KM-620.8
    γ_1_value = γ_1(ϵ_1_value, H_value)              # KM-620.3
    γ_2_value = γ_2(ϵ_2_value, H_value)              # KM-620.4
    return γ_1_value + γ_2_value - ϵ_p  # (<= 0)     # KM-620.2
end
ChrisRackauckas commented 4 days ago

@avik-pal do you know what happened to this default alg?

avik-pal commented 4 days ago

It seems to hit https://github.com/SciML/SciMLBase.jl/blob/c2fb81f79690ccee9358d432acfe746482835d93/src/problems/problem_interface.jl#L19, which probably needs to be caught earlier because unlike other SciMLProblems it does have a u0.

Probably @AayushSabharwal would know how to handle this?

avik-pal commented 4 days ago

⌃ [727e6d20] SimpleNonlinearSolve v1.1.0 -- This won't fix your problems but I would update to the latest version, SimpleNonlinearSolve has significantly improved since 1.1