Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mostly cosmetic changes and an example #431

Merged
merged 4 commits into from
Sep 30, 2023
Merged
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
2 changes: 1 addition & 1 deletion examples/birkhoff_polytope.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,4 @@ x0 = deepcopy(x00)
data = [trajectoryBCG]
label = ["BCG"]

plot_trajectories(data, label)
plot_trajectories(data, label, reduce_size=true, marker_shapes=[:dtriangle])
79 changes: 79 additions & 0 deletions examples/open_loop.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
using LinearAlgebra
using FrankWolfe
using Random

include("../examples/plot_utils.jl")

n = 10000
k = 500
s = 97
@info "Seed $s"
Random.seed!(s)


# strongly convex set
xp2 = 10 * ones(n)
diag_term = 100 * rand(n)
covariance_matrix = zeros(n,n) + LinearAlgebra.Diagonal(diag_term)
lmo2 = FrankWolfe.EllipsoidLMO(covariance_matrix)

f2(x) = norm(x - xp2)^2
function grad2!(storage, x)
@. storage = 2 * (x - xp2)
end

x0 = FrankWolfe.compute_extreme_point(lmo2, randn(n))

res_2 = FrankWolfe.frank_wolfe(
f2,
grad2!,
lmo2,
copy(x0),
max_iteration=k,
line_search=FrankWolfe.Agnostic(2),
print_iter= k / 10,
epsilon=1e-5,
verbose=true,
trajectory=true,
)

res_4 = FrankWolfe.frank_wolfe(
f2,
grad2!,
lmo2,
copy(x0),
max_iteration=k,
line_search=FrankWolfe.Agnostic(4),
print_iter= k / 10,
epsilon=1e-5,
verbose=true,
trajectory=true,
)

res_6 = FrankWolfe.frank_wolfe(
f2,
grad2!,
lmo2,
copy(x0),
max_iteration=k,
line_search=FrankWolfe.Agnostic(6),
print_iter= k / 10,
epsilon=1e-5,
verbose=true,
trajectory=true,
)

res_10 = FrankWolfe.frank_wolfe(
f2,
grad2!,
lmo2,
copy(x0),
max_iteration=k,
line_search=FrankWolfe.Agnostic(10),
print_iter=k / 10,
epsilon=1e-5,
verbose=true,
trajectory=true,
)

plot_trajectories([res_2[end], res_4[end], res_6[end], res_10[end]], ["ell = 2 (default)", "ell = 4", "ell = 6", "ell = 10"], marker_shapes=[:dtriangle, :rect, :circle, :pentagon])
2 changes: 1 addition & 1 deletion src/afw.jl
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ function away_frank_wolfe(
println(
"GRADIENTTYPE: $grad_type LAZY: $lazy lazy_tolerance: $lazy_tolerance MOMENTUM: $momentum AWAYSTEPS: $away_steps",
)
println("Linear Minimization Oracle: $(typeof(lmo))")
println("LMO: $(typeof(lmo))")
if (use_extra_vertex_storage || add_dropped_vertices) && extra_vertex_storage === nothing
@warn(
"use_extra_vertex_storage and add_dropped_vertices options are only usable with a extra_vertex_storage storage"
Expand Down
2 changes: 1 addition & 1 deletion src/blended_cg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ function blended_conditional_gradient(
)
grad_type = typeof(gradient)
println("GRADIENTTYPE: $grad_type lazy_tolerance: $lazy_tolerance")
println("Linear Minimization Oracle: $(typeof(lmo))")
println("LMO: $(typeof(lmo))")

if (use_extra_vertex_storage || add_dropped_vertices) && extra_vertex_storage === nothing
@warn(
Expand Down
6 changes: 3 additions & 3 deletions src/fw_algorithms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function frank_wolfe(
)
grad_type = typeof(gradient)
println("MOMENTUM: $momentum GRADIENTTYPE: $grad_type")
println("Linear Minimization Oracle: $(typeof(lmo))")
println("LMO: $(typeof(lmo))")
if memory_mode isa InplaceEmphasis
@info("In memory_mode memory iterates are written back into x0!")
end
Expand Down Expand Up @@ -330,7 +330,7 @@ function lazified_conditional_gradient(
)
grad_type = typeof(gradient)
println("GRADIENTTYPE: $grad_type CACHESIZE $cache_size GREEDYCACHE: $greedy_lazy")
println("Linear Minimization Oracle: $(typeof(lmo))")
println("LMO: $(typeof(lmo))")
if memory_mode isa InplaceEmphasis
@info("In memory_mode memory iterates are written back into x0!")
end
Expand Down Expand Up @@ -570,7 +570,7 @@ function stochastic_frank_wolfe(
println(
"GRADIENTTYPE: $(typeof(f.storage)) MOMENTUM: $(momentum_iterator !== nothing) batch policy: $(typeof(batch_iterator)) ",
)
println("Linear Minimization Oracle: $(typeof(lmo))")
println("LMO: $(typeof(lmo))")
if memory_mode isa InplaceEmphasis
@info("In memory_mode memory iterates are written back into x0!")
end
Expand Down
2 changes: 1 addition & 1 deletion src/pairwise.jl
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ function blended_pairwise_conditional_gradient(
)
grad_type = typeof(gradient)
println("GRADIENTTYPE: $grad_type LAZY: $lazy lazy_tolerance: $lazy_tolerance")
println("Linear Minimization Oracle: $(typeof(lmo))")
println("LMO: $(typeof(lmo))")
if use_extra_vertex_storage && !lazy
@info("vertex storage only used in lazy mode")
end
Expand Down