Skip to content

Commit d1fcbfc

Browse files
committed
Upgrade to ProximalAlgorithms v0.5
* drop support for ForwardBackward optimizer; * add support for PANOCplus; * make PANOCplus the default optimizer; * stabilize unstable unit test.
1 parent ef08702 commit d1fcbfc

13 files changed

+135
-138
lines changed

Project.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "StructuredOptimization"
22
uuid = "46cd3e9d-64ff-517d-a929-236bc1a1fc9d"
3-
version = "0.3.0"
3+
version = "0.4.0-ci+20230622"
44

55
[deps]
66
AbstractOperators = "d9c5613a-d543-52d8-9afd-8f241a8c3f1c"
@@ -15,8 +15,8 @@ RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd"
1515
AbstractOperators = "0.1 - 0.2"
1616
DSP = "0.5.1 - 0.6"
1717
FFTW = "1"
18-
ProximalAlgorithms = "0.3 - 0.4"
19-
ProximalOperators = "0.8 - 0.14"
18+
ProximalAlgorithms = "0.5"
19+
ProximalOperators = "0.15"
2020
RecursiveArrayTools = "1 - 2"
2121
julia = "1.4"
2222

docs/src/solvers.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ You can pick the algorithm to use as `Solver` object from the
2323
package. Currently, the following algorithms are supported.
2424

2525
```@docs
26-
ForwardBackward
2726
ZeroFPR
2827
PANOC
28+
PANOCplus
2929
```
3030

3131

src/StructuredOptimization.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ using AbstractOperators
66
using ProximalOperators
77
using ProximalAlgorithms
88

9-
import ProximalAlgorithms:ForwardBackward, ZeroFPR, PANOC
10-
export ForwardBackward, ZeroFPR, PANOC
9+
import ProximalAlgorithms: ZeroFPR, PANOC, PANOCplus
10+
export ZeroFPR, PANOC, PANOCplus
1111

1212
include("syntax/syntax.jl")
1313
include("calculus/precomposeNonlinear.jl") # TODO move to ProximalOperators?

src/arraypartition.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import ProximalOperators
22
import RecursiveArrayTools
33

44
@inline function ProximalOperators.prox(
5-
h::ProximalOperators.ProximableFunction,
5+
h,
66
x::RecursiveArrayTools.ArrayPartition,
77
gamma...
88
)
@@ -13,7 +13,7 @@ import RecursiveArrayTools
1313
end
1414

1515
@inline function ProximalOperators.gradient(
16-
h::ProximalOperators.ProximableFunction,
16+
h,
1717
x::RecursiveArrayTools.ArrayPartition
1818
)
1919
# unwrap
@@ -24,13 +24,13 @@ end
2424

2525
@inline ProximalOperators.prox!(
2626
y::RecursiveArrayTools.ArrayPartition,
27-
h::ProximalOperators.ProximableFunction,
27+
h,
2828
x::RecursiveArrayTools.ArrayPartition,
2929
gamma...
3030
) = ProximalOperators.prox!(y.x, h, x.x, gamma...)
3131

3232
@inline ProximalOperators.gradient!(
3333
y::RecursiveArrayTools.ArrayPartition,
34-
h::ProximalOperators.ProximableFunction,
34+
h,
3535
x::RecursiveArrayTools.ArrayPartition
3636
) = ProximalOperators.gradient!(y.x, h, x.x)

src/calculus/precomposeNonlinear.jl

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@ import ProximalOperators: gradient!, gradient # this can be removed when moved t
22

33
export PrecomposeNonlinear
44

5-
struct PrecomposeNonlinear{P <: ProximableFunction,
5+
struct PrecomposeNonlinear{P,
66
T <: AbstractOperator,
7-
D <: AbstractArray,
7+
D <: AbstractArray,
88
C <: AbstractArray
9-
} <: ProximableFunction
10-
g::P
9+
}
10+
g::P
1111
G::T
1212
bufD::D
1313
bufC::C
1414
bufC2::C
1515
end
1616

17-
function PrecomposeNonlinear(g::P, G::T) where {P, T}
17+
function PrecomposeNonlinear(g::P, G::T) where {P, T}
1818
t, s = domainType(G), size(G,2)
1919
bufD = eltype(s) <: Int ? zeros(t,s) : ArrayPartition(zeros.(t,s))
2020
t, s = codomainType(G), size(G,1)

src/solvers/build_solve.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ julia> A, b = randn(10,4), randn(10);
1818
1919
julia> p = problem( ls(A*x - b ) , norm(x) <= 1 );
2020
21-
julia> StructuredOptimization.parse_problem(p, ForwardBackward());
21+
julia> StructuredOptimization.parse_problem(p, PANOCplus());
2222
```
2323
"""
2424
function parse_problem(terms::Tuple, solver::T) where T <: ForwardBackwardSolver
@@ -65,14 +65,14 @@ julia> A, b = randn(10,4), randn(10);
6565
6666
julia> p = problem(ls(A*x - b ), norm(x) <= 1);
6767
68-
julia> solve(p, ForwardBackward());
68+
julia> solve(p, PANOCplus());
6969
7070
julia> ~x
7171
```
7272
"""
7373
function solve(terms::Tuple, solver::ForwardBackwardSolver)
7474
x, kwargs = parse_problem(terms, solver)
75-
x_star, it = solver(~x; kwargs...)
75+
x_star, it = solver(; x0 = ~x, kwargs...)
7676
~x .= x_star
7777
return x, it
7878
end

src/solvers/minimize.jl

+16-16
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ julia> @minimize ls(A*x-b) st x >= 0.;
2020
2121
julia> ~x # access array with solution
2222
23-
julia> @minimize ls(A*x-b) st norm(x) == 2.0 with ForwardBackward(fast=true);
23+
julia> @minimize ls(A*x-b) st norm(x) == 2.0 with PANOCplus();
2424
2525
julia> ~x # access array with solution
2626
```
@@ -29,28 +29,28 @@ Returns as output a tuple containing the optimization variables and the number
2929
of iterations spent by the solver algorithm.
3030
"""
3131
macro minimize(cf::Union{Expr, Symbol})
32-
cost = esc(cf)
32+
cost = esc(cf)
3333
return :(solve(problem($(cost)), default_solver()))
3434
end
3535

3636
macro minimize(cf::Union{Expr, Symbol}, s::Symbol, cstr::Union{Expr, Symbol})
37-
cost = esc(cf)
38-
if s == :(st)
39-
constraints = esc(cstr)
40-
return :(solve(problem($(cost), $(constraints)), default_solver()))
41-
elseif s == :(with)
42-
solver = esc(cstr)
37+
cost = esc(cf)
38+
if s == :(st)
39+
constraints = esc(cstr)
40+
return :(solve(problem($(cost), $(constraints)), default_solver()))
41+
elseif s == :(with)
42+
solver = esc(cstr)
4343
return :(solve(problem($(cost)), $(solver)))
44-
else
45-
error("wrong symbol after cost function! use `st` or `with`")
46-
end
44+
else
45+
error("wrong symbol after cost function! use `st` or `with`")
46+
end
4747
end
4848

4949
macro minimize(cf::Union{Expr, Symbol}, s::Symbol, cstr::Union{Expr, Symbol}, w::Symbol, slv::Union{Expr, Symbol})
50-
cost = esc(cf)
51-
s != :(st) && error("wrong symbol after cost function! use `st`")
52-
constraints = esc(cstr)
53-
w != :(with) && error("wrong symbol after constraints! use `with`")
54-
solver = esc(slv)
50+
cost = esc(cf)
51+
s != :(st) && error("wrong symbol after cost function! use `st`")
52+
constraints = esc(cstr)
53+
w != :(with) && error("wrong symbol after constraints! use `with`")
54+
solver = esc(slv)
5555
return :(solve(problem($(cost), $(constraints)), $(solver)))
5656
end

src/solvers/solvers_options.jl

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
using ProximalAlgorithms
22

3-
const ForwardBackwardSolver = Union{
4-
ProximalAlgorithms.ForwardBackward,
5-
ProximalAlgorithms.ZeroFPR,
6-
ProximalAlgorithms.PANOC,
7-
}
3+
const ForwardBackwardSolver = ProximalAlgorithms.IterativeAlgorithm
84

9-
const default_solver = ProximalAlgorithms.PANOC
5+
const default_solver = ProximalAlgorithms.PANOCplus

0 commit comments

Comments
 (0)