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

change return type to NamedTuple #447

Merged
merged 5 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
cleanup using
  • Loading branch information
matbesancon committed Nov 16, 2023
commit 987143327644d6f7c9af8eef930112348f99e335
5 changes: 0 additions & 5 deletions examples/adaptive_step_sizes.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using FrankWolfe
using ProgressMeter
using Arpack
using Plots
using DoubleFloats
using ReverseDiff

import LinearAlgebra

Expand Down
2 changes: 0 additions & 2 deletions examples/adaptive_step_sizes_nontrivial.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using FrankWolfe
using ProgressMeter
using Random
using Plots

using LinearAlgebra

Expand Down
6 changes: 0 additions & 6 deletions examples/approximate_caratheodory.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@

using FrankWolfe
using ProgressMeter
using Arpack
using Plots
using DoubleFloats
using ReverseDiff

using LinearAlgebra

n = Int(1e2);
Expand Down
10 changes: 2 additions & 8 deletions examples/away_step_cg.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
using FrankWolfe
using ProgressMeter
using Arpack
using Plots
using DoubleFloats
using ReverseDiff

import LinearAlgebra
using LinearAlgebra

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

Expand All @@ -17,7 +11,7 @@ xpi = rand(n);
total = sum(xpi);
const xp = xpi # ./ total;

f(x) = LinearAlgebra.norm(x - xp)^2
f(x) = norm(x - xp)^2
function grad!(storage, x)
@. storage = 2 * (x - xp)
end
Expand Down
6 changes: 0 additions & 6 deletions examples/birkhoff_polytope.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using FrankWolfe
using ProgressMeter
using Arpack
using Plots
using DoubleFloats
using ReverseDiff

using LinearAlgebra
using Random
import GLPK
Expand Down
6 changes: 0 additions & 6 deletions examples/blended_cg.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using FrankWolfe
using ProgressMeter
using Arpack
using Plots
using DoubleFloats
using ReverseDiff

using LinearAlgebra
using Random
using SparseArrays
Expand Down
6 changes: 0 additions & 6 deletions examples/blended_pairwise_vs_afw_sparity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ The default for AFW is K = 2.0
=#

using FrankWolfe
using ProgressMeter
using Arpack
using Plots
using DoubleFloats
using ReverseDiff

using LinearAlgebra
using Random

Expand Down
6 changes: 0 additions & 6 deletions examples/large_scale.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ NOTE.
=#

using FrankWolfe
using ProgressMeter
using Arpack
using Plots
using DoubleFloats
using ReverseDiff

using LinearAlgebra

n = Int(1e7)
Expand Down
6 changes: 0 additions & 6 deletions examples/lazy_away_step_cg-sparsity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ The default for AFW is lazy_tolerance = 2.0
=#

using FrankWolfe
using ProgressMeter
using Arpack
using Plots
using DoubleFloats
using ReverseDiff

using LinearAlgebra
using Random

Expand Down
10 changes: 2 additions & 8 deletions examples/lazy_away_step_cg.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
using FrankWolfe
using ProgressMeter
using Arpack
using Plots
using DoubleFloats
using ReverseDiff

import LinearAlgebra
using LinearAlgebra

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

Expand All @@ -18,7 +12,7 @@ xpi = rand(n);
total = sum(xpi);
const xp = xpi # ./ total;

f(x) = LinearAlgebra.norm(x - xp)^2
f(x) = norm(x - xp)^2
function grad!(storage, x)
@. storage = 2 * (x - xp)
end
Expand Down
4 changes: 0 additions & 4 deletions examples/lcg_cache_size.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using FrankWolfe
using ProgressMeter
using Arpack
using Plots

using LinearAlgebra

n = Int(1e4)
Expand Down
6 changes: 1 addition & 5 deletions examples/lcg_expensive_LMO.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
using FrankWolfe
using ProgressMeter
using Arpack
using Plots
using DoubleFloats
using ReverseDiff

using LinearAlgebra
using Random
Expand All @@ -25,7 +21,7 @@ const xp = xpi # ./ total;
# better for memory consumption as we do coordinate-wise ops

function cf(x, xp)
return LinearAlgebra.norm(x .- xp)^2 / n^2
return norm(x .- xp)^2 / n^2
end

function cgrad!(storage, x, xp)
Expand Down
6 changes: 0 additions & 6 deletions examples/lcg_expensive_LMO_results.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@
# compile time of Julia for the first run is not tainting the results

using FrankWolfe
using ProgressMeter
using Arpack
using Plots
using DoubleFloats
using ReverseDiff

using JSON
using LaTeXStrings
results = JSON.Parser.parsefile("lcg_expensive_data.json")
Expand Down
6 changes: 0 additions & 6 deletions examples/linear_regression.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ using the stochastic version of Frank-Wolfe.
"""

using FrankWolfe
using ProgressMeter
using Arpack
using Plots
using DoubleFloats
using ReverseDiff

using Random
using LinearAlgebra

Expand Down
10 changes: 2 additions & 8 deletions examples/lowerbound.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,7 @@ NOTE:
=#

using FrankWolfe
using ProgressMeter
using Arpack
using Plots
using DoubleFloats
using ReverseDiff

import LinearAlgebra
using LinearAlgebra

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

Expand All @@ -49,7 +43,7 @@ k = Int(1e3)
xp = 1 / n * ones(n);

# definition of objective
f(x) = LinearAlgebra.norm(x - xp)^2
f(x) = norm(x - xp)^2

# definition of gradient
function grad!(storage, x)
Expand Down
6 changes: 0 additions & 6 deletions examples/moi_optimizer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@
# to get accurate timings it is important to run twice so that the compile time of Julia for the first run
# is not tainting the results
using FrankWolfe
using ProgressMeter
using Arpack
using Plots
using DoubleFloats
using ReverseDiff

using LinearAlgebra
using LaTeXStrings

Expand Down
5 changes: 0 additions & 5 deletions examples/movielens.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using FrankWolfe
using ProgressMeter
using Arpack
using Plots
using DoubleFloats
using ReverseDiff

# download movielens data
using ZipFile, DataFrames, CSV
Expand Down
7 changes: 1 addition & 6 deletions examples/movielens_results.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,9 @@
# is not tainting the results

using FrankWolfe
using ProgressMeter
using Arpack
using Plots
using DoubleFloats
using ReverseDiff

using JSON
using LaTeXStrings

results = JSON.Parser.parsefile("movielens_result.json")

ref_optimum = results["trajectory_arr_lazy_ref"][end][2]
Expand Down
6 changes: 0 additions & 6 deletions examples/nonconvex_lasso.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@

using FrankWolfe
using ProgressMeter
using Arpack
using Plots
using DoubleFloats
using ReverseDiff

using LinearAlgebra


Expand Down
6 changes: 0 additions & 6 deletions examples/nuclear_norm.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using FrankWolfe
using ProgressMeter
using Arpack
using Plots
using DoubleFloats
using ReverseDiff

import Random
using SparseArrays, LinearAlgebra
using Test
Expand Down
6 changes: 0 additions & 6 deletions examples/polynomial_results.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@

using FrankWolfe
using ProgressMeter
using Arpack
using Plots
using DoubleFloats
using ReverseDiff

using JSON
using LaTeXStrings

Expand Down
6 changes: 0 additions & 6 deletions examples/polynomials.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using FrankWolfe
using ProgressMeter
using Arpack
using Plots
using DoubleFloats
using ReverseDiff

using LinearAlgebra
import Random

Expand Down
13 changes: 3 additions & 10 deletions examples/trajectory_comparison.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
using FrankWolfe
using ProgressMeter
using Arpack
using Plots
using DoubleFloats
using ReverseDiff

import LinearAlgebra
using LinearAlgebra

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

Expand All @@ -16,17 +10,16 @@ xpi = rand(n);
total = sum(xpi);
const xp = xpi ./ total;

f(x) = LinearAlgebra.norm(x - xp)^2
f(x) = norm(x - xp)^2

function grad!(storage, x)
storage .= 2 * (x - xp)
return nothing
end

# better for memory consumption as we do coordinate-wise ops

function cf(x, xp)
return @. LinearAlgebra.norm(x - xp)^2
return norm(x .- xp)^2
end

# lmo = FrankWolfe.KSparseLMO(100, 1.0)
Expand Down
3 changes: 0 additions & 3 deletions src/FrankWolfe.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ module FrankWolfe

using GenericSchur
using LinearAlgebra
using Printf
using ProgressMeter
using TimerOutputs
using SparseArrays: spzeros, SparseVector
import SparseArrays
import Random
Expand Down
2 changes: 1 addition & 1 deletion src/afw.jl
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ function away_frank_wolfe(
callback(state, active_set)
end

return x, v, primal, dual_gap, traj_data, active_set
return (x=x, v=v, primal=primal, dual_gap=dual_gap, traj_data=traj_data, active_set=active_set)
end

function lazy_afw_step(x, gradient, lmo, active_set, phi, epsilon, d; use_extra_vertex_storage=false, extra_vertex_storage=nothing, lazy_tolerance=2.0, memory_mode::MemoryEmphasis=InplaceEmphasis())
Expand Down