JuliaNLSolvers / NLsolve.jl

Julia solvers for systems of nonlinear equations and mixed complementarity problems

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Newton still uses `eye`

arnavs opened this issue · comments

Get the LoadError: UndefVarError: eye not defined error when I use method = :newton. This is on the latest tagged release (v2.1.0). See below for some of the error message:

Full Dynamic: Error During Test at /Users/arnavsood/.julia/dev/PerlaTonettiWaugh/test/runtests.jl:9
  Got exception outside of a @test
  LoadError: UndefVarError: eye not defined
  Stacktrace:
   [1] newton_(::OnceDifferentiable{Array{Float64,1},Array{Float64,2},Array{Float64,1}}, ::Array{Float64,1}, ::Float64, ::Float64, ::Int64, ::Bool, ::Bool, ::Bool, ::Static, ::NLsolve.NewtonCache{Array{Float64,1}}) at /Users/arnavsood/.julia/packages/NLsolve/2p0rf/src/solvers/newton.jl:108
   [2] newton_(::OnceDifferentiable{Array{Float64,1},Array{Float64,2},Array{Float64,1}}, ::Array{Float64,1}, ::Float64, ::Float64, ::Int64, ::Bool, ::Bool, ::Bool, ::Static) at /Users/arnavsood/.julia/packages/NLsolve/2p0rf/src/solvers/newton.jl:54
   [3] newton at /Users/arnavsood/.julia/packages/NLsolve/2p0rf/src/solvers/newton.jl:142 [inlined] (repeats 2 times)
   [4] #nlsolve#14(::Symbol, ::Float64, ::Float64, ::Int64, ::Bool, ::Bool, ::Bool, ::Static, ::Float64, ::Bool, ::Int64, ::Float64, ::typeof(nlsolve), ::OnceDifferentiable{Array{Float64,1},Array{Float64,2},Array{Float64,1}}, ::Array{Float64,1}) at /Users/arnavsood/.julia/packages/NLsolve/2p0rf/src/nlsolve/nlsolve.jl:20
   [5] (::getfield(NLsolve, Symbol("#kw##nlsolve")))(::NamedTuple{(:method, :xtol, :ftol, :iterations, :store_trace, :show_trace, :extended_trace, :linesearch, :factor, :autoscale, :m, :beta),Tuple{Symbol,Float64,Float64,Int64,Bool,Bool,Bool,Static,Float64,Bool,Int64,Float64}}, ::typeof(nlsolve), ::OnceDifferentiable{Array{Float64,1},Array{Float64,2},Array{Float64,1}}, ::Array{Float64,1}) at ./none:0
   [6] #nlsolve#15(::Symbol, ::Float64, ::Float64, ::Int64, ::Bool, ::Bool, ::Bool, ::Static, ::Float64, ::Bool, ::Int64, ::Float64, ::Symbol, ::Bool, ::typeof(nlsolve), ::getfield(PerlaTonettiWaugh, Symbol("#stationary_numerical_given_vals#19")){Float64,Int64,Float64,Int64,Float64,Float64,Int64}, ::Array{Float64,1}) at /Users/arnavsood/.julia/packages/NLsolve/2p0rf/src/nlsolve/nlsolve.jl:60
   [7] #nlsolve at ./none:0 [inlined]
   [8] #stationary_numerical#13(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::NamedTuple{(:ρ, :σ, :N, :θ, :γ, :κ, :ζ, :η, :Theta, :χ, :υ, :μ, :δ, :d),Tuple{Float64,Float64,Int64,Float64,Float64,Float64,Int64,Int64,Int64,Float64,Float64,Int64,Float64,Int64}}, ::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::Array{Float64,1}) at /Users/arnavsood/.julia/dev/PerlaTonettiWaugh/src/full/stationary.jl:82

That's not good :) but as discussed with @antoine-levitt earlier, that whole catch should probably just be an error. You're in singular jacobian territory here if I'm not remembering wrong. Are you sure you're problem is wellbehaved in the region x has wandered off into?

@pkofod Almost certainly not well-behaved. But yeah, this issue was less about getting Newton to work for this problem, than that something inside is using that function.

Yes, that's a problem. I'm only saying it, because that "handling" of the error is potentially extremely expensive and you might want to fix your problem instead of "using" the code in that branch. If the Jacobian is sparse this will make it dense, and then you might instantly run out of ram anyway!

However, eye should certainly go, thanks for the report.

Gotcha, that makes sense. Thanks for the tip.