Gnimuc / LBFGSB.jl

Julia wrapper for L-BFGS-B Nonlinear Optimization Code
MIT License
38 stars 6 forks source link

Wrapper edit to avoid re-allocation of gradient #6

Closed bblankrot closed 5 years ago

bblankrot commented 5 years ago

Replaced the tuple (f, g) with f and g!, where g!(z,x) overwrites z with the gradient at the point x. This prevents the re-allocation of the gradient vector in each iterate. For the example in README.md, this change reduced run time by 10% and halved the allocated memory. The effects are more dramatic as the number of iterations and variables grows.

To maintain backwards compatibility, I left the original wrapper as is (with its test), and added a test for the new wrapper.

coveralls commented 5 years ago

Pull Request Test Coverage Report for Build 31


Changes Missing Coverage Covered Lines Changed/Added Lines %
src/wrapper.jl 21 22 95.45%
<!-- Total: 21 22 95.45% -->
Totals Coverage Status
Change from base Build 19: 0.06%
Covered Lines: 55
Relevant Lines: 57

💛 - Coveralls
Gnimuc commented 5 years ago

LGTM, thanks!