Skip to content

Commit 7cf78b8

Browse files
authored
various fixes to docs and docstrings (#21)
* various fixes to docs and docstrings * address comments * showing ProxAlg docs * fixed docs deps * update docs
1 parent 4dde469 commit 7cf78b8

16 files changed

Lines changed: 210 additions & 218 deletions

docs/Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ AbstractOperators = "d9c5613a-d543-52d8-9afd-8f241a8c3f1c"
33
DSP = "717857b8-e6f2-59f4-9121-6e50c889abd2"
44
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
55
FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"
6+
ProximalAlgorithms = "140ffc9f-1907-541a-a177-7475e0a401e9"
7+
StructuredOptimization = "46cd3e9d-64ff-517d-a929-236bc1a1fc9d"

docs/make.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
using Documenter, StructuredOptimization, LinearAlgebra, DSP, FFTW, AbstractOperators
1+
using Documenter, StructuredOptimization,
2+
LinearAlgebra, DSP, FFTW, AbstractOperators, ProximalAlgorithms
23

34
makedocs(
4-
modules = [StructuredOptimization],
5+
modules = [StructuredOptimization,ProximalAlgorithms],
56
format = Documenter.HTML(),
67
sitename = "StructuredOptimization",
78
authors = "Niccolò Antonello and Lorenzo Stella",

docs/src/solvers.md

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,15 @@
1919
## Specifying solver and options
2020

2121
You can pick the algorithm to use as `Solver` object from the
22-
[`ProximalAlgorithms.jl`](https://github.com/kul-forbes/ProximalAlgorithms.jl))
23-
package. Currently, the following algorithms are supported:
24-
25-
* `ProximalAlgorithms.ForwardBackward`, also known as *proximal gradient*
26-
method [[1]](http://www.mit.edu/~dimitrib/PTseng/papers/apgm.pdf), [[2]](http://epubs.siam.org/doi/abs/10.1137/080716542). Nesterov acceleration can be enabled, which significantly
27-
improves its performance for convex problems.
28-
* `ProximalAlgorithms.ZeroFPR`, a Newton-type forward-backward algorithm,
29-
proposed in [[3]](https://arxiv.org/abs/1606.06256), using L-BFGS
30-
directions to accelerate convergence.
31-
* `ProximalAlgorithms.PANOC`, another Newton-type forward-backward algorithm,
32-
proposed in [[4]](https://doi.org/10.1109/CDC.2017.8263933), also using
33-
L-BFGS directions.
22+
[`ProximalAlgorithms.jl`](https://github.com/kul-forbes/ProximalAlgorithms.jl)
23+
package. Currently, the following algorithms are supported.
24+
25+
```@docs
26+
ForwardBackward
27+
ZeroFPR
28+
PANOC
29+
```
30+
3431

3532
## Parse and solve
3633

src/StructuredOptimization.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ using AbstractOperators
88
using ProximalOperators
99
using ProximalAlgorithms
1010

11+
import ProximalAlgorithms:ForwardBackward, ZeroFPR, PANOC
12+
export ForwardBackward, ZeroFPR, PANOC
13+
1114
include("syntax/syntax.jl")
1215
include("calculus/precomposeNonlinear.jl") # TODO move to ProximalOperators?
1316
include("arraypartition.jl") # TODO move to ProximalOperators?

src/solvers/build_solve.jl

Lines changed: 2 additions & 7 deletions
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> build(p, PG());
21+
julia> StructuredOptimization.parse_problem(p, ForwardBackward());
2222
```
2323
"""
2424
function parse_problem(terms::Tuple, solver::T) where T <: ForwardBackwardSolver
@@ -65,14 +65,9 @@ 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, ProximalAlgorithms.ForwardBackward());
68+
julia> solve(p, ForwardBackward());
6969
7070
julia> ~x
71-
4-element Array{Float64,1}:
72-
-0.6427139974173074
73-
-0.29043653211431103
74-
-0.6090539651510192
75-
0.36279278640995494
7671
```
7772
"""
7873
function solve(terms::Tuple, solver::ForwardBackwardSolver)

src/solvers/minimize.jl

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,32 @@
1-
export @minimize
1+
export @minimize
22

33
"""
4-
`@minimize cost [st ctr] [with slv_opt]`
4+
@minimize cost [st ctr] [with slv_opt]
55
6-
Minimize a given problem with cost function `cost`, constraints `ctr` and solver options `slv_opt`.
6+
Minimize a given problem with cost function `cost`, constraints `ctr` and solver options `slv_opt`.
77
88
# Example
99
1010
```julia
11-
julia> A, b = randn(10,4), randn(10);
11+
julia> using StructuredOptimization
12+
13+
julia> A, b, x = randn(10,4), randn(10), Variable(4);
1214
1315
julia> @minimize ls(A*x-b) + 0.5*norm(x);
14-
it | gamma | fpr | tau | FBE |
15-
------|------------|------------|------------|------------|
16-
1 | 2.9152e-02 | 2.7656e+00 | 1.0000e+00 | 5.5181e+00 |
17-
9 | 2.9152e-02 | 9.9682e-05 | 1.0000e+00 | 4.4086e+00 |
16+
17+
julia> ~x # access array with solution
1818
1919
julia> @minimize ls(A*x-b) st x >= 0.;
20-
it | gamma | fpr | tau | FBE |
21-
------|------------|------------|------------|------------|
22-
1 | 5.8304e-02 | 1.0068e+00 | 1.0000e+00 | 6.6282e+00 |
23-
3 | 5.8304e-02 | 9.5210e-16 | 1.0000e+00 | 6.5654e+00 |
2420
25-
julia> it, slv = @minimize ls(A*x-b) st norm(x) == 2.0 with PG(maxit = 5);
26-
it | gamma | fpr |
27-
------|------------|------------|
28-
1 | 6.1373e-02 | 2.2090e+01 |
29-
5 | 3.0686e-02 | 5.5190e-01 |
21+
julia> ~x # access array with solution
3022
31-
```
23+
julia> @minimize ls(A*x-b) st norm(x) == 2.0 with ForwardBackward(fast=true);
3224
33-
Returns as output a tuple containing the number of iterations and the constructed solver.
25+
julia> ~x # access array with solution
26+
```
3427
28+
Returns as output a tuple containing the optimization variables and the number
29+
of iterations spent by the solver algorithm.
3530
"""
3631
macro minimize(cf::Union{Expr, Symbol})
3732
cost = esc(cf)

0 commit comments

Comments
 (0)