Skip to content

Commit 9c160ef

Browse files
committed
docs: trust region docstring
1 parent 8f27d1f commit 9c160ef

File tree

1 file changed

+44
-45
lines changed

1 file changed

+44
-45
lines changed

lib/SimpleNonlinearSolve/src/trust_region.jl

Lines changed: 44 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,47 @@
1-
2-
# """
3-
# SimpleTrustRegion(; autodiff = AutoForwardDiff(), max_trust_radius = 0.0,
4-
# initial_trust_radius = 0.0, step_threshold = nothing,
5-
# shrink_threshold = nothing, expand_threshold = nothing,
6-
# shrink_factor = 0.25, expand_factor = 2.0, max_shrink_times::Int = 32,
7-
# nlsolve_update_rule = Val(false))
8-
9-
# A low-overhead implementation of a trust-region solver. This method is non-allocating on
10-
# scalar and static array problems.
11-
12-
# ### Keyword Arguments
13-
14-
# - `autodiff`: determines the backend used for the Jacobian. Defaults to `nothing` (i.e.
15-
# automatic backend selection). Valid choices include jacobian backends from
16-
# `DifferentiationInterface.jl`.
17-
# - `max_trust_radius`: the maximum radius of the trust region. Defaults to
18-
# `max(norm(f(u0)), maximum(u0) - minimum(u0))`.
19-
# - `initial_trust_radius`: the initial trust region radius. Defaults to
20-
# `max_trust_radius / 11`.
21-
# - `step_threshold`: the threshold for taking a step. In every iteration, the threshold is
22-
# compared with a value `r`, which is the actual reduction in the objective function divided
23-
# by the predicted reduction. If `step_threshold > r` the model is not a good approximation,
24-
# and the step is rejected. Defaults to `0.1`. For more details, see
25-
# [Rahpeymaii, F.](https://link.springer.com/article/10.1007/s40096-020-00339-4)
26-
# - `shrink_threshold`: the threshold for shrinking the trust region radius. In every
27-
# iteration, the threshold is compared with a value `r` which is the actual reduction in the
28-
# objective function divided by the predicted reduction. If `shrink_threshold > r` the trust
29-
# region radius is shrunk by `shrink_factor`. Defaults to `0.25`. For more details, see
30-
# [Rahpeymaii, F.](https://link.springer.com/article/10.1007/s40096-020-00339-4)
31-
# - `expand_threshold`: the threshold for expanding the trust region radius. If a step is
32-
# taken, i.e `step_threshold < r` (with `r` defined in `shrink_threshold`), a check is also
33-
# made to see if `expand_threshold < r`. If that is true, the trust region radius is
34-
# expanded by `expand_factor`. Defaults to `0.75`.
35-
# - `shrink_factor`: the factor to shrink the trust region radius with if
36-
# `shrink_threshold > r` (with `r` defined in `shrink_threshold`). Defaults to `0.25`.
37-
# - `expand_factor`: the factor to expand the trust region radius with if
38-
# `expand_threshold < r` (with `r` defined in `shrink_threshold`). Defaults to `2.0`.
39-
# - `max_shrink_times`: the maximum number of times to shrink the trust region radius in a
40-
# row, `max_shrink_times` is exceeded, the algorithm returns. Defaults to `32`.
41-
# - `nlsolve_update_rule`: If set to `Val(true)`, updates the trust region radius using the
42-
# update rule from NLSolve.jl. Defaults to `Val(false)`. If set to `Val(true)`, few of the
43-
# radius update parameters -- `step_threshold = 0.05`, `expand_threshold = 0.9`, and
44-
# `shrink_factor = 0.5` -- have different defaults.
45-
# """
1+
"""
2+
SimpleTrustRegion(; autodiff = AutoForwardDiff(), max_trust_radius = 0.0,
3+
initial_trust_radius = 0.0, step_threshold = nothing,
4+
shrink_threshold = nothing, expand_threshold = nothing,
5+
shrink_factor = 0.25, expand_factor = 2.0, max_shrink_times::Int = 32,
6+
nlsolve_update_rule = Val(false))
7+
8+
A low-overhead implementation of a trust-region solver. This method is non-allocating on
9+
scalar and static array problems.
10+
11+
### Keyword Arguments
12+
13+
- `autodiff`: determines the backend used for the Jacobian. Defaults to `nothing` (i.e.
14+
automatic backend selection). Valid choices include jacobian backends from
15+
`DifferentiationInterface.jl`.
16+
- `max_trust_radius`: the maximum radius of the trust region. Defaults to
17+
`max(norm(f(u0)), maximum(u0) - minimum(u0))`.
18+
- `initial_trust_radius`: the initial trust region radius. Defaults to
19+
`max_trust_radius / 11`.
20+
- `step_threshold`: the threshold for taking a step. In every iteration, the threshold is
21+
compared with a value `r`, which is the actual reduction in the objective function divided
22+
by the predicted reduction. If `step_threshold > r` the model is not a good approximation,
23+
and the step is rejected. Defaults to `0.1`. For more details, see
24+
[Rahpeymaii, F.](https://link.springer.com/article/10.1007/s40096-020-00339-4)
25+
- `shrink_threshold`: the threshold for shrinking the trust region radius. In every
26+
iteration, the threshold is compared with a value `r` which is the actual reduction in the
27+
objective function divided by the predicted reduction. If `shrink_threshold > r` the trust
28+
region radius is shrunk by `shrink_factor`. Defaults to `0.25`. For more details, see
29+
[Rahpeymaii, F.](https://link.springer.com/article/10.1007/s40096-020-00339-4)
30+
- `expand_threshold`: the threshold for expanding the trust region radius. If a step is
31+
taken, i.e `step_threshold < r` (with `r` defined in `shrink_threshold`), a check is also
32+
made to see if `expand_threshold < r`. If that is true, the trust region radius is
33+
expanded by `expand_factor`. Defaults to `0.75`.
34+
- `shrink_factor`: the factor to shrink the trust region radius with if
35+
`shrink_threshold > r` (with `r` defined in `shrink_threshold`). Defaults to `0.25`.
36+
- `expand_factor`: the factor to expand the trust region radius with if
37+
`expand_threshold < r` (with `r` defined in `shrink_threshold`). Defaults to `2.0`.
38+
- `max_shrink_times`: the maximum number of times to shrink the trust region radius in a
39+
row, `max_shrink_times` is exceeded, the algorithm returns. Defaults to `32`.
40+
- `nlsolve_update_rule`: If set to `Val(true)`, updates the trust region radius using the
41+
update rule from NLSolve.jl. Defaults to `Val(false)`. If set to `Val(true)`, few of the
42+
radius update parameters -- `step_threshold = 0.05`, `expand_threshold = 0.9`, and
43+
`shrink_factor = 0.5` -- have different defaults.
44+
"""
4645
@kwdef @concrete struct SimpleTrustRegion <: AbstractSimpleNonlinearSolveAlgorithm
4746
autodiff = nothing
4847
max_trust_radius = 0.0

0 commit comments

Comments
 (0)