What Kristoffer and Miles said, but specifically all algorithm constructors
accept a linesearch! keyword, and in the case of ConjugateGradient we have
(see
https://github.com/JuliaOpt/Optim.jl/blob/1cf3fbe053edeb8a388ff0d03af75386ad2e3457/src/cg.jl#L106
)
immutable ConjugateGradient{T} <: Optimizer
eta::Float64
P::T
precondprep::Function
linesearch!::Function
end
function ConjugateGradient(;
linesearch!::Function = hz_linesearch!,
eta::Real = 0.4,
P::Any = nothing,
precondprep::Function = (P, x) -> nothing)
ConjugateGradient{typeof(P)}(Float64(eta), P, precondprep, linesearch!)
end
I hope that explains it.
On Tuesday, May 3, 2016 at 11:48:07 AM UTC+2, Eric Forgy wrote:
>
> This sounds great and your changes with the API and dispatch are
> reassuring because I recently implemented something similar (for a totally
> unrelated package). A general question...
>
> You wrote
>
> optimize(df, x0, BFGS())
>
> I'm curious why you didn't make this
>
> optimize(df, x0, BFGS)
>
> Is there any performance difference between the two and why did you go
> with the former rather than the latter?
>
> Thanks for the update.
>
> Best regards,
> Eric
>