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

AssertionError: isfinite(phi_c) && isfinite(dphi_c) #157

Open
ErikLW opened this issue Mar 4, 2022 · 3 comments
Open

AssertionError: isfinite(phi_c) && isfinite(dphi_c) #157

ErikLW opened this issue Mar 4, 2022 · 3 comments

Comments

@ErikLW
Copy link

ErikLW commented Mar 4, 2022

Hi,
I have seen, that this issue has come up before, but since this was some time ago I thought it might be helpful to start another issue:
I am optimizing a function using the Optim package with uses LineSearch.jl for the line search. Can you explain to me how I should interpret the following error and what I could do to avoid it?
Thanks in advance

AssertionError: isfinite(phi_c) && isfinite(dphi_c)

Stacktrace:
  [1] secant2!(ϕdϕ::LineSearches.var"#ϕdϕ#6"{Optim.ManifoldObjective{OnceDifferentiable{Float64, Array{Float64, 5}, Array{Float64, 5}}}, Array{Float64, 5}, Array{Float64, 5}, Array{Float64, 5}}, alphas::Vector{Float64}, values::Vector{Float64}, slopes::Vector{Float64}, ia::Int64, ib::Int64, phi_lim::Float64, delta::Float64, sigma::Float64, display::Int64)
    @ LineSearches C:\Users\weerd\.julia\packages\LineSearches\Ki4c5\src\hagerzhang.jl:369
  [2] (::HagerZhang{Float64, Base.RefValue{Bool}})(ϕ::Function, ϕdϕ::LineSearches.var"#ϕdϕ#6"{Optim.ManifoldObjective{OnceDifferentiable{Float64, Array{Float64, 5}, Array{Float64, 5}}}, Array{Float64, 5}, Array{Float64, 5}, Array{Float64, 5}}, c::Float64, phi_0::Float64, dphi_0::Float64)
    @ LineSearches C:\Users\weerd\.julia\packages\LineSearches\Ki4c5\src\hagerzhang.jl:269
  [3] HagerZhang
    @ C:\Users\weerd\.julia\packages\LineSearches\Ki4c5\src\hagerzhang.jl:101 [inlined]
  [4] perform_linesearch!(state::Optim.LBFGSState{Array{Float64, 5}, Vector{Array{Float64, 5}}, Vector{Array{Float64, 5}}, Float64, Array{Float64, 5}}, method::LBFGS{Nothing, InitialStatic{Float64}, HagerZhang{Float64, Base.RefValue{Bool}}, Optim.var"#20#22"}, d::Optim.ManifoldObjective{OnceDifferentiable{Float64, Array{Float64, 5}, Array{Float64, 5}}})
    @ Optim C:\Users\weerd\.julia\packages\Optim\LScFu\src\utilities\perform_linesearch.jl:59
  [5] update_state!(d::OnceDifferentiable{Float64, Array{Float64, 5}, Array{Float64, 5}}, state::Optim.LBFGSState{Array{Float64, 5}, Vector{Array{Float64, 5}}, Vector{Array{Float64, 5}}, Float64, Array{Float64, 5}}, method::LBFGS{Nothing, InitialStatic{Float64}, HagerZhang{Float64, Base.RefValue{Bool}}, Optim.var"#20#22"})
    @ Optim C:\Users\weerd\.julia\packages\Optim\LScFu\src\multivariate\solvers\first_order\l_bfgs.jl:204
  [6] optimize(d::OnceDifferentiable{Float64, Array{Float64, 5}, Array{Float64, 5}}, initial_x::Array{Float64, 5}, method::LBFGS{Nothing, InitialStatic{Float64}, HagerZhang{Float64, Base.RefValue{Bool}}, Optim.var"#20#22"}, options::Optim.Options{Float64, Nothing}, state::Optim.LBFGSState{Array{Float64, 5}, Vector{Array{Float64, 5}}, Vector{Array{Float64, 5}}, Float64, Array{Float64, 5}})
    @ Optim C:\Users\weerd\.julia\packages\Optim\LScFu\src\multivariate\optimize\optimize.jl:54
  [7] optimize
    @ C:\Users\weerd\.julia\packages\Optim\LScFu\src\multivariate\optimize\optimize.jl:36 [inlined]
  [8] optimize(f::Function, g::Function, initial_x::Array{Float64, 5}, method::LBFGS{Nothing, InitialStatic{Float64}, HagerZhang{Float64, Base.RefValue{Bool}}, Optim.var"#20#22"}, options::Optim.Options{Float64, Nothing}; inplace::Bool, autodiff::Symbol)
    @ Optim C:\Users\weerd\.julia\packages\Optim\LScFu\src\multivariate\optimize\interface.jl:155
@jbrea
Copy link

jbrea commented May 4, 2024

I'm facing the same issue. Any ideas what is causing this?

@timholy
Copy link
Contributor

timholy commented Jul 30, 2024

Once #177 merges you should be able to gain more insight. But in general terms, your objective function seems to be returning non-finite values or derivatives. (@assert means "the following is supposed to be true," and if you get an AssertionError it means that it was not true.)

@pkofod
Copy link
Member

pkofod commented Aug 5, 2024

It's merged and you can use it on master. I will try to put out a new version soon.

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

No branches or pull requests

4 participants