Skip to content

Newton + LineSearch in Hot Loop: Reduce allocations #290

Open
@DanielDoehring

Description

I really like the NLsolve.jl package in conjunction with LineSearches.jl - great stuff!

I have a scalar, relatively simple nonlinear equation that I can solve using

res = nlsolve(gamma -> f(gamma[1], bla, bla, bla),
              gamma -> j(gamma[1], bla, bla, bla),
              [gamma], method = :newton,  ftol = 2 * eps(RealT), iterations = 20,
              linesearch = LineSearches.BackTracking(order=3))
gamma = res.zero[1]

which works really well.
The issue is, however, that I get a couple allocations whenever I call this. Is there any way to reduce these by e.g. initalizing the problem once and then updating it later?

The functions f and g stay constant over time, although their arguments bla change over time.

Xref: https://discourse.julialang.org/t/newton-linesearch-in-hot-loop-reduce-allocations/122585

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions