Skip to content

Commit

Permalink
Using more general calculus rules (#18)
Browse files Browse the repository at this point in the history
* using Ax_mul_Bx and HadamardProd instead of NonLinearCompose and Hadamard

* added Ax_mul_Bxt and Axt_mul_Bx

* fix to docs
  • Loading branch information
nantonel authored Mar 28, 2019
1 parent d90fe83 commit 2620090
Show file tree
Hide file tree
Showing 11 changed files with 399 additions and 326 deletions.
2 changes: 1 addition & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ makedocs(
)

deploydocs(
repo = "github.com/kul-forbes/AbstractOperators.jl.git",
repo = "github.com/kul-forbes/StructuredOptimization.jl.git",
target = "build",
)
80 changes: 40 additions & 40 deletions src/solvers/build_solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,36 +23,36 @@ julia> build(p, PG());
"""
function build(terms::Tuple, solver::ForwardBackwardSolver)
x = extract_variables(terms)
# Separate smooth and nonsmooth
smooth, nonsmooth = split_smooth(terms)
# Separate quadratic and nonquadratic
quadratic, smooth = split_quadratic(smooth)
kwargs = Array{Any, 1}()
if is_proximable(nonsmooth)
g = extract_proximable(x, nonsmooth)
append!(kwargs, [(:g, g)])
if !isempty(quadratic)
fq = extract_functions(quadratic)
Aq = extract_operators(x, quadratic)
append!(kwargs, [(:fq, fq)])
append!(kwargs, [(:Aq, Aq)])
end
if !isempty(smooth)
if is_linear(smooth)
fs = extract_functions(smooth)
As = extract_operators(x, smooth)
append!(kwargs, [(:As, As)])
else
fs = extract_functions_nodisp(smooth)
As = extract_affines(x, smooth)
fs = PrecomposeNonlinear(fs, As)
end
append!(kwargs, [(:fs, fs)])
end
return build_iterator(x, solver; kwargs...)
end
error("Sorry, I cannot solve this problem")
x = extract_variables(terms)
# Separate smooth and nonsmooth
smooth, nonsmooth = split_smooth(terms)
# Separate quadratic and nonquadratic
quadratic, smooth = split_quadratic(smooth)
kwargs = Array{Any, 1}()
if is_proximable(nonsmooth)
g = extract_proximable(x, nonsmooth)
append!(kwargs, [(:g, g)])
if !isempty(quadratic)
fq = extract_functions(quadratic)
Aq = extract_operators(x, quadratic)
append!(kwargs, [(:fq, fq)])
append!(kwargs, [(:Aq, Aq)])
end
if !isempty(smooth)
if is_linear(smooth)
fs = extract_functions(smooth)
As = extract_operators(x, smooth)
append!(kwargs, [(:As, As)])
else
fs = extract_functions_nodisp(smooth)
As = extract_affines(x, smooth)
fs = PrecomposeNonlinear(fs, As)
end
append!(kwargs, [(:fs, fs)])
end
return build_iterator(x, solver; kwargs...)
end
error("Sorry, I cannot solve this problem")
end

################################################################################
Expand Down Expand Up @@ -83,10 +83,10 @@ julia> solve!(x_solver);
"""
function solve!(x_and_iter::Tuple{Tuple{Vararg{Variable}}, ProximalAlgorithms.ProximalAlgorithm})
x, iterator = x_and_iter
it, x_star = ProximalAlgorithms.run!(iterator)
~x .= x_star
return it, iterator
x, iterator = x_and_iter
it, x_star = ProximalAlgorithms.run!(iterator)
~x .= x_star
return it, iterator
end


Expand All @@ -109,15 +109,15 @@ Variable(Float64, (4,))
julia> A, b = randn(10,4), randn(10);
julia> solve(p,PG());
it | gamma | fpr |
------|------------|------------|
1 | 7.6375e-02 | 1.8690e+00 |
12 | 7.6375e-02 | 9.7599e-05 |
it | gamma | fpr |
------|------------|------------|
1 | 7.6375e-02 | 1.8690e+00 |
12 | 7.6375e-02 | 9.7599e-05 |
```
"""
function solve(terms::Tuple, solver::ForwardBackwardSolver)
built_slv = build(terms, solver)
return solve!(built_slv)
built_slv = build(terms, solver)
return solve!(built_slv)
end
Loading

0 comments on commit 2620090

Please sign in to comment.