Skip to content
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
e9534d9
First few steps towards handling Keywords.
kellertuer Aug 21, 2025
930c10f
Start a first list.
kellertuer Aug 21, 2025
0714780
runs formatter
kellertuer Aug 21, 2025
dbd1145
Define two macros to extract and extend Keyword arguments.
kellertuer Aug 22, 2025
e4e7fd8
I noticed that there might be different signatures, add a roadmap how…
kellertuer Aug 22, 2025
cbec114
move internal keywords more consistently to a `_` prefix and sketch t…
kellertuer Aug 22, 2025
b32aac2
Update src/plans/keywords.jl
kellertuer Aug 22, 2025
dc05c50
Switch to a much easier form with one internal function.
kellertuer Aug 23, 2025
83ed046
Merge branch 'master' into kellertuer/accepted-keywords
kellertuer Sep 7, 2025
3bb35fc
Add first prototype.
kellertuer Sep 7, 2025
0535fa4
Fix a doc string.
kellertuer Sep 7, 2025
a6aacf3
fix another typo.
kellertuer Sep 7, 2025
2d89801
Fix documentation.
kellertuer Sep 7, 2025
9afc485
add the keyword check to solvers until CMAES
kellertuer Sep 7, 2025
057376f
Start Changelog.
kellertuer Sep 7, 2025
6c72a51
Missed to fix the typo in the docs.
kellertuer Sep 7, 2025
e2ba7d3
fix a call.
kellertuer Sep 7, 2025
688f4f7
further work on keyword checks
kellertuer Sep 8, 2025
c32d458
rename the in keyword to from
kellertuer Sep 8, 2025
d3968f8
Add the remaining tests
kellertuer Sep 8, 2025
2277c79
Merge branch 'master' into kellertuer/accepted-keywords
kellertuer Sep 8, 2025
2573cf5
Fix two small bugs, one old one I only saw due to the new warnings (a…
kellertuer Sep 8, 2025
ceb4c46
Work a bit on code coverage.
kellertuer Sep 8, 2025
8ca3c4a
export keywords_accepted as an interface function.
kellertuer Sep 8, 2025
26152e1
fix a typo.
kellertuer Sep 8, 2025
e44d3ee
Fix documentation.
kellertuer Sep 8, 2025
63042ff
Error printing and hints.
kellertuer Sep 8, 2025
db36735
further tests.
kellertuer Sep 8, 2025
d040dc9
Update src/plans/keywords.jl
kellertuer Sep 9, 2025
51acc8b
Update src/plans/keywords.jl
kellertuer Sep 9, 2025
01d386f
Simplify `origins` to always be a vector.
kellertuer Sep 9, 2025
72bd3d2
Merge branch 'master' into kellertuer/accepted-keywords
kellertuer Sep 9, 2025
87188f4
Bump version number.
kellertuer Sep 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,21 @@ The file was started with Version `0.4`.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.5.22] unreleased

### Added

* a `keywords_accepted(f, mode=:warn; kwargs...)` function that verifies that all keywords are accepted by a certain function.
* an internal function `calls_with_kwargs(f)` to indicate which functions `f` passes `kwargs...` to.
* a `KeywordsErrorMode` preference parameter to control how keywords that are not used/allowed should be treated. Values are `"none"`, `"warn"` (default), and `"error"`.

* the typo in the name `AdaptiveRgularizationWithCubicsModelObjective` is fixed to `AdaptiveRegularizationWithCubicsModelObjective`.

## [0.5.21] September 5, 2025

### Added

* a system to track keywords, warning when unused ones are passed and a static way to explore possible keywords.
* a `warm_start_factor` field to `ProximalGradientMethodBacktrackingStepsize` to allow to scale the stepsize in the backtracking procedure.
* a `gradient=` keyword in several `Stepsize`s, such that one can avoid to internally avoid computing the gradient again.
* used the ``gradient=` keyword in
Expand Down
21 changes: 20 additions & 1 deletion docs/src/plans/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,30 @@ You can further activate a “Tutorial” mode by `set_parameter!(:Mode, "Tutori
Manopt.is_tutorial_mode
```

# A factory for providing manifold defaults
## A factory for providing manifold defaults

In several cases a manifold might not yet be known at the time a (keyword) argument should be provided. Therefore, any type with a manifold default can be wrapped into a factory.

```@docs
Manopt.ManifoldDefaultsFactory
Manopt._produce_type
```

## Keyword arguments and their verification

Internally `Manopt.jl` passes keywords for the (high-level) solver
functions to several inner functions, e.g. to add debug or caching.
Besides the documentation, one can check with the internal function [`Manopt.accepted_keywords`](@ref) which keywords a solver accepts.

A solver also warns, if a keyword is passed, that is not handled by the
solver or any of the inner functions it calls.

```@docs
Manopt.Keywords
Manopt.accepted_keywords
Manopt.ManoptKeywordError
Manopt.add!
Manopt.calls_with_kwargs
Manopt.direct_keywords
Manopt.keywords_accepted
```
4 changes: 2 additions & 2 deletions docs/src/solvers/adaptive-regularization-with-cubics.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ Manopt.LanczosState
There is a generic objective, that implements the sub problem

```@docs
AdaptiveRagularizationWithCubicsModelObjective
AdaptiveRegularizationWithCubicsModelObjective
```

Since the sub problem is given on the tangent space, you have to provide

```
arc_obj = AdaptiveRagularizationWithCubicsModelObjective(mho, σ)
arc_obj = AdaptiveRegularizationWithCubicsModelObjective(mho, σ)
sub_problem = DefaultProblem(TangentSpaceAt(M,p), arc_obj)
```

Expand Down
2 changes: 2 additions & 0 deletions ext/ManoptRecursiveArrayToolsExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ end
function alternating_gradient_descent(
M::ProductManifold, ago::ManifoldAlternatingGradientObjective, p; kwargs...
)
Manopt.keywords_accepted(alternating_gradient_descent; kwargs...)
q = copy(M, p)
return alternating_gradient_descent!(M, ago, q; kwargs...)
end
Expand Down Expand Up @@ -110,6 +111,7 @@ function alternating_gradient_descent!(
retraction_method::AbstractRetractionMethod = default_retraction_method(M, typeof(p)),
kwargs...,
)
Manopt.keywords_accepted(alternating_gradient_descent!; kwargs...)
dagmo = Manopt.decorate_objective!(M, agmo; kwargs...)
dmp = DefaultManoptProblem(M, dagmo)
agds = AlternatingGradientDescentState(
Expand Down
5 changes: 3 additions & 2 deletions src/Manopt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ include("solvers/conjugate_gradient_descent.jl")
include("solvers/conjugate_residual.jl")
include("solvers/cyclic_proximal_point.jl")
include("solvers/difference_of_convex_algorithm.jl")
include("solvers/difference-of-convex-proximal-point.jl")
include("solvers/difference_of_convex_proximal_point.jl")
include("solvers/DouglasRachford.jl")
include("solvers/exact_penalty_method.jl")
include("solvers/projected_gradient_method.jl")
Expand Down Expand Up @@ -481,6 +481,7 @@ export adaptive_regularization_with_cubics,
gradient_descent!,
interior_point_Newton,
interior_point_Newton!,
keywords_accepted,
LevenbergMarquardt,
LevenbergMarquardt!,
mesh_adaptive_direct_search,
Expand Down Expand Up @@ -516,7 +517,7 @@ export solve!
export ApproxHessianFiniteDifference, ApproxHessianSymmetricRankOne, ApproxHessianBFGS
export update_hessian!, update_hessian_basis!
export ExactPenaltyCost, ExactPenaltyGrad, AugmentedLagrangianCost, AugmentedLagrangianGrad
export AdaptiveRagularizationWithCubicsModelObjective
export AdaptiveRegularizationWithCubicsModelObjective
export ExactPenaltyCost, ExactPenaltyGrad
export SmoothingTechnique, LinearQuadraticHuber, LogarithmicSumOfExponentials
#
Expand Down
2 changes: 2 additions & 0 deletions src/documentation_glossary.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ define!(:LaTeX, :bar, (letter) -> raw"\bar" * "$(letter)")
define!(:LaTeX, :big, raw"\big")
define!(:LaTeX, :bigl, raw"\bigl")
define!(:LaTeX, :bigr, raw"\bigr")
define!(:LaTeX, :biggl, raw"\biggl")
define!(:LaTeX, :biggr, raw"\biggr")
define!(:LaTeX, :Big, raw"\Big")
define!(:LaTeX, :Bigl, raw"\Bigl")
define!(:LaTeX, :Bigr, raw"\Bigr")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@doc """
AdaptiveRagularizationWithCubicsModelObjective
AdaptiveRegularizationWithCubicsModelObjective

A model for the adaptive regularization with Cubics

Expand All @@ -17,40 +17,40 @@ cf. Eq. (33) in [AgarwalBoumalBullinsCartis:2020](@cite)

# Constructors

AdaptiveRagularizationWithCubicsModelObjective(mho, σ=1.0)
AdaptiveRegularizationWithCubicsModelObjective(mho, σ=1.0)

with either an [`AbstractManifoldHessianObjective`](@ref) `objective` or an decorator containing such an objective.
"""
mutable struct AdaptiveRagularizationWithCubicsModelObjective{
mutable struct AdaptiveRegularizationWithCubicsModelObjective{
E <: AbstractEvaluationType,
O <: Union{ManifoldHessianObjective, AbstractDecoratedManifoldObjective},
R,
} <: AbstractManifoldSubObjective{E, O}
objective::O
σ::R
end
function AdaptiveRagularizationWithCubicsModelObjective(
function AdaptiveRegularizationWithCubicsModelObjective(
mho::O, σ::R = 1.0
) where {
E, O <: Union{AbstractManifoldHessianObjective{E}, AbstractDecoratedManifoldObjective{E}}, R,
}
return AdaptiveRagularizationWithCubicsModelObjective{E, O, R}(mho, σ)
return AdaptiveRegularizationWithCubicsModelObjective{E, O, R}(mho, σ)
end
function set_parameter!(
f::AdaptiveRagularizationWithCubicsModelObjective,
f::AdaptiveRegularizationWithCubicsModelObjective,
::Union{Val{:σ}, Val{:RegularizationParameter}},
σ,
)
f.σ = σ
return f
end

get_objective(arcmo::AdaptiveRagularizationWithCubicsModelObjective) = arcmo.objective
get_objective(arcmo::AdaptiveRegularizationWithCubicsModelObjective) = arcmo.objective

@doc """
get_cost(TpM, trmo::AdaptiveRagularizationWithCubicsModelObjective, X)
get_cost(TpM, trmo::AdaptiveRegularizationWithCubicsModelObjective, X)

Evaluate the tangent space [`AdaptiveRagularizationWithCubicsModelObjective`](@ref)
Evaluate the tangent space [`AdaptiveRegularizationWithCubicsModelObjective`](@ref)

```math
m(X) = f(p) + ⟨$(_tex(:grad)) f(p), X ⟩_p + $(_tex(:frac, "1", "2")) ⟨$(_tex(:Hess)) f(p)[X], X⟩_p
Expand All @@ -60,7 +60,7 @@ m(X) = f(p) + ⟨$(_tex(:grad)) f(p), X ⟩_p + $(_tex(:frac, "1", "2")) ⟨$(_t
at `X`, cf. Eq. (33) in [AgarwalBoumalBullinsCartis:2020](@cite).
"""
function get_cost(
TpM::TangentSpace, arcmo::AdaptiveRagularizationWithCubicsModelObjective, X
TpM::TangentSpace, arcmo::AdaptiveRegularizationWithCubicsModelObjective, X
)
M = base_manifold(TpM)
p = TpM.point
Expand All @@ -69,13 +69,13 @@ function get_cost(
Y = get_objective_hessian(M, arcmo, p, X)
return c + inner(M, p, G, X) + 1 / 2 * inner(M, p, Y, X) + arcmo.σ / 3 * norm(M, p, X)^3
end
function get_cost_function(arcmo::AdaptiveRagularizationWithCubicsModelObjective)
function get_cost_function(arcmo::AdaptiveRegularizationWithCubicsModelObjective)
return (TpM, X) -> get_cost(TpM, arcmo, X)
end
@doc """
get_gradient(TpM, trmo::AdaptiveRagularizationWithCubicsModelObjective, X)
get_gradient(TpM, trmo::AdaptiveRegularizationWithCubicsModelObjective, X)

Evaluate the gradient of the [`AdaptiveRagularizationWithCubicsModelObjective`](@ref)
Evaluate the gradient of the [`AdaptiveRegularizationWithCubicsModelObjective`](@ref)

```math
$(_tex(:grad)) m(X) = $(_tex(:grad)) f(p) + $(_tex(:Hess)) f(p)[X]
Expand All @@ -85,22 +85,22 @@ $(_tex(:grad)) m(X) = $(_tex(:grad)) f(p) + $(_tex(:Hess)) f(p)[X]
at `X`, cf. Eq. (37) in [AgarwalBoumalBullinsCartis:2020](@cite).
"""
function get_gradient(
TpM::TangentSpace, arcmo::AdaptiveRagularizationWithCubicsModelObjective, X
TpM::TangentSpace, arcmo::AdaptiveRegularizationWithCubicsModelObjective, X
)
M = base_manifold(TpM)
p = TpM.point
G = get_objective_gradient(M, arcmo, p)
return G + get_objective_hessian(M, arcmo, p, X) + arcmo.σ * norm(M, p, X) * X
end
function get_gradient!(
TpM::TangentSpace, Y, arcmo::AdaptiveRagularizationWithCubicsModelObjective, X
TpM::TangentSpace, Y, arcmo::AdaptiveRegularizationWithCubicsModelObjective, X
)
M = base_manifold(TpM)
p = TpM.point
get_objective_hessian!(M, Y, arcmo, p, X)
Y .= Y + get_objective_gradient(M, arcmo, p) + arcmo.σ * norm(M, p, X) * X
return Y
end
function get_gradient_function(arcmo::AdaptiveRagularizationWithCubicsModelObjective)
function get_gradient_function(arcmo::AdaptiveRegularizationWithCubicsModelObjective)
return (TpM, X) -> get_gradient(TpM, arcmo, X)
end
16 changes: 9 additions & 7 deletions src/plans/augmented_lagrangian_plan.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
_doc_AL_Cost(iter) = "$(_tex(:Cal, "L"))_{ρ^{($iter)}}(p, μ^{($iter)}, λ^{($iter)})"
_doc_AL_Cost_long = raw"""
_doc_AL_Cost_long = """
```math
\mathcal L_\rho(p, μ, λ)
= f(x) + $(_tex(:frac, "ρ", "2")) \biggl(
\sum_{j=1}^n \Bigl( h_j(p) + $(_tex(:frac, "λ_j", "ρ")) \Bigr)^2
+
\sum_{i=1}^m \max\Bigl\{ 0, $(_tex(:frac, "μ_i", "ρ} + g_i(p) \Bigr\"))^2
\Bigr)
$(_tex(:Cal, "L"))_ρ(p, μ, λ)
= f(x) + $(_tex(:frac, "ρ", "2"))$(_tex(:biggl))(
$(_tex(:sum, "j=1", "n"))$(_tex(:Bigl))(
h_j(p) + $(_tex(:frac, "λ_j", "ρ"))
$(_tex(:Bigr)))^2
+
$(_tex(:sum, "i=1", "m"))$(_tex(:max))$(_tex(:set, "0, $(_tex(:frac, "μ_i", "ρ")) + g_i(p)"))^2
$(_tex(:biggr)))
```
"""

Expand Down
Loading
Loading