Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions benchmarks/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[deps]
AbstractOperators = "d9c5613a-d543-52d8-9afd-8f241a8c3f1c"
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
Debugger = "31a5f54b-26ea-5ae9-a837-f05ce5417438"
ECOS = "e2685f51-7e38-5353-a97d-a921fd2c8199"
ImageView = "86fae568-95e7-573e-a6b2-d8a6b900c9ef"
Images = "916415d5-f1e6-5110-898d-aaa5f9f070e0"
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
MathProgBase = "fdba3010-5040-5b88-9595-932c9decdf73"
SCS = "c946c3f1-0d1f-5ce8-9dea-7daa1f7e2d13"
StructuredOptimization = "46cd3e9d-64ff-517d-a929-236bc1a1fc9d"
TestImages = "5e47fb64-e119-507b-a336-dd2b206d9990"
34 changes: 18 additions & 16 deletions benchmarks/TotalVariation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ using AbstractOperators
using Images
using ImageView
using TestImages
using Random

function set_up()
srand(123)
Random.seed!(1234)
img = testimage("cameraman")

X = convert(Array{Float64},img) # convert image to array
Xt = X.+sqrt(0.006*vecnorm(X,Inf))*randn(size(X)) # add noise
Xt = X.+sqrt(0.006*norm(X,Inf))*randn(size(X)) # add noise
Xt[Xt .< 0] .= 0. #make sure pixels are in range
Xt[Xt .> 1] .= 1.

Expand All @@ -32,7 +33,7 @@ function run_demo()
end

function solve_problem!(slv,V, Y, Xt, X, lambda)
it, = @minimize ls(-V'*Y+Xt)+conj(lambda*norm(Y,2,1,2)) with slv
it = @minimize ls(-V'*Y+Xt)+conj(lambda*norm(Y,2,1,2)) with slv
return it
end

Expand All @@ -42,31 +43,32 @@ function benchmark(;verb = 0, samples = 5, seconds = 100, tol = 1e-3, maxit = 50

solvers = ["ZeroFPR",
"PANOC",
"FPG",
"PG"]
"ForwardBackward"]
slv_opt = ["(verbose = $verb, tol = $tol, gamma = 1/8, maxit = $maxit)",
"(verbose = $verb, tol = $tol, gamma = 1/8, maxit = $maxit)",
"(verbose = $verb, tol = $tol, gamma = 1/8, maxit = $maxit)",
"(verbose = $verb, tol = $tol, gamma = 1/8, maxit = $maxit)"]

its = Dict([(sol,0.) for sol in solvers])
for i in eachindex(solvers)

setup = set_up()
solver = eval(parse(solvers[i]*slv_opt[i]))
solver = eval(Meta.parse(solvers[i]*slv_opt[i]))

suite[solvers[i]] =
@benchmarkable(it = solve_problem!(solver, setup...),
setup = (
it = 0;
setup = deepcopy($setup);
solver = deepcopy($solver) ),
teardown = (
$its[$solvers[$i]] = it;
),
evals = 1, samples = samples, seconds = seconds)
@benchmarkable(
it = solve_problem!(solver, setup...),
setup = (
it = 0;
setup = deepcopy($setup);
solver = deepcopy($solver)
),
teardown = (
$its[$solvers[$i]] = it[2];
),
evals = 1, samples = samples, seconds = seconds)
end

println("Starting run")
results = run(suite, verbose = (verb != 0))
println("TotalVariation its")
println(its)
Expand Down