Skip to content

Commit

Permalink
update benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
lostella committed Jan 20, 2024
1 parent 2e062c3 commit 9ac83c0
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions benchmark/benchmarks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@ using FileIO

const SUITE = BenchmarkGroup()

function ProximalAlgorithms.value_and_gradient_closure(f::ProximalOperators.LeastSquaresDirect, x)
res = f.A*x - f.b
norm(res)^2, () -> f.A'*res
end

struct SquaredDistance{Tb}
b::Tb
end

(f::SquaredDistance)(x) = norm(x - f.b)^2

function ProximalAlgorithms.value_and_gradient_closure(f::SquaredDistance, x)
diff = x - f.b
norm(diff)^2, () -> diff
end

for (benchmark_name, file_name) in [
("Lasso tiny", joinpath(@__DIR__, "data", "lasso_tiny.jld2")),
("Lasso small", joinpath(@__DIR__, "data", "lasso_small.jld2")),
Expand Down Expand Up @@ -42,21 +58,21 @@ for (benchmark_name, file_name) in [
SUITE[k]["ZeroFPR"] = @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 = Translate(SqrNormL2(), -$b)
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)
x0 = zeros($T, size($A, 2))
f = Translate(SqrNormL2(), -$b)
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)
x0 = zeros($T, size($A, 2))
f = Translate(SqrNormL2(), -$b)
f = SquaredDistance($b)
g = NormL1($lam)
end

Expand Down

0 comments on commit 9ac83c0

Please sign in to comment.