JuliaNLSolvers / NLSolversBase.jl

Base package for optimization and equation solver software in JuliaNLSolvers
Other
30 stars 28 forks source link

Add option to specify ForwardDiff chunk size #126

Open touste opened 4 years ago

touste commented 4 years ago

Hi, it would be nice to have this option available (and propagate it to Optim.jl as well), this setting can have a great impact on performances/allocations in some situations (see for ex: https://discourse.julialang.org/t/large-memory-allocation-in-forwarddiff/42581/14).

Thanks!

longemen3000 commented 3 years ago

if i remember correctly, the constructors accept a chunk keyword: on OnceDifferentiable: https://github.com/JuliaNLSolvers/NLSolversBase.jl/blob/62d2199f70cce78479658da08d346bbc060fc2f7/src/objective_types/oncedifferentiable.jl#L16-L19 on TwiceDIfferentiable: https://github.com/JuliaNLSolvers/NLSolversBase.jl/blob/62d2199f70cce78479658da08d346bbc060fc2f7/src/objective_types/twicedifferentiable.jl#L103-L104

pkofod commented 3 years ago

Yes if you define the objective type yourself it is possible. I supposed OP is asking for this to be a keyword for optimize?

touste commented 3 years ago

Hi, I did indeed wish for it to be available in optimize. However since then I think I have a better understanding of the functionalities of the packages, and it is possible to use optimize with a OnceDifferentiable of TwiceDifferentiable function, which accept this option, so it indirectly solves the problem. Perhaps a heads up in the doc of Optim.jl could let users know about the possibility to use OnceDifferentiable or TwiceDifferentiable functions? Otherwise feel free to close the issue.

pkofod commented 3 years ago

Perhaps a heads up in the doc of Optim.jl could let users know about the possibility to use OnceDifferentiable or TwiceDifferentiable functions?

Yeah, I had originally chosen not to focus too much on this because I wasn't sure whether or not I wanted users to use them directly :) But it would solve the problem for now. I do think that it makes sense to allow for chunk size to be et in optimize as well though.