Skip to content

Commit 9fd0127

Browse files
committed
docs(advanced-jsosolvers): update TRUNK/TRON subsolver usage to new keyword API (fixes #145)
- Add migration note showing old subsolver_type => new subsolver=:symbol API - Update solver dictionary examples to use subsolver = :cgls, :crls, :lsqr, :lsmr - Add explicit TRUNK and TRON examples with subsolver, rtol, atol, max_time - Add reference to JSOSolvers allowed_subsolvers lists - Link to Krylov.jl docs for subsolver algorithm details - Fix grammar and copy edits (heading, wording, plurals)
1 parent 71339a3 commit 9fd0127

File tree

1 file changed

+28
-8
lines changed

1 file changed

+28
-8
lines changed

tutorials/advanced-jsosolvers/index.jmd

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ tags: ["solvers", "krylov", "benchmark", "least squares"]
44
author: "Tangi Migot"
55
---
66

7-
# Comparing subsolvers for nonlinear least squares JSOSolvers solvers
7+
# Comparing subsolvers for nonlinear least squares in JSOSolvers
88

99
This tutorial showcases some advanced features of solvers in JSOSolvers.
1010

1111
```julia
1212
using JSOSolvers
1313
```
1414

15-
We benchmark different subsolvers used in the solvers TRUNK for unconstrained nonlinear least squares problems.
15+
We benchmark different subsolvers used in the solver TRUNK for unconstrained nonlinear least squares problems.
1616
The first step is to select a set of problems that are nonlinear least squares.
1717

1818
```julia
@@ -38,7 +38,7 @@ For this task, several solvers are available.
3838
JSOSolvers.trunkls_allowed_subsolvers
3939
```
4040

41-
This benchmark could also be followed for the solver TRON where the following subsolver are available.
41+
This benchmark could also be followed for the solver TRON where the following subsolvers are available.
4242

4343
```julia
4444
JSOSolvers.tronls_allowed_subsolvers
@@ -50,15 +50,35 @@ These linear least squares solvers are implemented in the package [Krylov.jl](ht
5050
using Krylov
5151
```
5252

53+
For example, to call TRUNK with an explicit subsolver and tolerances:
54+
55+
```julia
56+
stats = trunk(nls; subsolver = :cgls)
57+
```
58+
5359
We define a dictionary of the different solvers that will be benchmarked.
5460
We consider here four variants of TRUNK using the different subsolvers.
5561

62+
The same subsolver selection pattern applies to TRON’s least-squares specialization:
63+
64+
```julia
65+
stats_tron = tron(nls; subsolver = :lsmr, rtol = RTOL, atol = ATOL, max_time = max_time)
66+
```
67+
68+
```julia
69+
solvers = Dict(
70+
:trunk_cgls => nlp -> trunk(nlp; subsolver = :cgls),
71+
:trunk_crls => nlp -> trunk(nlp; subsolver = :crls),
72+
:trunk_lsqr => nlp -> trunk(nlp; subsolver = :lsqr),
73+
:trunk_lsmr => nlp -> trunk(nlp; subsolver = :lsmr)
74+
)
75+
```
76+
5677
```julia
78+
RTOL = 1e-6; ATOL = 1e-8; max_time = 60.0
5779
solvers = Dict(
58-
:trunk_cgls => model -> trunk(model, subsolver_type = CglsSolver),
59-
:trunk_crls => model -> trunk(model, subsolver_type = CrlsSolver),
60-
:trunk_lsqr => model -> trunk(model, subsolver_type = LsqrSolver),
61-
:trunk_lsmr => model -> trunk(model, subsolver_type = LsmrSolver)
80+
:trunkls_lsmr => nlp -> trunk(nlp; rtol = RTOL, atol = ATOL, subsolver = :lsmr, max_time = max_time),
81+
:trunkls_cg => nlp -> trunk(nlp; rtol = RTOL, atol = ATOL, subsolver = :cg, max_time = max_time),
6282
)
6383
```
6484

@@ -91,5 +111,5 @@ profile_solvers(stats, costs, costnames)
91111
```
92112

93113
The CRLS and CGLS variants are the ones solving more problems, and even though the difference is rather small the CGLS variant is consistently faster which seems to indicate that it is the most appropriate subsolver for TRUNK.
94-
The size of the problems were rather small here, so this should be confirmed on larger instance.
114+
The size of the problems was rather small here, so this should be confirmed on larger instances.
95115
Moreover, the results may vary depending on the origin of the test problems.

0 commit comments

Comments
 (0)