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

Difficult to get low gradients #7

Open
dspoel opened this issue Apr 14, 2024 · 4 comments
Open

Difficult to get low gradients #7

dspoel opened this issue Apr 14, 2024 · 4 comments

Comments

@dspoel
Copy link

dspoel commented Apr 14, 2024

I have implemented your LBFGS implementation in my chemistry code and try to use it to minimize the energy of molecules using a classical potential function. For some compounds it is very difficult to get the gradients small enough. For my application I need them to be under 1e-6. I tried playing with mu and eta, but little effect.

One more piece of information is that for some difficult cases some of the gradients are always zero, due to symmetry. I find that breaking the symmetry sometimes makes it possible to get a converged minimization on function value, but still with gradient that are > 1e-4.

Suggestions welcome.

@ssloy
Copy link
Member

ssloy commented Apr 15, 2024

I do not fully grasp the problem. Mu and eta do not dictate the norm of the gradient, those are assumptions on the convexity of the function to minimize.

The norm of the gradient is dictated solely by the function you try to minimize and therefore is computed inside the callback you pass to the L-BFGS.

@dspoel
Copy link
Author

dspoel commented Apr 15, 2024

Thanks for your quick answer. I realise the gradient is provided by my function, but I find that either the function value converges to 0 before the gradients are sufficiently small, or the linear search failed. Maybe my x (atomic coordinates) do not have sufficient precision? Alternatively, I wonder if I can tweak parameters of the algorithm to have it search harder?

@ssloy
Copy link
Member

ssloy commented Apr 15, 2024

What precision do you have in your variables? Do you still feed double precision to stlbfgs or have you modified it?

@dspoel
Copy link
Author

dspoel commented Apr 15, 2024

I'm using the standard double precision, the code is unmodified. What happens when the gradients get small is that the change in function value is even smaller. As stated in issue #8 I will try integer x, which should be feasible since I know the range of x values are below 10 in absolute numbers.

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