SciML / NonlinearSolve.jl

High-performance and differentiation-enabled nonlinear solvers (Newton methods), bracketed rootfinding (bisection, Falsi), with sparsity and Newton-Krylov support.
https://docs.sciml.ai/NonlinearSolve/stable/
MIT License
216 stars 39 forks source link

`step!` on `init(NonlinearProblem(...)` with `NonlinearSolvePolyAlgorithmCache` shows method error #363

Closed jamblejoe closed 4 months ago

jamblejoe commented 5 months ago

No method error for step! on init(NonlinearProblem(...) with NonlinearSolvePolyAlgorithmCache.

Minimal Reproducible Example 👇

From README:

f(u, p) = u .* u .- 2
u0 = @SVector[1.0, 1.0]
prob = NonlinearProblem(f, u0)
nlcache = init(prob);
step!(nlcache)

Error & Stacktrace ⚠️

ERROR: MethodError: no method matching __step!(::NonlinearSolve.NonlinearSolvePolyAlgorithmCache{false, 7, Tuple{…}, NonlinearSolvePolyAlgorithm{…}})

Closest candidates are:
  __step!(::NonlinearSolve.GeneralizedDFSaneCache{iip}; recompute_jacobian, kwargs...) where iip
   @ NonlinearSolve ~/.julia/packages/NonlinearSolve/UPIol/src/core/spectral_methods.jl:157
  __step!(::NonlinearSolve.GeneralizedFirstOrderAlgorithmCache{iip, GB}; recompute_jacobian, kwargs...) where {iip, GB}
   @ NonlinearSolve ~/.julia/packages/NonlinearSolve/UPIol/src/core/generalized_first_order.jl:203
  __step!(::NonlinearSolve.ApproximateJacobianSolveCache{INV, GB, iip}; recompute_jacobian) where {INV, GB, iip}
   @ NonlinearSolve ~/.julia/packages/NonlinearSolve/UPIol/src/core/approximate_jacobian.jl:220

Stacktrace:
 [1] step!(::NonlinearSolve.NonlinearSolvePolyAlgorithmCache{…}; kwargs::@Kwargs{})
   @ NonlinearSolve ~/.julia/packages/NonlinearSolve/UPIol/src/core/generic.jl:52
 [2] step!(::NonlinearSolve.NonlinearSolvePolyAlgorithmCache{false, 7, Tuple{…}, NonlinearSolvePolyAlgorithm{…}})
   @ NonlinearSolve ~/.julia/packages/NonlinearSolve/UPIol/src/core/generic.jl:48
 [3] top-level scope
   @ REPL[85]:1
Some type information was truncated. Use `show(err)` to see complete types.

Environment (please complete the following information):

  [8913a72c] NonlinearSolve v3.5.3 `https://github.com/SciML/NonlinearSolve.jl.git#master`
julia> 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: 8 × Apple M1
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, apple-m1)
  Threads: 1 on 4 virtual cores
avik-pal commented 5 months ago

This one is kind of expected because it was not clear to me what a single step of a polyalgorithm means.

  1. Is it single step of the current algorithm?
  2. Is it a single step of all the algorithms?

Based on how solve works it should be the former but i was not too confident about this.

cc @ChrisRackauckas

ChrisRackauckas commented 5 months ago

Single step of the current algorithm I think makes the most sense.