Skip to content

Commit ab33f47

Browse files
committed
Bump to JSOSolvers 0.14 in Comparing subsolvers for nonlinear least squares in JSOSolvers
1 parent b6c520c commit ab33f47

File tree

2 files changed

+25
-15
lines changed

2 files changed

+25
-15
lines changed

tutorials/advanced-jsosolvers/Project.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ SolverBenchmark = "581a75fa-a23a-52d0-a590-d6201de2218a"
88

99
[compat]
1010
ADNLPModels = "0.7"
11-
JSOSolvers = "0.11"
12-
Krylov = "0.9"
11+
JSOSolvers = "0.14"
1312
OptimizationProblems = "0.7"
1413
Plots = "1"
1514
SolverBenchmark = "0.6"

tutorials/advanced-jsosolvers/index.jmd

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,24 @@ 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
1919
using ADNLPModels
2020
using OptimizationProblems
2121
using OptimizationProblems.ADNLPProblems
2222
df = OptimizationProblems.meta
23-
names = df[(df.objtype .== :least_squares) .& (df.contype .== :unconstrained), :name]
24-
ad_problems = (eval(Meta.parse(problem))(use_nls = true) for problem ∈ names)
23+
problem_names = df[(df.objtype .== :least_squares) .& (df.contype .== :unconstrained), :name]
24+
ad_problems = (eval(Meta.parse(problem))(use_nls = true) for problem ∈ problem_names)
2525
```
2626

2727
These problems are [`ADNLSModel`](https://github.com/JuliaSmoothOptimizers/ADNLPModels.jl) so derivatives are generated using automatic differentiation.
@@ -38,27 +38,38 @@ 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
4545
```
4646

4747
These linear least squares solvers are implemented in the package [Krylov.jl](https://github.com/JuliaSmoothOptimizers/Krylov.jl).
48+
For detailed descriptions of each subsolver's algorithm and when to use it, see the [Krylov.jl documentation](https://jso.dev/Krylov.jl/stable/).
49+
50+
We define a dictionary of the different solvers that will be benchmarked.
51+
We consider here four variants of TRUNK using the different subsolvers.
52+
53+
For example, to call TRUNK with an explicit subsolver:
4854

4955
```julia
50-
using Krylov
56+
stats = trunk(nls, subsolver = :cgls)
5157
```
5258

53-
We define a dictionary of the different solvers that will be benchmarked.
54-
We consider here four variants of TRUNK using the different subsolvers.
59+
The same subsolver selection pattern applies to TRON's least-squares specialization:
60+
61+
```julia
62+
stats_tron = tron(nls, subsolver = :lsmr)
63+
```
64+
65+
Now we define the solver dictionary for benchmarking:
5566

5667
```julia
5768
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)
69+
:trunk_cgls => model -> trunk(model, subsolver = :cgls),
70+
:trunk_crls => model -> trunk(model, subsolver = :crls),
71+
:trunk_lsqr => model -> trunk(model, subsolver = :lsqr),
72+
:trunk_lsmr => model -> trunk(model, subsolver = :lsmr)
6273
)
6374
```
6475

@@ -91,5 +102,5 @@ profile_solvers(stats, costs, costnames)
91102
```
92103

93104
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.
105+
The size of the problems was rather small here, so this should be confirmed on larger instances.
95106
Moreover, the results may vary depending on the origin of the test problems.

0 commit comments

Comments
 (0)