From 2d1c16a5cd97b650dad4fe677f06c20c40715041 Mon Sep 17 00:00:00 2001 From: Sebastian Pokutta <23001135+pokutta@users.noreply.github.com> Date: Sun, 14 Feb 2021 16:15:28 +0100 Subject: [PATCH 1/4] intermediate --- examples/largeScale.jl | 7 ++++--- src/FrankWolfe.jl | 8 ++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/examples/largeScale.jl b/examples/largeScale.jl index c8cad6944..435e26749 100644 --- a/examples/largeScale.jl +++ b/examples/largeScale.jl @@ -1,7 +1,7 @@ import FrankWolfe import LinearAlgebra -n = Int(1e9) +n = Int(1e4) k = 1000 xpi = rand(n); @@ -16,10 +16,10 @@ end # better for memory consumption as we do coordinate-wise ops function cf(x, xp) - return @. norm(x - xp)^2 + return @. LinearAlgebra.norm(x - xp)^2 end -function cgrad(storage, x, xp) +function cgrad!(storage, x, xp) return @. storage = 2 * (x - xp) end @@ -33,6 +33,7 @@ FrankWolfe.benchmark_oracles(x -> cf(x, xp), (str, x) -> cgrad!(str, x, xp), lmo (str, x) -> cgrad!(str, x, xp), lmo, x0, + nep=false, max_iteration=k, line_search=FrankWolfe.agnostic, print_iter=k / 10, diff --git a/src/FrankWolfe.jl b/src/FrankWolfe.jl index 4ef7fcc63..9e034ae85 100644 --- a/src/FrankWolfe.jl +++ b/src/FrankWolfe.jl @@ -53,6 +53,7 @@ function fw( verbose=false, linesearch_tol=1e-7, emphasis::Emphasis=blas, + nep=false, gradient=nothing ) function print_header(data) @@ -143,6 +144,13 @@ function fw( @emphasis(emphasis, gradient = (momentum * gradient) + (1 - momentum) * gtemp) end first_iter = false + + # build-in NEP here + if nep === true + # argmin_v v^T(1-2y) + # y = x_t - 1/L * (t+1)/2 * gradient + @. gradient = 1 - 2 * (x - 1 / L * (t+1) / 2 * gradient) + end v = compute_extreme_point(lmo, gradient) From 640cd5339aade9d9e99b3f680d093c534504cf95 Mon Sep 17 00:00:00 2001 From: Sebastian Pokutta <23001135+pokutta@users.noreply.github.com> Date: Sun, 14 Feb 2021 16:32:04 +0100 Subject: [PATCH 2/4] working on nep implementation --- examples/largeScale.jl | 5 +++-- src/FrankWolfe.jl | 17 +++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/examples/largeScale.jl b/examples/largeScale.jl index c078b7501..18eafd496 100644 --- a/examples/largeScale.jl +++ b/examples/largeScale.jl @@ -1,8 +1,8 @@ import FrankWolfe using LinearAlgebra -n = Int(1e4) -k = 1000 +n = Int(1e5) +k = 10000 xpi = rand(n); total = sum(xpi); @@ -34,6 +34,7 @@ FrankWolfe.benchmark_oracles(x -> cf(x, xp), (str, x) -> cgrad!(str, x, xp), lmo lmo, x0, nep=false, + L=2, max_iteration=k, line_search=FrankWolfe.agnostic, print_iter=k / 10, diff --git a/src/FrankWolfe.jl b/src/FrankWolfe.jl index 9e034ae85..113240b11 100644 --- a/src/FrankWolfe.jl +++ b/src/FrankWolfe.jl @@ -145,13 +145,6 @@ function fw( end first_iter = false - # build-in NEP here - if nep === true - # argmin_v v^T(1-2y) - # y = x_t - 1/L * (t+1)/2 * gradient - @. gradient = 1 - 2 * (x - 1 / L * (t+1) / 2 * gradient) - end - v = compute_extreme_point(lmo, gradient) # go easy on the memory - only compute if really needed @@ -170,6 +163,14 @@ function fw( (t, primal, primal - dual_gap, dual_gap, (time_ns() - time_start) / 1.0e9), ) end + + # build-in NEP here + if nep === true + # argmin_v v^T(1-2y) + # y = x_t - 1/L * (t+1)/2 * gradient + @. gradient = 1 - 2 * (x - 1 / (L * 2 / (t+1)) * gradient) + v = compute_extreme_point(lmo, gradient) + end if line_search === agnostic gamma = 2 // (2 + t) @@ -313,7 +314,7 @@ function lcg( tt::StepType = regular time_start = time_ns() - if line_search == shortstep && L == Inf + if (line_search == shortstep || nep === true ) && L == Inf println("FATAL: Lipschitz constant not set. Prepare to blow up spectacularly.") end From d34d01a944297d9a3240b18f680404fa367ccd7b Mon Sep 17 00:00:00 2001 From: Sebastian Pokutta <23001135+pokutta@users.noreply.github.com> Date: Sun, 14 Feb 2021 16:36:36 +0100 Subject: [PATCH 3/4] minor -> just moved the check to the right function --- src/FrankWolfe.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/FrankWolfe.jl b/src/FrankWolfe.jl index 113240b11..fbc08aa24 100644 --- a/src/FrankWolfe.jl +++ b/src/FrankWolfe.jl @@ -101,7 +101,7 @@ function fw( trajData = [] time_start = time_ns() - if (line_search === shortstep || line_search === adaptive) && L == Inf + if (line_search === shortstep || line_search === adaptive || nep === true ) && L == Inf println("FATAL: Lipschitz constant not set. Prepare to blow up spectacularly.") end @@ -314,7 +314,7 @@ function lcg( tt::StepType = regular time_start = time_ns() - if (line_search == shortstep || nep === true ) && L == Inf + if line_search == shortstep && L == Inf println("FATAL: Lipschitz constant not set. Prepare to blow up spectacularly.") end From d5c5f21c25c733222f65bd997968a2c3533f83dc Mon Sep 17 00:00:00 2001 From: Sebastian Pokutta <23001135+pokutta@users.noreply.github.com> Date: Sat, 20 Feb 2021 21:51:05 +0100 Subject: [PATCH 4/4] just update gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 17ee9912f..c394e1ab8 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ test/bug.jl before.pdf after.pdf *.pdf +prof.txt