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

Include searchdirection in OptimizationState #723

Open
goerz opened this issue Mar 26, 2024 · 2 comments
Open

Include searchdirection in OptimizationState #723

goerz opened this issue Mar 26, 2024 · 2 comments

Comments

@goerz
Copy link

goerz commented Mar 26, 2024

It would be convenient if OptimizationState included a searchdirection and/or a step width. I can usually pull these quantities out of the original state, but it would be nice to have them in a well-defined location.

For simple gradient descent, the search direction would be the negative gradient, but e.g. for LBFGS it would be the direction obtained from the internal quasi-Hessian. Knowing the search direction allows to really drill down into the linesearch, see, e.g., the plots in the README of GRAPELinesearchAnalysis.jl. In principle, I can infer the search direction as the difference in u from the previous iteration, but then I don't know the step width (how far the optimizer went in the direction of the search direction). Knowing both quantities directly from the solver is useful for actually checking that the update is in the search direction, but if that's guaranteed, only one of them would be sufficient.

@goerz
Copy link
Author

goerz commented Mar 26, 2024

I can usually pull these quantities out of the original state

Well, I thought I could, but it turns out the state is woefully inadequate, at least for some optimizers. I'm dumping state in the callback in an optimization with NLopt.LD_LBFGS() and seeing this:

Optimization.OptimizationState{Vector{Float64}, Float64, Nothing, Nothing, Nothing}
  iter: Int64 0
  u: Array{Float64}((9,)) [0.13823471888875286, 0.30634894494361153, 0.1562189341456497, 2.6013349121108944, 2.601329761795745, 3.6818511117018, 4.997713711972462, 4.989897143702104, 4.9818589345359605]
  objective: Float64 0.01069630598006488
  grad: Nothing nothing
  hess: Nothing nothing
  original: Nothing nothing

So it's missing a lot of information, and doesn't forward any internal LD_LBFGS state.

@ChrisRackauckas
Copy link
Member

Yes, we need to fill it in a bit more per optimizer, and not all optimizers have al linformation.

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

2 participants