-
-
Notifications
You must be signed in to change notification settings - Fork 83
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
Manopt.jl integration #437
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0ee5078
basic Riemannian Nelder-Mead and gradient descent
mateuszbaran 58519d6
minor improvements
mateuszbaran 682cf30
docs stub
mateuszbaran a3715d8
more work on Manopt glue code
mateuszbaran 1717303
Documentation and some fixes for Manopt quasi-Newton call
mateuszbaran 129aefc
Merge branch 'master' into mbaran/manopt
mateuszbaran 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 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 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 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 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 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,81 @@ | ||
# [Manopt.jl](@id manopt) | ||
[`Manopt`](https://github.com/JuliaManifolds/Manopt.jl) is Julia package implementing various algorithm focusing on manifold-based constraints. When all or some of the constraints are in the form of Riemannian manifolds, optimization can be often performed more efficiently than with generic methods handling equality or inequality constraints. | ||
|
||
See [`Manifolds`](https://github.com/JuliaManifolds/Manifolds.jl) for a library of manifolds that can be used as constraints. | ||
|
||
## Installation: OptimizationManopt.jl | ||
|
||
To use this package, install the `OptimizationManopt` package: | ||
|
||
```julia | ||
import Pkg; Pkg.add("OptimizationManopt") | ||
``` | ||
|
||
## Methods | ||
|
||
`Manopt.jl` algorithms can be accessed via Optimization.jl using one of the following optimizers: | ||
|
||
- `ConjugateGradientDescentOptimizer` | ||
- `GradientDescentOptimizer` | ||
- `NelderMeadOptimizer` | ||
- `ParticleSwarmOptimizer` | ||
- `QuasiNewtonOptimizer` | ||
|
||
For a more extensive documentation of all the algorithms and options please consult the [`Documentation`](https://manoptjl.org/stable/). | ||
|
||
## Local Optimizer | ||
|
||
### Derivative-Free | ||
|
||
The Nelder-Mead optimizer can be used for local derivative-free optimization on manifolds. | ||
|
||
```@example Manopt1 | ||
using Optimization, OptimizationManopt, Manifolds | ||
rosenbrock(x, p) = (1 - x[1])^2 + 100 * (x[2] - x[1]^2)^2 | ||
x0 = [0.0, 1.0] | ||
p = [1.0,100.0] | ||
f = OptimizationFunction(rosenbrock) | ||
opt = OptimizationManopt.NelderMeadOptimizer(Sphere(1)) | ||
prob = Optimization.OptimizationProblem(f, x0, p) | ||
sol = solve(prob, opt) | ||
``` | ||
|
||
### Gradient-Based | ||
|
||
Manopt offers gradient descent, conjugate gradient descent and quasi-Newton solvers for local gradient-based optimization. | ||
|
||
Note that the returned gradient needs to be Riemannian, see for example [https://manoptjl.org/stable/functions/gradients/](https://manoptjl.org/stable/functions/gradients/). | ||
Note that one way to obtain a Riemannian gradient is by [projection and (optional) Riesz representer change](https://juliamanifolds.github.io/Manifolds.jl/latest/features/differentiation.html#Manifolds.RiemannianProjectionBackend). | ||
|
||
```@example Manopt2 | ||
using Optimization, OptimizationManopt, Manifolds | ||
rosenbrock(x, p) = (1 - x[1])^2 + 100 * (x[2] - x[1]^2)^2 | ||
function rosenbrock_grad!(storage, x, p) | ||
storage[1] = -2.0 * (p[1] - x[1]) - 4.0 * p[2] * (x[2] - x[1]^2) * x[1] | ||
storage[2] = 2.0 * p[2] * (x[2] - x[1]^2) | ||
project!(Sphere(1), storage, x, storage) | ||
end | ||
x0 = [0.0, 1.0] | ||
p = [1.0,100.0] | ||
f = OptimizationFunction(rosenbrock; grad = rosenbrock_grad!) | ||
opt = OptimizationManopt.GradientDescentOptimizer(Sphere(1)) | ||
prob = Optimization.OptimizationProblem(f, x0, p) | ||
sol = solve(prob, opt) | ||
``` | ||
|
||
## Global Optimizer | ||
|
||
### Without Constraint Equations | ||
|
||
The particle swarm optimizer can be used for global optimization on a manifold without constraint equations. It can be especially useful on compact manifolds such as spheres or orthogonal matrices. | ||
|
||
```@example Manopt3 | ||
using Optimization, OptimizationManopt, Manifolds | ||
rosenbrock(x, p) = (1 - x[1])^2 + 100 * (x[2] - x[1]^2)^2 | ||
x0 = [0.0, 1.0] | ||
p = [1.0,100.0] | ||
f = OptimizationFunction(rosenbrock) | ||
opt = OptimizationManopt.ParticleSwarmOptimizer(Sphere(1)) | ||
prob = Optimization.OptimizationProblem(f, x0, p) | ||
sol = solve(prob, opt) | ||
``` |
This file contains 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 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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Julia Manifolds | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains 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,10 @@ | ||
name = "OptimizationManopt" | ||
uuid = "e57b7fff-7ee7-4550-b4f0-90e9476e9fb6" | ||
authors = ["Mateusz Baran <[email protected]>"] | ||
version = "0.1.0" | ||
|
||
[deps] | ||
Manifolds = "1cead3c2-87b3-11e9-0ccd-23c62b72b94e" | ||
ManifoldsBase = "3362f125-f0bb-47a3-aa74-596ffd7ef2fb" | ||
Manopt = "0fc0a36d-df90-57f3-8f93-d78a9fc72bb5" | ||
Optimization = "7f7a1694-90dd-40f0-9382-eb1efda571ba" |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...actually ( ;) ) the convergence is the same local quadratic convergence as for the Euclidean case.