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

Reused the gradient calculation in the adaptive algorithm. #336

Merged
merged 1 commit into from
Feb 17, 2020

Conversation

mrshirts
Copy link
Collaborator

The adaptive algorithm was calculating the gradient an extra type per cycle. It needs to calculate the gradient twice, to figure out how close the self-consistent iteration and NR steps are, but it was calculating it again a third time to start the loop. Now, it instead stores the gradient that has the lowest norm for the next cycle. It turns out that hessian calculations are not that much slower than gradient calculations in many cases, so eliminating the gradient call helps.

This reduces the number of gradient calls by 1/3 with no loss of accuracy. For a sample large problem (500 states, 1000 samples / state) it reduced the total time taken by ~10%, which is good for 3 lines of code and no loss of accuracy.

Copy link
Contributor

@Lnaden Lnaden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Lnaden Lnaden merged commit e5c18f5 into pymbar4 Feb 17, 2020
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

Successfully merging this pull request may close these issues.

None yet

2 participants