-
Notifications
You must be signed in to change notification settings - Fork 10
update solvers to follow ProximalAlgorithms #19
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
28e597b
update solvers to follow ProximalAlgorithms
lostella 5ca0bdd
updated title
lostella cf16336
remove println
lostella 33d08af
REQUIRE -> Project.toml
lostella aa3728e
re-enabled tests
lostella d3a1b3e
increment tolerances a bit
lostella 727b81a
add Julia 1.2 to travis
lostella File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import ProximalOperators | ||
| import RecursiveArrayTools | ||
|
|
||
| @inline function ProximalOperators.prox( | ||
| h::ProximalOperators.ProximableFunction, | ||
| x::RecursiveArrayTools.ArrayPartition, | ||
| gamma... | ||
| ) | ||
| # unwrap | ||
| y, fy = ProximalOperators.prox(h, x.x, gamma...) | ||
| # wrap | ||
| return RecursiveArrayTools.ArrayPartition(y), fy | ||
| end | ||
|
|
||
| @inline function ProximalOperators.gradient( | ||
| h::ProximalOperators.ProximableFunction, | ||
| x::RecursiveArrayTools.ArrayPartition | ||
| ) | ||
| # unwrap | ||
| grad, fx = ProximalOperators.gradient(h, x.x) | ||
| # wrap | ||
| return RecursiveArrayTools.ArrayPartition(grad), fx | ||
| end | ||
|
|
||
| @inline ProximalOperators.prox!( | ||
| y::RecursiveArrayTools.ArrayPartition, | ||
| h::ProximalOperators.ProximableFunction, | ||
| x::RecursiveArrayTools.ArrayPartition, | ||
| gamma... | ||
| ) = ProximalOperators.prox!(y.x, h, x.x, gamma...) | ||
|
|
||
| @inline ProximalOperators.gradient!( | ||
| y::RecursiveArrayTools.ArrayPartition, | ||
| h::ProximalOperators.ProximableFunction, | ||
| x::RecursiveArrayTools.ArrayPartition | ||
| ) = ProximalOperators.gradient!(y.x, h, x.x) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,105 +1,9 @@ | ||
| abstract type Solver end | ||
| using ProximalAlgorithms | ||
|
|
||
| abstract type ForwardBackwardSolver <: Solver end | ||
| const ForwardBackwardSolver = Union{ | ||
| ProximalAlgorithms.ForwardBackward, | ||
| ProximalAlgorithms.ZeroFPR, | ||
| ProximalAlgorithms.PANOC, | ||
| } | ||
|
|
||
| export Solver, ForwardBackwardSolver | ||
|
|
||
| ################################################################################ | ||
| export PG, FPG | ||
|
|
||
| """ | ||
| `PG(;kwargs...)` | ||
|
|
||
| Creates an object `PG` containing the options of the Proximal Gradient solvers: | ||
|
|
||
| * `gamma`, stepsize (default: unspecified, determined automatically) | ||
| * `maxit`, maximum number of iteration (default: `10000`) | ||
| * `tol`, halting tolerance on the fixed-point residual (default: `1e-4`) | ||
| * `adaptive`, adaptively adjust `gamma` (default: `false` if `gamma` is provided) | ||
| * `fast`, enables accelerated method (default: `false`) | ||
| * `verbose`, verbosity level (default: `1`) | ||
| * `verbose_freq`, verbosity frequency for `verbose = 1` (default: `100`) | ||
|
|
||
| """ | ||
| struct PG <: ForwardBackwardSolver | ||
| kwargs::Iterators.Pairs | ||
| function PG(; kwargs...) | ||
| new(kwargs) | ||
| end | ||
| end | ||
|
|
||
| """ | ||
| `FPG(;kwargs...)` | ||
|
|
||
| Same as `PG`, creates the options of the Fast Proximal Gradient solver. | ||
|
|
||
| """ | ||
| function FPG(; kwargs...) | ||
| return PG(; kwargs..., fast=true) | ||
| end | ||
|
|
||
| function build_iterator(x, solver::PG; kwargs...) | ||
| x, ProximalAlgorithms.FBSIterator(~x; solver.kwargs..., kwargs...) | ||
| end | ||
|
|
||
| ################################################################################ | ||
| export ZeroFPR | ||
|
|
||
| """ | ||
| `ZeroFPR(;kwargs...)` | ||
|
|
||
| Creates an object `ZeroFPR` containing the options of the ZeroFPR solver: | ||
|
|
||
| * `gamma`, stepsize (default: unspecified, determined automatically) | ||
| * `maxit`, maximum number of iteration (default: `10000`) | ||
| * `tol`, halting tolerance on the fixed-point residual (default: `1e-4`) | ||
| * `adaptive`, adaptively adjust `gamma` (default: `false` if `gamma` is provided) | ||
| * `fast`, enables accelerated method (default: `false`) | ||
| * `verbose`, verbosity level (default: `1`) | ||
| * `verbose_freq`, verbosity frequency for `verbose = 1` (default: `100`) | ||
| * `memory`, memory of the `LBFGS` operator (default: `10` ) | ||
|
|
||
| """ | ||
| struct ZeroFPR <: ForwardBackwardSolver | ||
| kwargs::Iterators.Pairs | ||
| function ZeroFPR(; kwargs...) | ||
| new(kwargs) | ||
| end | ||
| end | ||
|
|
||
| function build_iterator(x, solver::ZeroFPR; kwargs...) | ||
| x, ProximalAlgorithms.ZeroFPRIterator(~x; solver.kwargs..., kwargs...) | ||
| end | ||
|
|
||
| ################################################################################ | ||
| export PANOC | ||
|
|
||
| """ | ||
| `ZeroFPR(;kwargs...)` | ||
|
|
||
| Creates an object `PANOC` containing the options of the PANOC solver: | ||
|
|
||
| * `gamma`, stepsize (default: unspecified, determined automatically) | ||
| * `maxit`, maximum number of iteration (default: `10000`) | ||
| * `tol`, halting tolerance on the fixed-point residual (default: `1e-4`) | ||
| * `adaptive`, adaptively adjust `gamma` (default: `false` if `gamma` is provided) | ||
| * `fast`, enables accelerated method (default: `false`) | ||
| * `verbose`, verbosity level (default: `1`) | ||
| * `verbose_freq`, verbosity frequency for `verbose = 1` (default: `100`) | ||
| * `memory`, memory of the `LBFGS` operator (default: `10` ) | ||
|
|
||
| """ | ||
| struct PANOC <: ForwardBackwardSolver | ||
| kwargs::Iterators.Pairs | ||
| function PANOC(; kwargs...) | ||
| new(kwargs) | ||
| end | ||
| end | ||
|
|
||
| function build_iterator(x, solver::PANOC; kwargs...) | ||
| x, ProximalAlgorithms.PANOCIterator(~x; solver.kwargs..., kwargs...) | ||
| end | ||
|
|
||
| default_solver = PANOC | ||
|
|
||
| ################################################################################ | ||
| const default_solver = ProximalAlgorithms.PANOC |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.