diff --git a/benchmark/benchmarks.jl b/benchmark/benchmarks.jl index 035b35d..f80f206 100644 --- a/benchmark/benchmarks.jl +++ b/benchmark/benchmarks.jl @@ -13,18 +13,18 @@ function ProximalAlgorithms.value_and_gradient_closure( x, ) res = f.A * x - f.b - norm(res)^2, () -> f.A' * res + norm(res)^2 / 2, () -> f.A' * res end struct SquaredDistance{Tb} b::Tb end -(f::SquaredDistance)(x) = norm(x - f.b)^2 +(f::SquaredDistance)(x) = norm(x - f.b)^2 / 2 function ProximalAlgorithms.value_and_gradient_closure(f::SquaredDistance, x) diff = x - f.b - norm(diff)^2, () -> diff + norm(diff)^2 / 2, () -> diff end for (benchmark_name, file_name) in [ @@ -45,56 +45,56 @@ for (benchmark_name, file_name) in [ m, n = size(A) SUITE[k]["ForwardBackward"] = - @benchmarkable solver(x0 = x0, f = f, g = g) setup = begin - solver = ProximalAlgorithms.ForwardBackward(tol = 1e-6) + @benchmarkable solver(x0=x0, f=f, g=g) setup = begin + solver = ProximalAlgorithms.ForwardBackward(tol=1e-6) x0 = zeros($T, size($A, 2)) f = LeastSquares($A, $b) g = NormL1($lam) end SUITE[k]["FastForwardBackward"] = - @benchmarkable solver(x0 = x0, f = f, g = g) setup = begin - solver = ProximalAlgorithms.FastForwardBackward(tol = 1e-6) + @benchmarkable solver(x0=x0, f=f, g=g) setup = begin + solver = ProximalAlgorithms.FastForwardBackward(tol=1e-6) x0 = zeros($T, size($A, 2)) f = LeastSquares($A, $b) g = NormL1($lam) end SUITE[k]["ZeroFPR"] = - @benchmarkable solver(x0 = x0, f = f, A = $A, g = g) setup = begin - solver = ProximalAlgorithms.ZeroFPR(tol = 1e-6) + @benchmarkable solver(x0=x0, f=f, A=$A, g=g) setup = begin + solver = ProximalAlgorithms.ZeroFPR(tol=1e-6) x0 = zeros($T, size($A, 2)) f = SquaredDistance($b) g = NormL1($lam) end SUITE[k]["PANOC"] = - @benchmarkable solver(x0 = x0, f = f, A = $A, g = g) setup = begin - solver = ProximalAlgorithms.PANOC(tol = 1e-6) + @benchmarkable solver(x0=x0, f=f, A=$A, g=g) setup = begin + solver = ProximalAlgorithms.PANOC(tol=1e-6) x0 = zeros($T, size($A, 2)) f = SquaredDistance($b) g = NormL1($lam) end SUITE[k]["PANOCplus"] = - @benchmarkable solver(x0 = x0, f = f, A = $A, g = g) setup = begin - solver = ProximalAlgorithms.PANOCplus(tol = 1e-6) + @benchmarkable solver(x0=x0, f=f, A=$A, g=g) setup = begin + solver = ProximalAlgorithms.PANOCplus(tol=1e-6) x0 = zeros($T, size($A, 2)) f = SquaredDistance($b) g = NormL1($lam) end SUITE[k]["DouglasRachford"] = - @benchmarkable solver(x0 = x0, f = f, g = g, gamma = $R(1)) setup = begin - solver = ProximalAlgorithms.DouglasRachford(tol = 1e-6) + @benchmarkable solver(x0=x0, f=f, g=g, gamma=$R(1)) setup = begin + solver = ProximalAlgorithms.DouglasRachford(tol=1e-6) x0 = zeros($T, size($A, 2)) f = LeastSquares($A, $b) g = NormL1($lam) end SUITE[k]["DRLS"] = - @benchmarkable solver(x0 = x0, f = f, g = g, Lf = Lf) setup = begin - solver = ProximalAlgorithms.DRLS(tol = 1e-6) + @benchmarkable solver(x0=x0, f=f, g=g, Lf=Lf) setup = begin + solver = ProximalAlgorithms.DRLS(tol=1e-6) x0 = zeros($T, size($A, 2)) f = LeastSquares($A, $b) Lf = opnorm(($A)' * $A) @@ -102,11 +102,11 @@ for (benchmark_name, file_name) in [ end SUITE[k]["AFBA-1"] = - @benchmarkable solver(x0 = x0, y0 = y0, f = f, g = g, beta_f = beta_f) setup = + @benchmarkable solver(x0=x0, y0=y0, f=f, g=g, beta_f=beta_f) setup = begin beta_f = opnorm($A)^2 solver = - ProximalAlgorithms.AFBA(theta = $R(1), mu = $R(1), tol = $R(1e-6)) + ProximalAlgorithms.AFBA(theta=$R(1), mu=$R(1), tol=$R(1e-6)) x0 = zeros($T, size($A, 2)) y0 = zeros($T, size($A, 2)) f = LeastSquares($A, $b) @@ -114,10 +114,10 @@ for (benchmark_name, file_name) in [ end SUITE[k]["AFBA-2"] = - @benchmarkable solver(x0 = x0, y0 = y0, h = h, L = $A, g = g) setup = begin + @benchmarkable solver(x0=x0, y0=y0, h=h, L=$A, g=g) setup = begin beta_f = opnorm($A)^2 solver = - ProximalAlgorithms.AFBA(theta = $R(1), mu = $R(1), tol = $R(1e-6)) + ProximalAlgorithms.AFBA(theta=$R(1), mu=$R(1), tol=$R(1e-6)) x0 = zeros($T, size($A, 2)) y0 = zeros($T, size($A, 1)) h = Translate(SqrNormL2(), -$b) @@ -125,8 +125,8 @@ for (benchmark_name, file_name) in [ end SUITE[k]["SFISTA"] = - @benchmarkable solver(x0 = x0, f = f, Lf = Lf, g = g) setup = begin - solver = ProximalAlgorithms.SFISTA(tol = $R(1e-3)) + @benchmarkable solver(x0=x0, f=f, Lf=Lf, g=g) setup = begin + solver = ProximalAlgorithms.SFISTA(tol=$R(1e-3)) x0 = zeros($T, size($A, 2)) f = LeastSquares($A, $b) g = NormL1($lam)