From f3891c9320a38f11dc21afacae16b9db34b6bb11 Mon Sep 17 00:00:00 2001 From: Jutho Haegeman Date: Thu, 3 Sep 2020 14:25:01 +0200 Subject: [PATCH] fix major bug in CG --- Project.toml | 2 +- src/cg.jl | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Project.toml b/Project.toml index 1b71b5d..f7bc9ac 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "OptimKit" uuid = "77e91f04-9b3b-57a6-a776-40b61faaebe0" authors = ["Jutho Haegeman"] -version = "0.1.0" +version = "0.2.0" [deps] LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" diff --git a/src/cg.jl b/src/cg.jl index 7bedce0..7ea1235 100644 --- a/src/cg.jl +++ b/src/cg.jl @@ -83,9 +83,6 @@ function optimize(fg, x, alg::ConjugateGradient; @info @sprintf("CG: iter %4d: f = %.12f, ‖∇f‖ = %.4e, α = %.2e, β = %.2e, nfg = %d", numiter, f, normgrad, α, β, nfg) - # increase α for next step - α = 2*α - # transport gprev, ηprev and vectors in Hessian approximation to x gprev = transport!(gprev, xprev, ηprev, α, x) if precondition === _precondition @@ -94,6 +91,9 @@ function optimize(fg, x, alg::ConjugateGradient; Pgprev = transport!(Pgprev, xprev, ηprev, α, x) end ηprev = transport!(deepcopy(ηprev), xprev, ηprev, α, x) + + # increase α for next step + α = 2*α end if verbosity > 0 if normgrad <= alg.gradtol