JuliaSmoothOptimizers / SolverTools.jl

Tools for developing nonlinear optimization solvers.
Other
26 stars 18 forks source link

Preallocate on LineModel #166

Closed abelsiqueira closed 2 years ago

abelsiqueira commented 3 years ago

Stores xt inside LineModel to prevent allocations.

WIP because I can't predict the allocations of armijo_wolfe yet. Testing manually with this script gives a different result.

codecov[bot] commented 3 years ago

Codecov Report

Merging #166 (8c2015c) into main (9f316a3) will increase coverage by 0.46%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #166      +/-   ##
==========================================
+ Coverage   90.64%   91.11%   +0.46%     
==========================================
  Files           8        8              
  Lines         171      180       +9     
==========================================
+ Hits          155      164       +9     
  Misses         16       16              
Impacted Files Coverage Δ
src/linesearch/line_model.jl 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 9f316a3...8c2015c. Read the comment docs.

abelsiqueira commented 3 years ago

@dpo, I've updated with allocations tests, but there are a few issues.

First, the allocation of the LineModel API and of Armijo is different on 1.3, so it fails.

The allocation of Armijo is not really well defined. I initially thought it was (8 + nbk) * 32 + 16, but that actually only works for bk_max >= 4, which sets nbk = 4. However, if I change bk_max < 4, then it becomes (7 + 1.5nbk) * 32. But this doesn't work for nbk = 4. So I used min(12.5 * 32 + 16, 7 + 1.5nbk) * 32. Furthermore, if I use a loop for the test, then it allocates and additional 208.

Any suggestions?

dpo commented 3 years ago

Does the armijo_wolfe in #146 allocate?

abelsiqueira commented 3 years ago

Does the armijo_wolfe in #146 allocate?

Probably, I made no efforts to remove allocations on #146.

github-actions[bot] commented 2 years ago
Package name latest stable
JSOSolvers.jl
Percival.jl
github-actions[bot] commented 2 years ago
Package name latest stable
JSOSolvers.jl
Percival.jl
github-actions[bot] commented 2 years ago
Package name latest stable
JSOSolvers.jl
Percival.jl
github-actions[bot] commented 2 years ago
Package name latest stable
JSOSolvers.jl
Percival.jl
dpo commented 2 years ago

Maybe restrict allocation tests to Julia > 1.3?

github-actions[bot] commented 2 years ago
Package name latest stable
JSOSolvers.jl
Percival.jl
github-actions[bot] commented 2 years ago
Package name latest stable
JSOSolvers.jl
Percival.jl