Skip to content

Commit

Permalink
fix benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
lostella committed Jul 20, 2024
1 parent 70e2743 commit 95f49a5
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions benchmark/benchmarks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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 [
Expand All @@ -45,88 +45,88 @@ 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)
g = NormL1($lam)
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)
g = NormL1($lam)
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)
g = NormL1($lam)
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)
Expand Down

0 comments on commit 95f49a5

Please sign in to comment.