Skip to content

Commit 2620090

Browse files
authored
Using more general calculus rules (#18)
* using Ax_mul_Bx and HadamardProd instead of NonLinearCompose and Hadamard * added Ax_mul_Bxt and Axt_mul_Bx * fix to docs
1 parent d90fe83 commit 2620090

11 files changed

+399
-326
lines changed

docs/make.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ makedocs(
1616
)
1717

1818
deploydocs(
19-
repo = "github.com/kul-forbes/AbstractOperators.jl.git",
19+
repo = "github.com/kul-forbes/StructuredOptimization.jl.git",
2020
target = "build",
2121
)

src/solvers/build_solve.jl

+40-40
Original file line numberDiff line numberDiff line change
@@ -23,36 +23,36 @@ julia> build(p, PG());
2323
2424
"""
2525
function build(terms::Tuple, solver::ForwardBackwardSolver)
26-
x = extract_variables(terms)
27-
# Separate smooth and nonsmooth
28-
smooth, nonsmooth = split_smooth(terms)
29-
# Separate quadratic and nonquadratic
30-
quadratic, smooth = split_quadratic(smooth)
31-
kwargs = Array{Any, 1}()
32-
if is_proximable(nonsmooth)
33-
g = extract_proximable(x, nonsmooth)
34-
append!(kwargs, [(:g, g)])
35-
if !isempty(quadratic)
36-
fq = extract_functions(quadratic)
37-
Aq = extract_operators(x, quadratic)
38-
append!(kwargs, [(:fq, fq)])
39-
append!(kwargs, [(:Aq, Aq)])
40-
end
41-
if !isempty(smooth)
42-
if is_linear(smooth)
43-
fs = extract_functions(smooth)
44-
As = extract_operators(x, smooth)
45-
append!(kwargs, [(:As, As)])
46-
else
47-
fs = extract_functions_nodisp(smooth)
48-
As = extract_affines(x, smooth)
49-
fs = PrecomposeNonlinear(fs, As)
50-
end
51-
append!(kwargs, [(:fs, fs)])
52-
end
53-
return build_iterator(x, solver; kwargs...)
54-
end
55-
error("Sorry, I cannot solve this problem")
26+
x = extract_variables(terms)
27+
# Separate smooth and nonsmooth
28+
smooth, nonsmooth = split_smooth(terms)
29+
# Separate quadratic and nonquadratic
30+
quadratic, smooth = split_quadratic(smooth)
31+
kwargs = Array{Any, 1}()
32+
if is_proximable(nonsmooth)
33+
g = extract_proximable(x, nonsmooth)
34+
append!(kwargs, [(:g, g)])
35+
if !isempty(quadratic)
36+
fq = extract_functions(quadratic)
37+
Aq = extract_operators(x, quadratic)
38+
append!(kwargs, [(:fq, fq)])
39+
append!(kwargs, [(:Aq, Aq)])
40+
end
41+
if !isempty(smooth)
42+
if is_linear(smooth)
43+
fs = extract_functions(smooth)
44+
As = extract_operators(x, smooth)
45+
append!(kwargs, [(:As, As)])
46+
else
47+
fs = extract_functions_nodisp(smooth)
48+
As = extract_affines(x, smooth)
49+
fs = PrecomposeNonlinear(fs, As)
50+
end
51+
append!(kwargs, [(:fs, fs)])
52+
end
53+
return build_iterator(x, solver; kwargs...)
54+
end
55+
error("Sorry, I cannot solve this problem")
5656
end
5757

5858
################################################################################
@@ -83,10 +83,10 @@ julia> solve!(x_solver);
8383
8484
"""
8585
function solve!(x_and_iter::Tuple{Tuple{Vararg{Variable}}, ProximalAlgorithms.ProximalAlgorithm})
86-
x, iterator = x_and_iter
87-
it, x_star = ProximalAlgorithms.run!(iterator)
88-
~x .= x_star
89-
return it, iterator
86+
x, iterator = x_and_iter
87+
it, x_star = ProximalAlgorithms.run!(iterator)
88+
~x .= x_star
89+
return it, iterator
9090
end
9191

9292

@@ -109,15 +109,15 @@ Variable(Float64, (4,))
109109
julia> A, b = randn(10,4), randn(10);
110110
111111
julia> solve(p,PG());
112-
it | gamma | fpr |
113-
------|------------|------------|
114-
1 | 7.6375e-02 | 1.8690e+00 |
115-
12 | 7.6375e-02 | 9.7599e-05 |
112+
it | gamma | fpr |
113+
------|------------|------------|
114+
1 | 7.6375e-02 | 1.8690e+00 |
115+
12 | 7.6375e-02 | 9.7599e-05 |
116116
117117
```
118118
119119
"""
120120
function solve(terms::Tuple, solver::ForwardBackwardSolver)
121-
built_slv = build(terms, solver)
122-
return solve!(built_slv)
121+
built_slv = build(terms, solver)
122+
return solve!(built_slv)
123123
end

0 commit comments

Comments
 (0)