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

Add limited memory broyden implementation #41

Merged
merged 3 commits into from
Feb 11, 2023

Conversation

avik-pal
Copy link
Member

This is not too useful (and will be slower than Broyden) on small problems. But it scales quite well.

julia> using SimpleNonlinearSolve

julia> f = (u, p) -> u .* u .- 2.0;
julia> probN = NonlinearProblem(f, ones(1000));

julia> @benchmark sol = solve(probN, Broyden())
BenchmarkTools.Trial: 97 samples with 1 evaluation.
 Range (min  max):  45.189 ms  72.033 ms  ┊ GC (min  max): 6.37%  8.07%
 Time  (median):     51.164 ms              ┊ GC (median):    8.35%
 Time  (mean ± σ):   51.708 ms ±  4.675 ms  ┊ GC (mean ± σ):  8.29% ± 1.78%

    █ ▁▆▁ ▁▃▁▁ ▃ ▃█▆  ▁    █▁                                  
  ▇▄█▇███▁████▄█▁███▇▇█▄▄▇▇██▇▇▄▇▁▇▄▁▄▁▄▄▁▄▇▁▄▁▄▁▁▁▁▁▁▁▁▁▁▁▁▄ ▁
  45.2 ms         Histogram: frequency by time          66 ms <

 Memory estimate: 130.39 MiB, allocs estimate: 126.

julia> @benchmark sol = solve(probN, LBroyden())
BenchmarkTools.Trial: 4978 samples with 1 evaluation.
 Range (min  max):  692.494 μs    3.050 ms  ┊ GC (min  max):  0.00%  58.68%
 Time  (median):     855.718 μs               ┊ GC (median):     0.00%
 Time  (mean ± σ):   987.179 μs ± 388.915 μs  ┊ GC (mean ± σ):  11.79% ± 16.94%

   ▁▃▅██▇▆▆▅▄▃▃▂▁                                     ▁▂▂▂▁▁▁▁  ▂
  ▆███████████████▇▆▅▃▄▁▁▁▃▁▃▃▄▁▁▃▃▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▆███████████ █
  692 μs        Histogram: log(frequency) by time       2.34 ms <

 Memory estimate: 3.85 MiB, allocs estimate: 415.

@codecov
Copy link

codecov bot commented Feb 10, 2023

Codecov Report

Merging #41 (c00b3b3) into main (a748c90) will increase coverage by 0.11%.
The diff coverage is 94.00%.

@@            Coverage Diff             @@
##             main      #41      +/-   ##
==========================================
+ Coverage   92.70%   92.81%   +0.11%     
==========================================
  Files          12       13       +1     
  Lines         507      557      +50     
==========================================
+ Hits          470      517      +47     
- Misses         37       40       +3     
Impacted Files Coverage Δ
src/SimpleNonlinearSolve.jl 0.00% <ø> (ø)
src/lbroyden.jl 94.00% <94.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@ChrisRackauckas
Copy link
Member

If it's main use is for bigger equations, maybe setup the loop to use cached arrays.

@avik-pal
Copy link
Member Author

The tests probably need to be fixed. They will fail if the solver finds the "other" solution.

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